// JavaScript Document

var searchstr = 'Search this site';
var searchinputfade = '#cdcdcd';
var searchinputid = 's';

/* General functions */
function trim(str) {
	return str.replace(/^\s+|\s+$/g, '');
}
function function_exists (function_name) {
    // Checks if the function exists  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/function_exists
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Steve Clay
    // +   improved by: Legaev Andrey
    // *     example 1: function_exists('isFinite');
    // *     returns 1: true
    if (typeof function_name == 'string'){
        return (typeof this.window[function_name] == 'function');
    } else{
        return (function_name instanceof Function);
    }
}

/* Specific usage functions */
function fillsearch() {
	if(document.getElementById(searchinputid)) {
		var myel = document.getElementById(searchinputid);
		if(trim(myel.value) == '') {
			myel.value = searchstr;
			myel.style.color = searchinputfade;
		}
	}
}
function clearsearch() {
	if(document.getElementById(searchinputid)) {
		var myel = document.getElementById(searchinputid);
		if(myel.value == searchstr) {
			myel.value = '';
			myel.style.color = '';
		}
	}
}

/* Call necessary onload functions */
if(document.getElementById(searchinputid)) {
	var s = document.getElementById(searchinputid);
	s.onfocus = function() { clearsearch() };
	s.onblur = function() { fillsearch() };
	fillsearch();
}
google.load("jquery", "1.4.1");
google.load("jqueryui", "1.7.2");