

$(document).ready(function(){

	if($(".page").height() < 500){
		$(".page").height(500);
	}
	
	if($("div").hasClass("subnav")){
		$("#filarian").css("margin-top", "-6px");
	}else{
		$("#filarian").css("padding-top", "6px");
	}


	$("#btVflash").hover(
		function(){
			$("#layerVflash").show();
			$(this).css("z-index", "80");
			$("#btBoutique").css("z-index", "79");
			posLayerVf();
		},
		function(){
			$("#layerVflash").hide();
			$("#btBoutique").css("z-index", "80");
		}
	);

	$("#layerVflash").hover(
		function(){
			$(this).show();
			$("#btVflash").addClass("on");
			$("#btBoutique").css("z-index", "79");
		},
		function(){
			$(this).hide();
			$("#btVflash").removeClass("on");
			$("#btBoutique").css("z-index", "80");
		}
	);

	$("#btBoutique").hover(
		function(){
			$("#layerBoutique").show();
			$(this).css("z-index", "80");
			$("#btVflash").css("z-index", "79");
			posLayerBoutique();
		},
		function(){
			$("#layerBoutique").hide();
			$("#btVflash").css("z-index", "80");
		}
	);

	$("#layerBoutique").hover(
		function(){
			$(this).stop();
			$(this).show();
			$("#btBoutique").addClass("on");
			$("#btVflash").css("z-index", "79");
		},
		function(){
			$(this).stop();
			$(this).hide();
			$("#btBoutique").removeClass("on");
			$("#btVflash").css("z-index", "80");
		}
	);
	

	$("#layerVflash ul li a").hover(
		function(){
			$(this).addClass("on");
		},
		function(){
			$(this).removeClass("on");
		}
	);	
	

	$("#header .panier").hover(
		function(){
			$("#layerPanier").css("display", "block");
			$(this).addClass("on");
		},
		function(){
			$("#layerPanier").css("display", "none");
			$(this).removeClass("on");
		}
	);
						   
	$("#header .panier").click(function(){
    	window.location=$(this).attr("id");
		return false;
	});	

	$("#layerPanier").hover(
		function(){
			$(this).stop();
			$(this).css("display", "block");
			$("#header .panier").addClass("on");
		},
		function(){
			$(this).stop();
			$(this).css("display", "none");
			$("#header .panier").removeClass("on");
		}
	);
	
	
	//GESTION DE LA SOUS NAV BOUTIQUE
	$(".linksLevel ul li a").hover(
		function(){
			if($(this).next().hasClass("ssnav")){
				$(".linksLevel ul li a span").css("display", "none");

				var p = $(this).parent();
				var position = p.position();

				
				var widthLi = $(this).outerWidth() - 2;
				$(this).children("span").css("width", widthLi+"px");
				$(this).children("span").css("display", "block");
				
				
				$(this).next().css("display", "block");
				$(this).next().css("left", position.left);
				$(this).addClass("on");
			}
		},
		function(){
			if($(this).next().hasClass("ssnav")){
				$(this).children("span").css("display", "none");
				$(this).next().css("display", "none");
				$(this).removeClass("on");
			}
		}
	);
	
	$(".linksLevel ul li ul").hover(
		function(){
			$(this).css("display", "block");
			$(this).prev().addClass("on");
			$(this).prev().children("span").css("display", "block");
		},
		function(){
			$(this).css("display", "none");
			$(this).prev().removeClass("on");
			$(this).prev().children("span").css("display", "none");
		}
	);
	/**********************/
	
	//alert("Taille : "+$(".contentLeft ul.fOvreflow").parent().height());
	//alert($("ul.filtreTaille").length);
	
	if($("ul.filtreTaille").length < 2){
		$("ul.filtreTaille").parent().css("paddingBottom", "8px");
	}
	
	if($(".contentLeft ul.filtreCouleur").height() > 190){
		$(".contentLeft ul.filtreCouleur").css("width", "170px");
		$(".contentLeft ul.filtreCouleur").parent().css("height", "190px");
		$(".contentLeft ul.filtreCouleur").parent().css("overflow-y", "scroll");
	}
	
	if($(".contentLeft ul.fOvreflow").height() > 190){
		$(".contentLeft ul.fOvreflow").css("width", "170px");
		$(".contentLeft ul.fOvreflow").parent().css("height", "190px");
		$(".contentLeft ul.fOvreflow").parent().css("overflow-y", "scroll");
	}
	
	if($(".contentLeft ul.filtreMarque").height() > 190){
		$(".contentLeft ul.filtreMarque").css("width", "170px");
		$(".contentLeft ul.filtreMarque").parent().css("height", "190px");
		$(".contentLeft ul.filtreMarque").parent().css("overflow-y", "scroll");
	}
	
	$(".contentLeft ul.catNiv0 li span").click(function(){
		$(this).next().slideToggle("fast");
		$(this).toggleClass("close");
	});

	$(".blocProduit").hover(
		function(){
			if(!$(this).hasClass("noStock")){
				$(this).addClass("on");
			}
		},
		function(){
			if(!$(this).hasClass("noStock")){
				$(this).removeClass("on");
			}
		}
	);	

	$(".produitPlus .dejaVu a").hover(
		function(){
			$(this).children().next().fadeIn("fast");
		},
		function(){
			$(this).children().next().fadeOut("fast");
		}
	);	
	
	$(".ficheContener .content .tabs ul li a").click(function(){
		$(".ficheContener .content .tabs ul li a").removeClass("active");
		$(this).addClass("active");
		var revTemp = "#"+$(this).attr("rev");
		$(".ficheContener .content .tabContent").removeClass("active");
		$(revTemp).addClass("active");
	});
	

	$(".ficheContener .tdThumb img").click(function(){
		$(".ficheContener .tdThumb .thumbImg").removeClass("active");
		$(".ficheContener .tdThumb .thumbImg").css("borderColor", "#e8e8e8");
		$(this).addClass("active");
		$(this).css("borderColor", "#4e4e4e");
	});

	$(".ficheContener .tdThumb img").hover(
		function(){
			if(!$(this).hasClass("active")){
				$(this).css("borderColor", "#4e4e4e");
			}
		},
		function(){
			if(!$(this).hasClass("active")){
				$(this).css("borderColor", "#e8e8e8");
			}
		}
	);	

	$(".next a").hover(
		function(){
			$(this).prev().fadeIn("fast");
		},
		function(){
			$(this).prev().fadeOut("fast");
		}
	);	

	$(".prev a").hover(
		function(){
			$(this).prev().fadeIn("fast");
		},
		function(){
			$(this).prev().fadeOut("fast");
		}
	);	
	
	
	// FADE NE FONCTIONNE PAS SOUS IE6
	$("#infoPrix").hover(
		function(){
			$("#ficheInfoPrix").show();
		},
		function(){
			$("#ficheInfoPrix").hide();
		}
	);
	
	
	// FADE NE FONCTIONNE PAS SOUS IE6
	$("#infoParrain").hover(
		function(){
			$("#layParrain").show();
		},
		function(){
			$("#layParrain").hide();
		}
	);
	
	$("#infoSociete").hover(
		function(){
			$("#laySociete").show();
		},
		function(){
			$("#laySociete").hide();
		}
	);
	
	$("#infoAdresse").hover(
		function(){
			$("#layAdresse").show();
		},
		function(){
			$("#layAdresse").hide();
		}
	);
	
	// FADE NE FONCTIONNE PAS SOUS IE6
	$("#infoSaveCard").hover(
		function(){
			$("#laySaveCard").show();
		},
		function(){
			$("#laySaveCard").hide();
		}
	);
	

	$(".faqQs").click(function(){
		if(!$(this).hasClass("active")){
			$(".faqQs").removeClass("active");
			$(".faqDetail").slideUp("fast");
			$(this).next().slideDown("fast");
			$(this).addClass("active");
		}else{
			$(this).next().slideUp("fast");
			$(this).removeClass("active");
		}
	});
						   
	$(".trClick").click(function(){
    	window.location=$(this).attr("id");
		return false;
	});
	
	
	//OUVERTURE NYROMODALS
	
	//OUVERTURE CRYPTO
	$('#nyroCrypto').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 700,
			height: 300
		});
		return false;							
	});
	
	
	//OUVERTURE CGV
	$('#nyroCgv').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 700,
			height: 400
		});
		return false;							
	});
	
	//OUVERTURE CGV FOOTER
	$('#nyroCgvFooter').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 700,
			height: 400
		});
		return false;							
	});
	
	//OUVERTURE SATISFAIT REMBOURSER
	$('#nyroSatRemb').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 525,
			height: 190
		});
		return false;							
	});
	
	//OUVERTURE PAIEMENT 100% SECURISER
	$('#nyroPaiement').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 525,
			height: 150
		});
		return false;							
	});
	
	//OUVERTURE SAV
	$('#nyroSav').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 525,
			height: 150
		});
		return false;							
	});
	
	//OUVERTURE CONCEPT UNIQUE
	$('#nyroConcept').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 525,
			height: 150
		});
		return false;							
	});
	
	//OUVERTURE DONNEES PERSONNELLES
	$('#nyroDonneesPersonnelles').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 525,
			height: 250
		});
		return false;							
	});
	
	//OUVERTURE DONNEES PERSONNELLES
	$('#nyroDonneesPerso').click(function(e) {
		e.preventDefault();
		$.nyroModalManual({
			url: this.href,
			forceType: 'iframe',
			width: 525,
			height: 240
		});
		return false;							
	});

});


