$(function() {
   $("tr > td").hover(function() {
       $(this).addClass("now_line");
       $next =$(this).next();
        $prev =$(this).prev();
       $($next).addClass("now_line");
       $($next).next().addClass("now_line");
       $($prev).addClass("now_line");
       $($prev).prev().addClass("now_line");
       
   }, function() {
       $(this).removeClass("now_line");
       $next =$(this).next();
       $prev =$(this).prev();
       $(this).next().removeClass("now_line");
       $($next).next().removeClass("now_line");
       $(this).prev().removeClass("now_line");
       $($prev).prev().removeClass("now_line");
   });
	   
});

$(document).ready(function() {
	function megaHoverOver(){
		$(this).find(".drop").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				$(this).find("ul").each(function() {rowWidth += $(this).width(); });//Calculate row
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {
				$(this).calcSubWidth();
				if(rowWidth > biggestRow) {	biggestRow = rowWidth;	}		//Find biggest row
			});
			//Set width
			$(this).find(".drop").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			$(this).calcSubWidth();
			$(this).find(".drop").css({'width' : rowWidth});//Set Width
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".drop").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


	var config = {    
		 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 10,   // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 250,     // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#sub_navi li .drop").css({'opacity':'30'});
	$("ul#sub_navi li").hoverIntent(config);



});


