/**
*
*for pulling model type based on selected make
*
*/

var xmlHttp


function showModel(str)

{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
 var url="pomod_prc.php"

url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 } 
}


function switchstate(sta)
 { 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="sw_state2.php"
 url=url+"?s="+sta
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateswitched 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 } 

function stateswitched() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtState").innerHTML=xmlHttp.responseText 
 } 
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}



function CopyInput(form) {
form.sh_fname.value = form.fname.value;
form.sh_lname.value = form.lname.value;
form.sh_company.value = form.company.value;
form.sh_address.value = form.address.value;
form.sh_city.value = form.city.value;
form.sh_state.value = form.state.selectedIndex;
form.sh_zip.value = form.zip.value;
form.sh_state.value = form.state.value;
form.sh_country.value = form.country.value;
form.sh_phone.value = form.phone.value;
form.sh_fax.value = form.fax.value;
form.sh_email.value = form.email.value;
}


//to check all required fields

function checkall() {

if (document.form1.year.selectedIndex == "")
{document.form1.year.focus();
alert ("You must first select the Year of the vehicle")
return false;
}

if (document.form1.make.selectedIndex == "")
{document.form1.make.focus();
alert ("Please select the Vehicel Make")
return false;
}

if (document.form1.models.selectedIndex == "")
{document.form1.models.focus();
alert ("Please select the Vehicel Model")
return false;
}

if (document.form1.engine.value == "")
{document.form1.engine.focus();
alert ("Please enter the Engine Size")
return false;
 }

if (document.form1.subject.value == "")
{document.form1.subject.focus();
alert ("Please enter a Brief caption of the ECM problem")
return false;
 }


 if (document.form1.explain.value == "") {
   document.form1.explain.focus();
   alert("The Explanation field cannot be empty");
   return false;
 }


if (!document.form1.Agree.checked)
{document.form1.Agree.focus();
alert ("You must agree to our Terms of Sale")
return false;
 }


if (document.form1.fname.value == "")
{document.form1.fname.focus();
alert ("Please enter your Firstname")
return false;
}


if (document.form1.lname.value == "")
{document.form1.lname.focus();
alert ("Please enter your Lastname")
return false;
}


if (document.form1.address.value == "")
{document.form1.address.focus();
alert ("Please enter your billing Address")
return false;
}

if (document.form1.city.value == "")
{document.form1.city.focus();
alert ("Please enter your billing City")
return false;
 }

if (document.form1.state.value == "")
{document.form1.state.focus();
alert ("Please enter your billing State")
return false;
}

if (document.form1.zip.value == "")
{document.form1.zip.focus();
alert ("Please enter your billing Zip code")
return false;
 }

if (document.form1.email.value.length < 7 || document.form1.email.value.indexOf("@")==-1 || document.form1.email.value.indexOf(".")==-1 || document.form1.email.value.indexOf("!")!=-1){
  document.form1.email.focus();
  alert("You did not provide a valid Email address. A valid\nEmail address would look something like this:\n\nusername@yourdomain.com\n");
  return false;
 }

 return true;
}

