function SubmitData1(field, event)
{
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode == 13)
  {
   callvalidate();
   return false;
  }
  else
  {
	return true;
  }
}
function callvalidate()
{
if(document.formquote.make2.value == "")
{
alert ("Please Select the Make"); 
document.formquote.make2.focus();
return (false);
}
if(document.formquote.modell.value == "")
{
alert ("Please Select Car Model");
document.formquote.modell.focus();
return (false);
}
if(document.formquote.strFirst.value == "")
{
alert ("Please Enter Your First Name");
document.formquote.strFirst.focus();
return (false);
}
   var iChars = "!@#$%^&*()+=-[]\\\;,/{}|\":<>?";
   for (var i = 0; i < document.formquote.strFirst.value.length; i++) {
  	if (iChars.indexOf(document.formquote.strFirst.value.charAt(i)) != -1) {
  	alert ("Your FirstName has special characters or blank spaces. \nThese are not allowed.\n Please remove them and try again.");
  	document.formquote.strFirst.focus();
  	return false;
  	}
	}

if(document.formquote.strLast.value == "")
{
alert ("Please Enter Your Last Name");
document.formquote.strLast.focus();
return (false);
}
   var iChars = "!@#$%^&*()+=-[]\\\;,/{}|\":<>?Q";
   for (var i = 0; i < document.formquote.strLast.value.length; i++) {
  	if (iChars.indexOf(document.formquote.strLast.value.charAt(i)) != -1) {
  	alert ("Your LastName has special characters or blank spaces. \nThese are not allowed.\n Please remove them and try again.");
  	document.formquote.strLast.focus();
  	return false;
  	}
	}
if(document.formquote.strAddress.value == "")
{
alert ("Please Enter Your Address");
document.formquote.strAddress.focus();
return (false);
}
/*
if(document.formquote.strCity.options[document.formquote.strCity.selectedIndex].text == "")
{
alert ("Please Select Your City Name");
document.formquote.strCity.focus();
return (false);
}
if(document.formquote.strState.value == "")
{
alert ("Please Enter Your State Name");
document.formquote.strState.focus();
return (false);
}*/
if(document.formquote.strZIP.value == "")
{
alert ("Please Enter Your Zip Code");
document.formquote.strZIP.focus();
return (false);
}
if(document.formquote.strPhone1.value == "")
{
alert ("please Enter Your Phone Number");
document.formquote.strPhone1.focus();
return (false);
}
if(document.formquote.strPhone2.value == "")
{
alert ("please Enter Your Phone Number");
document.formquote.strPhone2.focus();
return (false);
}
if(document.formquote.strPhone3.value == "")
{
alert ("please Enter Your Phone Number");
document.formquote.strPhone3.focus();
return (false);
}
if(document.formquote.stremail.value == "")
{
alert ("Please Enter Your Email-Id");
document.formquote.stremail.focus();
return (false);
}
var iChars = "!@#$%^&*()+=[]\\\;,/{}|\":<>?0123456789";
   	if (iChars.indexOf(document.formquote.stremail.value.charAt(1)) != -1)
    {
  	alert ("Email Id should not start with an Numeric or special characters. \nThese are not allowed.\n Please remove them and try again.");
 	document.formquote.stremail.focus();
  	return false;
  	}
    if (document.formquote.stremail.value != "")
	{
		var at="@"
		var dot="."
		var str=document.formquote.stremail.value;
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1 || str.indexOf(dot)==-1)
		{
		   alert("Email-Id should have atleast one '@' and '.'")
		   document.formquote.stremail.focus();
		   return false
		}
		if (str.indexOf(at)==0 || str.indexOf(at)==lstr-1)
		{
			   alert("@ should be placed in correct postion")
			   document.formquote.stremail.focus();
			   return false
		}
		if (str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1)
		{
 				alert("Please enter a valid emailid")
 				document.formquote.stremail.focus();
 				return false
		}
		if (str.indexOf(at,(lat+1))!=-1)
		{
 				alert("continous @ symbol is not allowed")
 				document.formquote.stremail.focus();
 				return false
		}
 		var varNextDot = ldot+1;
 		for(i=0; i<10; i++)
 		{
	 		if (str.indexOf(dot,(varNextDot))==varNextDot)
	 		{
		 	   alert("continuous . symbol is not allowed")
		 	   varNextDot=varNextDot+1;
		 	   document.formquote.stremail.focus();
		 	   return false
	 		 }
	 	 }

	 	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
 		 {
	 	    	alert("Please enter a valid emailid")
	 			document.formquote.stremail.focus();
	 			return false
		 }
	 	 if (str.indexOf(dot,(lat+2))==-1)
 		 {
	 			alert("Please enter a valid emailid")
	 			document.formquote.stremail.focus();
	 			return false
 		 }
		 else
		 {
		 document.formquote.action = "QuoteFormAction.php";
		 document.formquote.method = "post";
		 document.formquote.submit();
		 }		 
 	 }
   if(document.formquote.frame.value == "")
{
alert ("Please Enter Your Email-Id");
document.formquote.frame.focus();
return (false);
}
}
function callvalidate1()
{
if(document.form1.make.value == "")
{
alert ("Please Select the Make");
document.form1.make.focus();
return (false);
}
if(document.form1.model.value == "")
{
alert ("Please Select Car Model");
document.form1.model.focus();
return (false);
}
if(document.form1.trim.value == "")
{
alert ("Please Select Car Trim Level");
document.form1.trim.focus();
return (false);
}
if(document.form1.strFirst.value == "")
{
alert ("Please Enter Your First Name");
document.form1.strFirst.focus();
return (false);
}
   var iChars = "!@#$%^&*()+=-[]\\\;,/{}|\":<>?";
   for (var i = 0; i < document.form1.strFirst.value.length; i++) {
  	if (iChars.indexOf(document.form1.strFirst.value.charAt(i)) != -1) {
  	alert ("Your FirstName has special characters or blank spaces. \nThese are not allowed.\n Please remove them and try again.");
  	document.form1.strFirst.focus();
  	return false;
  	}
	}

if(document.form1.strLast.value == "")
{
alert ("Please Enter Your Last Name");
document.form1.strLast.focus();
return (false);
}
   var iChars = "!@#$%^&*()+=-[]\\\;,/{}|\":<>?Q";
   for (var i = 0; i < document.form1.strLast.value.length; i++) {
  	if (iChars.indexOf(document.form1.strLast.value.charAt(i)) != -1) {
  	alert ("Your LastName has special characters or blank spaces. \nThese are not allowed.\n Please remove them and try again.");
  	document.form1.strLast.focus();
  	return false;
  	}
	}
if(document.form1.strAddress.value == "")
{
alert ("Please Enter Your Address");
document.form1.strAddress.focus();
return (false);
}
/*
if(document.formquote.strCity.options[document.formquote.strCity.selectedIndex].text == "")
{
alert ("Please Select Your City Name");
document.formquote.strCity.focus();
return (false);
}
if(document.formquote.strState.value == "")
{
alert ("Please Enter Your State Name");
document.formquote.strState.focus();
return (false);
}*/
if(document.form1.strZIP.value == "")
{
alert ("Please Enter Your Zip Code");
document.form1.strZIP.focus();
return (false);
}
if(document.form1.strPhone1.value == "")
{
alert ("please Enter Your Phone Number");
document.form1.strPhone1.focus();
return (false);
}
if(document.form1.strPhone2.value == "")
{
alert ("please Enter Your Phone Number");
document.form1.strPhone2.focus();
return (false);
}
if(document.form1.strPhone3.value == "")
{
alert ("please Enter Your Phone Number");
document.form1.strPhone3.focus();
return (false);
}
if(document.form1.stremail.value == "")
{
alert ("Please Enter Your Email-Id");
document.form1.stremail.focus();
return (false);
}
var iChars = "!@#$%^&*()+=[]\\\;,/{}|\":<>?0123456789";
   	if (iChars.indexOf(document.form1.stremail.value.charAt(1)) != -1)
    {
  	alert ("Email Id should not start with an Numeric or special characters. \nThese are not allowed.\n Please remove them and try again.");
 	document.form1.stremail.focus();
  	return false;
  	}
    if (document.form1.stremail.value != "")
	{
		var at="@"
		var dot="."
		var str=document.form1.stremail.value;
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1 || str.indexOf(dot)==-1)
		{
		   alert("Email-Id should have atleast one '@' and '.'")
		   document.form1.stremail.focus();
		   return false
		}
		if (str.indexOf(at)==0 || str.indexOf(at)==lstr-1)
		{
			   alert("@ should be placed in correct postion")
			   document.form1.stremail.focus();
			   return false
		}
		if (str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1)
		{
 				alert("Please enter a valid emailid")
 				document.form1.stremail.focus();
 				return false
		}
		if (str.indexOf(at,(lat+1))!=-1)
		{
 				alert("continous @ symbol is not allowed")
 				document.form1.stremail.focus();
 				return false
		}
 		var varNextDot = ldot+1;
 		for(i=0; i<10; i++)
 		{
	 		if (str.indexOf(dot,(varNextDot))==varNextDot)
	 		{
		 	   alert("continuous . symbol is not allowed")
		 	   varNextDot=varNextDot+1;
		 	   document.form1.stremail.focus();
		 	   return false
	 		 }
	 	 }

	 	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
 		 {
	 	    	alert("Please enter a valid emailid")
	 			document.form1.stremail.focus();
	 			return false
		 }
	 	 if (str.indexOf(dot,(lat+2))==-1)
 		 {
	 			alert("Please enter a valid emailid")
	 			document.form1.stremail.focus();
	 			return false
 		 }
		 else
		 {
		 document.form1.action = "QuoteFormAction.php";
		 document.form1.method = "post";
		 document.form1.submit();
		 }		 
 	 }

}
function validate()
{
//alert ("test");
if (document.formquote.make.value == "")
	{
	alert ("Please Select Make");
	document.formquote.make.focus();
	return (false);
	}
if (document.formquote.model.value == "")
	{
	alert ("Please Select Model");
	document.formquote.model.focus();
	return (false);
	}	
if (document.formquote.strZIP.value == "")
	{
	alert ("Please Enter ZIP");
	document.formquote.strZIP.focus();
	return (false);
	}		
}
function createRequest()
{
	var reqObj = null;
	try {
	   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (err)	{
	   try {
		reqObj = new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   catch (err2) {
		try {
		   reqObj = new XMLHttpRequest();
		}
		catch (err3) {
		   reqObj = null;
		}
	   }
	}
	return reqObj;
}
function callback() 
{
//alert ("hello");
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
	objLinkList 	= eval("document.form1."+"model");
	//objLinkList 	= eval("formquote.model");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList[i].text =results[i];
		objLinkList[i].value = results[i];
	}
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}

function callchange()
{
//alert("hi hi hi hi");
xmlhttp = createRequest();
if(xmlhttp != null)
{
//alert ("final");
var mid = document.form1.make.value;
//alert (mid);
// call open with GET or POST, the URL, and true for asynchronous
if(mid != "")
{
//alert ("Focus");
xmlhttp.open("GET","Model_Details.php?mid="+mid+"&rand="+Math.random(1,10), true);
xmlhttp.onreadystatechange = callback;
xmlhttp.send(null);
}
}

function focus1()
{
//alert ("Focus");
}
}
function callbackstate() 
{
//alert ("hello");
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
	objLinkList 	= eval("document.formquote."+"strCity");
	//objLinkList 	= eval("formquote.strCity");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		//var opt = document.createElement('option');
		//opt.text = results[i];
		//opt.value = results[i];
		//objLinkList[i] = opt;		
		objLinkList[i].text =results[i];
		objLinkList[i].value = results[i];
	}
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}
function callstate()
{
xmlhttp = createRequest();
if(xmlhttp != null)
{
//alert ("final");
var mid = document.getElementById('strState').value;
//alert (mid);
// call open with GET or POST, the URL, and true for asynchronous
if(mid != "")
{
xmlhttp.open("GET","State_Details.php?sid="+document.getElementById('strState').value, true);
xmlhttp.onreadystatechange = callbackstate;
xmlhttp.send(null);
}
}
}
function callback2() 
{
//alert ("hello");
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name1 = xmlhttp.responseText;
	  //alert (name1);
	objLinkList 	= eval("document.formquote."+"strZIP");
	//objLinkList 	= eval("formquote.strZIP");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	//for(i=0;i<=results[0];i++)
	//{
		//objLinkList.length++;
		objLinkList.text =name1;
		objLinkList.value = name1;
	//}
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}
function callZip()
{
xmlhttp = createRequest();
if(xmlhttp != null)
{
//alert ("final");
var zid = document.formquote.strCity.options[document.formquote.strCity.selectedIndex].text;
//alert (zid);
// call open with GET or POST, the URL, and true for asynchronous
if(zid != "")
{
xmlhttp.open("GET","ZIP_Value.php?zid="+zid, true);
xmlhttp.onreadystatechange = callback2;
xmlhttp.send(null);
}
}
}
function call()
{
	//alert ("test");
xmlhttp = createRequest();
if(xmlhttp != null)
{
	//alert ("done");
	var zzid = document.form1.strZIP.value;	
	//alert (zzid);
	xmlhttp.open("GET","StateCity.php?zid="+zzid+"&rand="+Math.random(1,10), true);
	xmlhttp.onreadystatechange = callback3;
	xmlhttp.send(null);		
}
}
function callback3() 
{
//alert ("hello");
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	 if (name == "")
	 {
		 alert ("inavalid Zip Code");
	 }
	 
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
		//alert(results[1]);
			//alert(results[2]);
	objLinkList1 	= eval("document.form1."+"strState");
	objLinkList 	= eval("document.form1."+"strCity");
	//objLinkList 	= eval("formquote.strCity");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList.text =results[1];
		objLinkList.value = results[1];
	}
	for(i=2;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList1.text =results[2];
		objLinkList1.value = results[2];		
	}	
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}
function calltrim1()
{

}
function pause(numberMillis) {
        var now = new Date();
        var exitTime = now.getTime() + numberMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
                return;
        }
    }
