$(document).ready(function() {
	var browser = jQuery.browser;
	if(browser.msie)
	{
		if(Number(browser.version) <= 8)
		{
			//$(".spectable tbody tr td:last-child").css( "border-right", "#c6c9cd solid 1px" );
			//$(".spectable tbody tr:nth-child(2n+1)").removeClass().addClass("tdstyle1");
			//$(".spectable tbody tr:nth-child(2n)").removeClass().addClass("tdstyle2");
			/*
			$(".onecoltable tbody tr td:last-child,.fiyattable tbody tr td:last-child").css( "border-right", "#c6c9cd solid 1px" );
			$(".onecoltable tbody tr:nth-child(2n+1)").removeClass().addClass("tdstyle1-one-col");
			$(".onecoltable tbody tr:nth-child(2n)").removeClass().addClass("tdstyle2-one-col");
			$(".fiyattable tbody tr:nth-child(2n)").css("background-color","#e2e3e4");
			*/
		}
	}
						   
	function megaHoverOver(){
		$(this).find(".sub,.gen").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(); 
				});	
			};
		})(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(".sub,.gen").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub,.gen").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub,.gen").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}
	
	$("ul#topnav li").mouseenter(megaHoverOver).mouseleave(megaHoverOut);
});
