// Fiche Article

/* Impression */
function initPrint(){
	$(".printLink").click(function(){
		$(".displayLayerTab").hide();
		$("#tab1").show();
		$(".stdDeployTab .navTab li").removeClass("active");/* DIGITAS - 12/10/09 : Modifications Retours  */
		$(".stdDeployTab .navTab li:first-child").addClass("active");/* DIGITAS - 12/10/09 : Modifications Retours  */
		window.print();
		return false;
	});
	$(".printLinkTab").click(function(){
		window.print();
		return false;
	});
}

/* Gestion des onglets */
/*DIGITAS 18/09/08 modifs*/
function initTab(){
	$(".displayLayerTab").hide();
	$("ul.subContent").hide();
	$("div.toolTip").hide();
	$("div.liseret").hide();
	$("a.detailLink").bind("click",showDetail);
	$("a.showToolTip").bind("click",showNewToolTip);
	$("div.stockInfoBulle").hide();
	$("div.precommandeInfoBulle").hide();
	$(".stdDeployTab .navTab a").each(function(){/* DIGITAS - 12/10/09 : Modifications Retours  */
		if($(this).parent().attr("class") == "active"){
			layerSwitch($(this));
		}
	});	
	$(".stdDeployTab .navTab a").click(function(){/* DIGITAS - 12/10/09 : Modifications Retours  */
	
		layerSwitch($(this));
		return false;
	});	
	toTab2();
	showPrecommandeInfoBulle();
	showStockInfoBulle();
}

function showDetail(){
	if($(this).parents("li.totalOfPack").find("ul.subContent:hidden").length == 1){
		$(this).parents("li.totalOfPack").find("ul.subContent").show();
		$(this).removeClass("notDeploy").addClass("deploy");
		$(this).parents("li.totalOfPack").find("div.liseret").show();
	}else{
		$(this).parents("li.totalOfPack").find("ul.subContent").hide();
		$(this).removeClass("deploy").addClass("notDeploy");
		$(this).parents("li.totalOfPack").find("div.liseret").hide();
	};
	
	return false;
}

function showNewToolTip(){
	if($(this).parents("div.blocGaranties").find("div.toolTip:hidden").length == 1){
		$(this).parents("div.blocGaranties").find("div.toolTip").show();
	}else{
		$(this).parents("div.blocGaranties").find("div.toolTip").hide();
	};
	
	return false;
}

function showPrecommandeInfoBulle(){
	
	$("p.showPrecommandeInfoBulle img").hover(
		function(){
			if($(this).parents("div.stockLine").find("div.precommandeInfoBulle:hidden").length == 1){
				$(this).parents("div.stockLine").find("div.precommandeInfoBulle").show();
			}
		},
		function(){
			if($(this).parents("div.stockLine").find("div.precommandeInfoBulle:visible").length == 1){
				$(this).parents("div.stockLine").find("div.precommandeInfoBulle").hide();
			}
		}
	)

	return false;
}

function showStockInfoBulle(){
	
	$("p.showStockInfoBulle img").hover(
		function(){
			if($(this).parents("div.stockLine").find("div.stockInfoBulle:hidden").length == 1){
				$(this).parents("div.stockLine").find("div.stockInfoBulle").show();
			}
		},
		function(){
			if($(this).parents("div.stockLine").find("div.stockInfoBulle:visible").length == 1){
				$(this).parents("div.stockLine").find("div.stockInfoBulle").hide();
			}
		}
	)

	return false;
}

/*DIGITAS 18/09/08 fin modifs*/

function layerSwitch(linkElt){
	$(".displayLayerTab").hide();
		
	var linkTab = $(linkElt).attr("href").split("#");
	$("#"+linkTab[1]).show();
	
	$(".stdDeployTab .navTab li").removeClass("active");/* DIGITAS - 12/10/09 : Modifications Retours  */
	$(linkElt).parent().addClass("active");
	return false;
}

/* DIGITAS - 21/04/2009 : Modification de la fonction */
function toTab2(){

	jQuery("a[class*=totab]").click(function(){
		var linkTab = jQuery(this).attr("href").split("#");
		jQuery(".stdDeployTab .navTab li a").each(function(){/* DIGITAS - 12/10/09 : Modifications Retours  */
			if (jQuery(this).attr("href").split("#")[1] == linkTab[1]){
				jQuery(this).trigger("click");
			}
		});
		window.location.href = "#top";
		return false;
	});

}
/* DIGITAS - 21/04/2009 : Fin Modification de la fonction */


/* DIGITAS - 21/04/2009 : Ajout Retours */
function initDisplayPack(){
	jQuery(".packListItem[class!=packListItem activeItem] .detailPackDisplay").hide();
}

function displayLayerPack(){
	if(jQuery(this).parents(".packListItem").attr("class") == "packListItem activeItem"){
		jQuery(this).parents(".packListItem").removeClass("activeItem");
		jQuery(this).parents(".packListItem").find(".detailPackDisplay").hide();
	}
	else{
		jQuery(this).parents(".packListItem").addClass("activeItem");
		jQuery(this).parents(".packListItem").find(".detailPackDisplay").show();	
	}
	return false;
}

/* DIGITAS - 21/04/2009 : Fin Ajout Retours */


function initScroll(){
	window.scrollTo(0, 132);
}

/*DIGITAS 26/08/08 : modifs*/
function initScrollBoutique(){
	window.scrollTo(0, 295);
}
/*DIGITAS 26/08/08 : fin modifs*/

/*DIGITAS 26/08/08 : fin modifs*/

function initScrollBoutique2(){
	window.scrollTo(0, 282);
}

/*DIGITAS 21/08/08 modifs*/
$(window).load(function(){
	initTab()
});

/* DIGITAS - 01/06/2009 : Ajout Jeux video */

/* CAROUSEL */
function carouselVideoGame(){
	if($(".gameVideoCarsousel").length){
		$('.gameVideoCarsousel').jcarousel();
	}
}

/* INIT */
$(window).load(function(){
	carouselVideoGame();
});
	
/* DIGITAS - 01/06/2009 : FIN Ajout Jeux video */

$(document).ready(function(){	
	initPrint();
	
	/* DIGITAS - 21/04/2009 : Ajout Retours */
	if($(".listPushShop").length){
		$('.listPushShop').jcarousel();
	}
	initDisplayPack();
	jQuery(".packListItem .productDisplay .seeMoreLink a").bind("click", displayLayerPack);
	
	/* DIGITAS - 21/04/2009 : Fin Ajout Retours */
	
});
/*DIGITAS 21/08/08 fin modifs*/

