var status=0;
	function keydown()
	{
		if(status==0)
		{
			document.getElementById('query').value="";
			status=1;
		}		
	}

	function doload()
	{
		document.getElementById('query').focus();
		document.getElementById('query').value='Enter keywords to search whatever you like!'
	}


window.onload = function() {
		doload();onLoad();
	}




function onLoad() {
		// Create a search control
		searchControl = new GSearchControl();
	
		// add a regular web search, with a custom label 'web'
		var webSrearch = new GwebSearch();
		webSrearch.setUserDefinedLabel("web");
		searchControl.addSearcher(webSrearch);
		
		
		// add a site-limited web search, with a custom label
		var siteSearch = new GwebSearch();
		siteSearch.setUserDefinedLabel("RapidShare.com");
		siteSearch.setSiteRestriction("rapidlibrary.com");
		searchControl.addSearcher(siteSearch);
					
 
 
		// add a site-limited web search, with a custom label
		var siteSearch = new GwebSearch();
		siteSearch.setUserDefinedLabel("MegaUpload.com");
		siteSearch.setSiteRestriction("4megaupload.com");
		searchControl.addSearcher(siteSearch);
		
		
		
 
		// add a site-limited web search, with a custom label
		var siteSearch = new GwebSearch();
		siteSearch.setUserDefinedLabel("Torrents");
		siteSearch.setSiteRestriction("isohunt.com");
		searchControl.addSearcher(siteSearch);
 
		
		// add a site-limited web search, with a custom label
		var siteSearch = new GwebSearch();
		siteSearch.setUserDefinedLabel("Mp3s");
		siteSearch.setSiteRestriction("beemp3.com");
		searchControl.addSearcher(siteSearch);
		
		// add a site-limited web search, with a custom label
		var siteSearch = new GwebSearch();
		siteSearch.setUserDefinedLabel("Games");
		siteSearch.setSiteRestriction("games.playndownload.com");
		searchControl.addSearcher(siteSearch);
				
		
		// add a blog search, with a custom label
		var blogsSrearch = new GblogSearch();
		blogsSrearch.setUserDefinedLabel("weblogs");
		searchControl.addSearcher(blogsSrearch);
 
		
 
		
		// setting the draw mode for the Google search
		var drawOptions = new GdrawOptions();
		// use tabbed view
		drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
		// set the input field (instead of the default one)
		drawOptions.setInput(document.getElementById('query'));
		// actually write the needed markup to the page
		searchControl.draw(document.getElementById("searchcontrol"), drawOptions);
		// set the google logo container
		GSearch.getBranding(document.getElementById("branding"));
	}
	
	var query = null;
	document.onkeydown = function(event) { kd(event); };
	function kd(e) {
		// make it work on FF and IE
		if (!e) e = event;
		
		if (e.keyCode == 32)		
   		 insertkeywords(query.value);
 
		// use ESC to clear the search results
		if (e.keyCode == 27)
			searchControl.clearAllResults();
		// get the input field
		if (query == null)
			query = document.getElementById('query');
		// and move the focus in there
		query.focus();
		
		//document.getElementById("gsc-control").setAttribute(width,'900px');
	}
	
	
 
 
 
function stateChanged(arg)
{}
 
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 insertkeywords(keywords)
{ 
 
 
xmlhttp=GetXmlHttpObject(); 
 
 
var url="engine.asp";
url="engine.asp?action=add";
url= url + "&keywords=" + keywords;
 
 
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
 
}
 
