function window_onload() {
	//Get the directory and page
	var sPath = window.location.pathname;
	var sDir = sPath.split('/');
	var sPage = sDir[sDir.length-1].split('.');
	var aPage = sPage[0];
	aPage = aPage.toLowerCase();
	
	//Set button box for current page on the left navigation menu
	var theBox = "#003399 2px solid"
	if (!(aPage=="eepassword" || aPage=="eesignup" || aPage=="emppassword")) {
		document.all.item("btn" + aPage).style.border = theBox;
	}
		
	//Set focuses
	switch (aPage){		
		//Employees
		case "members": {
			var chooser = document.all.item("pnlChooser");
			var login = document.all.item("pnlLogin");
			if (chooser != null) {
				document.all.item("txtCase").focus();
			}
			if (login != null) {
				document.all.item("EEUsername").focus();
			}
			break;
		}
		case "eepassword": {document.all.item("username").focus(); break}
		case "eesignup": {document.all.item("ssn1").focus(); break}
		//Sponsors
		case "sponsors":  {
			var chooser = document.all.item("pnlChooser");
			var login = document.all.item("pnlLogin");
			if (chooser != null) {
				document.all.item("txtCase").focus();
			}
			if (login != null) {
				document.all.item("account").focus();
			}
			break;
		}
	}
}

function destination(){
	s = new String(window.location.host);	
	if (s.toLowerCase()=="localhost") {
		return "http://localhost/jpfarley/"
	}else{
		return "http://www.jpfarley.com/jpfarley/"
	}
}

//SIDE MENU
//Mouseovers
function SideMenu_onmouseover(that) {
	that.style.textDecoration = "underline";
}
function SideMenu_onmouseout(that) {
	that.style.textDecoration = "none";
}
//Web Troubleshoot
function btnWebTroubleshoot_onclick() {
	document.location.href=(destination(false) + "Corporation/WebTroubleshoot.aspx");
}
//ContactUs
function btnContactUs_onclick() {
	document.location.href=(destination(false) + "Corporation/ContactUs.aspx");
}

//SPLITTERS
function CheckCase() {
	exp = /^[a-z0-9A-Z]{7}$/;
	if (exp.test(document.all.item('txtCase').value)) {
		return true;
	}else{
		alert("A Group ID must have 7 characters.");
		document.all.item('txtCase').value = "";
		document.all.item('txtCase').focus();
		return false;
	}
}
function txtCase_onfocus(that) {
	that.value = "";
}
function txtCase_onkeypress(that) {	
	//alert("Banner Script, txtCase_onkeypress(that)");
	if (event.keyCode==13) {		
		document.all.item('btnGo').click();
		return false;
	}
}
function DoGo(that) {
	//alert("Banner Script, DoGo");
	if (CheckCase()) {
		that.click();
	}else{
	return false;	
	}
}

//Third box EE and ER
function Login(x,who){
	document.f1.action=x; //Set posting			
	//Validate and submit existing user
	if (who=="btnPageLogin") {
		if (document.all.item('EEUsername').value!="" && document.all.item('EEPassword').value!="") {
			document.f1.submit();
		}else{			
			alert("Please enter SSN and Password.");				
		}
	}
	//Validate and submit new user
	if (who=="btnNewEnrollee") {
		if (document.all.item('username').value!="" && document.all.item('password').value!="" && document.all.item('account').value!="") {
			document.f1.submit();
		}else{			
			alert("Please enter Group #, Division, and Password.");				
		}
	}				
}
function LoginNew() {
	if(event.keyCode==13) {
		document.all.item('btnNewEnrollee').click();
	}	
}