var xmlHttp;

function showHint(str)
{ 
  document.getElementById("txtHint").innerHTML="<img src=\""+webroot+"/comments/images/loading.gif\">";
if (str.length > 0)
{ 
  var url = webroot+"/comments/response.php?sid=" + Math.random() + str
  
  xmlHttp=GetXmlHttpObject(stateChanged)
  xmlHttp.open("POST", url , true)
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", str.length);
  xmlHttp.setRequestHeader("Connection", "close");
  
  xmlHttp.send(str);
} 
else
{ 
  document.getElementById("txtHint").innerHTML="";
} 
} 

function stateChanged()
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
    document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
    var str = xmlHttp.responseText;
    if(str.indexOf("received")!='-1')
      document.getElementById("comments").innerHTML="";
  }
}

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp

}
if (navigator.userAgent.indexOf("MSIE")>=0)
{
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
} 
