<!--

//MRowntree 13/11/2006
//additional js include directive to call in the mail Domains
document.write('<scr' + 'ipt src="/jsincludes/mailDomains/mailDomains.js" language="javascript" type="text/javascript"></scr' + 'ipt>');

function show(id){
	document.getElementById(id).style.display = 'inline';
}
function validateAddress(incoming) {
	//alert(incoming);
	// refined routine: MRowntree 08/09/2006
	var email_regex =  /^([a-zA-Z][\w\._-]*[a-zA-Z0-9])@([a-zA-Z0-9_-]+)\.([a-zA-Z0-9]+\.[a-zA-Z\.]*[a-zA-Z])$/;
	// is the email address valid and formatted as we'd expect?
	//alert(email_regex.test(incoming));
	//return false;
	if(email_regex.test(incoming)){
		// do the parts correspond as they should?
		var s_mailBox = document.chkAccountSignIn.mailbox.value = RegExp.$1;
		var s_userId = document.chkAccountSignIn.iaf_userid.value = RegExp.$2;
		var s_vendorDomain = document.chkAccountSignIn.iaf_VendorDomain.value = RegExp.$3;
		//alert("|" + s_mailBox + "|" + s_userId + "|" + s_vendorDomain + "|");
		//test to see if the domains are correct
		if (a_mailDomains){
			var bIsDomain = 0;
			for(var i=0;i < a_mailDomains.length; i++){
				//alert(a_mailDomains[i] + "\n" + s_vendorDomain);
				if (s_vendorDomain == a_mailDomains[i]){
					bIsDomain = 1;
					break;
				}
			}
			if(bIsDomain){
				return true;
			}else{
				alert('The email address that you provided contains the domain \''+ s_vendorDomain +'\' which is not as valid email address');
				return false;
			}		
		}else{
		// the 'a_mailDomains' variable doesn't exist, so we cannot check the domains correctly
		alert('The list of email Domains has not been successfully loaded, so we cannot currently validate the email address that you entered.\nPlease try again later.');
		return false;
		}
	}else{
		alert('The email address that you entered is not the correct format');
		return false;
	}
}
	
function checkUserDetails(){
	var mypass = document.getElementById("j_password");
	var addr   = document.getElementById("j_username");
	
	if(addr.value == ""){
		show("loginFailed");
		addr.focus();
		return false;
	}
	if (!validateAddress(addr.value)) {
		show("loginFailed");
		addr.focus();
		return false;
	}
	if(mypass.value == ""){
		show("loginFailed");
		mypass.focus();
		return false;
	}
	if(mypass.value.length < 4){
		show("loginFailed");
		mypass.focus();
		return false;
	}
	for (i=0; i < mypass.value.length;i++) {
		if (mypass.value.charCodeAt(i) < 45 || mypass.value.charCodeAt(i) > 122) {
			show("loginFailed");
			mypass.focus();
			return false;
		}
	}
	document.chkAccountSignIn.submit();
	return true;
}
//-->