// JavaScript Document
function bringToFront(){
		window.focus();							
		}
function fnPopup0(url,winname,width,height) {
		var screenheight=screen.height;
		var screenwidth=screen.width;
		var vposition= (screenheight - width)/2;
		var hposition=  (screenwidth - height)/2;
		window.open(url,winname,'Width='+width+',Height='+height+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no'+',left='+hposition+',top='+vposition);
		}		
function fnValExpenses(){
	if (!document.getElementById("rdoExpensesSelf").checked &&
    	!document.getElementById("rdoExpensesCompany").checked &&
    	!document.getElementById("rdoExpensesUndecided").checked) {		
		alert("incomplete");
    	return false;		
    }
}
function fnValSeminar(){
	if (!document.getElementById("rdoSeminarYes").checked &&
    	!document.getElementById("rdoSeminarNo").checked &&
    	!document.getElementById("rdoSeminarUndecided").checked) {		
		alert("incomplete");
    	return false;		
    }
}
function fnValCourses() {
	if (
		document.getElementById("chkCourse01").checked == false &&
        document.getElementById("chkCourse02").checked == false &&
        document.getElementById("chkCourse03").checked == false &&
        document.getElementById("chkCourse04").checked == false &&
        document.getElementById("chkCourse05").checked == false &&
        document.getElementById("chkCourse06").checked == false &&
        document.getElementById("chkCourse07").checked == false &&		
        document.getElementById("chkCourse08").checked == false &&
        document.getElementById("chkCourse09").checked == false &&		
        document.getElementById("chkCourse10").checked == false		
		) {	  
		 alert("Please select at least one checkbox.\n");		 
		 return false;
     }
	if ( (document.getElementById("chkCourse10").checked == true) && (document.getElementById("txtOtherCourses").value.length == 0)) {
		alert("Please Specify Other Courses");
		 return false;
	}
}
function fnValEmail(id){
	if (document.getElementById(id).value.length >0) {
	 i=document.getElementById(id).value.indexOf("@")
	 j=document.getElementById(id).value.indexOf(".",i)
	 k=document.getElementById(id).value.indexOf(",")
	 kk=document.getElementById(id).value.indexOf(" ")
	 jj=document.getElementById(id).value.lastIndexOf(".")+1
	 len=document.getElementById(id).value.length
 	if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
 	}
 	else {
 		alert("Please enter an exact email address.\n" +
		document.getElementById(id).value + " is invalid.");
		return false;
 	}
	}
 }

function  fnValNumber(id){
	//alert on finding all numbers
var nonums = /^[0-9]*$/;
if (nonums.test(document.getElementById(id).value)) {
     alert("Please enter at least one letter in the \"username\" field.");
     return false;
	}

}
function fnReqdField(formname,id){
	
}
function fnCourseSurveyFormValidation(){
	var check;  
	fnValCourses(); // Check to see atleast on course is checked	
	fnValExpenses(); // Check Expenses is checked or not
	fnValSeminar(); //  Check Seminar is checked or not
	fnValEmail("txtHRContactEmail"); // Validate hr e-mail	
	fnValEmail("txtEMail"); // Validate Personal e-mail	
	document.coursesurveyform.submit();
    }

/* Used in course survey form */

function removeChild() {
	var totalChild = document.getElementById('drpTiming').length;	
	for(i=0;i<totalChild;i++){
		document.getElementById('drpTiming').removeChild(document.getElementById('drpTiming').firstChild);		
		}
	}
function selectTimings(dayvalue){
	var arrtimings = arrDays[dayvalue];
	var arrvalue = eval(arrtimings);
	for (var zxc0=0;zxc0<arrvalue.length;zxc0++){
		var o = document.createElement('option');
		o.value=arrvalue[zxc0];
		o.appendChild(document.createTextNode(arrvalue[zxc0]));
		document.getElementById('drpTiming').appendChild(o);
	}
}
function selectDays() {
	var timingsindex= document.getElementById('drpDay').selectedIndex;
	if(timingsindex==0){
		document.getElementById('drpTiming').className="hidden";		
		}
		else {
			document.getElementById('drpTiming').className="txtbox";		
		}
		removeChild();	
		var dayvalue = document.getElementById('drpDay').value;
		selectTimings(dayvalue);	
	}
	
function ScrollIt(){
			window.scrollTo(document.all("PageX").value,document.all("PageY").value);
			}
function setcoords(){
			if (document.all){
				PageScrollLeft = document.body.scrollLeft;
				PageScrollTop = document.body.scrollTop;
				}
			else{
				PageScrollLeft = window.pageXOffset;
				PageScrollTop = window.pageYOffset;				
				}
			document.all("PageX").value = PageScrollLeft;
			document.all("PageY").value = PageScrollTop;			
	
			}
     
function openWindow() {
	newWindow = window.open("coursesurveypopup.html","coursesurvey","height=322,width=350,status=0,menubar=0");
	newWindow.focus();
	}
function openHomePopup() {
	newWindow = window.open("attendseminarpopup.htm","attendseminarpopup","height=200,width=400,status=0,menubar=0");
	newWindow.focus();
	}
function reposition() {
	var winheight=document.body.offsetHeight;
	var winwidth=document.body.offsetWidth;
	var screenheight=screen.height;
	var screenwidth=screen.width;
	var vposition= (screenheight - winheight)/2;
	var hposition=  (screenwidth - winwidth)/2;
	window.moveTo(hposition,vposition);
	window.focus();
}

function openSurvey() {
	newWindow = window.open("coursesurvey/coursesurvey.aspx","coursesurveyform");
	newWindow.focus();
	window.close();
}

function cookieDetector(){
	if(!document.cookie) {	
		openWindow();		
		} 
	else {
		
	}	
}
function setCookie(){
					var expire_days = 30
					var expire_date = new Date()
					var ms_from_now = expire_days * 24 * 60 * 60 * 1000
					expire_date.setTime(expire_date.getTime() + ms_from_now)
					var expire_string = expire_date.toGMTString()
					// Set the cookie
					document.cookie="Name=CourseSurvey; expires=" + expire_string
	}
function menuhide() {
	document.getElementById("submenu").className="hidden";
	}
function menuopen() {
	document.getElementById("submenu").className="show";
	timeoutID = setTimeout("menuhide()",3000,"javascript");		
	function fnClearTimeOut() {
		clearTimeout(timeoutID);	
	}
	}
function clearmenuhide() {	
	fnClearTimeOut();
	}
	/*
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("submenu");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;
*/