function autoCompOff(id)
{
	document.getElementById(id).setAttribute("autocomplete","off");
}

function addEvent(obj, event, fct) {
    if (obj.attachEvent) //Est-ce IE ?
        obj.attachEvent("on" + event, fct); //Ne pas oublier le "on"
    else
        obj.addEventListener(event, fct, true);
}

function al4()
{
	autoCompOff("categorie_rech");
	autoCompOff("location_rech");
}
addEvent(window , "load", al4);

function whereismouse(obj)
{
	if (obj.id!="categorie_rech" || obj.id!="resultats1" || obj.id!="resultlist1" || obj.id!="categorie_rech" || obj.id!="resultats2" || obj.id!="resultlist2")
	{
		document.getElementById('resultats1').innerHTML = "";
		document.getElementById('resultats1').style.display = "none";
		document.getElementById('resultats2').innerHTML = "";
		document.getElementById('resultats2').style.display = "none";
	}
}

function checkSearch(mot, champ, champs_result)
{
	if(mot.length>1)
	{
		var xhr; 
		try 
		{  
			xhr = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch(e) 
		{
			try{xhr = new ActiveXObject('Microsoft.XMLHTTP');}
			catch(e2)
			{
				try{xhr = new XMLHttpRequest();}
				catch(e3){xhr = false;}
			}
		}

		xhr.onreadystatechange = function()
		{ 
			if(xhr.readyState  == 4)
			{
				if(xhr.status  == 200)
				{
					document.getElementById(champs_result).style.display = "block";
					document.getElementById(champs_result).innerHTML = xhr.responseText;
				}
				else
				{
					document.resultats="Error code " + xhr.status;
				}
			}
		};

		xhr.open("GET", "./recherche.php?type="+champ+"&quoi="+mot, true);
		xhr.send(null);
	}
	else
	{
		document.getElementById(champs_result).innerHTML = "";
	}
}

function gotoresult(result, champ)
{
	//document.location.href="./result.php?ville="+result;
	document.getElementById(champ).value = result;
}


