	var mode = "";

	$(document).ready(function() {
		var widthCheck = 0;
		var heightCheck = 0;
		var serie = $('.containeurContenu').attr("id");
		var widthBody = $('body').width();
		var heightBody = $('body').height();
		
		
		
		//console.log(BrowserDetect.browser)
		if ((widthBody <= 1359) || (widthBody >= 9999) || (heightBody <= 700)) {
			if (BrowserDetect.browser == "Chrome") {
				$('#footerVersionNormal').remove();
			}
			else {
				$('#footerVersionChrome').remove();
			}
		}
		else {
			$('#footerVersionChrome').remove();
			
			
			if(BrowserDetect.browser == "Chrome") {
				$('a').click(function() {
					$('body').scrollTop(0);
					setTimeout(function() { $('body').scrollTop(0); },1)
					setTimeout(function() { $('body').scrollTop(0); },3)
					setTimeout(function() { $('body').scrollTop(0); },5)
					setTimeout(function() { $('body').scrollTop(0); },10)
					setTimeout(function() { $('body').scrollTop(0); },15)
				});
		
			}
	
		}
		//var widthBody = 1000;
		//var heightBody = $('body').height();
		
		
		switchPub();
		floatSerie();
		animateEngrenage();
		

		
		$('#logoAnne').hover(function() {
			$('.backgroundLogo').css("backgroundPosition","0 -208px");
		},function() {
			$('.backgroundLogo').css("backgroundPosition","0 0");
		})
		
		$('#engrenage').hover(function() {
			$('#engrenageBg').css("display","block");
		},function() {
			$('#engrenageBg').css("display","none");
		})

		$('.zonePubContainer').hover(function() {
			$('#hoverPub').css("display","block");
			$('#hoverPub1').css("display","block");
			$('#hoverPub2').css("display","block");
			$('#hoverPub3').css("display","block");
		},function() {
			$('#hoverPub').css("display","none");
			$('#hoverPub1').css("display","none");
			$('#hoverPub2').css("display","none");
			$('#hoverPub3').css("display","none");
		})
		
		$('.masterHoverNewsletter').hover(function() {
			$('#hoverNewsletter').css("display","block");
		},function() {
			$('#hoverNewsletter').css("display","none");
		})
		
		$('.masterHoverForum').hover(function() {
			$('#hoverForum').css("display","block");
		},function() {
			$('#hoverForum').css("display","none");
		})
		
		
		$(".contenuTitre").dropShadow({left: 2, top:1, opacity: 1, blur:1,color: "#000"});
		
		$("body").oneTime("2500ms","dropshadow", function()  {
			
			//if(( && BrowserDetect.OS != "Mac")) {
				
				var browser = BrowserDetect.OS+BrowserDetect.browser;
				
			//if (BrowserDetect.OS != "Mac" && (BrowserDetect.browser != "Firefox")) {
				if (browser != "MacFirefox") {
					$(".sf-menu li a span").dropShadow({left: 1, top:1 , opacity: 1, blur:1,color: "#000"});
				}
			//}
			//}

			
		});
		
		/* 4:3 */
		if ((widthBody <= 1359) || (widthBody >= 9999) || (heightBody <= 700)) {

				mode = "4:3";


				
				//CSS FIX 4:3
				$('#conteneurContenu').width(905).css("border","0px solid red");
				
				$('#conteneurContenu #logoAnne').css("position","relative").css("float","left").height(208);
				$('#conteneurContenu #serieMenu').css("z-index","70").css("position","relative").css("left","0").css("top","0").css("float","left").css("marginLeft","70px").css("marginTop","20px");
				$('#conteneurContenu #contenu').css("position","relative").css("left","80px").css("top","0").css("magin","0 auto").css("float","left");
				$('#conteneurContenu .contenu').height("100%").css("minHeight","400px");
				
	
	
				//delete 
				//$('#conteneurBackground').css("display","none")
	
			
				$('#conteneurContenu #pub').css("position","relative").css("left","0").css("top","95px").css("magin","0 auto").css("float","left").css("marginLeft","60px");
				$('#conteneurContenu .zoneLangue').css("left","740px").css("top","0");
				
			
				$('.customScrollBox').css("overflow","auto");
				$('#mcs_container').css("overflow","auto");
				
				
				$('body').css("overflow","auto");
				
				serie2 = serie.split("_");

				
				setTimeout("validFlash(serie2[1])",2000);
				
				
				var heightBodyCalculIE7 = $('body').height();
				
				$('body').css("height",heightBodyCalculIE7+"px");
				
				if (serie == "serie_5") {	
					var heightCalcul = (heightBody-445);
				}
				else {
					var heightCalcul = (heightBody-320);
				}
				
				var heightTitre = parseInt($('.contenuTitreBg').height());
				
				var titreHeight = ($('.contenuTitreBg').height()-134);
				
				if (titreHeight > 20) {
					$('#mcs_container').css("top","20px");
				}
				else {
					//$('#mcs_container').height(heightCalcul);
				}
				

				var heigthtbl = $('.tblTitre').height();
				if (serie == "serie_5") {
					$('.contenuTitreContaineur').height(heigthtbl+22);
					$('.contenuTitreBg').height(heigthtbl+22);
				}
				
				$("body").everyTime("50ms","intervalResizeBackgroundFlash", function()  {
					var widthBody = $('body').width();
					var heightBody = $('body').height();
					if ((widthCheck != widthBody) || (heightCheck != heightBody)) {
						resizeBackground();
						heightCheck = heightBody;
						widthCheck = widthBody;
					}
				});
			
				resizeTitre43(serie,$('.contenuTitreBg').height());
		}
		
		/* 16:9 */
		else {
								
			mode = "16:9";
			$("body").everyTime("50ms","intervalResizeBackgroundFlash", function() {
				
				var widthBody = $('body').width();
				var heightBody = $('body').height();
				
				if (widthCheck != widthBody || heightCheck != heightBody) {
						resizeBackground();
					
						heightCheck = heightBody;
						widthCheck = widthBody;
						//==================================================================================
						//== resize Containeur =============================================================
						//==================================================================================
						var xWidthComplet = 9999;
						var xWidthZoneContenuMax = 1800;
						var xWidthZoneContenuMin = 1360;
						var y = 0; 
						var d = xWidthComplet - xWidthZoneContenuMin;
						var e = xWidthZoneContenuMax - xWidthZoneContenuMin;
						
						y = ((widthBody - xWidthZoneContenuMin) / d) * e + xWidthZoneContenuMin;
						
						if (widthBody > xWidthComplet) {
							$('#conteneurContenu').width(xWidthZoneContenuMax);
						}
						else {
							$('#conteneurContenu').width(y);
						}
						
						
						$('#conteneurContenu').height(heightBody);
						
						if (serie == "serie_5") {
						
							var heightCalcul = (heightBody-365);
						}
						else if (serie == "serie_12") {
							var topSerie = "45px";
							var heightCalcul = (heightBody-365);
						}
						else {
							var heightCalcul = (heightBody-320);
						}
						
						$('#conteneurContenu #contenu').css("top",topSerie);
						$('.containeurContenu .contenu').height(heightCalcul);
						
						
						resizeTitre(serie,heightCalcul);
						//==================================================================================
						//== resize zone marque + menu =====================================================
						//==================================================================================
						var z = 0;
						var zWidthMax = 310;
						
						z = (widthBody - xWidthZoneContenuMin) / d * zWidthMax;
						
						if (z > 0) {
							if (z > zWidthMax) {
								$('#conteneurContenu #serieMenu').css("left",zWidthMax+"px");
							}
							else {
								$('#conteneurContenu #serieMenu').css("left",z+"px");
							}
						}
						
						//==================================================================================
						//== resize zone marque + menu =====================================================
						//==================================================================================				
						if (widthBody >= 1360 && widthBody <= 9999) {
							var paddingLeftPub = 15;
							var widthPub = $('#pub').width();
							var leftPub = ((y - widthPub));
							$('#conteneurContenu #pub').css("left",leftPub);
							$('#conteneurContenu .zoneLangue').css("left",leftPub);
							
							var widthContenu = $('#contenu').width();
							var leftContenu = ((y - widthContenu)-(widthPub+paddingLeftPub));
							$('#conteneurContenu #contenu').css("left",leftContenu);
						}
						
						//==================================================================================
						//== footer & height Contenu =======================================================
						//==================================================================================	
						if (heightBody > 700) {
	
							var heightFooter = $('#conteneurContenu #footer').height();
							var calculHeightFooter = heightBody - heightFooter;
							$('#conteneurContenu #footer').css("top",calculHeightFooter+"px");
							$('#conteneurContenu #footer').width(y);

						}
					}
						
			});				
		}

	});

	//==================================================================================
	//== Animate footer serie ==========================================================
	//==================================================================================	
	function animateEngrenage() {
		var positionBgEngrenage = 0;
		var sensEngrenage = "gauche";
		var animationSerie = false;
		$('#engrenage').click(function() {
			var heightSerie = $('.containeurSerieFooter').height();
			if (animationSerie == false) {
				animationSerie = true;
				
				if (sensEngrenage == "gauche") {
	
					$('.containeurSerieFooter').animate({ top: '-='+heightSerie },1000);
					sensEngrenage = "droite";
					
					$("body").everyTime("50ms","everyTimeEngrenage", function() {	
						if (positionBgEngrenage <= -128) {
							positionBgEngrenage = 0;
						}
						else {
							positionBgEngrenage = positionBgEngrenage-64;
						}
						$('#engrenage').css("backgroundPosition","0 "+positionBgEngrenage+"px");
					});
				}
				else if (sensEngrenage == "droite") {
					positionBgEngrenage = -128;
	
					$('.containeurSerieFooter').animate({ top: '+='+heightSerie },1000);
					sensEngrenage = "gauche";
	
					$("body").everyTime("50ms","everyTimeEngrenage", function() {	
						if (positionBgEngrenage >= 0) {
							positionBgEngrenage = -128;
						}
						else {
							positionBgEngrenage = positionBgEngrenage+64;
						}
						$('#engrenage').css("backgroundPosition","0 "+positionBgEngrenage+"px");
					});
				}
			}
	
			$("body").oneTime("1s","oneTimeEngrenage", function() {	
				$("body").stopTime("everyTimeEngrenage");
				animationSerie = false;
			});
	
		});
	}




	function resizeTitre(serie,heightCalcul) {
		//==================================================================================
		//== resize titre  =================================================================
		//==================================================================================
		
		var heightTitre = parseInt($('.contenuTitreBg').height());
		var titreHeight = ($('.contenuTitreBg').height()-170);
		$('.contenuTitreBg h1').css("min-height",50);
		
		$("body").oneTime("600ms","intervalResizeBackgroundFlash", function()  {							
			var titreHeight2 = ($('.contenuTitreBg').height());
			log(titreHeight2);
			//$('#titreBrut').css("lineHeight","30px");
		
			//console.log(titreHeight2);
		
			if (titreHeight2 <= 166) {
				if(serie=="serie_5") {
				//	w("1 ligne");
					$('#mcs_container').height(heightCalcul-55);
					$('#mcs_container').css("top","55px");
					$('.contenuTitreBg h1').css("paddingTop",20);
				}
				else if(serie=="serie_12") {
					$('#mcs_container').css("top","10px");
					$('#mcs_container').height(heightCalcul-10);
				}
				else if(serie=="serie_13") {
					$('#mcs_container').css("top","10px");
					$('#mcs_container').height(heightCalcul-10);
				}
				else {
					$('#mcs_container').css("top","10px");
					$('#mcs_container').height(heightCalcul-10);
				}
					
			}
			else if (titreHeight2 < 204) {
				//w("2 ligne");
				if(serie=="serie_5") {
					$('#mcs_container').height(heightCalcul-70);
					$('#mcs_container').css("top","70px");
				}
				else if(serie=="serie_12") {
					$('#mcs_container').css("top","20px");
					$('#mcs_container').height(heightCalcul-20);
				}
				else if(serie=="serie_13") {
					$('#mcs_container').css("top","20px");
					$('#mcs_container').height(heightCalcul-20);
				}
				else {
					$('#mcs_container').height(heightCalcul-10);
					$('#mcs_container').css("top","10px");
				}
			}
			else if (titreHeight2 < 245) {
				//w("3	 ligne");
				if(serie=="serie_5") {
					$('#mcs_container').height(heightCalcul-110);
					$('#mcs_container').css("top","110px");
				}
				else if(serie=="serie_12") {
					$('#mcs_container').css("top","70px");
					$('#mcs_container').height(heightCalcul-70);
				}
				else if(serie=="serie_13") {
					$('#mcs_container').css("top","70px");
					$('#mcs_container').height(heightCalcul-70);
				}
				else {
					$('#mcs_container').height(heightCalcul-60);
					$('#mcs_container').css("top","60px")
				}

			}
			else if (titreHeight2 < 286) {
				//w("4	 ligne");
				if(serie=="serie_5") {
					$('#mcs_container').height(heightCalcul-120);
					$('#mcs_container').css("top","120px");
				}
				else if(serie=="serie_12") {
					$('#mcs_container').css("top","110px");
					$('#mcs_container').height(heightCalcul-110);
				}
				else if(serie=="serie_13") {
					$('#mcs_container').css("top","110px");
					$('#mcs_container').height(heightCalcul-110);
				}
				else {
					$('#mcs_container').height(heightCalcul-100);
				$('#mcs_container').css("top","100px");
				}
				
			}
			else if (titreHeight2 < 327) {
				//w("5	 ligne");
				if(serie=="serie_5") {
					$('#mcs_container').height(heightCalcul-70);
					$('#mcs_container').css("top","70px");
				}
				else if(serie=="serie_12") {
					$('#mcs_container').css("top","160px");
					$('#mcs_container').height(heightCalcul-160);
				}
				else if(serie=="serie_13") {
					$('#mcs_container').css("top","160px");
					$('#mcs_container').height(heightCalcul-160);
				}
				else {
					$('#mcs_container').height(heightCalcul-150);
					$('#mcs_container').css("top","150px");
				}
				
			}
			else {
				$('#mcs_container').height(heightCalcul);
			}
			
			
			if(serie=="serie_9") {
				if (titreHeight2 <= 154) {
				}
				else if (titreHeight2 <= 161) {
					//log("fdsfds");
					$('#mcs_container').css("top","20px");
					$('#mcs_container').height(heightCalcul-20);
				}
			}
			
		
		});
		
		
		
	}

	function resizeTitre43(serie,heightCalcul) {
		//==================================================================================
		//== resize titre  =================================================================
		//==================================================================================
		//console.log("allo")
		//var heightTitre = parseInt($('.contenuTitreBg').height());
	//	var titreHeight = ($('.contenuTitreBg').height());
		
		var heightTitre = parseInt($('.contenuTitreBg').height());
		var titreHeight = ($('.contenuTitreBg').height()-170);
		$('.contenuTitreBg h1').css("min-height",50);
		
		
		$("body").oneTime("600ms","intervalResizeBackgroundFlash", function()  {							
			
			

			//$('#conteneurBackground').hide();
			var titreHeight2 = ($('.contenuTitreBg').height());
			
					
			$('.containeurContenu .contenu').height(($('.container').height()));
			
			var heightBody = $('body').height();
			//$('#conteneurContenu').height(heightBody);


			//pour chrome
			//$('body').height($('#conteneurContenu').height()+30);
			
			
			//console.log(BrowserDetect.Browser);
			
			if (BrowserDetect.Browser == "Chrome") {
				
			}
			
			//$('html').height($('#conteneurContenu').height());
			
			if (titreHeight2 < 163) {
				if(serie=="serie_5") {
					//console.log("1 ligne");
					
					
					//$('#mcs_container').height(($('.container').height()));
					$('#mcs_container').css("top","10px");
				}
				else {
					//console.log($('.container').height());
					$('#mcs_container').css("top","0px");
					
				}
					
			}
			
			//log(titreHeight2);
			if(serie=="serie_9") {
				if (titreHeight2 <= 154) {
				}
				else if (titreHeight2 <= 161) {
					//log("fdsfds");
					$('#mcs_container').css("top","20px");
					$('#mcs_container').height(heightCalcul-20);
				}
			}
		
		});
		
		
		
	}

	//==================================================================================
	//= Float inverse selecteur série ==================================================
	//==================================================================================
	function floatSerie() {	
		var nbChild =  $('.listingSerieFooter').children().length;
		var strNonDynamique = "";
		var limitChild = 3;
		var y = Math.ceil(nbChild/limitChild);
		var countChild = 1;
			
		for (x=y; x >= 1; x--) {
			window['strhtml'+x] = "";
			$('.listingSerieFooter div').each(function() {
				id = $(this).attr("id").substr(2);
				if (id <= (x*limitChild) && id >= ((x*limitChild)-(limitChild-1))) {
					window['strhtml'+x]  += '<div class="zoneSerieBloc">'+$('#id'+id).html()+"</div>";
				}
			});
			window['strhtml'+x] += "<div style='clear:both;'></div>";
			strNonDynamique += window['strhtml'+x];
		}


		$(".containeurSerieFooter").html("").html(strNonDynamique);


		$("body").oneTime("450ms","oneTimeFixIE7", function() {
			
			var heightContaineurSerieFooter = $(".containeurSerieFooter").height();
			var widthContaineurSerieFooter = $(".containeurSerieFooter").width();
			$(".containeurSerieFooter").css("top",heightContaineurSerieFooter+"px");
			$('.MasterContaineurSerieFooter').height(heightContaineurSerieFooter);
			$('.MasterContaineurSerieFooter').width(widthContaineurSerieFooter);
			calculTop = -(heightContaineurSerieFooter-64);
			$('.MasterContaineurSerieFooter').css("top",calculTop+"px");
			
		});
		

	}

	//==================================================================================
	//== Background flash ==============================================================
	//==================================================================================
	function resizeBackground() {
		

			var widthBody = $('html').innerWidth();
			var heightBody = $('html').innerHeight();

			var widthBg = 1920;
			var heightBg = 1080;
			
			var ratioBg = (widthBg / widthBody);
			var ratioBgHeight = (heightBg / heightBody);
			
			var widthBackground = (widthBg / ratioBg);
			var heightBackground = (heightBg / ratioBg);
			
			var ratioSreen = (widthBody/heightBody);
			
			if (ratioSreen < 1.77) {
				var widthBackground = (widthBg/ratioBgHeight);
				var heightBackground = (heightBg/ratioBgHeight);
				var centerBackground = ((widthBackground-widthBody)/2);
				var middleBackground = 0;
			}
			else {
				var middleBackground = ((heightBackground-heightBody)/2);
				var centerBackground = 0;
			}
			
			$('#conteneurBackground').width(widthBody);
			$('#conteneurBackground').height(heightBody);
			$('#conteneurBackground').css("top",-(middleBackground)+"px");
			$('#conteneurBackground').css("left",-(centerBackground)+"px");
			
			$('#objectBackgroundFlash').attr("width",widthBackground);
			$('#objectBackgroundFlash').attr("height",heightBackground);
			
			
			var widthFooter;
			$("body").oneTime("200ms","oneTimeFixIE7", function() {

				widthFooter = 704;
				
				var widthConteneurContenu = $('#conteneurContenu').width();
	
				$('.conteneurFooterInfo').width(widthFooter);
				$('.conteneurFooterInfo').css("marginLeft",(widthConteneurContenu-widthFooter)+"px");
			});
	}
	
	//==================================================================================
	//= zone Pub Animate ===============================================================
	//==================================================================================
	function switchPub() {
		var nbChild =  $('#imagesPub #imgPubContaineur').children().length;
		if (nbChild > 0) {
			var firstNode = $('#imagesPub #imgPubContaineur img').get(0).nodeName;
			var srcImg = $('#imagesPub #imgPubContaineur img:eq(0)').attr('src');
			$('#imagesPub #imgPubContaineur').append('<img src="'+srcImg+'" />');
		
			var countImg = $('#imagesPub #imgPubContaineur').children().length;
			var widthImg = $('#imagesPub #imgPubContaineur img').width();
			$('#imgPubContaineur').width(countImg*widthImg);
			var marginLeftPub = "-134";
			
			$("body").everyTime("5s","intervalSwitchPub", function() {
		
				$('#imgPubContaineur').animate({ marginLeft: marginLeftPub+"px"},1000, function() {
					if (-((countImg-1)*widthImg) == marginLeftPub) {
						marginLeftPub = "-134";
						$('#imgPubContaineur').css("marginLeft","0px");
						
					}
					else {
						marginLeftPub = marginLeftPub-widthImg;
					}
				});	
			});
		}
	}
	
	
	//==================================================================================
	//= reload version 16:9 / 4:3 ======================================================
	//==================================================================================
	$(window).resize(function() {
		var widthBody = $('body').width();
		var heightBody = $('body').height();	
		
		var url = window.location.href.split("#");
		
		if (widthBody < 1360 && mode == "16:9") {
			window.location.href=url[0];
		}
		else if (widthBody >= 1360 && mode == "4:3") {
			window.location.href=url[0];
		}
		
	})
	
	
	//==================================================================================
	//= log console firebug ============================================================
	//==================================================================================	
	function w(txt) {
		//console.log(txt);
	}
	
	function twitter() {	
	  url = "http://twitter.com/home?status=";
    var haut=(screen.height-600)/2;
    var Gauche=(screen.width-700)/2;		
    window.open (url + document.URL, 'twitter', config='top='+haut+',left='+Gauche+',width=800, height=500, toolbar=no, menubar=no, scrollbars=yes, resizable=0, location=no, directories=no, status=no') 
  }

  function facebook() {
		urlSite = document.URL;
	  url = "http://www.facebook.com/sharer.php?u="+ urlSite + "&t=" +urlSite;
    var haut=(screen.height-600)/2;
    var Gauche=(screen.width-700)/2;
    window.open (url, 'facebook', config='top='+haut+',left='+Gauche+',width=800, height=500, toolbar=no, menubar=no, scrollbars=yes, resizable=0, location=no, directories=no, status=no') 
  }

	function validFlash(id) {
		//console.log($('#objectBackgroundFlash').length +"_"+id);
		$('body').css("backgroundImage","url('../images2011/background/bkg/"+id+".jpg')");
		$('body').css("backgroundPosition","center top");
		$('body').css("backgroundAttachment","fixed");
		$('body').css("backgroundRepeat","no-repeat");
		
		if (id == 5) {
			$('body').css("backgroundColor","#06151b");
		}
		else if(id == 9) {
			$('body').css("backgroundColor","#040602");
		}
		else if(id == 10) {
			$('body').css("backgroundColor","#010218");
		}
		else if(id == 11) {
			$('body').css("backgroundColor","#0f0f0c");
		}
		else if(id == 12) {
			$('body').css("backgroundColor","#020302");
		}
		else if(id == 13) {
			$('body').css("backgroundColor","#01010d");
		}
	}

	
	
		window.log = function(){
		log.history = log.history || [];   // store logs to an array for reference
		log.history.push(arguments);
		arguments.callee = arguments.callee.caller;  
		if(this.console) console.log( Array.prototype.slice.call(arguments) );
	};
	// make it safe to use console.log always
	(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});
	
	
	
