$(document).ready(function() {


/* ---------------------- */
/* ajustements navigation */
/* ---------------------- */

	// ajout barre vertical entre les li du menu footer
	$(".boxliens ul li:gt(0)").before("|");
	
	
/* ---------------------- */
/* box speciales */
/* ---------------------- */

	// entoure le contenu du lien avec un span
	$(".pano360 a, .coupcoeur a").wrapInner("<span></span>");
	
	// deplace la box de recherche
	if($(".catalog").length == 1 || $('.short_product').length > 0){
		$(".widgetCatalogSearch").insertAfter($("h1"));
	}else{
		$(".widgetCatalogSearch").remove();
	};
		
/* -------------------------------- */
/* LIGHTBOX ET CAROUSSEL */
/* -------------------------------- */

	// activation light sur toutes les images dans la fiche detaille
	if($("#product").length == 1){
		$("a.productLightbox").lightbox();
	};
	
	// regroupe les images additionnelles par 4
	var imgadd = $(".items").find("a"),
		nbensembles = Math.ceil(imgadd.length / 4);
	for (i=0; i<nbensembles; i++) {
		$(".items>a").slice(0,4).wrapAll("<div></div>")
	}
	// charge le plugin jquery tools et active le caroussel
	$("#additionnalPicture").after("<script src='/scripts/jquery.tools.min.js' type='text/javascript'></script><script type='text/javascript'>$('.scrollable').scrollable().navigator();</script>");
		
/* -------------------------------- */
/* FICHES PRODUIT */
/* -------------------------------- */

	// limite le nombre de caractere de la descrption dans les fiches resumees
	$(".descproduit").each(function(){
		var descprod = $(this).text().substring(0,90)
			descprod = descprod.substring(0,descprod.lastIndexOf(" ")-1) + "..."
		$(this).text(descprod);
	});
		
/* ---------------------- */
/* impression		  */
/* ---------------------- */

	// ouvrir la page dans une nouvelle fenetre
	$("a[title=imprimer]").click(function() {
		window.open($(this).attr("href"));
		return false;
	});
	
/* ---------------------- */
/* google translate		  */
/* ---------------------- */
	$('#lang_change_img').click(function(){
		lang_click();
	});
	function lang_click(){
		$('#google_translate_element select').click();
	}

});

