function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

function ChangeCritere(num_agence, partenaires)
{
	xmlHttpCat =GetXmlHttpObject()
	if (xmlHttpCat==null)
	{
		alert ("Votre navigateur ne supporte pas les requêtes HTTP")
		return
	}
	
	xmlHttpVille = GetXmlHttpObject()
	
	document.frm.categorie.style.visibility="hidden";  
	document.frm.ville.style.visibility="hidden";  
	
	 
	var transaction
	if (document.frm.transaction.length == null)
		transaction = "VENTE"
	else 
		transaction = (document.frm.transaction[0].checked) ? "VENTE" : "LOCATION"
	
	var param = "?num_agence=" + num_agence + "&partenaires="+ partenaires +"&transaction=" + transaction + "&Type_Bien=" + document.frm.type_bien.value + "&Prix=" + document.frm.prix.value;	
	
	var url
	
	url = "Categorie.asp" + param
	
	xmlHttpCat.onreadystatechange=stateCategorieChanged 
	xmlHttpCat.open("GET",url,true)
	xmlHttpCat.send(null)
	
	url= "Ville.asp" + param
	xmlHttpVille.onreadystatechange=stateVilleChanged 
	xmlHttpVille.open("GET",url,true)
	xmlHttpVille.send(null)
}

function stateCategorieChanged() 
{ 
	var selIndex;
	selIndex=0;
	if (xmlHttpCat.readyState==4 || xmlHttpCat.readyState=="complete")
	{ 
		opt=xmlHttpCat.responseText;
		document.frm.categorie.length=1;
		arrOp=opt.split('$$');
		var i;
		for(i=0;i<arrOp.length-1;i++)
		{	
			crtOp=arrOp[i].split('@@')
			document.frm.categorie.length = document.frm.categorie.length+1;
			document.frm.categorie.options[document.frm.categorie.length-1]=new Option(crtOp[1],crtOp[0]);
		}
		
		document.frm.categorie.style.visibility="visible";  
	} 
} 

function stateVilleChanged() 
{ 
	var selIndex;
	selIndex=0;
	if (xmlHttpVille.readyState==4 || xmlHttpVille.readyState=="complete")
	{ 
		opt = xmlHttpVille.responseText;
		document.frm.ville.length=1;
		arrOp=opt.split('$$');
		var i;
		for(i=0;i<arrOp.length-1;i++)
		{	
			crtOp=arrOp[i].split('@@')
			document.frm.ville.length = document.frm.ville.length+1;
			document.frm.ville.options[document.frm.ville.length-1]=new Option(crtOp[1],crtOp[0]);
		}
		
		document.frm.ville.style.visibility="visible";  
	} 
} 