function posLayerBoutique(){
	// Taille du layerBoutique
	var nbUl = $("#layerBoutique ul").length;
	$("#layerBoutique").css("width", (nbUl*120)+"px");
	$("#layerBoutique .footer").css("width", ((nbUl*120)-20)+"px");
	
	//Position du layerBoutique
	var widthWrapper = $("#wrapper").outerWidth();
	var widthLayerBoutique = $("#layerBoutique").outerWidth();
	var position = (widthWrapper/2) - (widthLayerBoutique/2);
	$("#layerBoutique").css("margin-left", position+"px");
	
	$("#layerBoutique ul:last").css("background", "none");	
}

function posLayerVf(){
	// Taille du layerVflash
	
	var nbUl = $("#layerVflash ul li").length;
	
	if(nbUl<5){
		var liWidth = $("#layerVflash ul").outerWidth();
		
		$("#layerVflash").css("width", liWidth+"px");
		$("#layerVflash .footer").css("width", (liWidth-20)+"px");
		
		//Position du layerVflash
		var widthWrapper = $("#wrapper").outerWidth();
		var widthLayerBoutique = $("#layerVflash").outerWidth();
		var position = (widthWrapper/2) - (widthLayerBoutique/2);
		$("#layerVflash").css("margin-left", position+"px");
		
	}
}

