var timerid;
var siteUrl;
function keyEvent()
{
	var d 		= document.getElementById("domain");
	d.onkeyup 	= startTimer;
}

function startTimer()
{
	var html = "";	
	html += "<div id=\"boxes\">";
	html += "	<div id=\"box1\" class=\"boxSearching\">";
	html += "		<div id=\"box1Info\">.com</div>";
	html += "		<div><center><br><img src=\"searching.gif\"></center></div>"
	html += "	</div>";
	html += "	<div id=\"box2\" class=\"boxSearching\">";
	html += "		<div id=\"box1Info\">.net</div>";
	html += "		<div><center><br><img src=\"searching.gif\"></center></div>"
	html += "	</div>";
	html += "	<div id=\"box3\" class=\"boxSearching\">";
	html += "		<div id=\"box1Info\">.mobi</div>";
	html += "		<div><center><br><img src=\"searching.gif\"></center></div>"
	html += "	</div>";
	html += "</div>";
	document.getElementById("iframe").innerHTML = html;
	
	clearTimeout(timerid);
	timerid = setTimeout("clear()", 200);
}

function clear()
{
	clearTimeout(timerid);
	var d = document.getElementById("domain").value;
	ajax("search.php", callbackFunction);
}

function callbackFunction(woot)
{
	document.getElementById("iframe").innerHTML = woot;
}

function ajax(url, callbackFunction)
{
	if (window.XMLHttpRequest)
		var request = new XMLHttpRequest();
	else
		var request = new ActiveXObject("MSXML2.XMLHTTP.3.0");
 
	request.open("POST", url, true);
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	request.send("domain=" + document.getElementById("domain").value);
	 
	request.onreadystatechange = function()
	{
		if (request.readyState == 4 && request.status == 200) 
			if (request.responseText)
 				callbackFunction(request.responseText);
	}
}

function focusI()
{
	siteUrl = document.getElementById("domain").value;
	if(siteUrl == "Live domains search...")	document.getElementById("domain").value = "";
}

function bmSite()
{
	var title	= "Dotmain.com Domain Search";
	var url		= "http://www.dotmain.com";
	
	if (window.sidebar) 		{ window.sidebar.addPanel(title, url, ""); 	} 
	else if(window.external) 	{ window.external.AddFavorite( url, title); }
}