/*
	FUNCTIONS
		beginSearch()
			Submit: get text value
					pass it as variable to Google within Search URL string
						along with xslt to transformDoc .aspx

		changeSearchResultsPage(nextUrl)
			Triggered from pages 1 2 3 4... nav at bottom of page
			nextUrl is long Google URL string
				Variable at end of string incremented (by 10) to get different page

		checkEnter(e)
			submit if enter key pushed
			
		setCursorOnLoad()
			Check if form element there, when there, set the curso
*/

var globalSearchCollection = "chargerWater";

document.write('<' + 'script');
document.write(' language="javascript"');
document.write(' type="text/javascript"');
document.write(' src="/javascriptO2/ajaxMultiple.js">');
document.write('</' + 'script' + '>');

setCursorOnLoad();

function beginSearch(){
	var searchTerm = '';

	if(typeof(document.gs) != "undefined"){
		searchTerm = document.gs.q.value;
		SetGetCookie('searchEntered',searchTerm);
	}else if(getCookie('searchEntered') != null){
		searchTerm = getCookie('searchEntered');
	}

	var searchCollection = window.globalSearchCollection;
	var searchURL = '/o2net/applications/transformDoc/Default.aspx?XsltDoc=/xslt/googleSearchResults.xslt&XmlDoc=http://google.orbisdesign.net/search?access=p~output=xml_no_dtd~ie=UTF-8~client=clear_frontend200808~q=' + searchTerm + '~ud=1~site=' + searchCollection + '~oe=UTF-8~filter=0~start=0';
	xmlhttpPost(searchURL,'httpReqResults');
}
function changeSearchResultsPage(nextUrl){
	var searchCollection = window.globalSearchCollection;
	loadingMessage('/images/loading_3.gif',10);

	if(nextUrl.length > 10){
		xmlhttpPost(nextUrl,'httpReqResults');
	}else{
		xmlhttpPost('/o2net/applications/transformDoc/Default.aspx?XsltDoc=/xslt/googleSearchResults.xslt&XmlDoc=http://google.orbisdesign.net/search?access=p~output=xml_no_dtd~ie=UTF-8~client=clear_frontend200808~q=~ud=1~site=' + searchCollection + '~oe=UTF-8~filter=0~start=0','httpReqResults');
	}	
}
function checkEnter(e){
	var characterCode;

	if(e && e.which){
		e = e;
		characterCode = e.which;
	}else{
		e = event;
		characterCode = e.keyCode;
	}
	
	if(characterCode == 13){
		beginSearch();
		return false
	}else{
		return true
	}
}
function setCursorOnLoad(){
	if(document.getElementById('formArea')){
		document.gs.q.focus();
		document.gs.q.style.borderColor = '#ff0000';
	}else{
		setTimeout('setCursorOnLoad()',500);
	}
}