var xmlhttp;
var currSearch;
function showResult(str,idsearch,lang)
{
currSearch = idsearch;

longueur = document.formulaire22.elements['motclef'].value.length;
if (longueur<=1)
{
	document.getElementById(currSearch).innerHTML="";
	document.getElementById(currSearch).style.border="0px";
	document.getElementById(currSearch).style.backgroundColor="transparent";
	return;
}

xmlhttp=GetXmlHttpObject()
if (xmlhttp==null)
  {
  alert ("Your browser does not support XML HTTP Request");
  return;
  }
var url="livesearch.php";
url=url+"?q="+str.value;
url=url+"&t="+str.name;
url=url+"&lg="+lang;
//url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged ;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById(currSearch).innerHTML='<a href="javascript:;" onclick="hideLivesearch();" class="closelivesearch">&nbsp;</a>';
  document.getElementById(currSearch).innerHTML+=xmlhttp.responseText;
  document.getElementById(currSearch).style.border="1px solid #A5ACB2";
  document.getElementById(currSearch).style.backgroundColor="#ffffff";
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function hideLivesearch()
{
 document.getElementById(currSearch).innerHTML="";
 document.getElementById(currSearch).style.border="0px";
 document.getElementById(currSearch).style.backgroundColor="transparent";
}

function assignRubrique(id,string)
{
 document.formulaire.elements['rub'].value = string;
 document.formulaire.elements['rubrique'].value = id;
 hideLivesearch();
}

function assignProspect(id,string)
{
 document.formulaire.elements['prospect_email'].value = string;
 //document.formulaire.elements['prospect_id'].value = id;
 //document.getElementById('prospectok').innerHTML ='<img src="../Images/Icone/check-vert.gif" />';
 hideLivesearch();
}

function assignProduit(id,string)
{
 //document.formulaire22.elements['motclef'].value = string;
 document.formulaire22.elements['noprod'].value = id;
 //document.getElementById('prospectok').innerHTML ='<img src="../Images/Icone/check-vert.gif" />';
 hideLivesearch();
 //permet de valider le formulaire sur le click du produit
 document.formulaire22.submit();
}