﻿

$(document).ready(function () {

    // now the page is loaded - go about loading the nav previews
//    $('ul.primary-nav li').each(
//        function () {
//            var thissubnavpanel = $(this).find('div.subnavpanel');
//            if (thissubnavpanel.attr('class') == 'subnavpanel') {
//                // only load if it exists (not undefined)
//                $.ajax({
//                    type: "GET",
//                    url: "/subnavpanel.asp",
//                    data: "panel=" + thissubnavpanel.attr('id'),
//                    success: function (msg) {
//                        //alert(msg);
//                        thissubnavpanel.html(msg);
//                    }
//                });
//            }
//        }
//    );

    $('ul.primary-nav li').hover(
        function () {
            var thissubnavpanel = $(this).find('div.subnavpanel');
            thissubnavpanel.show();
            var thisprimarylink = $(this).find('a');
            thisprimarylink.addClass('on');
        },
        function () {
            var thissubnavpanel = $(this).find('div.subnavpanel');
            thissubnavpanel.fadeOut(50);
            var thisprimarylink = $(this).find('a');
            thisprimarylink.removeClass('on');
        }
    );
    
});







//    hideAllSecNavExceptSelected();

//    if ($('ul.primary-nav li a.on').size() > 0) { // if any of the navigation is already selected (ie not the homepage)
//        showSecNav($('ul.primary-nav li a.on').parent());
//    }

//    $('ul.primary-nav li').hover(
//        function () {
//            hideAllSecNavExceptSelectedAndThis(this);
//            secNavInUse = true;
//            showSecNav(this);
//        },
//        function () {
//            hideIfNoLongerInUse;
//            secNavInUse = false;
//        }
//    );

//});

//function showSecNav(what) {

//    $(what).find('.secondary').show();
//    $(what).find('a').addClass('hover');
//    $(what).addClass('hover');
//    $(what).find('div.navigationpreview')
//        .show()
//        .animate({ height: "330px" }, { queue: false, duration: 300 })
//        .animate({ top: "97px" }, 300)
//        ;
//}

//function hideAllSecNavExceptSelected() {

//    if ($('ul.primary li a.selected').size() == 0) {
//        $('ul.primary').removeClass('joinsecnav');
//    }

//    $('ul.primary li').each(
//        function () {
//            if ($.inArray("selected", $(this).find('a').attr('class').split(' '))) {

//                $(this).find('.secondary').hide();
//                $(this).removeClass('hover');
//                $(this).find('a').removeClass('hover');
//                $(this).find('div.navigationpreview')
//                    .clearQueue('fx')
//                    .hide()
//                    .height(0)
//                    .animate({ top: "85px" }, 0)
//                    ;

//            }
//        }
//    );

//}

//function hideAllSecNavExceptSelectedAndThis(what) {

//    if ($('ul.primary li a.selected').size() == 0) {
//        $('ul.primary').removeClass('joinsecnav');
//    }

//    $('ul.primary li').each(
//        function () {
//            if ($(what).find('a').text() != $(this).find('a').text()) {

//                if ($.inArray("selected", $(this).find('a').attr('class').split(' '))) {

//                    $(this).find('.secondary').hide();
//                    $(this).removeClass('hover');
//                    $(this).find('a').removeClass('hover');
//                    $(this).find('div.navigationpreview')
//                        .clearQueue('fx')
//                        .hide()
//                        .height(0)
//                        .animate({ top: "85px" }, 0)
//                        ;

//                }
//            }
//        }
//    );

//}

//function hideIfNoLongerInUse() {
//    if (!secNavInUse) {
//        hideAllSecNavExceptSelected();
//    }
//}



