/* 
NOTES: 

* this will detect the user's browser and fill the search box with the appropriate placeholder text (if any)

* requires that the serach form is named Search_Google -- i.e., must write ' id="Search_Google" ' for this script to work. otherwise, change everything in this document to the appropriate name - be sure to do so site-wide where this script is used. better yet, make the name a library item so it is updated appropriately.
*/ 

function detect() {
	var agent		= navigator.userAgent.toLowerCase();
	var safariVer	= ( agent.indexOf( "safari/" ) != -1) ? parseInt( agent.split( "safari/" )[1] ) : 0;
	this.isMac	= ( agent.indexOf( "mac" ) != -1 );
	this.isWin	= ( agent.indexOf( "win" ) != -1 );
	this.isWin2k	= ( this.isWin && (
		agent.indexOf( "nt 5" ) != -1 ) );
	this.isWinSP2	= ( this.isWin && (
		agent.indexOf( "xp" ) != -1 || 
		agent.indexOf( "sv1" ) != -1 ) );
	this.isOther	= (
		agent.indexOf( "unix" ) != -1 || 
		agent.indexOf( "sunos" ) != -1 || 
		agent.indexOf( "bsd" ) != -1 ||
		agent.indexOf( "x11" ) != -1 || 
		agent.indexOf( "linux" ) != -1 );
	this.isSafari	= ( agent.indexOf( "safari" ) != -1 );
	this.isSafari2	= ( safariVer >= 312 );
	this.isOpera	= ( agent.indexOf( "opera" ) != -1 );
	this.isNN		= ( agent.indexOf( "netscape" ) != -1 );
	this.isIE		= ( agent.indexOf( "msie" ) != -1 );
}

var browser = new detect();
var string = "Search Audiobooks";
var Search_Google = document.getElementById( "Search_Google" );

if ( !browser.isSafari2 ) {
	Search_Google.style.color = "#80808c";
	Search_Google.value = string;
	Search_Google.onfocus = function() {
		if ( Search_Google.value == "Search Audiobooks" && ( Search_Google.style.color == "#80808c" || Search_Google.style.color == "rgb(128, 128, 140)" ) ) 			{
			Search_Google.value = "";
			Search_Google.style.color = "#000";
		}
		if ( Search_Google.value == "top 10" && ( Search_Google.style.color == "#80808c" || Search_Google.style.color == "rgb(128, 128, 140)" ) ) 			{
			Search_Google.value = "";
			Search_Google.style.color = "#000";
		}
	};
	Search_Google.onblur = function() {
		if ( Search_Google.value == "" ) {
			Search_Google.value = string;
			Search_Google.style.color = "#80808c";
		}
	};
} else {
	Search_Google.style.color = "#000";
	Search_Google.type = "search";
	Search_Google.setAttribute("autosave", "Audiobooks.org Searches");
	Search_Google.setAttribute("results", "5");
	Search_Google.setAttribute("placeholder", "Search Audiobooks");
}