
jQuery(function($) {
    $("div.navSelect a").click(function() {
        var showid = this.id.replace("menu", "item");

        $("#subHeader").text($(this).text());
        $("#navPanel").html($("#" + showid).html());
        //alert(this.id);
        //alert($(this).text());
    });


    //    $("#closetool").click(function() {
    //        if (this.className == "collapse") {
    //            hideSider();
    //        }
    //        else {
    //            showSider();
    //        }

    //    });


    $(document).ready(function() {
        if (self != top) {
            top.location.href = window.location.href;
        }

        resizeWindow();

        $("a").bind("focus", function() {
            if (this.blur) {
                this.blur();
            }
        });

        //        if ($("input[name='navState']").val() == 1) {
        //          
        //        }

        if ($(".navSelect a.current").length > 0)
            $(".navSelect a.current").trigger('click');
        else
            $(".navSelect a:first").trigger('click');

    });   


});

function BindNavStateEvent(id) {
    $(id).click(function() {
      if ($(id).hasClass("collapse")) {
            hideSider(id);
        }
        else {
            showSider(id);
        }

    });
}

function hideSider(id) {
    //        if ($("input[name='navState']").val() == 1) {
    $(id).removeClass("collapse");
    $(id).addClass("expand");
    $("#navigation").width(32);
    $("#subHeader").hide();
    $("#content").css("left", "42px");
    //        $("input[name='navState']").val(0);
    //        }
}

function showSider(id) {
    $(id).removeClass("expand");
    $(id).addClass("collapse");
    $("#navigation").width(200);
    $("#subHeader").show();
    $("#content").css("left", "210px");

}


window.onresize = function() {
    resizeWindow();
};

function resizeWindow() {
    var windowHeight = getWindowHeight();

    document.getElementById("content").style.height = (windowHeight - 97) + "px";
    document.getElementById("contentPanel").style.height = (windowHeight - 124) + "px";
    document.getElementById("navigation").style.height = (windowHeight - 97) + "px";
}

function getWindowHeight() {
    var windowHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}

