/**
 ****************************
 * Atomic CSS Style Functions
 ****************************
 */
/**
 * Set element visible.
 */
function BU_setVisible(id) {
    var element = BU_getElementStyle(id);
    if (element != null) {
        element.visibility = "visible";
    }
}

function BU_setOn(id) {
    var element = BU_getElementStyle(id);
    if (element != null) {
        element.display = 'block';
        element.visibility = "visible";
    }
}

/**
 * Set element hidden.
 */
function BU_setHidden(id) {
    var element = BU_getElementStyle(id);
    if (element != null) {
        element.visibility = "hidden";
    }
}

/**
 * Set element hidden.
 */
function BU_setOff(id) {
    var element = BU_getElementStyle(id);
    if (element != null) {
        element.display = 'none';
        element.visibility = "hidden";
    }
}

/**
 * Set element text color.
 */
function BU_setTextColor(id, color) {
    var element = BU_getElementStyle(id);
    if (element != null) {
        element.color = color;
    }
}

/**
 * Set element background color.
 */
function BU_setBackgroundColor(id, color) {
    var element = BU_getElementStyle(id);
    if (element != null) {
        element.backgroundColor = color;
    }
}

/**
 *****************************
 * Element Retrieval Functions 
 *****************************
 */
/**
 * Get the element with the specified id.
 */
function BU_getElementById(id) {
    var element = null;
    if (BU_isBrowserIE5Up()) {
        element = document.all[id];
    }
    else {
        element = document.getElementById(id);
    }
    return element;
}

/**
 * Get the element with the specified id.
 */
function BU_getElementByIdWithDocument(id, doc) {
    var element = null;
    if (BU_isBrowserIE5Up()) {
        element = doc.all[id];
    }
    else {
        element = doc.getElementById(id);
    }
    return element;
}


/**
 * Get the style of the element with the specified id.
 */
function BU_getElementStyle(id) {
    var style = null;
    var element = BU_getElementById(id);
    if (element != null) {
        style = element.style;
    }
    return style;
}

/**
 *****************************
 * Default Form/Data Functions
 *****************************
 */
/**
 * Returns true if the value is an unexpanded tag.
 */
function BU_isTag(value) {
    var tag = false;
    var tagPattern = /^.*\[#.*#\].*$/;
    if (tagPattern.test(value)) {
        tag = true;
    }
    return tag;
}

/**
 * Convert the given string to an integer.
 */
function BU_toInt(string) {
    var value = "" + string;
    if (value.indexOf("px") != -1) {
        value = value.substring(0, value.length - 2);
    }
    return parseInt(value);
}

/*
 *****************************
 * Browser Detection Functions
 *****************************
 */
/**
 * Returns true if Netscape 4.7, 4.8, 4.9.
 */
function BU_isBrowserNetscape4() {
    var status = false;
    var version = parseFloat(navigator.appVersion);
    if ((navigator.appName == "Netscape") && (version >= 4.7) && (version < 5.0)) {
        status = true;
    }
    return status;
}

/**
 * Returns true if netscape 5.0 or higher.
 */
function BU_isBrowserNetscape5Up() {
    var status = false;
    if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 5)) {
        status = true;
    }
    return status;
}

/**
 * Returns true if Internet Explorer 5.0 or higher.
 */
function BU_isBrowserIE5() {
    var status = false;
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        var userAgent = navigator.userAgent.split("MSIE");
        var version = parseFloat(userAgent[1]);
        if ((version >= 5.0) && (version < 5.5)) {
            status = true;
        }
    }
  return status;
}

/**
 * Returns true if Internet Explorer 5.0 or higher.
 */
function BU_isBrowserIE5Up() {
    var status = false;
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        var userAgent = navigator.userAgent.split("MSIE");
        var version = parseFloat(userAgent[1]);
        if (version >= 5.0) {
            status = true;
        }
    }
  return status;
}

/**
 * Check for supported browsers.
 */
function BU_isSupportedBrowser(displayMessage) {
    var isSupported = true;
    if (BU_isBrowserNetscape4()) {
        isSupported = false;
        if (displayMessage) {
            var message = ""; 
            message += "The Netscape browser version you are using may have problems with this web page.\n";
            message += "For better performance you may want to consider upgrading to Netscape version 6.0\n";
            message += "and higher or Internet Explorer 5.0 and higher.";
            alert(message);
        }
    }
    return isSupported;
}

/**
 **********************
 * Macromedia Functions
 **********************
 */
/**
 * Modified Macromedia Function
 */
function MM_callJS(jsStr) { //v2.0
    var value = false;
    var index = jsStr.indexOf('(');
    if (index == -1) {
        value = eval(jsStr);
    }
    else {
        var name = jsStr.substring(0, index);
        if (typeof(this[name]) == "function") {
            value = eval(jsStr);
        }
    }
    return value;
}
