
window.onload = function() {
	if(document.getElementById("searchkeywords")) {
		document.getElementById("searchkeywords").focus();
	}
}


function setResultsValue(searchresultsdiv,imghostdiv)
{
    window.imghostdiv = imghostdiv;
    window.resultsdiv = searchresultsdiv;
}

var SrchxmlHttp;
var resultsdiv;
var imghostdiv;


function showArticle(str,name,results,imghostdiv)
{ 

setResultsValue(results,imghostdiv)


if (SrchxmlHttp != null && SrchxmlHttp.readyState != 0 && SrchxmlHttp.readyState != 4)
 {
   SrchxmlHttp.abort();
 }
 
 try
 {
   SrchxmlHttp = new XMLHttpRequest();
 } 
 catch (error)
 {
   try
   {
     SrchxmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch (error)
   {
     SrchxmlHttp = null;

     return false;
   }
 }
  
var url="http://www.toolkitsupport.co.uk/getarticle.asp"
url=url+"?keywords="+str
SrchxmlHttp.onreadystatechange=SearchStateChanged;
SrchxmlHttp.open("GET",url,true)
SrchxmlHttp.send(null)

}

function SearchStateChanged() 
{ 
var theheight = 0;
if (SrchxmlHttp.readyState==4 || SrchxmlHttp.readyState=="complete")
{ 
 /* If the data was retrieved successfully */
   if (SrchxmlHttp.status == 200)
   {
     document.getElementById(window.imghostdiv).style.display = "none";
     document.getElementById(window.resultsdiv).innerHTML=SrchxmlHttp.responseText 
	//toolkit_canned_response.focus();
	if(document.getElementById("searchMenu")) {
		//document.getElementById("searchMenu").focus();
		theheight = 18 * Number(document.getElementById("countarticles").value);
		if (theheight > 100) { 
			theheight = 100;
		}
 		document.getElementById("searchMenu").style.display = "block"; 
		document.getElementById("searchMenu").style.height = theheight+'px';
		document.getElementById("searchMenu").style.zindex = 999;
	}
     //alert (SrchxmlHttp.responseText)
   }
   /* IE returns a status code of 0 on some occasions, so ignore this case */
   else if (SrchxmlHttp.status != 0)
   {
     document.getElementById(window.imghostdiv).style.display = "none";
     alert("There was an error whilst retrieving your results: " + SrchxmlHttp.statusText);
   } 
} 
else {
document.getElementById(window.imghostdiv).style.display = "block";

}
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
