// Login Validator in JavaScript
// Author 	:	by palPALANI, Web Designer
// file name:	utility.js; Create Date : 12102005
// Use 		:	onkeypress="return entsub(event, this.form, '1')"
//				1 - userID, 2 - Password
// Browsers :	Independent

//This function user for detect the browser, ie., IE, Nerscafe, FireFox, etc.,
function BrowserDetect() {
	doc=window.document;
	navVersion=navigator.appVersion.toLowerCase();
	this.ie4=(!doc.getElementById&&doc.all)?true:false;
	this.ie5=(navVersion.indexOf("msie 5.0")!=-1)?true:false;
	this.ie55=(navVersion.indexOf("msie 5.5")!=-1)?true:false;
	this.ie6=(navVersion.indexOf("msie 6.0")!=-1)?true:false;
	this.isIE=(this.ie5||this.ie55||this.ie6)?true:false;
	this.isGecko=!this.isIE;
}

//initialising the browser detection
myBrowser = new BrowserDetect();

//call function based on browsers
function entsub(event, ourform, whichFld) {
	if (myBrowser.isIE) {
		if (window.event && window.event.keyCode == 13)
			keyPressVal(ourform, whichFld);
		else
			return true;
	} else {
		if (event && event.which == 13)
			keyPressVal(ourform, whichFld);
		else
			return true;
	}
}

//This function user for Validating fields
function keyPressVal(theForm, whichFlds) {
	if (theForm.fuserid.value == "" && whichFlds=='1') {
		alert("Please enter a value for the \"userid\" field.");
		theForm.fuserid.focus();
		return (false);
	} else if (theForm.fpassword.value == "" && whichFlds=='1') {
		theForm.fpassword.focus();
		return (false);
	} else if (theForm.fuserid.value == "" && whichFlds=='2') {
		theForm.fuserid.focus();
		return (false);
	} else if (theForm.fpassword.value == "" && whichFlds=='2') {
		theForm.fpassword.focus();
		return (false);
	}
	theForm.submit();
}