var search_text = "search homelands.org";

function loadCss(filename){
	var fileref=document.createElement("link")
	fileref.setAttribute("rel", "stylesheet")
	fileref.setAttribute("type", "text/css")
	fileref.setAttribute("href", filename)
	if (typeof fileref!="undefined")
	 document.getElementsByTagName("head")[0].appendChild(fileref)
}

function loadJavascript(filename){
	var fileref=document.createElement('script')
	fileref.setAttribute("type","text/javascript")
	fileref.setAttribute("src", filename)
	if (typeof fileref!="undefined")
	 document.getElementsByTagName("head")[0].appendChild(fileref)
}

function ClearSearchBar(bar) {
	if(search_text == $F(bar)) {
		bar.writeAttribute('value','');
		ClearBackground(bar);
	}
}

function ResetSearchBar(bar) {
	if("" == $F(bar)) {
		bar.writeAttribute('value',search_text);
		ClearBackground(bar);
	}
}

function ClearBackground(bar) {
	bar.setStyle({
		backgroundImage: ''
	});
}

function DoOnLoad() {
	if("Mac" == BrowserDetect.OS) {
		$('sa').setStyle({
			'margin-right': '5px'
		});
		if("Firefox" == BrowserDetect.browser) {
			$('sb').setStyle({
				'padding-bottom': '0',
				'padding-top': '2px'
			});
		}
	}
	
	// Remove the Google Custom Search watermark in the search field
	ClearBackground($('sb'));
	// Set the search box text to search_text
	ResetSearchBar($('sb'));
	
	// Add the onFocus and onBlur handlers to the search box
	var doOnFocus = function() { ClearSearchBar($('sb')); };
	var doOnBlur  = function() { ResetSearchBar($('sb')); };
	if('Explorer' == BrowserDetect.browser) {
		$('sb').onfocusin = doOnFocus;
		$('sb').onfocusout = doOnBlur;
		$('sb').setStyle({
			'position': 'static',
			'top': '0',
			'margin-top': '-1px'
		});
	} else {
		$('sb').addEventListener('focus',doOnFocus,true);
		$('sb').addEventListener('blur',doOnBlur,true);
	}
}
window.onload = DoOnLoad;

// Load the scripts that handle the music player
loadJavascript('/inc/addevent.js');
loadJavascript('/inc/popup.js');
