
//Logon script for Personal

if ( top.location != self.location ) {
                  top.location=self.location;
               }

if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion.charAt(0)) < 5)) { 
	document.captureEvents(Event.KEYPRESS);
	document.onkeypress = forceAlphaNumeric;
}


function validateLogon( ) {

	var userid 		= document.form1.j_username.value;
	var	password	= document.form1.j_password.value;
	
	if (( userid.length == 0 )  ||  ( password.length == 0 )) {
		alert( "In order to access First National Online, please enter your User ID and Password then select Logon again.  If you forgot your User ID or Password, please click on the 'Forgot Your User ID' or 'Forgot Your Password' links." );
		document.form1.j_username.select();
		document.form1.j_username.focus();
	}
	else {
		if (document.form1.submitted.value != "yes") {
			document.form1.submitted.value = "yes";
			document.form1.action = "https://" + self.location.host + "/iwsOnline/public/authenticate/authenticate.do";
			document.form1.submit();
		}	
	}
}

function forceAlphaNumeric(e,textObject) {
			
	        var charCode = (navigator.appName == "Netscape")?e.which:e.keyCode;
	        var targetElement = (navigator.appName == "Netscape")?e.target:e.srcElement;

		// NS 6.0 weirdness
		if ((charCode==0)&&(e.keyCode > 0)) {
			charCode = e.keyCode;
		}

	        var aChar = String.fromCharCode(charCode);
	
	        var myCriteria = /[0-9]/gi;
	        var myMatch = aChar.match(myCriteria);
	        if (myMatch != null){return charCode;}
	
	        var myCriteria = /[a-z]/gi;
	        var myMatch = aChar.match(myCriteria);
	        if (myMatch != null){return charCode;}
	
	        if(charCode==8){return charCode;}
	        if(charCode==9){return charCode;}
	        if(charCode==13){
	        	if (targetElement==document.forms[0].j_password){
	        		document.form1.submit();
	        	}
	        	if (targetElement==document.forms[0].j_username){
	        		document.forms[0].j_password.focus();
	        		return (false);
	        	}
	        }
	return false;
}
/* 
function focusCursor(){
	var form = document.forms[0];
	if ((form.j_username.value == "") && (form.j_password.value == "") ){
		form.j_username.focus();
   	}
}
*/
function popupWin(location, name) {
        open (location,name,"scrollbars=yes,menubar=no,resizable=1,copyhistory=0,height=550,width=750");
}

function smartLogon(){
	var form = document.forms[0];
	form.FUNCTION.value="SmartLogon";
	form.action = "https://" + self.location.host + "/welcome/jsp/smartcard/checkmimeandreader.jsp";
	form.target = "_parent";
	form.submit();
	return;
}

function go(location)
{
	var form = document.forms[0];
	
	if (location == "forgotpasscode" ) {
	        if (form.FAILEDFORGOT.value != 'Y') {
	                form.action="https://" + self.location.host + "/welcome/jsp/smartcard/forgotpasscode/fp_cardstatus.jsp";
	        } else {
	                form.action="https://" + self.location.host + "/welcome/jsp/smartcard/forgotpasscode/fp_previouslyfailed.jsp";
	        }
        	form.target="_top";
        	form.submit();
	}
	else {
        	self.parent.window.location = location;
	}

}




