function googleSearchIt() {
	// Create a search control
	searchControl = new GSearchControl();

	// Create web searcher w/ restrictions
	siteSearch = new GwebSearch();
	siteSearch.setUserDefinedLabel(siteLabel);
	siteSearch.setSiteRestriction(siteUrl);

	//Visibility & Draw Options
	var sopt = new GsearcherOptions();
	sopt.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);

	var dopt = new GdrawOptions();
	dopt.setDrawMode(searchControl.DRAW_MODE_LINEAR);
	dopt.setInput(document.getElementById('googleSearchQuery'));
	//if(input){ dopt.setInput(input); }

	//Add search to control
	searchControl.addSearcher(siteSearch, sopt);
	searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
	searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF);
	searchControl.draw(document.getElementById(searchid),dopt);

	//Set callback function
	searchControl.setSearchCompleteCallback(null, googleResultIt);

	//Execute a search
	searchControl.execute(query);

	//Append Google branding and Blue Spider to the end of the results
	document.getElementById('googleSearchBranding').appendChild(GSearch.getBranding());
/*	blueSpiderLink = document.createElement('a');
	blueSpiderLink.setAttribute('href', bsURL);
	blueSpiderBrand = document.createElement('img');
	blueSpiderBrand.setAttribute('src', bsLogo);
	blueSpiderBrand.setAttribute('alt', 'Blue Spider Inc');
	blueSpiderLink.appendChild(blueSpiderBrand);
	document.getElementById('googleSearchBranding').appendChild(blueSpiderLink);
*/
}

function googleResultIt( ) {
	var noResultsDiv = document.getElementById('googleSearchNoResults');

	if ( siteSearch.results.length == 0 ) {	
		noResultsDiv.style.visibility = 'visible';
		noResultsDiv.style.display = 'block';

		noResultsDiv.innerHTML = '<div style="margin-top:20px;margin-bottom:20px;font-size:16px;">Your search - <b>' + document.getElementById('googleSearchQuery').value + '</b> - did not match any documents.</div>'
	} else {
		noResultsDiv.style.visibility = 'hidden';
		noResultsDiv.style.display = 'none';
	}
}

if(window.attachEvent){
	window.attachEvent("onload", googleSearchIt);
} else{
	SafeAddOnload(googleSearchIt);
}
