// jDiv - a jQuery plugin
// (c) Skyrocket Labs
// http://www.skyrocketlabs.com
// fred@skyrocketlabs.com
// Created: 10.24.2009
// Last updated: 02.06.2010

// DISPLAYS HIDDEN DIVS AS SUBMENUS ON HOVER

$jQ = jQuery.noConflict();


$jQ(document).ready(function() {
    var hide = false;
    // Shows the DIV on hover with a fade in

    $jQ(".jmenu").hover(function() {

        $jQ(".hidden-div").hide();

        if (hide) clearTimeout(hide);                

        $jQ("#hidden-div" + $jQ(this).attr("id")).show();
        //$jQ("#overlay2").fadeTo("fast", 0.7);
    
        // The main nav menu item is assigned the 'active' CSS class
        $jQ(this).addClass("active");

        var menuId = "#" + $jQ(this).attr("id");

        $jQ("#hidden-div" + $jQ(this).attr("id")).hover(function() {

            if (hide) clearTimeout(hide);
            $jQ(menuId).addClass("active");
            $jQ(menuId).addClass("menu2Active");
            

        }, function() {

            // If your mouse moves out of the displayed hidden DIV, the DIv fades out and removes the 'active' class
            hide = setTimeout(function() { $jQ("#" + $jQ(this).attr("id")).fadeOut("fast"); });

            //$jQ("#" + $jQ(this).attr("id")).stop().fadeIn();
            $jQ("#" + $jQ(this).attr("id")).fadeOut("fast");
            $jQ(menuId).removeClass("active");
            $jQ(".menu2").removeClass("menu2Active");
            $jQ(menuId).removeClass("active");
            $jQ(".menu2").css("color", "#EFEFEF");
            $jQ(this).removeClass("active");
            //$jQ("#overlay2").fadeTo("fast",0);

        });
    }, function() {

        var ident = $jQ(this).attr("id");

        // Fades out the DIV and removes the 'active' class from the main nav menu item
        hide = setTimeout(function() {
            $jQ("#hidden-div" + ident).fadeOut("fast");
            //$jQ("#overlay2").fadeTo("fast",0);
        });

        $jQ("#" + ident).removeClass("active");

    });
    // Ensures the DIV displays when your mouse moves away from the main nav menu item

    $jQ(".menu2").hover(function() {

        $jQ(".hidden-div-right").hide();
        $jQ(".menu2").removeClass("active");
        $jQ(".menu2").removeClass("menu2Active");
        $jQ(".menu2").css("color", "#EFEFEF");
        if (hide) clearTimeout(hide);

        $jQ("#hidden-div-right" + $jQ(this).attr("id")).fadeIn();

        // The main nav menu item is assigned the 'active' CSS class
        $jQ(this).addClass("menu2Active");
        $jQ(this).addClass("active");
        $jQ(this).css("color", "#222");

        var menuId = "#" + $jQ(this).attr("id");

        $jQ("#hidden-div-right" + $jQ(this).attr("id")).hover(function() {

            if (hide) clearTimeout(hide);
            $jQ(menuId).addClass("active");


        }, function() {

            // If your mouse moves out of the displayed hidden DIV, the DIv fades out and removes the 'active' class
            hide = setTimeout(function() { $jQ("#" + $jQ(this).attr("id")).fadeOut("fast"); });
            //$jQ("#" + $jQ(this).attr("id")).stop().fadeIn();
            $jQ("#" + $jQ(this).attr("id")).fadeOut("fast");
            $jQ(menuId).removeClass("active");
            $jQ(menuId).removeClass("menu2Active");
            $jQ(menuId).css("color", "#EFEFEF");

        });
    }, function() {
        //  var ident = $jQ(this).attr("id");
        // Fades out the DIV and removes the 'active' class from the main nav menu item
        //hide = setTimeout(function() {
        //  $jQ("#hidden-div-right" + ident).fadeOut("fast");
        //  });
        //$jQ("#" + ident).removeClass("active");
    });

});
	
