<!--//--><![CDATA[//><!--

var highlightMenu = true;
var textResizing = true;
var expandingMenu = true;

$(document).ready(function(){
    
    var hoverConfig = {
        over : function() {$(this).addClass("hover");},
        out : function() {$(this).removeClass("hover");},
        interval : 0,
        timeout : 500,
        sensitivity : 3
    }
    
    $("#nav li").hoverIntent(hoverConfig);
    $("#nav-prod li").hoverIntent(hoverConfig);
		
	$("#nav a").each(function(){
        // Add active class to current page link in the menu
        if (highlightMenu) {
            if (location.href.indexOf(this.href) != -1) $(this).parent().addClass("active");
        }
        
        // Expand lists when the user tabs through menu items
        $(this).focus(function() {
            $(this).parents('li').addClass('hover');
        });
        // Collapse lists again when the link loses focus
        $(this).blur(function() {
            $(this).parents('#nav li').removeClass('hover');
        });
    });
    
    // Text resizing
    if(textResizing){
        changeTextSize(readCookie('style'));
        $('#widgets a').click(function(event){
            event.preventDefault();
            changeTextSize(this.id);
        });
    }
    
    if(expandingMenu){
        var navid = "" + $.query.get('n');    
        $("#nav-prod > li > ul.subnav").hide();    

        if(navid != ""){
            $("#nav-prod ul#" + navid).parents("ul.subnav").show();
            $("#nav-prod ul#" + navid).parents("li.navdrop").children("a").addClass("open");
            $("#nav-prod ul#" + navid).show();
            
        }
           
        $("#nav-prod > li.navdrop > a").next("ul.subnav").children("li").children("a").each(function(){      
            //$(this).attr("href", $(this).attr("href") + "&n=" + $(this).parent("li").parent("ul").attr("id"));
        });
        
        $("#nav-prod > li.navdrop > a").click(function(e) {
            e.preventDefault();
            $(this).next("ul.subnav").slideToggle();
            $(this).toggleClass("open");
        });
    }    
    
    if ($(".productBox") != null) {
        var maxHeight = 0;                    
        if ($(".catListing") != null) {
            $(".catListing .productBox").each(function(){ if($(this).height() > maxHeight) maxHeight = $(this).height(); });                                        
            $(".catListing .productBox").height(maxHeight+15);    
        }
        maxHeight = 0;                    
        if ($(".productGrid") != null) {
            $(".productGrid .productBox").each(function(){ if($(this).height() > maxHeight) maxHeight = $(this).height(); });                                        
            $(".productGrid .productBox").height(maxHeight+15);    
        }
    }
});
