
function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Your email address seems to be incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username in your email address contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("The domain name of your email address contains invalid characters.");
return false;
   }
}
if (user.match(userPat)==null) {
alert("The name in your email address doesn't seem to be valid.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address in your email address is invalid!");
return false;
   }
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name of your email address does not seem to be valid.");
return false;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Your email address must end in a well-known domain or two letter " + "country.");
return false;
}
if (len<2) {
alert("Your email address is missing a hostname!");
return false;
}
return true;
}


function ConfirmForm(what)
{

if (emailCheck(document.quoteform.d_email.value))
	{
	if ( (document.quoteform.d_first_name.value=="")  || (document.quoteform.d_last_name.value=="") ||  (document.quoteform.d_email.value=="") || (document.quoteform.d_city.value=="") || (document.quoteform.d_state.value=="") || (document.quoteform.a_country.value=="") || (document.quoteform.a_city.value=="") || (document.quoteform.est_pickup_date.value=="") )
		{
		alert ("Please complete the fields denoted with an *");
		}
		
	else if (document.quoteform.d_email.value != document.quoteform.d_v_email.value)
		{
			
		alert ("Email Verification doesn't match. Please verify your email address");
	
		}

	else if ( (document.quoteform.cargo1_year.value=="")  || (document.quoteform.cargo1_make.value=="") ||  (document.quoteform.cargo1_model.value=="")  )	
		{
			
		alert ("Please select or indicate a vehicle to transport");
	
		}
		
	else
		{
			//document.quoteform.submit();
			new Ajax.Updater('quote_content', '/sovphpajax/txn_newquote_ajax.php', {method: 'post', asynchronous:true, evalScripts:true, parameters:Form.serialize(document.quoteform), onLoading: function() {ajax_loading();}});
		}


	}

}

function build_date(what)
{

	document.quoteform.est_pickup_date.value = document.quoteform.month.value + "/" + document.quoteform.day.value + "/" + document.quoteform.year.value; 
	
}




