// Fonctions pour la recherche sur le site
var xmlHttp;
function testHint(aStr){
	if (aStr.length >0){
		if (document.getElementById('rdbens').checked==true) 
			showHint(aStr,1,0);
		else
		if (document.getElementById('rdbsite').checked==true) 
			showHint(aStr,0,0);
	}
}

function showHint(str,ens,res)	 {
	if (res==1) { document.getElementById('motif').value = "";}
	
	if (str.length==0) {
		 document.getElementById('txtHint').innerHTML="Vous cherchez...";
		 return;
	 }
	 xmlHttp=GetXmlHttpObject()
	 if (xmlHttp==null) {
		 alert ("Browser does not support HTTP Request");
		 return;
	 }
	 var url="ajaxtest.php";
	 url=url+"?q="+str;
	 url=url+"&ens="+ens;
	 url=url+"&res="+res;
	 url=url+"&sid="+Math.random();
	 xmlHttp.onreadystatechange=stateChanged ;
	 xmlHttp.open("GET",url,true);
	 xmlHttp.send(null);
 }

 function stateChanged(){
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
	 document.getElementById('txtHint').innerHTML=xmlHttp.responseText ;
	 }
 }
 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;
 }

function disableCR(){
    if((event.keyCode==13)||(event.which==13)){
            return false
	        }
}


