var xmlHttp;
var BASEURL = "http://tahoogle.com/";

/***********************************************************************/
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 txtfocus(obj, str)
{
	if (obj.value == str)
	{
		obj.value = "";
		obj.select();
	}
}

/**************************************************************************************************************/
function txtblur(obj, str)
{
	if (obj.value == "")
	{
		obj.value = str;
	}
}

/**************************************************************************************************************/
function ChoosePhotoWindow(url)
{
	var x = window.open(url, '', 'width=730,height=720,left=0,top=0, directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,resizable=0');
	x.focus();
}

/**************************************************************************************************************/
function VideoWindow(url)
{
	var x = window.open(url, '', 'width=790,height=720,left=0,top=0, directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,resizable=0');
	x.focus();
}

/**************************************************************************************************************/
function EmailFriendWindow(url)
{
	var x = window.open(url, '', 'width=500,height=400,left=0,top=0, directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,resizable=0');
	x.focus();
}

/**************************************************************************************************************/
function MediumWindow(url)
{
	var x = window.open(url, '', 'width=600,height=500,left=0,top=0, directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,resizable=0');
	x.focus();
}

/**************************************************************************************************************/
function LargeWindow(url)
{
	var x = window.open(url, '', 'width=720,height=600,left=0,top=0, directories=0,location=0,menubar=0,scrollbars=yes,status=yes,toolbar=0,resizable=yes');
	x.focus();
}

/**************************************************************************************************************/
function PlaySound(SoundName) 
{
  document.getElementById("SoundPlayer").innerHTML = "<embed src='" + SoundName + "' hidden=true autostart=true loop=false>";
}

/**************************************************************************************************************/
function noenter(e)
{
 var unicode=e.keyCode? e.keyCode : e.charCode;  return !(unicode == 13); 
}

/***********************************************************************/
function getSearchHint(str)
{
	xmlHttp = GetXmlHttpObject();
	
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request.")
		return
	} 
	
	var url = BASEURL + "ajax/getsearchhint.php?q=" + str + "&sid=" + Math.random();
	
	xmlHttp.onreadystatechange = gotSearchHint; 
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
} 

function gotSearchHint() 
{ 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
	{ 
		//alert(xmlHttp.responseText);
		
		document.getElementById("SearchHint").innerHTML = xmlHttp.responseText;
	} 
}

function showSearchHint(str)
{
	if (str.length == 0)
  { 
		document.getElementById("SearchHint").style.display = "none";
		return;
  }
	
	document.getElementById('SearchHint').innerHTML = "<img src='image/loading.gif'>";
	document.getElementById('SearchHint').style.display = "block";
	
	getSearchHint(str);
}

function doSearch(str)
{
	if (str == null)
		str = document.getElementById('txtSearch').value;
	
	window.location = "search.php?q=" + str;
}
/**************************************************************************************************************/