<!--

// Trim spaces from the left and right of the value
String.prototype.trim = 
    function() 
    {
        return this.replace(/^\s+|\s+$/g, '');
    };

// Return x number of characters from the left of the value
String.prototype.left = 
    function(characters) 
    {
        if (characters <= 0)
            return '';
        else if (characters > this.length)
            return this;
        else
            return this.substring(0, characters);
    };

// Return x number of characters from the right of the value
String.prototype.right =
    function Right(characters)
    {
        if (characters <= 0)
            return '';
        else if (characters > this.length)
            return this;
        else 
        {
        return this.substring(this.length, this.length - characters);
        }
    };   


// Temporary functions that are being used - need to fully test the new global.js to make sure it works before moving the whole file up

// Shortcut to return an element by ID
function GE(id)
{
    return document.getElementById(id);
}

// Return the value property
function getValueOf(id)
{
    return document.getElementById(id).value;
}

// Add multiple functions to the OnLoad event
function addOnLoadEvent(newFunction) 
{   
    var existingFunction = window.onload;
    if( typeof window.onload != 'function' ) 
        window.onload = newFunction;
    else 
    {   
        window.onload = function() 
                        {   
                            if( existingFunction )   
                                existingFunction(); 
                            newFunction(); 
                        } 
    } 
} 

// Return the xmlHTTP object for AJAX Calls
function createXMLHTTPObject()
{   
    var xmlHTTP = null;
    try
    {   // Firefox, Opera 8.0+, Safari
        xmlHTTP = new XMLHttpRequest();
    }
    catch (e)
    {   // Internet Explorer
        try
        {   xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {   xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHTTP;
}

    // Helper function for an AJAX call (Asynchronous) - note that the 2nd and 3rd parameters are optional
    function executeAJAX(scriptURL, scriptArguments, requestMethod) {

        // Define the variables and clean up the function parameters
        var xmlHTTP = getXMLHTTPObject();
        var requestMethod = (requestMethod == undefined || requestMethod == '') ? 'GET' : requestMethod.toUpperCase();
        var scriptArguments = (scriptArguments == undefined) ? '' : scriptArguments;
        
        
        // Make the call using the XML HTTP object
        xmlHTTP.open(requestMethod, scriptURL, false);

        if( requestMethod == 'POST') {
            xmlHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        }
        
        try {
            xmlHTTP.send(scriptArguments);
        }
        catch(e) {
            return 'XML HTTP ERROR';
        }

        return xmlHTTP.responseText;
    
    }
    
    
    // Return a QueryString value (Empty string if not found)
    function queryStringValue(value) {
        fullQueryString = window.location.search.substring(1);
        queryStringValue = fullQueryString.split("&");
        for ( var cnt = 0; cnt < queryStringValue.length; cnt++) {
            var currentValue = queryStringValue[cnt].split("=");
            if (currentValue[0] == value) {
                return currentValue[1];
            }
        }
        return '';
    }

    
    // Read the value of a cookie (Empty string if not found)
    function readCookie(name) {
        var cookieName = name + "=";
        var currentCookies = document.cookie.split(';');
        for( var cnt = 0; cnt < currentCookies.length; cnt++) {
            var currentCookie = currentCookies[cnt];
            while ( currentCookie.charAt(0) == ' ') {
                currentCookie = currentCookie.substring(1, currentCookie.length);
            }
            if ( currentCookie.indexOf(cookieName) == 0 ) {
                return currentCookie.substring(cookieName.length, currentCookie.length);
            }
        }
        return '';
    }

    
    // Add multiple functions to the OnLoad event
    function addOnLoadEvent(newFunction) {   
        var existingFunction = window.onload;
        if( typeof window.onload != 'function' ) {   
            window.onload = newFunction;
        }
        else {   
            window.onload = function() {   
                                if( existingFunction ) {   
                                    existingFunction(); 
                                } 
                                newFunction(); 
                            } 
        } 
    } 
    
    //// Legacy Javascript Functions /////////////////////////////////////////////////////////////////////////////////////////////////
    

    
    function OpenWindow( url, width, height, options, name ) {
        if ( ! width ) width = 600;
        if ( ! height ) height = 400;
        if ( ! options ) options = "scrollbars=yes,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes";
        if ( ! name ) name = "outsideSiteWindow";

        var newWin = window.open( url, name, "width=" + width + ",height=" + height + "," + options );
        }

    function OpenChiclet(url,title) {
        window.open(url,title,"toolbar=false location=false  status=false");
    }

    function SubmitChanges()
    {
        document.form1.change.value="yes";
        document.form1.submit();
    }

    function ResetLeft()
    {
        document.form1.change.value="yes";
        document.form1.resetleft.value="yes";
        document.form1.submit();
    }
    function ResetRight()
    {
        document.form1.change.value="yes";
        document.form1.resetright.value="yes";
        document.form1.submit();
    }

    function autoTab(input, len, e) 
    {	var isNN = ( navigator.appName.indexOf("Netscape") != -1 );
        var keyCode	= (isNN) ? e.which : e.keyCode ; 
        var filter	= (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46] ;
        if( input.value.length >= len && !containsElement(filter, keyCode) ) 
        {	input.value = input.value.slice(0, len) ;
            input.form[(getIndex( input ) + 1) % input.form.length].focus() ;
        }
        return true;
    }

    function containsElement(arr, ele) 
    {	var found = false
        var index = 0;
        while( !found && index < arr.length )
        if( arr[index] == ele )
            found = true ;
        else
            index++;
        return found;
    }

    function getIndex(input) 
    {	var index = -1
        var i = 0
        var found = false ;
        while( i < input.form.length && index == -1 )
        if( input.form[i] == input)
            index = i ;
        else 
            i++;
        return index;
    }
    
    // Create and return an Anchor tag (Link)
    function createElementLink(name, url, text, hovertext)
    {
        var element = document.createElement('a');
        setElementNameAndID(element, name);
        element.innerHTML = text;
        element.setAttribute('href', url)
        element.setAttribute('title', (hovertext == undefined ? text : hovertext));
        return element
    }
    
    // Update the element's Name and ID properties
    function setElementNameAndID(element, name)
    {
        element.setAttribute('name', name);
        element.setAttribute('id', name);
    }
    
    function getXMLHTTPObject()
    {   
        return createXMLHTTPObject();
    }


//-->