/*********************** For Trim Details *******************/
function createRequest1()
{
	var reqObj = null;
	try {
	   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (err)	{
	   try {
		reqObj = new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   catch (err2) {
		try {
		   reqObj = new XMLHttpRequest();
		}
		catch (err3) {
		   reqObj = null;
		}
	   }
	}
	return reqObj;
}
function calltrim()   
{
		//alert ("test");
xmlhttp = createRequest1();
//setTimeout("calltrim1()", 3000);
//pause(1000);
if(xmlhttp != null)
{
//alert ("final");
var modid = document.form1.model.value;
//alert (modid);
// call open with GET or POST, the URL, and true for asynchronous
if(modid != "")
{
xmlhttp.open("GET","Trim_Details.php?modid="+modid+"&rand="+Math.random(1,10), true);
xmlhttp.onreadystatechange = calltrimdet;
xmlhttp.send(null);
}
}
}
function calltrimdet() 
{
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
	objLinkList 	= eval("document.form1."+"trim");
	//objLinkList 	= eval("formquote.model");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList[i].text =results[i];
		objLinkList[i].value = results[i];
	}
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}
/*********************** For Trim Details *******************/

/*********************** For Exterior Color Details *******************/
function createRequest2()
{
	var reqObj = null;
	try {
	   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (err)	{
	   try {
		reqObj = new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   catch (err2) {
		try {
		   reqObj = new XMLHttpRequest();
		}
		catch (err3) {
		   reqObj = null;
		}
	   }
	}
	return reqObj;
}
function callexterior()   
{
		//alert ("test1");
xmlhttp = createRequest2();
//pause(1000);
if(xmlhttp != null)
{
//alert ("final");
var modid = document.formquote.model.value;
//alert (modid);
// call open with GET or POST, the URL, and true for asynchronous
if(modid != "")
{
xmlhttp.open("GET","Exterior_Details.php?modid="+modid+"&rand="+Math.random(1,10), true);
xmlhttp.onreadystatechange = callexteriordet;
xmlhttp.send(null);
}
}
}
function callexteriordet() 
{
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
	objLinkList 	= eval("document.formquote."+"excolor");
	//objLinkList 	= eval("formquote.model");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList[i].text =results[i];
		objLinkList[i].value = results[i];
	}
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}
/*********************** For Exterior Color Details *******************/

/*********************** For Inner Color Details *******************/
function createRequest3()
{
	var reqObj = null;
	try {
	   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (err)	{
	   try {
		reqObj = new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   catch (err2) {
		try {
		   reqObj = new XMLHttpRequest();
		}
		catch (err3) {
		   reqObj = null;
		}
	   }
	}
	return reqObj;
}
function callinterior()   
{
	//alert ("test2");
xmlhttp = createRequest3();
//pause(1000);
if(xmlhttp != null)
{
//alert ("final");
var modid = document.formquote.model.value;
//alert (modid);
// call open with GET or POST, the URL, and true for asynchronous
if(modid != "")
{
xmlhttp.open("GET","Interior_Details.php?modid="+modid+"&rand="+Math.random(1,10), true);
xmlhttp.onreadystatechange = callinteriordet;
xmlhttp.send(null);
}
}
}
function callinteriordet() 
{
	if (xmlhttp.readyState == 4) {
	//alert(xmlhttp.readyState);
		//alert(xmlhttp.status);
	  if (xmlhttp.status == 200) {
	  var name = xmlhttp.responseText;
	  //alert (name);
	   var results = xmlhttp.responseText.split(",");
	//alert(results[0]);
	objLinkList 	= eval("document.formquote."+"incolor");
	//objLinkList 	= eval("formquote.model");
	objLinkList.length=1;
	//alert (objLinkList.length);	
	//alert (results.length);
	for(i=1;i<=results[0];i++)
	{
		objLinkList.length++;
		objLinkList[i].text =results[i];
		objLinkList[i].value = results[i];
	}
	//alert(results);
	   }
      else {
         // an error occurred, handle it appropriately
      }
	}
}
/*********************** For Inner Color Details *******************/
