
function get_search_form()
{
	FormElements = document.body.getElementsByTagName("FORM");
	
	if(FormElements)
	{
		for(i=0;i<FormElements.length;i++)
		{
			if(FormElements[i].action == '/search' ||
			   FormElements[i].action == 'http://www.google.com/search' ||	
			   FormElements[i].action == '/custom' ||	
			   FormElements[i].action == '/unclesam' ||	
			   FormElements[i].action == '/linux' ||	
			   FormElements[i].action == '/bsd' ||	
			   FormElements[i].action == '/mac' ||	
			   FormElements[i].action == '/microsoft')
			   {
				   return FormElements[i];
			   }
		}
	}
	
	return null
}

function InstallGS()
{
	if(gsID.readyState == "loaded")
	{
		var f = get_search_form();
		if (!f || !f.q || !f.btnG) return;
		f.q.setAttribute("autocomplete", "off");
		InstallAC(f, f.q, f.btnG, 'search', 'en');
		f.q.setAttribute("autocomplete", "off");
	}
	
	
}

function addGoogleSuggest() 
{
	var f = get_search_form();
	if (!f || !f.q || !f.btnG) return;
	f.q.setAttribute("autocomplete", "off");
	var s = document.createElement('script');
	s.src = '/ac.js';
	s.id  = "gsID"
	s.onreadystatechange = InstallGS;
	document.getElementsByTagName('head')[0].appendChild(s);
}

var href = document.location.href;

// Google 
if (!(/\.(js|css|xml|rss|pdf)$/.test(href)) &&
	!(/complete\/search/.test(href)) 		&&
	 ( /^http[s]?:\/\/[^.]*\.(google|googleproxy)\.[a-z\.]+\//.test(href) || /^http:\/\/(64\.233\.161\.99|64\.233\.161\.104|64\.233\.161\.105|64\.233\.161\.147|64\.233\.167\.99|64\.233\.167\.104|64\.233\.167\.147|64\.233\.171\.99|64\.233\.171\.104|64\.233\.171\.105|64\.233\.171\.147|64\.233\.179\.99|64\.233\.179\.99|64\.233\.183\.99|64\.233\.183\.104|64\.233\.185\.99|64\.233\.185\.104|64\.233\.187\.99|64\.233\.187\.104|64\.233\.189\.104|66\.102\.7\.104|66\.102\.7\.105|66\.102\.7\.147|66\.102\.9\.104|66\.102\.11\.104|216\.239\.37\.104|216\.239\.37\.105|216\.239\.37\.147|216\.239\.39\.104|216\.239\.53\.104|216\.239\.57\.98|216\.239\.57\.104|216\.239\.57\.105|216\.239\.57\.147|216\.239\.59\.104|216\.239\.59\.105|216\.239\.63\.104|66\.249\.81\.99)\//.test(href) )) 
	 {

		
		if ((href.match(/^http:\/\/[^\/]+\/$/i) || href.match(/^http:\/\/[^\/]+\/(search|custom|firefox|webhp|unclesam|linux|bsd|mac|microsoft|ig)/i))) 
		{
			addGoogleSuggest();
		}
	}

