$(document).ready(function() {
	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 951;
				$(this).find("ul").each(function() {		
					/*rowWidth += $(this).width();*/
				});	
			};
		})(jQuery);
                
			$(this).find(".sub").css({'width' : '956px'});

                         //Changement couleurs boutons
                        $(this).find("#button0").css({'background' : '#515862','color':'white'});
                        $(this).find("#button1").css({'background' : '#28797B','color':'white'});
                        $(this).find("#button2").css({'background' : '#55C4C8','color':'white'});
                        $(this).find("#button3").css({'background' : '#CF9C8C','color':'white'});
                        $(this).find("#button4").css({'background' : '#DE75BB','color':'white'});
                        $(this).find("#button5").css({'background' : '#FB6252','color':'white'});
                        $(this).find("#button6").css({'background' : '#529CFB','color':'white','width':'119px'});

                        $(this).find("#cont1").css({'margin' : '0px'});
                        $(this).find("#cont2").css({'margin-left' : '-138px'});
                        $(this).find("#cont3").css({'margin-left' : '-276px'});
                        $(this).find("#cont4").css({'margin-left' : '-414px'});
                        $(this).find("#cont5").css({'margin-left' : '-552px'});
                        $(this).find("#cont6").css({'margin-left' : '-690px'});
                        $(this).find("#cont7").css({'margin-left' : '-828px'});

                        $(this).find("#cont1 .stitle a").css({'color' : '#515862'});
                        $(this).find("#cont2 .stitle a").css({'color' : '#28797B'});
                        $(this).find("#cont3 .stitle a").css({'color' : '#55C4C8'});
                        $(this).find("#cont4 .stitle a").css({'color' : '#CF9C8C'});
                        $(this).find("#cont5 .stitle a").css({'color' : '#DE75BB'});
                        $(this).find("#cont6 .stitle a").css({'color' : '#FB6252'});
                        $(this).find("#cont7 .stitle a").css({'color' : '#529CFB'});
                      

                    
	}

	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
          $(this).find("#button0").css({'background' : 'white','color':'#556E73'});
          $(this).find("#button1").css({'background' : 'white','color':'#556E73'});
          $(this).find("#button2").css({'background' : 'white','color':'#556E73'});
          $(this).find("#button3").css({'background' : 'white','color':'#556E73'});
          $(this).find("#button4").css({'background' : 'white','color':'#556E73'});
          $(this).find("#button5").css({'background' : 'white','color':'#556E73'});
          $(this).find("#button6").css({'background' : 'white','color':'#556E73'});
	}

	var config = {    
		 sensitivity: 2,
		 interval: 100,
		 over: megaHoverOver,
		 timeout: 300,
		 out: megaHoverOut
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li .sub ul").css({'list-style':'none'});
	$("ul#topnav li").hoverIntent(config);

});


