function submitform()
{
	str = document.forms['searchform'].search.value;
	document.forms['searchform'].searchsubmit.value = "";
	str = str.toLowerCase();
	str = str.replace(/[' ']/g,'-');
	if (str.length > 2) 
	{
		document.forms['searchform'].action="http://www.thekeyworddirectory.com/keywords/" + str + ".html";
		document.forms['searchform'].submit();
	}
	else {
		alert("Minimum 3 Charcters");
	}
}
function submitclassified()
{
	str = document.forms['searchform'].search.value;
	document.forms['searchform'].searchsubmit.value = "";
	str = str.toLowerCase();
	str = str.replace(/[' ']/g,'-');
	if (str.length > 2) 
	{
		document.forms['searchform'].action="http://www.thekeyworddirectory.com/classifieds/" + str + ".html";
		document.forms['searchform'].submit();
	}
	else {
		alert("Minimum 3 Charcters");
	}
}
function errorMsg()
{
  alert("Netscape 6 or Mozilla is needed to install a sherlock plugin");
}
function addEngine(name,ext,cat,type)
{
  if ((typeof window.sidebar == "object") && (typeof
  window.sidebar.addSearchEngine == "function"))
  {
	window.sidebar.addSearchEngine(
	  name,
	  ext,
	  cat,
	  type );
  }
  else
  {
	errorMsg();
  }
}
function processform1()
{
	document.forms['listedform'].action="http://www.thekeyworddirectory.com/submit.php";
	document.forms['listedform'].submit();
}

//livesearch//
var xmlhttp;
var stra = '';
function showResult(str)
{
	hideLivesearch('livesearch');
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null)
	  {
		alert ("Your browser does not support XML HTTP Request");
		return;
	  }
	if (str.length>2)
	  {
		var url="http://www.thekeyworddirectory.com/livesearch.php";
		url=url+"?q="+str;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChanged ;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		var ls = document.getElementById("livesearch");
		ls.style.display = "block";
	  }
}
function stateChanged()
{
	if (xmlhttp.readyState==4)
	  {
		if (xmlhttp.responseText != " ")
		{
			document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
			document.getElementById("livesearch").style.border="1px solid #A5ACB2";
		} else {
			hideLivesearch('livesearch');	
		}
	  }
}
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(hiddenDivName)
{
    if (getObj(hiddenDivName) != null)
    {
        getObj(hiddenDivName).style.display = 'none';
	}
}
function getObj(n, d) { 
    var p,i,x;  
    if(!d) {
        d=document; 
    }
    if((p=n.indexOf("?")) > 0 && parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; 
        n=n.substring(0,p);
    }
    if(!(x=d[n]) && d.all) {
        x=d.all[n]; 
    }
    for (i=0; !x && i<d.forms.length; i++) {
        x=d.forms[i][n];
    }
    for(i=0; !x&&d.layers && i<d.layers.length; i++) {
        x=getObj(n,d.layers[i].document);
    }
    if(!x && d.getElementById) {
        x=d.getElementById(n); 
    }
    return x;
}
function hideDiv() {
	  //var ls1 = document.getElementById("livesearch");
	  //ls1.style.display = "none";
}
function showDiv() {
	  var ls = document.getElementById("livesearch");
	  ls.style.display = "block";
	  //var ls = document.getElementById("livesearch");
	  //if ( ls.style.display === "" ) {
		//ls.style.display = "block";
		//return;
	  //}
	  //if ( ls.style.display === "none" ) {
		//ls.style.display = "block";
		//return;
	  //} 
}

function submitonEnter(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == "13"){
		submitform();
		//document.form1.submit();
	}
}
function submitonEnterClassified(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == "13"){
		submitclassified();
		//document.form1.submit();
	}
} 
