var xmlHttp;

//  showContent
function showContent(strElementID, strFile)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url=strFile; 

switch (strElementID)
	{
	case "menu":
		xmlHttp.onreadystatechange=stateChanged_menu;
		break;
	case "main":
		xmlHttp.onreadystatechange=stateChanged_main;
		break;
	case "section1":
		xmlHttp.onreadystatechange=stateChanged_section1;
		break;
	case "section2":
		xmlHttp.onreadystatechange=stateChanged_section2;
		break;
	case "section3":
		xmlHttp.onreadystatechange=stateChanged_section3;
		break;
	case "section4":
		xmlHttp.onreadystatechange=stateChanged_section4;
		break;
	default:
		break;
	}

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

//  stateChanged_menu
function stateChanged_menu() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("menu").innerHTML=xmlHttp.responseText;
	}
}

//  stateChanged_main
function stateChanged_main() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("main").innerHTML=xmlHttp.responseText;
	}
}

//  stateChanged_section1
function stateChanged_section1() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("section1").innerHTML=xmlHttp.responseText;
	}
}

//  stateChanged_section2
function stateChanged_section2() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("section2").innerHTML=xmlHttp.responseText;
	}
}

//  stateChanged_section3
function stateChanged_section3() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("section3").innerHTML=xmlHttp.responseText;
	}
}

//  stateChanged_section4
function stateChanged_section4() 
{ 
if (xmlHttp.readyState==4)
	{
	document.getElementById("section4").innerHTML=xmlHttp.responseText;
	}
}

//  GetXmlHttpObject
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;
}


/*****************************
**  Dealer Search routines  **
*****************************/
// 	dealers_AfterBrands()
function dealers_AfterBrands()
{
showContent('section2','buyData.php?action=select&brand='+document.dealerSearch.brand.value);
document.getElementById("section3").innerHTML="";
document.getElementById("section4").innerHTML="";
}

// 	dealers_AfterCountry()
function dealers_AfterCountry()
{
showContent('section3','buyData.php?action=select&brand='+document.dealerSearch.brand.value+'&country='+document.dealerSearch.country.value);
}

// 	dealers_AfterCity()
function dealers_AfterCity()
{
showContent('section4','buyData.php?action=lookup&brand='+document.dealerSearch.brand.value+'&country='+document.dealerSearch.country.value+'&city='+document.dealerSearch.city.value);
}


/*****************************
**  Servicer Search routines  **
*****************************/
// 	servicer_AfterBrands()
function servicer_AfterBrands()
{
showContent('section2','serviceData.php?action=select&brand='+document.servicerSearch.brand.value);
document.getElementById("section3").innerHTML="";
document.getElementById("section4").innerHTML="";
}

// 	servicer_AfterCountry()
function servicer_AfterCountry()
{
showContent('section3','serviceData.php?action=select&brand='+document.servicerSearch.brand.value+'&country='+document.servicerSearch.country.value);
}

// 	servicer_AfterCity()
function servicer_AfterCity()
{
showContent('section4','serviceData.php?action=lookup&brand='+document.servicerSearch.brand.value+'&country='+document.servicerSearch.country.value+'&city='+document.servicerSearch.city.value);
}
