var litiumkc = function() {
    // *******************************************************
    // Functionality for Litium Menu
    // *******************************************************
    /// <summary>
    ///	Fix PNG images in IE6
    /// </summary>
    /// <returns>void</returns>
    function fixPng() {
        for (var i = 0; i < document.images.length; i++) {
            var img = document.images[i]
            var imgName = img.src.toUpperCase()
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='image');\"></span>"
                img.outerHTML = strNewHTML
                i = i - 1
            }
        }
    }

    /// <summary>
    ///	Starts timer
    /// </summary>
    /// <returns>void</returns> 
    function startTimer() {
        // Stop previous timer
        if (this.$timer) {
            clearTimeout(this.$timer);
        }
        this.$timer = setTimeout(function() { hideAll(); }, 1000);
    }
    /// <summary>
    ///	Stop timer
    /// </summary>
    /// <returns>void</returns>    
    function stopTimer() {
        if (this.$timer) { clearTimeout(this.$timer); }
    }

    /// <summary>
    ///	Hide the whole Litium Menu
    /// </summary>
    /// <returns>void</returns> 
    function hideAll() {
        var x = document.getElementsByTagName('div');
        for (var i = 0; i < x.length; i++) {
            // Close all divs with and ID starting with 'subdiv_'
            if (x[i].id.substring(0, 7) == 'subdiv_') {
                x[i].style.display = "none";
            }
        }
        var allATags = document.getElementsByTagName('a');
        for (var i = 0; i < allATags.length; i++) {
            // Set css class of all a with ID starting with 'menulink_'
            if (allATags[i].id.substring(0, 9) == 'menulink_') {
                $(allATags[i]).attr("class", "LitiumMenuItem");
            }
        }

    }

    /// <summary>
    ///	show specific sub menu
    /// </summary>
    /// <param>sender</param>
    /// <param>element id</param>
    /// <returns>void</returns> 
    function showSubMenu(sender, elementID) {
        stopTimer();
        // Loop through all divs
        var x = document.getElementsByTagName('div');
        var allATags = document.getElementsByTagName('a');
        var ourElement = document.getElementById(elementID);

        for (var i = 0; i < allATags.length; i++) {
            // Set css class of all a with ID starting with 'menulink_'
            if (allATags[i].id.substring(0, 9) == 'menulink_') {
                if (allATags[i].id != sender.id) {
                    $(allATags[i]).attr("class", "LitiumMenuItem");

                }
            }
        }

        for (var i = 0; i < x.length; i++) {
            // Close all divs with and ID starting with 'subdiv_'
            if (x[i].id.substring(0, 7) == 'subdiv_') {
                if (x[i].id != ourElement.id) {
                    x[i].style.display = "none";
                }
            }
        }

        $(sender).attr("class", "LitiumMenuItemSelected");
        $(ourElement).show();
        // Set left position based on parent object
        var pos = $(sender).offset();
        $(ourElement).css("left", pos["left"]);
    }


    // *******************************************************
    // Functionality for footer
    // *******************************************************

    /// <summary>
    ///	Set the footer height so it will fill rest of page
    /// </summary>
    /// <returns>void</returns> 
    function SetDivHeight() {
        // Declare
        var totalHeight = $(document.getElementById("#page")).height();
        // Determine if the total amount of divs are larger than the screen size
        if (totalHeight < WindowHeight()) {
            $(document.getElementById("footer")).height(WindowHeight() - totalHeight);
        }

        // Determine if the text inside the bottom div are larger than the parent div
        if ($(document.getElementById("footertext")).height() > $(document.getElementById("footer")).height()) {
            $(document.getElementById("footer")).height($(document.getElementById("footertext")).height());
        }
    }


    /// <summary>
    ///	Returns the actually height of windows
    /// </summary>
    /// <returns>void</returns> 
    function WindowHeight() {
        var height = 0;
        if (typeof (window.innerHeight) == 'number') {
            //Non-IE
            height = window.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {
            //IE 6+ in 'standards compliant mode'
            height = document.documentElement.clientHeight;
        } else if (document.body && document.body.clientHeight) {
            height = document.body.clientHeight;
        }
        return parseInt(height);
    }

    /// <summary>
    /// General utilities.
    /// </summary>
    //--------------------------------------------------------------------------		

    //--------------------------------------------------------------------------
    function init() {
        if ((jQuery.browser.version >= 5.5) && (document.body.filters)) {
            fixPng();
        }
        SetDivHeight();        
    };
    //--------------------------------------------------------------------------
    return {init: init};
} ();
