

function LoadMenuNaviLeft(className) {
    $(".PRIMARY div").each(function(index) {
        $(this).css("display", "none");
    });
    $(".PRIMARY .DEFAULT").each(function(index) {
        $(this).css("display", "block");
    });
    if (className == null || className == undefined) {
        className = $("#NaviLeft").val();
    }
    if (className != null && className != undefined && className.length > 0) {
        var classes = className.split("/");
        $("." + classes[0] + ".CLOSED").css("display", "none");
        $("." + classes[0] + ".OPEN").css("display", "block");
        $("." + classes[1]).toggleClass("SELECTED");
    }
}

function LoadMenuNaviLeftZaza(className) {
    $(".ZAZACHAT div").each(function(index) {
        $(this).css("display", "none");
    });
    $(".ZAZACHAT .DEFAULT").each(function(index) {
        $(this).css("display", "block");
    });
    if (className == null || className == undefined) {
        className = $("#NaviLeftZaza").val();
    }
    if (className != null && className != undefined && className.length > 0) {
        var classes = className.split("/");
        $("." + classes[0] + ".CLOSED").css("display", "none");
        $("." + classes[0] + ".OPEN").css("display", "block");
    }
}

function LoadMenuNaviRight(className) {
    $(".NAVIGATIONRIGHT div").each(function(index) {
        $(this).css("display", "none");
    });
    $(".NAVIGATIONRIGHT .DEFAULT").each(function(index) {
        $(this).css("display", "block");
    });
    if (className == null || className == undefined) {
        className = $("#NaviRight").val();
    }
    if (className != null && className != undefined && className.length > 0) {
        var classes = className.split("/");
        $("." + classes[0] + ".OPEN").css("display", "block");
        $("." + classes[1]).toggleClass("SELECTED");
    }
}

function LoadMenuNaviRightLibrary(className) {
    $(".LIBRARYNAVIGATION div").each(function(index) {
        $(this).css("display", "none");
    });
    $(".LIBRARYNAVIGATION .DEFAULT").each(function(index) {
        $(this).css("display", "block");
    });
    if (className == null || className == undefined) {
        className = $("#NaviRightLibrary").val();
    }
    if (className != null && className != undefined && className.length > 0) {
        var classes = className.split("/");
        $("." + classes[0] + ".CLOSED").css("display", "none");
        $("." + classes[0] + ".OPEN").css("display", "block");
    }
}


function OpenDocument(templateId, contentId, menuId, anchorId) {
    var url = './default.aspx?tid=' + templateId;

    if (contentId != null) url += '&amp;cid=' + contentId;
    if (menuId != null) url += '&amp;mid=' + menuId;
    if (anchorId != null) url += '#' + anchorId;
    document.location.href = url;
}

function OpenQuickLink(el) {
    try {
        if (el.selectedIndex > 0) {
            document.location.href = el.options[el.selectedIndex].value;
        }
    }
    catch (e) { }
}

function rollSetup() {
    /** string added to "on" state images */
    var post = "_o";

    /** fetch the image tag array from the DOM */
    var imgTags = document.getElementsByTagName("img");

    /** loop through the images for find appropriate preloads */
    for (i = 0; i < imgTags.length; i++) {
        /** make sure there is a source defined */
        if (imgTags[i].src != '') {
            /** make sure the image tag has a class */
            tmpClass = imgTags[i].className;
            if (tmpClass) {
                /** match the image rollover class */
                if (tmpClass.match("rollover")) {
                    /** store the image source to the 'imgOut' attribute */
                    imgTags[i].imgOut = new Image();
                    imgTags[i].imgOut.src = imgTags[i].src;

                    /** pull apart the source string */
                    srcLength = imgTags[i].src.length;

                    srcName = imgTags[i].src.substr(0, srcLength - 4);
                    srcExt = imgTags[i].src.substr(srcLength - 4, srcLength);

                    /** store the image source to the 'imgOver' attribute */
                    imgTags[i].imgOver = new Image();
                    imgTags[i].imgOver.src = srcName + post + srcExt;

                    /** set up the 'onmouseover' and 'onmouseout' event handlers */
                    imgTags[i].onmouseover = function() {
                        this.src = this.imgOver.src;
                    }
                    imgTags[i].onmouseout = function() {
                        this.src = this.imgOut.src;
                    }
                }
            }
        }
    }
}

function changeClass(id, newclass) {
    var elm = document.getElementById(id);
    elm.className = newclass;
}

function addEvent(elm, evType, fn, useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
    }
    else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + evType, fn);
        return r;
    }
    else {
        elm['on' + evType] = fn;
    }
}

addEvent(window, 'load', rollSetup, false);
