﻿$(function () {
    var id;
    $('.parent').each(function (index) {
        $(this).hover(function () {
            document.getElementById("divparent" + index).style.backgroundImage = "url('/images/top/nav_arrow_02.png')";
            document.getElementById("divparent" + index).style.color = "#0c4d87";
            document.getElementById("parent_center" + index).style.backgroundImage = "url('/images/top/parent_hover.png')";
            document.getElementById("parent_left" + index).style.backgroundImage = "url('/images/top/parent_hover_left.png')";
            document.getElementById("parent_right" + index).style.backgroundImage = "url('/images/top/parent_hover_right.png')";
            document.getElementById("child" + index).style.display = "block";
        },
                function () {
                    hidemenu(index);
                }
           )
        $('#child' + index + ' td.childtd').each(function (index1) {
            $(this).hover(function () {
                this.style.backgroundColor = "#8da9db";
                this.style.color = "#ffffff";
            },
              function () {
                  this.style.backgroundColor = "#e5e9e5";
                  this.style.color = "#14548b";
              }
           )
        });
    });
});
$(function () {
    var id;
    $('.smallparent').each(function (index) {
        $(this).hover(function () {
            document.getElementById("smallparent" + index + "_div").style.color = "#ffffff";
            this.style.backgroundImage = "url('/images/top/1064a9.png')";
            document.getElementById("smallchild" + index).style.display = "block";
            var zero = getAbsPointx(document.getElementById("tophead"));
            var divoffsetx = getAbsPointx(this) - zero;
            if (divoffsetx > 780) {
                document.getElementById("smallchild" + index).style.left = (780 - divoffsetx).toString() + "px";
            }
        }, function () {
            hidesmallmenu(index);
        })
        $('#smallchild' + index + ' td.smallchildtd').each(function (index1) {
            $(this).hover(function () {
                this.style.color = "#ffffff";
                this.style.backgroundColor = "#8da9db";
            }, function () {
                this.style.color = "#000000";
                this.style.backgroundColor = "#f5f5f5";
            })
        })
    })
});
function hidemenu(index) {
    if (document.getElementById("parent" + index).title) {
        document.getElementById("divparent" + index).style.backgroundImage = "url('/images/top/nav_arrow_01.png')";
    }
    else {
        document.getElementById("divparent" + index).style.backgroundImage = "url('/images/top/nav_arrow_03.png')";
    }
    document.getElementById("divparent" + index).style.color = "#ffffff";
    document.getElementById("child" + index).style.display = "none";
    document.getElementById("parent_center" + index).style.backgroundImage = "";
    document.getElementById("parent_left" + index).style.backgroundImage = "";
    document.getElementById("parent_right" + index).style.backgroundImage = "";
}
function resetchild(i, j) {
    document.getElementById("childtd" + i + "_" + j).style.color = "#14548b";
    document.getElementById("childtd" + i + "_" + j).style.backgroundColor = "#e5e9e5";
    hidemenu(i);
}
function hidesmallmenu(index) {
    if (!document.getElementById("smallparent" + index + "_div").title) {
        document.getElementById("smallparent" + index + "_div").style.color = "#1064a9";
    }
    else {
        document.getElementById("smallparent" + index + "_div").style.color = "#000000";
    }
    document.getElementById("smallparent" + index).style.backgroundImage = "";
    document.getElementById("smallchild" + index).style.display = "none";
}
function resetsmallchild(i, j) {
    document.getElementById("smallchildtd_" + i + "_" + j).style.color = "#000000";
    document.getElementById("smallchildtd_" + i + "_" + j).style.backgroundColor = "#f5f5f5";
    hidesmallmenu(i);
}
function getAbsPointx(e) {
    var x = e.offsetLeft;
    //var y = e.offsetTop;
    while (e = e.offsetParent) {
        x += e.offsetLeft;
        //y += e.offsetTop;
    }
    return x;
} 
