$(document).ready(function(){
	/* 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 (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";
		// NEW value after adding "onglet achat en magasin"
		positionHubTools = positionHubTools + 115;
		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);
	
	/* END HUB  */		
	
	if(typeof(jQuery.fn.infiniteCarousel) == 'function'){
		initCarousel();
	}
	if(typeof(jQuery.fn.prettyPhoto)=='function'){
		$("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
	}

	//same height for 3 blocs of home page
	var numBox = 0;
	var firstBoxWidth = 0;
	$(".three-box .text-holder").each(function(){
		numBox = numBox + 1;
		if(numBox == 1){
			firstBoxWidth = $(this).height();
		}
	});
	$(".three-box .text-holder").css("height",firstBoxWidth);
	
	//jquery selectbox
	if( $(".jquery_select").selectbox != undefined){
		$(".jquery_select").selectbox({animationSpeed:"fast"});
	}
});

function initCarousel(){
	$('#gallery-1').infiniteCarousel({
		transitionSpeed: 500,
		inView:8,
		imagePath: '/common/img/V3bis/',
		advance:1,
		displayProgressBar: false,
		displayThumbnails: false,
		displayThumbnailNumbers: false,
		displayThumbnailBackground: false,
		holderHeight: false,
		holderWidth: false
	});
	$('#gallery-2 .holder-list').infiniteCarousel({
		transitionSpeed: 500,
		inView:1,
		imagePath: '/common/img/V3bis/',
		advance:1,
		displayProgressBar: false,
		displayThumbnailBackground: false,
		showControls: false,
		holderHeight: false,
		holderWidth: false
	});
	$('#gallery-3').infiniteCarousel({
		transitionSpeed: 500,
		inView:7,
		imagePath: '/common/img/V3bis/',
		advance:1,
		displayProgressBar: false,
		displayThumbnails: false,
		displayThumbnailNumbers: false,
		displayThumbnailBackground: false,
		holderHeight: false,
		holderWidth: false
	});
	$('#gallery-4').infiniteCarousel({
		transitionSpeed: 500,
		inView:4,
		imagePath: '/common/img/V3bis/',
		advance:1,
		displayProgressBar: false,
		displayThumbnails: false,
		displayThumbnailNumbers: false,
		displayThumbnailBackground: false,
		holderHeight: false,
		holderWidth: false
	});
	$('#gallery-5').infiniteCarousel({
		transitionSpeed: 700,
		inView:8,
		imagePath: '/common/img/V3bis/',
		advance:1,
		displayProgressBar: false,
		displayThumbnails: false,
		displayThumbnailNumbers: false,
		displayThumbnailBackground: false,
		holderHeight: false,
		holderWidth: false
	});
}
