function Check_email(emailStr) 
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|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 (document.TestDriveForm.Email.value==0)
{
	return true;
}
else
{
if (matchArray==null) {
alert("Your email address appears to be incorrect (check @ and .'s)");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Your email address contains invalid characters.");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Your email address contains a domain name with invalid characters.");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
return false;
   }
}
if (user.match(userPat)==null) {
alert("Your email address does not appear to be valid.");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
return false;
}var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("The IP address used in your email address is invalid!");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
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("Your email does not have a valid domain name.");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
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 name or two letter country.");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
return false;
}
if (len<2) {
alert("Your email address is missing a hostname");
document.TestDriveForm.Email.focus();
document.TestDriveForm.Email.select();
return false;
}
}
return true;
}

function ValidateForm()
{
		
	if(document.TestDriveForm.Title.options.selectedIndex==null)
	{

		alert("Select your Title");
		document.TestDriveForm.Title.focus();
		return false;

	}

	else if(document.TestDriveForm.Title.options.selectedIndex==4 && document.TestDriveForm.OtherTitle.value==0)
	{
		alert("Specify the Title");
		document.TestDriveForm.OtherTitle.focus();	
		return false;
					
	}
			
	else if(document.TestDriveForm.Title.options.selectedIndex==4 && document.TestDriveForm.OtherTitle.value=="Specify Other")
	{
		alert("Specify the Title");
		document.TestDriveForm.OtherTitle.focus();	
		document.TestDriveForm.OtherTitle.select();	
		return false;
				
					
	}
	
	else if (document.TestDriveForm.FirstName.value==0)
	{
		alert("Enter First Name");
		document.TestDriveForm.FirstName.focus();
		return false;
	}
	else if(document.TestDriveForm.LastName.value==0)
	{
		alert("Enter Last Name");
		document.TestDriveForm.LastName.focus();
		return false;
	}	
	else if(document.TestDriveForm.Age.options.selectedIndex==0)
	{
		alert("Specify your Age");
		document.TestDriveForm.Age.focus();
		return false;
	}	
	else if(document.TestDriveForm.country.options.selectedIndex==0)
	{
		alert("Select Country");
		document.TestDriveForm.country.focus();
		return false;
	}	
	else if(document.TestDriveForm.City.options.selectedIndex==0)
	{
		alert("Select City");
		document.TestDriveForm.City.focus();
		return false;
	}	
	else if(document.TestDriveForm.POBox_MailingAddress.value==0)
	{
		alert("Enter P.O. Box or Mailing address");
		document.TestDriveForm.POBox_MailingAddress.focus();
		return false;
	}	
	else if(document.TestDriveForm.ZipCode.value==0)
	{
		alert("Enter Zip Code");
		document.TestDriveForm.ZipCode.focus();
		return false;
	}	
	else if(document.TestDriveForm.Email.value==0)
	{
		alert("Enter a valid E-mail address");
		document.TestDriveForm.Email.focus();
		return false;
	}		
	else if(Check_email(document.TestDriveForm.Email.value)==false)
	{
		return false;
	}
	else if(document.TestDriveForm.PhoneNumber.value==0)
	{
		alert("Enter Phone Number");
		document.TestDriveForm.PhoneNumber.focus();
		return false;
	}	
		
	else if(document.TestDriveForm.Is_Work_Or_Home.options.selectedIndex==0)
	{
		alert("Specify if Telephone Number is work or home?");
		document.TestDriveForm.Is_Work_Or_Home.focus();
		return false;
	}
	
	else if(document.TestDriveForm.ContactLanguage.options.selectedIndex==0)
	{
		alert("Specify in which language we should communicate with you");
		document.TestDriveForm.ContactLanguage.focus();
		return false;
	}
	
	else if(document.TestDriveForm.TestdriveBrand.options.selectedIndex==0)
	{
		alert("Please indicate the Universal Motors Agencies vehicle you would like to test drive");
		document.TestDriveForm.TestdriveBrand.focus();
		return false;
	}	
	else if(document.TestDriveForm.showroom.options.selectedIndex==0)
	{
		alert("Please indicate the Universal Motors Agencies showroom where you want to take your test drive");
		document.TestDriveForm.showroom.focus();
		return false;
	}

	
	else if(document.TestDriveForm.How_To_Contact.options.selectedIndex==0)
	{
		alert("How would you like us to contact you?");
		document.TestDriveForm.How_To_Contact.focus();
		return false;
	}

	
	else if(document.TestDriveForm.Expected_Next_Vehicle_Purchase.options.selectedIndex==0)
	{
		alert("When do you expect to purchase your next vehicle?");
		document.TestDriveForm.Expected_Next_Vehicle_Purchase.focus();
		return false;
	}
	

	else if(document.TestDriveForm.Makes_Models_Considering.options.selectedIndex==0)
	{
		alert("How many makes and models you are considering?");
		document.TestDriveForm.Makes_Models_Considering.focus();
		return false;
	}
	
	//document.TestDriveForm.action="../util/send_testdrive_email.asp";
	document.TestDriveForm.submit();
	return true;
}