function init(){
	if(document.frmLogin.UserName.value=="") document.frmLogin.UserName.focus()
	else document.frmLogin.Password.focus()
}

function UserIDFocus(){document.frmLogin.UserName.select()}
function PasswordFocus(){document.frmLogin.Password.select()}

function login(){
	if(!window.clientInformation.cookieEnabled)
		alert("Your browser is set to not accept cookies.\n\nPlease set enable cookies, or our website will not function properly.")
	else{
		for(i=0;i<document["frmLogin"]["UserName"].value.length;i++)
		    document["frmLogin"]["UserName"].value = document["frmLogin"]["UserName"].value.replace(" ", "");

		// Test if the username specified starts with a 'P' or 'T'
		// As per change request 934183
		if ((document["frmLogin"]["UserName"].value.substr(0, 1).toUpperCase() !== 'P') &&
		 (document["frmLogin"]["UserName"].value.substr(0,1).toUpperCase() !== 'T'))
		{
		    alert("Please enter a valid username,\n\n(Starting with P followed by a Persal number). ");
		    document["frmLogin"]["UserName"].focus();
		    return false;
		}

/*
		alert(typeof (document["frmLogin"]["UserName"].value.substr(1, 10) * 1));

		alert((document["frmLogin"]["UserName"].value.substr(1, 10) * 1) == 'NaN')

		alert((document["frmLogin"]["UserName"].value.substr(1, 10) * 1) ) 		
*/

		if (isNaN(document["frmLogin"]["UserName"].value.substr(1, 10) * 1)) 
		    {
		        alert("Please enter a valid username,\n\n(Starting with P followed by a Persal number). ");
		        document["frmLogin"]["UserName"].focus();
		        return false; 
		    }

		if (document["frmLogin"]["UserName"].value.length < 4)
		    {
		        alert("Please enter a valid username,\n\n(Starting with P followed by a Persal number).");
			    document["frmLogin"]["UserName"].focus();
			    return false;			
			}
		else if (document["frmLogin"]["Password"].value.length < 8) 
            {
                alert("Please enter a password of at least 8 characters in length");
                document["frmLogin"]["Password"].focus();
                return false;
            }
        
		
		document["frmLogin"]["PageParm"].value = "LOGIN";
		document["frmLogin"].submit();
		document.all['deptDiv'].innerHTML='<table height="100%" width="100%"><tr><td align="center" style="font-size:15px"><span><strong>Processing logon</strong><br>Please wait...</span></td></tr></table>';
	}
}

function checkEnter(){
	if(window.event.keyCode==13)login();
}

// Keystroke Validation
// This is the last line of defence against the fking dumb users.



