function Start()
{
	var a = new Image()
	a.src = "http://www.keylessentryonline.com/Images/Home2.jpg"
	a.src = "http://www.keylessentryonline.com/Images/About2.jpg"
	a.src = "http://www.keylessentryonline.com/Images/Factory2.jpg"
	a.src = "http://www.keylessentryonline.com/Images/Aftermarket2.jpg"
	a.src = "http://www.keylessentryonline.com/Images/Search2.jpg"
	a.src = "http://www.keylessentryonline.com/Images/Contact2.jpg"
	a.src = "http://www.keylessentryonline.com/Images/Cart2.jpg"
}

function CheckForm()
{
	var CC = document.getElementById("CC").value
	var exm = document.getElementById("exm").options[document.getElementById("exm").selectedIndex].value
	var exy = document.getElementById("exy").options[document.getElementById("exy").selectedIndex].value
	var CCV = document.getElementById("CCV").value
	
	var billFirst = document.getElementById("billFirst").value
	var billLast = document.getElementById("billLast").value
	var billAddress = document.getElementById("billAddress").value
	var billCity = document.getElementById("billCity").value
	var x=document.getElementById("billState")
	var billState = x.options[x.selectedIndex].value
	var billZip = document.getElementById("billZip").value
	
	var shipFirst = document.getElementById("shipFirst").value
	var shipLast = document.getElementById("shipLast").value
	var shipAddress = document.getElementById("shipAddress").value
	var shipCity = document.getElementById("shipCity").value
	var y=document.getElementById("shipState")
	var shipState = y.options[y.selectedIndex].value
	var shipZip = document.getElementById("shipZip").value
	
	var Email = document.getElementById("Email").value
	
	if (CC && exm && exy && CCV && billFirst && billLast && billAddress && billCity && billState && billZip && shipFirst && shipLast && shipAddress && shipCity && shipState && shipZip && Email)
	{
		document.getElementById("Submit").innerHTML = '<input type="Submit" value="Submit" />'
	}
	else
	{
		document.getElementById("Submit").innerHTML = '<font color="red">*</font>Field is required.  Please fill out all required fields to activate the submit button.<br /><input type="submit" value="Submit (Disabled)" disabled />'
	}
}

function UseAbove()
{
	var billFirst = document.getElementById("billFirst").value
	var billLast = document.getElementById("billLast").value
	var billAddress = document.getElementById("billAddress").value
	var billCity = document.getElementById("billCity").value
	var x=document.getElementById("billState")
	var billState = x.options[x.selectedIndex].value
	var billZip = document.getElementById("billZip").value

	document.getElementById("shipFirst").value = billFirst
	document.getElementById("shipLast").value = billLast
	document.getElementById("shipAddress").value = billAddress
	document.getElementById("shipCity").value = billCity
	var y=document.getElementById("shipState")
	y.options[y.selectedIndex].value = billState
	y.options[y.selectedIndex].text = billState
	document.getElementById("shipZip").value = billZip

	CheckForm()
}

function DoSearch(method,cat)
{
	document.getElementById("VehicleTab").className = "stab"
	document.getElementById("ItemTab").className = "stab"
	document.getElementById("KeywordTab").className = "stab"
	document.getElementById("BrowseTab").className = "stab"
	
	document.getElementById("VehicleTab").style.zIndex = 4
	document.getElementById("ItemTab").style.zIndex = 3
	document.getElementById("KeywordTab").style.zIndex = 2
	document.getElementById("BrowseTab").style.zIndex = 1
	
	document.getElementById(method + "Tab").className = "mtab"
	document.getElementById(method + "Tab").style.zIndex = 5
	
	var cshow = cat
	var ctext = ""
	if (method == "Vehicle" || cat == "Factory")
	{
		cshow = "Factory Remotes"
	}
	else if (cat == "Aftermarket")
	{
		cshow = "Aftermarket Remotes"
	}
	else if (cat == "Magnadyne")
	{
		cshow = "Magnadyne Products"
	}
	else if (cat == "Security")
	{
		cshow = "Auto Security Products"
	}
	
	if (method == "Vehicle")
	{
		ctext = "<h2>Vehicle Search</h2><br />If you know the year, make, and model of the vehicle you want a remote for, you can enter them here.  The system will display all remotes that work with your chosen vehicle.  <b>Note:</b> This system searches Factory Remotes only."
	}
	else if (method == "Item")
	{
		ctext = "<h2>Item Search</h2><br />If you know the FCC  ID or Part Number, type it into the appropriate box, or select it from our list.  The system will display all remotes with the listed IDs."
	}
	else if (method == "Keyword")
	{
		ctext = "<h2>Keyword Search</h2><br />Enter a keyword into the search box to view all items in your current category (" + cat + ") that have that keyword in their information."
	}
	else if (method == "Browse")
	{
		ctext = "<h2>Browse</h2><br />Select a make or brand from the list provided, and refine your search by choosing a model.  Then, select the product whose information you wish to view."
	}
	
	document.getElementById("catname").innerHTML = "Searching " + cshow
	document.getElementById("infotext").innerHTML = ctext
	
	xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="DoSearch.php?method=" + method + "&cat=" + cat + "&sid="+Math.random()
  xmlHttp.onreadystatechange=ListSearch
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}

function ListSearch() 
{ 
	if (xmlHttp.readyState==1)
	{
		document.getElementById("folder").innerHTML="Loading."
	}
	if (xmlHttp.readyState==2)
	{
		document.getElementById("folder").innerHTML="Loading.."
	}
	if (xmlHttp.readyState==3)
	{
		document.getElementById("folder").innerHTML="Loading..."
	}
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
    document.getElementById("folder").innerHTML=xmlHttp.responseText
  }
}

function FillMake()
{
	var x=document.getElementById("Year")
	var choice=x.options[x.selectedIndex].value
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="FillMake.php?choice=" + choice + "&sid="+Math.random()
  xmlHttp.onreadystatechange=DoFill2
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}

function DoFill2() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
    document.getElementById("Makes").innerHTML=xmlHttp.responseText
  }
}

function FillModel()
{
	var x=document.getElementById("MakeList")
	var choice=x.options[x.selectedIndex].value
	var x=document.getElementById("Year")
	var choice2=x.options[x.selectedIndex].value
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="FillModel.php?choice=" + choice + "&choice2=" + choice2 + "&sid="+Math.random()
  xmlHttp.onreadystatechange=DoFill
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}

function DoFill() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
    document.getElementById("Models").innerHTML=xmlHttp.responseText
  }
}

function Go(choice)
{
	document.location = choice;
}

function Over(choice)
{
	document.getElementById(choice).src = "http://www.keylessentryonline.com/Images/" + choice + "2.jpg"
}

function Out(choice)
{
	document.getElementById(choice).src = "http://www.keylessentryonline.com/Images/" + choice + ".jpg"
}

function AJAX_FUNCTION(DOVAR)
{
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request")
    return
  } 
  var url="PHP_PAGE.php?VAR=" + DOVAR + "&sid="+Math.random()
  xmlHttp.onreadystatechange=AJAXCALL
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
}

function AJAXCALL() 
{ 
  if ((xmlHttp.readyState==4 || xmlHttp.readyState=="complete"))
  { 
    document.getElementById("AJAXDIV").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;
}