// JavaScript Document
function GetXmlHttpObject(handler)
{
   var objXMLHttp=null
   if (window.XMLHttpRequest)
   {
       objXMLHttp=new XMLHttpRequest()
   }
   else if (window.ActiveXObject)
   {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
   }
   return objXMLHttp
}
//

// Will populate data based on input
function getManufacturer(manuId)
{
   //update when live
   var url = 'manufacturers.php';	
   
   if (manuId==0)
   {
	  document.getElementById('divManufacturer').innerHTML = 
	  '<select name="productManufacturer" id="productManufacturer" class="style-select"><option>Manufacturer</option></select>';

		return;
   }
   
  document.getElementById('divManufacturer').innerHTML = 
  '<select name="productManufacturer" id="productManufacturer" class="style-select"><option>loading...</option></select>';
	  
 
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

   url=url+"?m="+manuId;
   url=url+"&sid="+Math.random();

   xmlHttp.onreadystatechange = 
   function()
   {
	   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	   {
			document.getElementById("divManufacturer").innerHTML= xmlHttp.responseText;
			
			if(	document.getElementById("div1") && document.getElementById("div2"))
			{
				if( manuId>2){
					document.getElementById("div1").style.display='none';
					document.getElementById("div2").style.display='';
				}
				else{
					document.getElementById("div1").style.display='';
					document.getElementById("div2").style.display='none';
				}
			}
	   }
   }
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}
