
$(document).ready(function() {		
						   
	/* HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB */	
	
	var isIE6 = ((navigator.userAgent.indexOf("MSIE 6.") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
	var isIE7 = ((navigator.userAgent.indexOf("MSIE 7.") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
	var winW = screen.width, winH = screen.height;
	
	function moveHub() {		
		if(typeof(hubToolsLeftPos)=='undefined') 
			hubToolsLeftPos = 0;
		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		  winW = window.innerWidth;
		  winH = window.innerHeight;
		 }
		 if (navigator.appName.indexOf("Microsoft")!=-1) {
		  winW = document.body.offsetWidth;
		  winH = document.body.offsetHeight;
		 }
		}
		
		if(isIE7 || isIE6){
			positionHub = Math.floor((winW-1000)/2);
		}else{
			positionHub = Math.floor((winW-1014)/2);
		}
		
		if(positionHub<1){positionHub=1;}
		
		if(winW > 996){
			$("#av").css("display","inline");
		}else{
			$("#av").css("display","none");
		}
		
		w2 = winW-positionHub;
		if(isIE6){w2 = w2 - 2;}
		positionHubTools = hubToolsLeftPos+positionHub+480;		
		
		if(isIE6){w2=w2-3;}
		
		positionHubStr = positionHub.toString()+"px";	
		positionHubToolsStr = positionHubTools.toString()+"px";
		
		$("#av").css("width",positionHubStr);	

		positionBackgroundLevel2 = -750+positionHub;
		positionBackgroundLevel2Str = positionBackgroundLevel2.toString()+"px 0px";
		
		$("#hubNav").css("background-position",positionBackgroundLevel2Str);		
		$("#in").css("height",42);
		$("#hubTools").css("left",positionHubToolsStr);
		$("#overlayPromoFR").css("left",positionHubStr);
		if(isIE6){
			$("#in").css("left","-5");	
		}

	 }
	 
	 
	moveHub();
	$(window).resize(moveHub);
	
	if(isIE7){$("#inputBlock").css("margin-left","8px");}
	
	$("#faqList").hide();
	
	var FaqActivated = 0;
	
	$("#FaqSelectorDisplay").click(function() {
		if(FaqActivated == 0){
			$("#faqList").slideToggle("slow");
			FaqActivated = 1
		}
		else if(FaqActivated == 1){
			$("#faqList").slideToggle("slow");
			FaqActivated = 0
		}
		
		if(NoticeActivated == 1){
			$("#NoticeList").slideToggle("slow");
			NoticeActivated = 0;
		}
		
		this.blur();
		return(false);
	});
	
	$("#NoticeList").hide();
	
	var NoticeActivated = 0;
	
	$("#NoticeSelectorDisplay").click(function() {
		if(NoticeActivated == 0){
			$("#NoticeList").slideToggle("slow");
			NoticeActivated = 1;
		}
		else if(NoticeActivated == 1){
			$("#NoticeList").slideToggle("slow");
			NoticeActivated = 0;
		}
		
		if(FaqActivated == 1){
			$("#faqList").slideToggle("slow");
			FaqActivated = 0;
		}
		
		this.blur();
		return(false);
	});
	
	/* HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB HUB */						   
	
	/*Hide link Lists - Add display effects*/
	$("#linkList1").hide();
	$("#linkList2").hide();
	$("#webLinkList").hide();
	
	/*$("#linkSelector1").click(function() {
		   $("#linkList1").SlideToggleUp("fast");
		   this.blur();
		   return(false);
	});*/
	var selector1Activated = 0;
	var selector2Activated = 0;
	var selector3Activated = 0;
	
	$("#linkSelector1").click(function() {
		if(selector1Activated == 0){
			$("#linkList1").slideToggle("slow");
				selector1Activated = 1
			}else if(selector1Activated == 1){
			$("#linkList1").slideToggle("slow");
				selector1Activated = 0
			}
		
		if(selector2Activated == 1){
			selector2Activated = 0;
			$("#linkList2").slideToggle("slow");
			}
		if(selector3Activated == 1){
			selector3Activated = 0;
			$("#webLinkList").slideToggle("slow");
		}
		this.blur();
		
		//$("#linkList1").toggle("slow");
		return(false);
	});
	
	/*$("#linkSelector2").click(function() {
		   $("#linkList2").SlideToggleUp("fast");
		   this.blur();
		   return(false);
	});*/
	
	$("#linkSelector2").click(function() {
		if(selector2Activated == 0){
			$("#linkList2").slideToggle("slow");
				selector2Activated = 1
			}else if(selector2Activated == 1){
			$("#linkList2").slideToggle("slow");
				selector2Activated = 0
			}
					
		if(selector1Activated == 1){
			selector1Activated = 0;
			$("#linkList1").slideToggle("slow");
			}
		if(selector3Activated == 1){
			selector3Activated = 0;
			$("#webLinkList").slideToggle("slow");
		}
		this.blur();
		return(false);
	});
	
	/*$("#webLinkSelector a:first").click(function() {
		  // $("#webLinkList").SlideToggleUp("fast");
		   $("#webLinkList").toggle("slow");
		   this.blur();
		   return(false);
	});*/
	
	$("#webLinkSelector").click(function() {
		  if(selector3Activated == 0){
			$("#webLinkList").slideToggle("slow");
				selector3Activated = 1
			}else if(selector3Activated == 1){
			$("#webLinkList").slideToggle("slow");
				selector3Activated = 0
			}
		   if(selector1Activated == 1){
			selector1Activated = 0;
			$("#linkList1").slideToggle("slow");
			}
		   if(selector2Activated == 1){
			selector2Activated = 0;
			$("#linkList2").slideToggle("slow");
			}
		
		   this.blur();
		   return(false);
	});
	
	$("#webLinkSelector ul a").click(function() {
		  document.location.href= this.href;
	});
	
	$("#webLinkSelectorUp a:first").click(function() {
		  // $("#webLinkList").SlideToggleUp("fast");
		   $("#webLinkList").slideToggle("slow");
		   this.blur();
		   return(false);
	});

	$("body").click(function() {
		if(selector1Activated == 1){
			$("#linkList1").slideToggle("slow");
			selector1Activated = 0;
		}
		
		if(selector2Activated == 1){
			$("#linkList2").slideToggle("slow");
			selector2Activated = 0;
		}
		
		if(selector3Activated == 1){
			$("#webLinkList").slideToggle("slow");
			selector3Activated = 0;
		}
		
		if(FaqActivated == 1){
			$("#faqList").slideToggle("slow");
			FaqActivated = 0;
		}
		
		if(NoticeActivated == 1){
			$("#NoticeList").slideToggle("slow");
			NoticeActivated = 0;
		}
	});
	
	if ( $("#hubTools").length > 0 ) {
		var topPosition = 88;
		/*if($("#menuTable").length > 0) 
			topPosition += 75;*/

		topPosition = topPosition + "px";
		$("#xpressContent").css("height", topPosition);
		$("#infoLayer2").css("top", topPosition);
		$("#infoLayer3").css("top", topPosition);
		$("#infoLayer4").css("top", topPosition);
		$("#homemotionLayer").css("top", topPosition);
		$("#infoLayerC1").css("top", topPosition);
		$("#infoLayerC2").css("top", topPosition);
		$("#infoLayerC3").css("top", topPosition);
		$("#infoLayerC4").css("top", topPosition);
		$("#infoLayerC5").css("top", topPosition);
		$("#infoLayerC6").css("top", topPosition);
	}
	else {
		if ((screen.height>=800))
		{
			$("#xpressContent").css("height", "18%");
			$("#infoLayer2").css("top", "18%");
			$("#infoLayer3").css("top", "18%");
			$("#infoLayer4").css("top", "18%");
			$("#homemotionLayer").css("top", "18%");
			$("#infoLayerC1").css("top", "18%");
			$("#infoLayerC2").css("top", "18%");
			$("#infoLayerC3").css("top", "18%");
			$("#infoLayerC4").css("top", "18%");
			$("#infoLayerC5").css("top", "18%");
			$("#infoLayerC6").css("top", "18%");
		}
		else
		{
			$("#xpressContent").css("height", "10%");
			$("#infoLayer2").css("top", "10%");
			$("#infoLayer3").css("top", "10%");
			$("#infoLayer4").css("top", "10%");
			$("#homemotionLayer").css("top", "10%");
			$("#infoLayerC1").css("top", "18%");
			$("#infoLayerC2").css("top", "18%");
			$("#infoLayerC3").css("top", "18%");
			$("#infoLayerC4").css("top", "18%");
			$("#infoLayerC5").css("top", "18%");
			$("#infoLayerC6").css("top", "18%");
		}
	}
	$("a.hideVideo").click(function() {
		$("#videoLayer").load("videoCloser.html");
		 return(false);
	});
	
	/* Documentation download */
	$("#leafletBlock .leafletNav1 ul").click(function() {
		   $("#leafletBlock .leafletNav2 ul").removeClass();
		   $("#leafletBlock .leafletNav1 ul").addClass("currentItem");
		   $("#leafletResults1").show();
		   $("#leafletResults2").hide();
		   return(false);
	});
	$("#leafletBlock .leafletNav2 ul").click(function() {
		   $("#leafletBlock .leafletNav1 ul").removeClass();
		    $("#leafletBlock .leafletNav2 ul").addClass("currentItem");
			$("#leafletResults2").show();
			$("#leafletResults1").hide();
		   return(false);
	});
	
	$("#leafletResults2").hide();
	
	/* Configurator Solution */
	/* */
	$("#productTab1").click(function() {
		   $("#productTab1").removeClass();
		   $("#productTab2").removeClass();
		   $("#productTab3").removeClass();
		   $("#productTab1").addClass("currentItem");
		   $("#productTab3").addClass("lastItem");		   
		   $("#productLayer1").show();
		   $("#productLayer2").hide();
		   $("#productLayer3").hide();		   
			$("#productLayer4").hide();		   
		   return(false);
	});
	$("#productTab2").click(function() {
		   $("#productTab1").removeClass();
		   $("#productTab2").removeClass();
		   $("#productTab3").removeClass();		   
		   $("#productTab2").addClass("currentItem");
		   $("#productTab3").addClass("lastItem");		   
			$("#productLayer2").show();
			$("#productLayer1").hide();
			$("#productLayer3").hide();			
			$("#productLayer4").hide();
		   return(false);
	});
	$("#productTab3").click(function() {
		   $("#productTab1").removeClass();
		   $("#productTab2").removeClass();
		   $("#productTab3").removeClass();		   
		   $("#productTab3").addClass("currentItem");
		   $("#productTab3").addClass("lastItem");		   
			$("#productLayer3").show();		
			$("#productLayer1").hide();
			$("#productLayer2").hide();
			$("#productLayer4").hide();
		   return(false);
	});
	$("#productTab4").click(function() {
		   $("#productTab1").removeClass();
		   $("#productTab2").removeClass();
		   $("#productTab3").removeClass();		   
		   $("#productTab4").removeClass();		   		   
		   $("#productTab4").addClass("currentItem");
		   $("#productTab4").addClass("lastItem");		   
			$("#productLayer4").show();		
			$("#productLayer1").hide();
			$("#productLayer2").hide();				
			$("#productLayer3").hide();							
		   return(false);
	});		

	$("#productLayer2").hide();	
	$("#productLayer3").hide();		
	$("#productLayer4").hide();	
	
	$(".stdContentLayerBlock").hide();	
	$(".stdHugeContentLayerBlock").hide();	
	
	/*Positioning top navigation*/
	$("#xpressAccess").css("position","absolute");
	
	
	
	
	/* manage SearchField input*/
	var searchFieldLanguage= $("#searchField").val();
	$("#searchField").focus(
		function(){
			$(this).val("");
			}			
		);
	$("#searchField").blur(
		function(){
			var reg = new RegExp("^[\ ]*$","gi");
			if(reg.test($(this).val())){
				$(this).val(searchFieldLanguage);
				}
			}
		);
		
	
	
	
	
	/*manage tooltips*/
	$('.toolTipInfo').Tooltip({
		delay:0,
		showBody: " - ",
		showURL:false
	});
	
	/*manage tooltips*/
	$('.toolTipDealerInfo').Tooltip({
		delay:0,
		showBody: " - ",
		showURL: false,
		extraClass: "test"
	});

	if (document.all) {
		$(".configItem").hoverClass ("sfHover");
		
	}
	
	
	
	/*manage TABS*/
	
	
	$("#productMainDetails1").removeClass();
	$("#productMainDetails2").removeClass();
	$("#productMainDetails1").addClass("openedContent");
	$("#productMainDetails2").addClass("closedContent");
	
	$("#productMainDetails1 h3 a").click(function() {
		$("#productMainDetails1").removeClass();
		$("#productMainDetails2").removeClass();
		$("#productMainDetails1").addClass("openedContent");
		$("#productMainDetails2").addClass("closedContent");
		this.blur();
	   return(false);
	});
	$("#productMainDetails2 h3 a").click(function() {
		$("#productMainDetails1").removeClass();
		$("#productMainDetails2").removeClass();
		$("#productMainDetails1").addClass("closedContent");
		$("#productMainDetails2").addClass("openedContent");
		this.blur();
	   return(false);
	});
	
	
	/*Manage product list details - Change LI classes*/
	$("#producDetailsContent2").css("overflow","hidden");
	$("#producDetailsList li a:first").addClass("currentItem");
	$("#producDetailsList li a").click(function(){

		$("#producDetailsList li a").removeClass();
		$(this).addClass("currentItem");
		if($.browser.safari){
			document.getElementById("producDetailsContent2").scrollTop = document.getElementById(this.href.split("#")[1]).offsetTop;
			return(false);
		}
	});
	
	/*Manage FAQ Answers - Change LI classes*/
	$("#faqDetailAnswers").css("overflow","hidden");
	/*$("#faqBlock .contentPrime dd a:first").addClass("currentItem");*/
	$("#faqBlock .contentPrime dd a").click(function(){

		$("#faqBlock .contentPrime dd a").removeClass();
		$(this).addClass("currentItem");
		if($.browser.safari){
			document.getElementById("faqDetailAnswers").scrollTop = document.getElementById(this.href.split("#")[1]).offsetTop;
			return(false);
		}
	});
	
	/*Manage layerInfos 1*/
	$("a.layerInfos").click(function() {
		showSupaLayers(this.hash);
		return(false);
	});
	$("a.stdLayerInfos").click(function() {
		showSupaLayers(this.hash);
		return(false);
	});
	
	$("a.closeLayer").click(function() {
		hideSupaLayers(this.hash);
		return(false);
	});
	
	$(".tellHim").click(function() {
		showSupaLayers('#tellaFriendLayer');
	});
	
	
	/*Manage infoLayer2 list Change DT class*/
	/*Initialise the list at StartUp*/
	$(".stdInfoList dt").addClass("closedList");
	$(".stdInfoList dt:first").removeClass();
	$(".stdInfoList dt:first").addClass("openedList");
	
	$(".stdInfoList dd ul").hide();
	$(".stdInfoList dd:first ul").show();
	
	
	$(".stdInfoList dt a").click(function(){

		$(".stdInfoList dt").removeClass();
		$(".stdInfoList dt").addClass("closedList");
		
		$(this).parent().removeClass();
		$(this).parent().addClass("openedList");
		
		$(".stdInfoList dd ul").hide();
		
		$(this).parent().next().children().show();
		$(this).parent().next().next().show();
	
	});
	
	/*Manage login Display toggle style*/
	$("#loginFormDisplay h3 a").addClass("closedContent");
	$("#loginFormSwithDisplay").css("display","none");
	$("#loginFormDisplay h3 a").toggle(function(){
		$(this).addClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
		},function(){
			$(this).removeClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
	});
	
	/*Manage address Display toggle style*/
	$("#addressFormDisplay h3 a").addClass("closedContent");
	$("#addressFormSwithDisplay").css("display","none");
	$("#addressFormDisplay h3 a").toggle(function(){
		$(this).addClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
		},function(){
			$(this).removeClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
	});
	
	/*Manage address Display toggle style*/
	$("#addressFormDisplay2 h3 a").addClass("closedContent");
	$("#addressFormSwithDisplay2").css("display","none");
	$("#addressFormDisplay2 h3 a").toggle(function(){
		$(this).addClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
		},function(){
			$(this).removeClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
	});	
	
	/*Manage address Display toggle style*/
	$("#addressFormDisplay3 h3 a").addClass("closedContent");
	$("#addressFormSwithDisplay3").css("display","none");
	$("#addressFormDisplay3 h3 a").toggle(function(){
		$(this).addClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
		},function(){
			$(this).removeClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
	});	
	
	
	/*Manage project Switching - Toogle Style*/
	$(".projectDisplay h3 a").addClass("closedContent");
	$(".projectSwitchDisplay").css("display","none");
	$(".projectDisplay h3 a").toggle(function(){
		$(this).addClass("openedContent");
		switchBlockDisplay(this.hash);
		return(false);
	},function(){
			$(this).removeClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
	});
	
	/*Manage Legal Mentions switching - Toogle Style*/
	
	$(".legalDisplay h3 a").attr("href","javascript:void(null);");
	$(".legalDisplay h3 a").addClass("closedContent");
	$(".legalSwitchDisplay").css("display","none");
	$(".legalDisplay h3 a").click(function(){
		$(this).parent().next().toggle("fast");
	});
	
	/*Manage SiteMap switching - Toogle Style*/
	$(".siteMapDisplay .sitemapParent h3 a.sitemaplink").addClass("closedContent");
	$(".siteMapDisplay .sitemapParent h3 span a.sitemaplink").removeClass("closedContent");
	//$(".siteMapSwitchDisplay .sitemapParent").css("display","none");
	$(".siteMapDisplay .sitemapParent h3 a.sitemaplink").toggle(function(){
		$(this).addClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
		},function(){
			$(this).removeClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
	});
	
	$(".siteMapDisplay .sitemapNoParent h3 a.sitemaplink").addClass("closedContent");
	$(".siteMapDisplay .sitemapNoParent h3 span a.sitemaplink").removeClass("closedContent");
	$(".siteMapSwitchDisplay").css("display","none");
	/*$(".siteMapDisplay h3 a").toggle(function(){
		$(this).addClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
		},function(){
			$(this).removeClass("openedContent");
			switchBlockDisplay(this.hash);
			return(false);
	});*/
	
	
	/*Toggle Map*/
	//$("a ").addClass("closedContent");
	
	$("a.flashMapLink").click(function(){
		$("li#item4").addClass("currentItem");
		//$("li#item5").removeClass("currentItem");
			$("#countryList").hide();
			switchMapDisplay(this.hash, "#introInterface");
			$("li#item5").removeClass("currentItem"); /* added 18.06.2007 */
			this.blur();
			$("a.flashMapLink").unbind();
			return(false);
		}
		);
	$("a.countryLink").click(function(){
		$("li#item5").addClass("currentItem");
			$(this.hash).SlideInRight(500, null, 'bouceout');
			this.blur();
			//$("a.countryLink").unbind();
			return(false);
		});
	$("a.closeCountryLayer").click(function(){
		$("li#item5").removeClass("currentItem");
			$(this.hash).hide();
			this.blur();
			//$("a.countryLink").unbind();
			return(false);
		});
	/*$("a.countryLink").toggle(function(){
		$("li#item5").addClass("currentItem");
			switchMapDisplay(this.hash);
			this.blur();
			return(false);
		},function(){
			$("li#item5").removeClass("currentItem");
			switchMapDisplay(this.hash);
			this.blur();
			return(false);
	});*/
	
	/*jCarousel*/
	$(".widget img").click(function() {
	    $(".widget .mid img").attr("src", $(this).attr("src"));
	})
    $(".jCarouselLite li").hoverClass ("sfHover");
	
	/*jCarousel*/
	 $(".jCarouselLite li a").click(function() {
		$(".jCarouselLite li").removeClass("tabs-selected");
		$(this).parent().addClass("tabs-selected");
		
		$(".fragmentItem").hide();
		
		showCarouselLayout($(this.hash));
		
	    return(false);
	})
	
	
	/* Barre d'avancement configurator */
	
	//update this Value - Number of steps for this univers. 
	// Then Duplicate "progressLimit" link in html, relatives to number of steps actually done by the user
	//var yourTotalSteps = 8; defined dynamically in configurator template
	if(typeof(window['yourTotalSteps']) != "undefined") {
		var progressBarSize = $('.progressBar').width();
		
		// Give the size of each duplicated link in html
		var itemSize = (progressBarSize/yourTotalSteps);	
		
		// Animate link
		$(".progressLimit").animate({
		  width: itemSize
		}, 500);
	}
	
	// CA40 Tab Navigation
	activeOngletsCa40();
	 
	 
	 
	//JQuery Layer Modal pour ouvrir les Flash des contenus dans ce layer
	
	//les flash de youtube et autre de ce genre n'ont pas le "wmode : transparent" dont nous avons besoin pour faire fonctionner le script, donc on reecrit le code du flash
	$(".openVideosInLayer embed").each(function(){
		if(!($(this).hasClass("no_mini"))){
			if($(this).parent()[0].tagName != "OBJECT"){
				var BaliseFlashSrc = $(this).attr("src");
				var BaliseFlashWidth = $(this).attr("width");
				var BaliseFlashHeight = $(this).attr("height");
				$(this).after("<embed src='"+BaliseFlashSrc+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='"+BaliseFlashWidth+"' height='"+BaliseFlashHeight+"' wmode='transparent'></embed>");
				$(this).remove();
			}
		}
	});
	
	$(".openVideosInLayer object").each(function(){
		if(!($(this).hasClass("no_mini"))){
			var objectTagFlashReplaced = 0;
			if($(this).find("embed").attr("src")){
				var BaliseFlashSrc = $(this).find("embed").attr("src");
				var BaliseFlashWidth = $(this).find("embed").attr("width");
				var BaliseFlashHeight = $(this).find("embed").attr("height");
				$(this).after("<embed src='"+BaliseFlashSrc+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='"+BaliseFlashWidth+"' height='"+BaliseFlashHeight+"' wmode='transparent'></embed>");
				$(this).remove();
				objectTagFlashReplaced = 1;
			}
			else if($(this).find("param")){
				//alert($(this).find("param").attr("name"));
				$(this).find("param").each(function(){
					if(($(this).attr("name")=="Src") || ($(this).attr("name")=="src")){
						var BaliseFlashSrc = $(this).attr("value");
						var BaliseFlashWidth = $(this).parent().attr("width");
						var BaliseFlashHeight = $(this).parent().attr("height");
						$(this).parent().after("<embed src='"+BaliseFlashSrc+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='"+BaliseFlashWidth+"' height='"+BaliseFlashHeight+"' wmode='transparent'></embed>");
						$(this).parent().remove();
						objectTagFlashReplaced = 1;
					}						
				});
			}
			
			if(objectTagFlashReplaced == 0){
				//le code du Flash n'est pas standard
			}
		}
	});
	
	//les flash ne sont pas cliquable sur tous les navigateurs, donc on met en place un div qui vient se mettre par dessus le flash (ce div ne sera cliquable que si il a un background et une opacit� 0)
	$(".openVideosInLayer embed").after("<span class='pardessus'></span>"); //action d'ouverture du flash dans un layer
	/*$(".pardessus").each(function(){
		var objectW = $(this).prev().attr("width");
		var objectH = $(this).prev().attr("height");
		$(this).css("height",objectH+"px");
		$(this).css("width",objectW+"px");
		$(this).css("margin-top","-"+objectH+"px");
	});*/
	
	//action d'ouverture du flash dans un layer
	$(".pardessus").click(function (e) {
		if(isIE6){
			// le layer s'ouvre en haut de la page avec IE6, donc on se scroll la page pour aller en haut
			showIt("globalLayout");
		}
		
		//ouverture du layer
		e.preventDefault();
		$("#basicModalContent").modal({onOpen: modalOpen,onClose: modalClose});
		if(isIE6){
			$("#modalOverlay").css("position","absolute");
			var pp = document.body.offsetHeight + 'px';
			$("#modalOverlay").css("height",pp);
			$("#modalContainer").css("position","absolute");
		}
		$("#basicModalContent").addClass("layer4flash");
		$(".layer4flash").prev().css("right","auto");
		$(".layer4flash").prev().css("left","30px");
		
		//copy du code du flash de la page, et on le met dans le layer
		var BaliseFlashSrc = $(this).prev().attr("src");
		var BaliseFlashWidth = $(this).prev().attr("width");
		var BaliseFlashHeight = $(this).prev().attr("height");
		$(".pourLeFlash").html("<embed src='"+BaliseFlashSrc+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='"+BaliseFlashWidth+"' height='"+BaliseFlashHeight+"' wmode='transparent'></embed>");
		
		//centrage horizontal dans le layer
		var marginFlash = (430 - BaliseFlashWidth)/2;
		marginFlash = marginFlash - 20;
		if(marginFlash > 0){
			$(".pourLeFlash").css("margin-left",marginFlash);
		}
	});
	
	$(".openVideosInLayer embed").each(function(){
		if($(this).hasClass("no_mini") && $(this).next().hasClass("pardessus")){
			$(this).next().remove();
			var wth = $(this).attr("width");
			var hht = $(this).attr("height");
			$(this).attr("style","width:"+wth+"px !important; height:"+hht+"px !important;");
		}
	});
	//END JQuery Layer Modal pour ouvrir les Flash des contenus dans ce layer
});


$.fn.hoverClass = function(c) {

	return this.each(function(){
		$(this).hover(
					  
			function() { $(this).addClass(c);},
			function() { $(this).removeClass(c);}
		);
	});
	
};

/*jcarousel showLayer*/
function showCarouselLayout(c){
	$(c).show();
	
}
function initCarouselLayout(){
	$(".fragmentItem").hide();
	//var currentProduct = $("li.tabs-selected a").attr("href").split("#")[1];
	//$("#"+currentProduct).show();
}

function switchBlockDisplay(a) {
	$(a).slideToggle("slow");
}
function switchMapDisplay(a, b) {
	$(a).SlideInRight(500, null, 'bouceout');
	$(b).SlideOutRight(500, null, 'bouceout');
}
function showFlashInfoLayer(a) {
	$("#supaLayer").height($("#primaryContent").height()+9);
	$("#supaLayer").show();
	$(a).show();
}

function showFlashInfoLayerNew(a) {
	var isIE7 = ((navigator.userAgent.indexOf("MSIE 7.") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
	var isIE6 = ((navigator.userAgent.indexOf("MSIE 6.") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
	
	$("#supaLayer").css("z-index","9990");
	$("#infoLayer2").css("z-index","9999");
	
	if(isIE7){$("#supaLayer").height($("#primaryContent").height()+115);}
	
	else if(isIE6){$("#supaLayer").height($("#primaryContent").height()+50);}
	
	else{$("#supaLayer").height($("#primaryContent").height()+9);}
	
	$("#supaLayer").show();
	$(a).show();
}

function showSupaLayers(a) {
	/*suplayer Function*/
	$("#supaLayer").height($("#primaryContent").height()+9);
	$("#supaLayer").show();
	$(a).show();
}

function showSupaLayers2(a) {
	/*suplayer Function*/
	$("#supaLayer").height($("#primaryContent").height()+80);
	$("#supaLayer").show();
	$(a).show();
}

function hideSupaLayers(b) {
	/*suplayer Function*/
	$("#supaLayer").hide();
	$(b).hide();
}
/* video player function */

/*function launchVideo(id) {
	$("#videoLayer").load("video"+id+".html");	
	showSupaLayers("#videoLayer");
}*/
// aba 2007-06-20
function launchVideo(filename) {	
	$("#videoLayer").load(filename);	
	showSupaLayers("#videoLayer");
}

function launchVideo2(filename) {	
	$("#videoLayer").load(filename);	
	showSupaLayers2("#videoLayer");
}

function loadFile(filename,target) {	
	$(target).load(filename);	
}

function thisMovie(movieName) {
     if (navigator.appName.indexOf("Microsoft") != -1) {
          return window[movieName]
     }
     else {
          return document[movieName]
     }
}
function closePlayer()
{
	 $("#videoLayer").load("videoCloser.html");
	 hideSupaLayers("#videoLayer");
}

function changeBackgnd(img,color,userid) {
	if(!color) color = '#423634';
	if(b.isIE) {
		$("body").css("background","#"+color+" url(/common/img/under/master_v3_b2c/"+img+")  no-repeat center top");
	} else {
		$("body").attr("style","background:#"+color+" url(/common/img/under/master_v3_b2c/"+img+")  no-repeat center top");
	}
	$("#backgroundChange").load("ajax_handlers/changeBackgnd.cfm?img="+img+"&color="+color+"&userid="+userid)
}

/* homemotionLayer function */

function launchHomemotion(sitename,language) {	
	$("#homemotionLayer").show();
	showSupaLayers("#homemotionLayer");
	var filename = "/"+sitename+"/homemotion.cfm";
	if(language) filename += "?language="+ language;
	$("#homemotion").load(filename);	
}

function launchAlarmAnimation(sitename,language) {	
	$("#homemotionLayer").show();
	showSupaLayers("#homemotionLayer");
	var filename = "/"+sitename+"/alarme.cfm";
	if(language) filename += "?language="+ language;
	$("#homemotion").load(filename);	
}

function closeHomemotion(sitename){
	hideSupaLayers("#homemotionLayer");
	$("#homemotion").load("/"+sitename+"/videoCloser.cfm");
}

function handle_trackingHome(taggingValue) {
		xt_med('F','2','Home::'+taggingValue);
}

function handle_trackingCatalogue(taggingValue) {
		xt_med('F','2','Catalogue::'+taggingValue);
}

function showIt(elID){
  var el = document.getElementById(elID);
  el.scrollIntoView(true);
}

/*$(".courrentItem").click(function() {
	    $(".courrentItem").css("display","none");
	})*/

/* ---- end homemotion functions  ----*/


function activeOngletsCa40(){
	$('#lienOnglet1').click(function(){
		$('#onglet2').css('display', 'none');
		$('#onglet3').css('display', 'none');
		$('#onglet1').css('display', 'block');
		$('#lienOnglet2').parent().removeClass('active');
		$('#lienOnglet3').parent().removeClass('active');
		$('#lienOnglet1').parent().addClass('active');
		return false;
	});
	
	$('#lienOnglet2').click(function(){
		$('#onglet3').css('display', 'none');
		$('#onglet1').css('display', 'none');
		$('#onglet2').css('display', 'block');
		$('#lienOnglet3').parent().removeClass('active');
		$('#lienOnglet1').parent().removeClass('active');
		$('#lienOnglet2').parent().addClass('active');
		return false;
	});
	
	$('#lienOnglet3').click(function(){
		$('#onglet2').css('display', 'none');
		$('#onglet1').css('display', 'none');
		$('#onglet3').css('display', 'block');
		$('#lienOnglet1').parent().removeClass('active');
		$('#lienOnglet2').parent().removeClass('active');
		$('#lienOnglet3').parent().addClass('active');
		
		//fire carousel in this TAB
		
		$("#onglet3 .jCarouselLite").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible:3,
			circular: false
		});
		
		return false;
	});
}

// CA 40 Suite

var bloc_actif = 1; //bloc à afficher par default = le 1er
			
function activerblock(ClassName,number){//class name est la class sans le numero
		var	bloc_courant = "." + ClassName + bloc_actif;
		var	bloc_a_activer = "." + ClassName + number;
		
		$(bloc_courant).hide();
		$(bloc_a_activer).show();
		
		bloc_actif = number;
}

// Fin CA 40
