//
// BEGIN functions for replacing search field with Safari's search field
// Source: http://bartelme.at/material/search/search_js.html

function addEvent(elm, evType, fn, useCapture) {
	// cross-browser event handling for IE5+, NS6 and Mozilla 
	// By Scott Andrew 
	if (elm.addEventListener) { 
		elm.addEventListener(evType, fn, useCapture); 
		return true; 
	} else if (elm.attachEvent) { 
		var r = elm.attachEvent('on' + evType, fn); 
		return r; 
	} else {
		elm['on' + evType] = fn;
	}
}

var DEF_VAL = ""; // Default Value
var isSafari = ((parseInt(navigator.productSub)>=20020000)&& // detecting WebCore
				(navigator.vendor.indexOf("Apple Computer")!=-1));

function replaceSearchField() {
	if (!document.getElementById) return;
	var searchField = document.getElementById('SearchField');
	if (isSafari) {
		searchField.setAttribute('type','search');
		searchField.setAttribute('value','');
		searchField.setAttribute('autosave','gadgetmadness.com');
		searchField.setAttribute('results','10');
		searchField.setAttribute('placeholder',DEF_VAL);
	} else {
		addEvent(searchField,'focus',focusSearch,false);
		addEvent(searchField,'blur',blurSearch,false);
		if (searchField.value == '') {
			searchField.value = DEF_VAL;
		}
	}
}

function focusSearch() {
	if (this.value==DEF_VAL) {
		this.value = '';
		this.setAttribute('class','focus');
	}
}

function blurSearch() {
	if (this.value=='') {
		this.value = DEF_VAL;
		this.removeAttribute('class','focus');
	}
}

addEvent(window,'load',replaceSearchField,false);

// END functions for replacing search field with Safari's search field
//

//
// BEGIN functions for blog roll pulldown redirection.

function BlogRollRedirect() {
	var BlogRollSelect = document.getElementById('BlogRollSelect');
	//window.location.href = BlogRollSelect.options[BlogRollSelect.selectedIndex].value;
	window.open(BlogRollSelect.options[BlogRollSelect.selectedIndex].value);
}

function AttachRedirectHandlers() {
	var BlogRollSelect = document.getElementById('BlogRollSelect');
	BlogRollSelect.onchange = BlogRollRedirect;
}

addEvent(window,'load',AttachRedirectHandlers,false);

// END functions for blog roll pulldown redirection.
//