function onFormLoad()
{
    var bFound = false;

    


        for(f = 0; f < document.forms.length; f++)
        {
            for(i = 0; i < document.forms[f].length; i++)
            {
                var element = document.forms[f][i];
                if(shouldFocus(element))
                {
                    document.forms[f][i].focus();
                    bFound = true;
                    break;
                }
            }
            // if found in this form, stop looking
            if(bFound)
                break;

       
    }
}

function shouldFocus(element)
{
    return ((element.tagName == "INPUT" &&  element.type == "text") ||
            element.tagName == "SELECT" || element.tagName == "TEXTAREA");
}

/**
 * Toggles an elements state based on the checked status of the given checkbox
 */
function setElementState(obj_checkbox, obj_textarea)
{
    if(!obj_checkbox.checked)
    {
        obj_textarea.disabled = true;
        //obj_textarea.style.background = '#cccccc';
    }
    else
    {
        obj_textarea.disabled = false;
         //obj_textarea.style.background= 'white';
    }
}

String.prototype.endsWith = function(s){
	var reg = new RegExp(s + "$");
	return reg.test(this);
}

function appendFormAction(form, actionAppend)
{
    if(!form.action.endsWith(actionAppend)) // avoid appending twice if user double clicks
    {
        form.action = form.action + actionAppend;
    }
}
