<!--
// If the page location does not equal the window location
if(window.self.location.href != window.top.location.href)
{
    window.top.location.replace(window.self.location.href);
}

// Adds a function to the onload event
function addLoadFunction(newFunction)
{
    // If window.onload is a function
	if(typeof window.onload == "function")
	{
    	var previousOnload = window.onload;

	    // New window.onload
		window.onload = function()
		{
			previousOnload();
			newFunction();
		}
	}
	else
	{
		window.onload = newFunction;
	}
}

// Checks that search text was entered and disables the submit button
function searchSubmit()
{
    // If the browser supports document.getElementById
    if(document.getElementById)
    {
        var searchForm = document.getElementById("search_form");

        // If the search form is found
        if(searchForm)
        {
            // On submit function
            searchForm.onsubmit = function()
            {
                // If the value is empty
                if(trim(document.getElementById("search_text").value) == "")
                {
                    alert("You must enter one or more terms to search for...");

                    return false;
                }
                else
                {
                    var searchButton = document.getElementById("search_search");

                    searchButton.setAttribute("disabled", true);
                    searchButton.setAttribute("value", "Searching...");

                    return true;
                }
            }
        }
    }
}

// Trims leading and trailing spaces from a string
function trim(string)
{
    // If the string is not empty
    if(string)
    {
        return string.replace(/^\s*|\s*$/g, "");
    }
    else
    {
        return "";
    }
}

addLoadFunction(searchSubmit);
//-->
