
$(function () {

    var tempHeight = 0;
    var origHeight = 0;

    //Main ul based menu
    $("ul.dropdown li").hover(
        function () {

            if ($.browser.msie && $.browser.version.substr(0, 1) < 9) {
                $('ul:first', this).css({ visibility: "visible", width: 200, color: "#000"});
                
            } else {
                $('ul:first', this).css({ visibility: "visible", width: 200, color: "#000" });
                $('ul:first', this).animate({ opacity: 1.0 }, 250);
            }

        },
        function () {

            if ($.browser.msie && $.browser.version.substr(0, 1) < 9) {
                $('ul:first', this).css({ visibility: "hidden" });
            } else {
                $('ul:first', this).animate({ opacity: 0.0 }, 250);
                $('ul:first', this).css({ visibility: "hidden" });
            }

        });


    //    //Feature div menu extender
    //    $("li.sub_menu").hoverIntent(
    //    function () {
    //        var p = $(this).parent();
    //        var pos = p.offset();
    //        var numFeatures = $(this).attr("numFeatures")

    //        tempHeight = 0;
    //        origHeight = p.height();

    //        if (origHeight < 200) {
    //            tempHeight = 200;
    //        } else {
    //            tempHeight = origHeight;
    //        }

    //    
    //        $("div.flyout", this).offset({ top: pos.top, left: pos.left + 200 });
    //        $(this).parent().animate({ width: '540px', height: tempHeight }, 250);
    //        $("div.flyout", this).css({ visibility: "visible", height: tempHeight - 20, width: 300 });
    //        $("div.flyout", this).animate({ opacity: 1.0 }, 1000);
    //    

    //    },
    //    function () {
    //        var p = $(this).parent();
    //        var pos = p.offset();

    //    
    //        $("div.flyout", this).offset({ top: pos.top, left: pos.left + 200 });
    //        $(this).parent().animate({ width: '200px', height: origHeight }, 250);
    //        $("div.flyout", this).animate({ opacity: 0.0 }, 0);
    //        $("div.flyout", this).css({ visibility: "hidden", height: 0, width: 0, backgroundColor: "#FFFFFF" });
    //        $("div.flyout", this).css({ visibility: "hidden", backgroundColor: "#FFFFFF" });
    //    
    //    });

    $(".PageSubMenu").hover(
        function () {
            $(this).css({ cursor: "pointer" });
            $(this).animate({ backgroundColor: "#124FAE" }, 100);
        },
        function () {
            $(this).animate({ backgroundColor: "#C0C0C0" }, 250);
        }
    );


    $(".SubFeatureText").click(
            function () {
                $(this).animate({ backgroundColor: "#EBF3FE" }, 175);
                $(this).animate({ backgroundColor: "#FFFFFF" }, 175);
                document.location.href = $(this).attr("href");
            }
        );
});

$(document).ready(function () {
    //apply link behaviour to sub menu
    $(".PageSubMenu").click(function () {
        document.location.href = $(this).attr("link");
    });

//    //position main dropdown menu elements NOT FINISHED AS IT NEED TO BE APPLIED AT STARTUP CORRECTLY
//    $("ul.dropdown li ul").ready(function () {
//    
//        var p = $(this).parent();
//        var pos = p.offset();

//        $(this).offset({ top: pos.top + 30, left: pos.left });
//    });
});
