var xmlHttp;

function showKwd(form)
{ 
  xmlHttp = GetXmlHttpObject();
  
  if(form.keyword.value.length != 0)
    document.getElementById("sres").style.visibility = "visible";
  else
    hideKwd();
  
  if(xmlHttp == null)
  {
    alert("Your browser does not support AJAX!");
    return;
  } 
  
  var url    = "prodotti_src.php";
  var params = "kwd=" + form.keyword.value;
       
  xmlHttp.onreadystatechange = stateChanged2;
  xmlHttp.open("POST",url,true);

  //Send the proper header information along with the request
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
  // xmlHttp.setRequestHeader("Content-type", "application/xhtml+xml;charset=iso-8859-1");
  xmlHttp.setRequestHeader("Content-length", params.length);
  xmlHttp.setRequestHeader("Connection", "close");
  
  xmlHttp.send(params);
  // xmlHttp.send(null);
} 

function stateChanged2() 
{ 
 if(xmlHttp.readyState == 4)
 { 
   if(xmlHttp.responseText.length != 0)
     document.getElementById("sres").innerHTML = xmlHttp.responseText;
   else
     hideKwd();
 }
}

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 setKwd(kwd)
{
  document.forms[0].keyword.value = kwd;
  document.getElementById("sres").style.visibility = "hidden";
  document.forms[0].submit();
}

function hideKwd()
{
  document.getElementById("sres").style.visibility = "hidden";
}

