window.onload = function() {
document.leadForm.EMAIL.focus();
};

function validateFormPage(form){
var errormsg = "";
if(form.PAYDAY_LOAN_VAL.value==""){
	errormsg = "Please enter a loan amount\n";
}
if(form.EMAIL.value==""){
	errormsg += "Please enter an email address";
}
else if(isValidEmail(form.EMAIL.value)==false){
	errormsg += "Please enter a valid email address";
}
if(errormsg !=""){
	alert(errormsg);
	form.EMAIL.focus();
	return false;
}


waitBlck(1);	
setTimeout("waitBlck(2)",2000);	
return false;
}


function isValidEmail(strEmail) {
  var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  if(trimString(strEmail).length ==0 ){ return false;}
  if (strEmail.length < 5) { return false; }
  if (!strEmail.match(re)) { return false; }
  return true;
}

function trimString(str) {
	if(str == null)
		return '';
	return str.replace(/^\s+|\s+$/g, '') ;
}

function waitBlck(casetype) {
	if(casetype ==1){
		document.getElementById('loading').style.visibility = "visible";				
	}
	else{
		document.getElementById('loading').style.visibility = "hidden";
		document.leadForm.submit();
	}
	return false; 
}

