// Javascript for pages that will have the input form for Gooogle Site Search
// The input form posts back to a processing page that should NOT include this file, although it is
// OK to include it since the 'kds_sitesearch' input will not be found on that page.
(function() {
	var blnUseGoogleBranding = false;
	
	// addLoadEvent - came from kds_init.js
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	};
	
	function siteSearchSetBranding() {
		if (eSearch) {
			if (eSearch.value == '') {
				eSearch.style.background = 'url("http://www.google.com/coop/intl/en/images/google_custom_search_watermark.gif") no-repeat scroll left center #FFF';
			}
		}
	};
	
	function siteSearchClearBranding() {
		if (eSearch) {
			eSearch.style.background = 'none repeat scroll 0 0 #FFF';
		}
	};
	
	var eSearch = null;
	
	addLoadEvent(function() {
		eSearch = document.getElementById('kds_sitesearch');
		if (eSearch) {
			eSearch.maxLength = 80; // keep consistent with form processing
			
			if (blnUseGoogleBranding) {
				siteSearchSetBranding();
				
				eSearch.onfocus = siteSearchClearBranding;
				eSearch.onblur = siteSearchSetBranding;
			}
		}
	});
})();

