function trim_all(strObjName){ 
	//this function removes the spaces from the variables
        var strObj = strObjName;
        var strRet = "";
        for (i = 0;i < strObj.length;i++)
        {
                if(strObj.charAt(i) != " " && strObj.charAt(i) != "")
                        strRet = strRet+strObj.charAt(i);
        }
        return strRet;
}

function checkform(){
	var fname = document.frmQuote.fname;
	var lname = document.frmQuote.lname;
	var email1 = document.frmQuote.email1;
	var email2 = document.frmQuote.email2;
	var address = document.frmQuote.address;
	var zip = document.frmQuote.zip;
	var phone1 = document.frmQuote.phone1;
	var phone2 = document.frmQuote.phone2;
	var phone3 = document.frmQuote.phone3;
	
	if(trim_all(fname.value)==""){
		alert("Enter the first name");
		fname.focus();
		return false;
	}
	
	if(trim_all(lname.value)==""){
		alert("Enter the last name");
		lname.focus();
		return false;
	}
		
	if(trim_all(email1.value) == ""){
		alert("Please enter an email id");
		email1.focus();
		return false;
	}
	//var reTESTfirstchar = /^[a-zA-Z]*$/
	var reEmail=/^[0-9a-zA-Z_\.-]+\@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z_\.-]*$/
	var reEDUEmail=/^[0-9a-zA-Z_\.-]+\@[0-9a-zA-Z_\-]+\.edu$/
	/*if(!reTESTfirstchar.test(email1.value.charAt(0))){
		alert("Email should start with an alphabet");
		email1.value = "";
		email1.focus();
		return false;
	}*/
	if(!reEmail.test(email1.value)){
		alert("Please enter a valid email address.");
        email1.value = "";
        email1.focus();
        return false;
	}
	
	if(trim_all(email2.value) == ""){
		alert("Please enter an email id");
		email2.focus();
		return false;
	}
	//var reTESTfirstchar = /^[a-zA-Z]*$/
	var reEmail=/^[0-9a-zA-Z_\.-]+\@[0-9a-zA-Z_\-]+\.[0-9a-zA-Z_\.-]*$/
	var reEDUEmail=/^[0-9a-zA-Z_\.-]+\@[0-9a-zA-Z_\-]+\.edu$/
	/*if(!reTESTfirstchar.test(email2.value.charAt(0))){
		alert("Email should start with an alphabet");
		email2.value = "";
		email2.focus();
		return false;
	}*/
	if(!reEmail.test(email2.value)){
		alert("Please enter a valid email address.");
        email2.value = "";
        email2.focus();
        return false;
	}
	
	
	if(email2.value != email1.value){
		alert("both email id's should be same");
		email1.value = "";
		email2.value = "";
		email1.focus();
		return false;
	}
	
	if(trim_all(address.value)==""){
		alert("Please enter the address");
		address.focus();
		return false;
	}
	if(trim_all(zip.value) == ""){
		alert("Please enter a Postal code");
		zip.focus();
		return false;
	}
	
	if(trim_all(phone1.value)==""){
		alert("Enter the phone no");
		phone1.focus();
		return false;
	}
	
	if(trim_all(phone2.value)==""){
		alert("Enter the phone no");
		phone2.focus();
		return false;
	}
	
	if(trim_all(phone3.value)==""){
		alert("Enter the phone no");
		phone3.focus();
		return false;
	}
	
	
	return true;
}

function submitForm()
{
	var strReturn;
	strReturn = checkform();
	if(strReturn==true)
	{
		document.frmQuote.btnSubmit.disabled = true;
		document.frmQuote.hdnSubmit.value = "submit";
		return true;
	}
	else
	{
		return false;
	}
}
