﻿// JScript File
$(document).ready(function() {
    createMenu();

    $('img[data-hover]').hover(function() {
        $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp');
    }).each(function() {
        $('<img />').attr('src', $(this).attr('data-hover'));
    });
});

function createMenu() {
    var submenuoffset = 0;
    var ultags = document.getElementById("main-menu").getElementsByTagName("ul");
    for (var t = 0; t < ultags.length; t++) {
        ultags[t].style.top = ultags[t].parentNode.offsetHeight + submenuoffset + "px";
        ultags[t].parentNode.onmouseover = function() {
            this.style.zIndex = 999;
            this.getElementsByTagName("ul")[0].style.visibility = "visible";
            //this.getElementsByTagName("div")[0].style.visibility = "visible";
            //var h = this.getElementsByTagName("ul")[0].offsetHeight + 10;
            var w = this.getElementsByTagName("ul")[0].offsetWidth;
            //this.getElementsByTagName("div")[0].style.height = h + "px";
            //this.getElementsByTagName("div")[0].style.width = w - 8 + "px";
            //this.getElementsByTagName("div")[0].style.marginTop = "25px";
            $(this.getElementsByTagName("ul")[0]).find("li a").css("width", w - 16 + "px");
            /*if (jQuery.browser.msie) {
                if (parseInt(jQuery.browser.version) < 8)
                    this.getElementsByTagName("div")[0].style.marginTop = "0px";
            } else {
                this.getElementsByTagName("div")[0].style.marginTop = "35px";
            }*/
        }
        ultags[t].parentNode.onmouseout = function() {
            this.style.zIndex = 0;
            this.getElementsByTagName("ul")[0].style.visibility = "hidden";
            //this.getElementsByTagName("div")[0].style.visibility = "hidden";
        }
    }
}
