function megadropdown(element){
	
	var config = {    
		 sensitivity: 	1, 				// number = sensitivity threshold (must be 1 or higher)    
		 interval: 		1, 				// number = milliseconds for onMouseOver polling interval    
		 over: 			megaHoverOver, 	// function = onMouseOver callback (REQUIRED)    
		 timeout: 		1, 				// number = milliseconds delay before onMouseOut    
		 out: 			megaHoverOut 	// function = onMouseOut callback (REQUIRED)    
	};
	
	megawidth = $(element).find("a").width();
	megawidth += 20;
	$(element).css({'width' : megawidth});
	
	$(element).find(".submenu").hide();
	$(element).hoverIntent(config);
	
	var config = {    
		 sensitivity:	1,
		 interval:		1,
		 over: 			subHoverOver,
		 timeout:		1,
		 out: 			subHoverOut
	};
	$(element).find("li").hoverIntent(config);
	
}

function subHoverOver(){
	$(this).addClass('over');
}
function subHoverOut(){
	$(this).removeClass('over');
}

function megaHoverOver(){
	
	$(this).find("a.menu").addClass('hover');
	$(this).find(".submenu").stop().fadeTo('fast', 1).show();
		
	//Calculate width of all ul's
	(function($) { 
		jQuery.fn.calcSubWidth = function() {
			rowWidth = 0;
			//Calculate row
			$(this).find("ul").each(function() {					
				rowWidth += $(this).width(); 
			});	
			//rowWidth += 50;
		};
	})(jQuery);
	
	if ( $(this).find(".row").length > 0 ) { //If row exists...
		var biggestRow = 0;	
		//Calculate each row
		$(this).find(".row").each(function() {							   
			$(this).calcSubWidth();
			//Find biggest row
			if(rowWidth > biggestRow) {
				biggestRow = rowWidth;
			}
		});
		//Set width
		$(this).find(".submenu").css({'width' :biggestRow});
		$(this).find(".row:last").css({'margin':'0'});
		
	} else { //If row does not exist...
		
		$(this).calcSubWidth();
		//Set Width
		$(this).find(".submenu").css({'width' : rowWidth});
		
	}
}

function megaHoverOut(){ 
	$(this).find(".submenu").stop().fadeTo('fast', 0, function() {
		$(this).parent().find("a.menu").removeClass('hover');
		$(this).hide(); 
	});
}
