
addLoadEvent(generalInit);
function generalInit() {
	var searchBox = getElement('searchterms');
	if(searchBox && !searchBox.isUsed) {
		searchBox.onfocus = function() { this.value = ""; this.isUsed = true; searchBox.onfocus = null; }			
	}
}



function addLoadEvent(func) {
    /*

        This will stack load functions on top of each other.
        Each function added will be called after onload in the
        order that they were added.

    */
    var oldonload = window.onload;
    if (typeof(window.onload) != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload.apply(this);
            func.apply(this);
        }
    }
}

var doc = document.getElementById;
function getElement(id) {
    /*

        A small quick little function to encapsulate the getElementById method.
        It includes a check to ensure we can use that method.

        If the id isn't a string, it will be returned as-is.

    */
    if (!doc) {
        return null;
    }
    return ((typeof(id) == "string") ? document.getElementById(id) : id);
}

function toggleElement() {
    /*

        Toggle the visibility of the given elements.  Elements
        are assumed to be initially not visible the first time
        they are used by this function.

    */
    if (!doc) {
        return;
    }
    for (i = 0; i < arguments.length; i++) {
        var element = getElement(arguments[i]);
        if (element) {
            if(element.isOn) {
                element.style.display = 'none';
                element.isOn = false;
            } else {
                element.style.display = 'block';
                element.isOn = true;
            }
        }
    }
} 
