/* $Id: global.js 28159 2011-05-02 16:58:24Z bridge $ */
/* global javascript functions for the corp webapp */
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
};

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

/* Login Form */
function clearDefaultValue(input) {
    // if this is the default password field (textfield that has a value 'Password'),
    // hide it and deplay the real password field
    if(input.id == "passwordtxt" && input.type == "text") {
        document.getElementById("passwordtxt").style.display = "none";
        document.getElementById("password").style.display = "inline";
	    document.getElementById("password").focus();
    } // if this is the login field and it has a default value, clear the default value
    else {
        if(input.id == "username" && input.value == "Email Address") {
            input.value = "";
        }
    }
}

function addDefaultValue(input) {
    // if this is the real password field and it is empty, make it the
    // default password field (a text field w/ value of 'Password')
    if(input.id == "password" && input.value.trim() == "") {
        document.getElementById("passwordtxt").style.display = "inline";
        document.getElementById("password").style.display = "none";
    } // if this is the login field and it is empty, add a default value
    else {
        if(input.id == "username" && input.value.trim() == "") {
            input.value = "Email Address";
        }
    }
}
