
var xmlHttp

function showCustomer(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="mod_ecm2.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)
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}


// switch for zip code
function ZipChg(zt)
 { 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="upship.php"
 url=url+"?s="+zt
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=zcode 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 } 

function zcode() 
{ 
if (xmlHttp.readyState==4)
 { 
 document.getElementById("txtZip").innerHTML=xmlHttp.responseText 
 } 
}


// for switching make field
function chgStatus(sta)
{ 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="chgstatus.php"
 url=url+"?s="+sta
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=chgState 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 } 

function chgState() 
{ 
if (xmlHttp.readyState==4)
 { 
 document.getElementById("makstatus").innerHTML=xmlHttp.responseText 
 } 
}


//for switching model

function chgMode(str)
{ 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="chgmode.php"
 url=url+"?p="+str
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=statechg 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 } 

function statechg() 
{ 
if (xmlHttp.readyState==4)
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 } 
}


// switch state
function switchstate(st)
{ 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="sw_state.php"
 url=url+"?k="+st
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateswitched 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 } 

function stateswitched() 
{ 
if (xmlHttp.readyState==4)
 { 
 document.getElementById("txtstate").innerHTML=xmlHttp.responseText 
 } 
}



// for ALL

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;
}

// end of AJAX


// step 2 address copy over

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;
}


// credit card cvv location help
function SecCode()
{
OpenWin = this.open("http://www.dieselecm.com/ccv.php", "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=300,height=380");
}



//step 2 check data

function checkdata() {

if (document.datareq.make.value == "")
{document.datareq.make.focus();
alert ("Please enter the Vehicel Make")
return false;
}

if (document.datareq.model.value == "")
{document.datareq.model.focus();
alert ("Please enter the Engine Model #")
return false;
}

if (document.datareq.cpl.value == "")
{document.datareq.cpl.focus();
alert ("Please enter the Model Engine CPL#")
return false;
 }

if (document.datareq.part_nr.value == "")
{document.datareq.part_nr.focus();
alert ("Please enter the ECM Part #")
return false;
 }


 if (document.datareq.subject.value.length < 4) {
   document.datareq.subject.focus();
   alert("Either you did not enter a Brief caption of the problem or the field contains\ntoo few characters. Please give a brief caption of your ECM problem.");
   return false;
 }

 if (document.datareq.message.value.length < 4) {
   document.datareq.message.focus();
   alert("The Engine or Truck Problem area contains too few characters.\nPlease describe what you think is the problem with your unit.");
   return false;
 }

if (!document.datareq.Agree.checked)
{document.datareq.Agree.focus();
alert ("You must agree to our Terms of Sale")
return false;
 }


 return true;
}


//step 3 check data

function checkinfo() {

if (document.inforeq.fname.value == "")
{document.inforeq.fname.focus();
alert ("Please enter your Firstname")
return false;
}

if (document.inforeq.lname.value == "")
{document.inforeq.lname.focus();
alert ("Please enter your Lastname")
return false;
}

if (document.inforeq.address.value == "")
{document.inforeq.address.focus();
alert ("Please enter your billing Address")
return false;
}

if (document.inforeq.city.value == "")
{document.inforeq.city.focus();
alert ("Please enter your billing City")
return false;
 }

if (document.inforeq.state.value == "")
{document.inforeq.state.focus();
alert ("Please enter your billing State")
return false;
}

if (document.inforeq.zip.value == "")
{document.inforeq.zip.focus();
alert ("Please enter your billing Zip code")
return false;
 }

if (document.inforeq.email.value.length < 7 || document.inforeq.email.value.indexOf("@")==-1 || document.inforeq.email.value.indexOf(".")==-1 || document.inforeq.email.value.indexOf("!")!=-1){
  document.inforeq.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;
}


//step 4 check shipping

function checkship() {

if (document.form1.qtyB.value == "")
{document.form1.qtyB.focus();
alert ("Please select a Shipping method")
return false;
}

if (document.form1.qty.value == "")
{document.form1.qty.focus();
alert ("Quantity field cannot be empty")
return false;
}

if (document.form1.qty.value == 0)
{document.form1.qty.focus();
alert ("Quantity cannot be 0")
return false;
}

 return true;
}


// calculation revolver
function shCour()
{
var shlist=document.getElementById("shList");
document.getElementById("courier").value=shlist.options[shlist.selectedIndex].text;
}

