
function loadData(name,table,value,value2,id,limit)
{
 //alert(' - '+name+' - '+table+' - '+value+' - '+value2+' - '+id+' - '+limit+' - ');
 //document.getElementById('marca').innerHTML='<option value="">Loading...</option>';
 document.getElementById(name).options.length=0; document.getElementById(name).options[0]=new Option("Loading...","",true,false);

 var xmlHttp;
 try
 {
  // Firefox, Opera 8.0+, Safari
  xmlHttp= new XMLHttpRequest();
 }
 catch (e)
 {
  // Internet Explorer
  try
  {
   xmlHttp= new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
   try
   {
    xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch (e)
   {
    alert("Your browser does not support AJAX!");
    return false;
   }
  }
 }

 xmlHttp.onreadystatechange= function()
 {
// 0	The request is not initialized
// 1	The request has been set up
// 2	The request has been sent
// 3	The request is in process
// 4	The request is complete
  if(xmlHttp.readyState==1)
  {
   //document.getElementById('marca').innerHTML='<option value="">Loading...</option>';
   //document.getElementById('marca').innerHTML='<option value=""></option>';
   document.getElementById(name).options.length=0; document.getElementById(name).options[0]=new Option("Loading...","",true,false);
  }
  if(xmlHttp.readyState==4)
  {
   //alert(xmlHttp.responseText);
   // Get the data from the server's response
   //document.getElementById('marca').innerHTML=xmlHttp.responseText;
   document.getElementById(name).options.length=0;
   elements=xmlHttp.responseText.split('.');
   for(i=0;i<elements.length;i++)
   {
    option=elements[i].split(',');
    document.getElementById(name).options[i]=new Option(option[0],option[1],(option[2]==1)?true:false,(option[3]==1)?true:false);
   }
  }
 }

 //xmlHttp.open("GET","getdata.php?t="+table+"&f="+name+"&v="+value+"&id="+id+"&r="+Math.ceil(99+Math.random()*900),true); //don't need table 't' ?...
 if(table=='marci') xmlHttp.open("GET","/app/getdata.php?t="+table+"&f="+name+"&v="+value+"&id="+id+(limit?("&limit="+limit):'')+"&r="+Math.ceil(99+Math.random()*900),true);
 if(table=='modele') xmlHttp.open("GET","/app/getdata.php?t="+table+"&f="+name+"&v1="+value+"&v2="+value2+"&id="+id+"&r="+Math.ceil(99+Math.random()*900),true);
 xmlHttp.send(null);

}
