
// メガドロップダウンメニュー

$(document).ready(function() {

//On Hover Over
function megaHoverOver(){
    $(this).find(".sub").stop().fadeTo('fast', 1).show(); 
   // (function($) {
//        //Function to calculate total width of all ul's
//        jQuery.fn.calcSubWidth = function() {
//            rowWidth = 0;
//            //Calculate row
//            $(this).find("ul").each(function() { 
//                rowWidth += $(this).width(); 
//            });
//        };
//    })(jQuery); 

    if ( $(this).find(".row").length > 0 ) { 

        var biggestRow = 0;	

        $(this).find(".row").each(function() {	
            $(this).calcSubWidth(); 
            //Find biggest row
            if(rowWidth > biggestRow) {
                biggestRow = rowWidth;
            }
        });

        $(this).find(".sub").css({'width' :biggestRow}); 
        $(this).find(".row:last").css({'margin':'0'});  

    } else { 

//        $(this).calcSubWidth();  
//        $(this).find(".sub").css({'width' : rowWidth}); 

    }
}
//On Hover Out
function megaHoverOut(){
  $(this).find(".sub").stop().fadeTo('fast', 0, function() { 
      $(this).hide();  
  });
}

//Set custom configurations
var config = {
     sensitivity: 2, 
     interval: 0, 
     over: megaHoverOver, 
     timeout: 0, 
     out: megaHoverOut 
};

$("ul#topnav li .sub").css({'opacity':'0'}); 
$("ul#topnav li").hoverIntent(config); 

});
//背景ブラックアウト

       $(function(){
            $('a.bg').hover(function(){
                var width  = $(document).width();
                var height = $(document).height();
                $('#bg').width(width)
                           .height(height)
                           .show()
                           .fadeTo(0, 0.5);
            });
            $('#bg').hover(function(){
                $(this).fadeTo('fast', 0, function(){
                    $(this).hide();
                });
            });
        });
		
		$(function(){
            $('a.bgNone').hover(function(){
                var width  = $(document).width();
                var height = $(document).height();
                $('#bg').width(width)
                           .height(height)
                           .show()
                           .fadeTo(0, 0);
            });
            $('#bg').hover(function(){
                $(this).fadeTo('fast', 0, function(){
                    $(this).hide();
                });
            });
        });

