var xmlHttp

function showHint(str,divbox,textbox)
{
	if (str.length==0)
	{ 
	  //document.getElementById("txtHint").innerHTML="";
	     document.getElementById(divbox).style.display ="none";
	     return;
	}
	if (document.getElementById("txtHint").innerHTML != "") {
		document.getElementById("suggestbox").style.display ="block";
	} else {
		document.getElementById("suggestbox").style.display ="none";
	}
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	    alert ("Your browser does not support AJAX!");
	    return;
	} 
	
        var url="http://www.enclos.com/gethint.php";
        url=url+"?q="+str;
        url=url+"&sid="+Math.random();
        xmlHttp.onreadystatechange= function(){stateChanged(divbox,textbox)};
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
} 

function stateChanged(divbox,textbox) 
{ 
   if (xmlHttp.readyState==1)
   {document.getElementById('searchinputbox').style.background='url(http://www.enclos.com/images/ajax-loader4.gif) no-repeat right #ededed';
   }
      
   if (xmlHttp.readyState==4)
   { 
   	
      document.getElementById('searchinputbox').style.background= '#ededed';
      document.getElementById(textbox).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 checkSearch(oldkeywords) {
	if (searchwithin.checked) {
	     keywords.value =  oldkeywords+' '+keyword.value;
	    // alert(keywords.value);
	} else {
	    keywords.value =  keyword.value;
	}
}

// Begin
function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}

function UnCheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
// End 


function rollover(id) {
	document.getElementById(id).style.display = 'block';	
}
function rollout(id) {
	document.getElementById(id).style.display = 'none';	
}

function oc(a)
{
  var o = {};
  for(var i=0;i<a.length;i++)
  {o[a[i]]='';}
  return o;
}

function modifyinput() {
	var keyword = document.getElementById('keywords2').value;
	var word = new Array();
	var newkeyword = '';
	word = keyword.split(" ");
	
	for (i=0;i<word.length;i++) {
		if (word[i].length<3 && word[i] in oc(['is', 'at'])) 
			newword = "";
		else 
			newword = word[i];
		newkeyword += newword+" ";
	}
	document.getElementById('keywords').value = newkeyword;
}

// function for select all checkboxes
function Check(chk)
{
	if(document.advance.Check_ctr1.checked==true){
		for (i = 0; i < chk.length; i++)
		chk[i].checked = true ;
	} else {
		for (i = 0; i < chk.length; i++)
		chk[i].checked = false ;
	}
}
function Check2(chk)
{
	if(document.advance.Check_ctr2.checked==true){
		for (i = 0; i < chk.length; i++)
		chk[i].checked = true ;
	} else {
		for (i = 0; i < chk.length; i++)
		chk[i].checked = false ;
	}
}
