function maxWindow()
{
/*	Commented out as this code causes major javascript security violation errors in most modern browsers. */
/*
	window.moveTo(0,0);
	
	if (document.all){
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
*/
}
	
function validateLogin() {
	//debugger	
	var sRequest = "<Request>";
	sRequest = sRequest + "<LN>" + encode(document.getElementById("txtLoginName").value) + "</LN>";		
	sRequest = sRequest + "<PW>" + encode(document.getElementById("txtPassword").value) + "</PW>";
	try {
		sRequest = sRequest + "<RU>" + encode(document.getElementById("chkRemember").checked.toString()) + "</RU>";
	} catch (e) {
		//Do nothing, we aren't in experimental mode (obviously)
	}
	sRequest = sRequest + "</Request>";
		
	var httpRequest = null;
	
	try {
		httpRequest = new XMLHttpRequest;
	} catch (e) {
		alert ("Cannot create XmlHttpRequest component.  Please ensure you are running the latest version of your browser.\n" + e.description);
		return 0;
	}		
	
		
	httpRequest.open ("POST", "ValidateStaffLogin.aspx", false);
	httpRequest.send (sRequest);
			
	if (httpRequest.status == 200) {
		//handle returned error here.
		var xmlDoc = httpRequest.responseXML;
		var node = xmlDoc.selectSingleNode( "//ERROR" );
			
		if (node != null) {
			alert(Sarissa.getText( node ));
			return 0;
		}		
	}
	else {
		//handle http error here		
		alert ("A server error occurred trying to log you in.\n" + httpRequest.statusText);
		return 0;
	}
				
	return 1;			
}
			
function txtLoginName_OnKeyPress(event){
	if (event.keyCode ==13){ 
		document.getElementById("txtPassword").focus();
	}
}
		
function txtPassword_OnKeyPress(event){
	if (event.keyCode ==13){ 
		btnSubmit_OnClick();
	}
}
		
function btnSubmit_OnClick(){			
				
	if (document.getElementById("txtLoginName").value.replace(/ /g, "") == "") {
		alert("Please type in your Login Name.");
		return;
	}	
	var mydate = new Date();
	mydate.setFullYear(mydate.getFullYear() + 1);
				
	if (validateLogin() == 0) {
		return;				
	}
	window.open("StaffOverDueJob.aspx", "_self", "" ,true);
}

function btnClear_OnClick () {
	document.getElementById("txtLoginName").value = "";
	document.getElementById("txtPassword").value = "";
	document.getElementById("txtLoginName").focus();
}

function btnForgot_onclick () {
	window.open("ForgotPassword.aspx", "", "height=250, width=500, resizable=no, scroll=no, status=no, left=" + ((window.screen.availWidth / 2) - (500 / 2)) + ", top=" + ((window.screen.availHeight / 2) - (250 / 2)));
}

function body_onload() {
	maxWindow();
	document.getElementById("txtLoginName").focus();
	if ( document.getElementById("txtLoginName").value != "" ) { document.getElementById("txtPassword").focus(); }
}