    // FormElementManager:
    //  - methods used by forms to hide/show errors. Can be used for any display management.
    //
    
    var focusedField = null;
    function InFocus(elementName){
        focusedField = elementName;
    }
    
    function ClearFocus(){
        focusedField = null;
    }
    
    // will turn the element OFF only if its on and the specified fields aren't currenty focused    
    function HideElementConditional(elementName, conditionalElement, focusFieldNames) {
        var fieldNames = focusFieldNames.split(",");
        var isFieldFocused = false;
        for(var i=0; i < fieldNames.length; i++){
            if(fieldNames[i] == focusedField){
                isFieldFocused = true;
                break;
            }
        }
        if(document.getElementById(elementName) != null && document.getElementById(conditionalElement) != null) {
            if(document.getElementById(conditionalElement).style.display != 'none' && !isFieldFocused)
                document.getElementById(elementName).style.display = 'none';
        }
    }

    function HideElement(elementName) {
        if(document.getElementById(elementName) != null)
            document.getElementById(elementName).style.display = 'none';
    }                      
    
    function ShowElementConditional(elementName, conditionalElement) {
        if(document.getElementById(elementName) != null && document.getElementById(conditionalElement) != null) {
            if(document.getElementById(conditionalElement).style.display != 'none')
                document.getElementById(elementName).style.display = 'block';
        }
    } 
    
    function ShowElement(elementName) {
        if(document.getElementById(elementName) != null)
            document.getElementById(elementName).style.display = 'block';
    }

    /* 
     * Method used to perform the switching of an elements class. Leave 
     * the conditions null if you don't want the change to be conditional. 
     */
    function ToggleClass(id, className, conditions){
        var element = document.getElementById(id);
        var conditionMet = false;
        if(conditions != null && conditions.length > 0){
            // we only want to toggle if the objects current class is one of the conditions
            var condArray = conditions.split(',');
            for (var i=0, len = condArray.length; i < len; i++){
                if(element.className == condArray[i]){
                    conditionMet = true;
                    break;
                }
            }
        }

        // if the conditions were met (or there weren't any) then change the class
        if(conditions == null || conditions.length == 0 || conditionMet)
            element.className = className;
    }
