﻿var BlaqScript = {

    // This function clears a field when called.
    // If there is a 'defaultValue' attribute on the field, the field will only be cleared
    // when the field value is not equal to the default value.
    ClearField : function(obj)
    {
        // Check that the browser supports the DOM methods used.
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;
    
        var defaultValue = "";
        
        if (obj.hasAttribute("defaultValue"))
        {
            defaultValue = obj.getAttribute("defaultValue");
            
            if(obj.value == defaultValue)
            {
                obj.value = "";
            }
        }
        else
        {
            obj.value = "";
        }
    },
    
    // This function restores a field default if the field value is empty.
    RestoreFieldDefault : function(obj)
    {
        if (!document.getElementById || !document.createElement || !document.appendChild) return false;
        
        if (obj.hasAttribute("defaultValue") && (obj.value == null || obj.value == "" ))
        {
            obj.value = obj.getAttribute("defaultValue");
        }
    }
};