//------------------- ET JEZ INVENTA LE SOMMAIRE DE FICHIER JS ---------------------//
//--- [CALLBACK]	- Toutes les fonctions de callback
//--- [HOMEPAGE]	- 
//--- [COMPTE_SUIVI]-
//--- [COMPTE_SUIVI] -
//--- [FOOTER]		- Barre des langues et radio boutons
//----------------------------------------------------------------------------------// 
/*paiement*/
function updFactAdr( upd ) {

	var inputs = jQuery("#account_form :input[type!=hidden]");
	var labels = jQuery("#account_form .label-info span");
	var pays_change = true;

	if( upd ) {
		inputs.each( function(i,el) {
		
			if (jQuery(this).attr("id") == 'pays_fact')
				{	labels.eq(i).text( jQuery("option:selected",this).text() );
					pays_change=true;}
			else
				labels.eq(i).text( jQuery(this).attr("value") );
		});
		jQuery("#factAdrCancelBtn").trigger("click");
	}
	
	if (pays_change && jQuery("#shipInfosLayer").css("display") == 'block')
		{
			jQuery("#frmFacturation #pays_coli").val(jQuery("#account_form #pays_fact").val());
			ReloadLivraison('frmFacturation');
		}
		
	setTimeout("jQuery('#factAdrMsgLayer').animate({height: 0})", 2000)

}

// changement d'adresse sur livraison
function charge_adresse(){

      if(jQuery('#selectAdr').val() == -1) {
        jQuery("#frmFacturation #nom").val( jQuery("#account_form #nom").val() );
        jQuery("#frmFacturation #prenom").val( jQuery("#account_form #prenom").val() );
        jQuery("#frmFacturation #adresse").val( jQuery("#account_form #adresse").val() );
        jQuery("#frmFacturation #adresse2").val( jQuery("#account_form #complementAdresse").val() );
        jQuery("#frmFacturation #adresse3").val( jQuery("#account_form #complementAdresse3").val() );
        jQuery("#frmFacturation #adresse4").val( jQuery("#account_form #complementAdresse4").val() );
        jQuery("#frmFacturation #codepostale").val( jQuery("#account_form #cp").val() );
        jQuery("#frmFacturation #ville").val( jQuery("#account_form #ville").val() );
        
        var pays_livrable = false;
        
        jQuery("#frmFacturation #pays_coli option").each( function(i,el){
        	if (jQuery("option",this).val() == jQuery("#account_form #pays_fact").val())
        		pays_livrable = true;
        });
        
      	if(pays_livrable) {
              jQuery("#frmFacturation #pays_coli")
                    .val( jQuery("#account_form #pays_fact").val() )
                    //.trigger("change")};
                    }
		
		
      } else if(jQuery('#selectAdr').val() != "") {
        jQuery("#frmFacturation input[name=reload]").val("1");
        jQuery("#frmFacturation").attr("action",jQuery("#frmFacturation").attr("action") + "?adresse_livraison_id=" + jQuery('#selectAdr').val());
        jQuery("#frmFacturation").submit();
      }
}


/* feed last seen products div with HTML*/
function updateLastSeenProducts(produit_id, colorid) {
				
	//only if the div exists on the current page 
		jQuery.get(
			BBVars.pageURL+"ajax/liste_produits_vus.cfm?produit_id="+produit_id+"&color_id="+colorid+"&action=add",
			function(data) {BBTool_openMsgBox(data, true);})
	//URL = BBVars.pageURL+"ajax/liste_produits_vus.cfm?produit_id="+produit_id+"&color_id="+colorid+"&action=add";
	//ColdFusion.navigate(URL,',mycallBack,myerrorhandler);
}

function BBTool_ajaxGet( url, width ) {
	var oldWidth = BBSettings.BBpopup.elementsSettings.width;
	BBSettings.BBpopup.elementsSettings.width = width + "px";
	jQuery.get(
		BBVars.pagesURL + url,
		function( data ) {
			BBTool_openMsgBox(data, true);
			BBSettings.BBpopup.elementsSettings.width = oldWidth + "px";
		});
}

/* feed last seen products div with HTML*/
function getLastSeenProducts()
{
		$.get(
			BBVars.pageURL+"ajax/liste_produits_vus.cfm",
			function(data) {BBTool_openMsgBox(data, true);},
			"html"
		)
		//only if the div exists on the current page 
		
}
function signUpNewsletter() {

	jQuery.get(
		BBVars.pagesURL + "ajax/mailing.cfm?isPopup=true",
		function(data) { BBTool_openMsgBox(data, true)}
	);

}

/*--------------------------------- [HEADER] ---------------------------------*/
function initLoginBlock() {

	var timer;

	jQuery(".headerLogin_link").bind("click", function(e) {
		e.preventDefault();
		if(jQuery('#headerConnect_layer').css("display") == "none") 
			jQuery('#headerConnect_layer').css({display: "block", opacity: 0}).stop().animate({opacity: 1}, function() {
					if(BBVars.isMsIE)
						this.style.removeAttribute("filter");
				});
			jQuery('#accountBlock_details').stop().animate({opacity: 0}, function(){
				jQuery(this).css("display", "none");
			});
			jQuery('#accountBlockInfos').removeClass("active");
	});
	
	jQuery("#loginBlockLayer").bind("mouseleave", function(event) {
		timer = setTimeout("block_mouseLeave('headerConnect_layer')", 3500);
	}).bind("mouseenter", function(event) {
		clearTimeout(timer);
	});
	
	jQuery("#loginBlockLayer *").bind("mouseenter", function(event) {
		clearTimeout(timer);
	});
}

function block_mouseLeave( blockID, titleID ) {
	jQuery('#'+blockID).stop().animate({opacity: 0}, function(){
		jQuery(this).css("display", "none");
	});
	
	jQuery('#' + titleID).removeClass("active");
}

function dspnewAccountLayer() {
	var timer2;
	jQuery("#accountBlockInfos").bind("click", function(event) {
		BBAccount('new');
		jQuery('#accountBlockInfos').addClass("active");
		jQuery('#accountBlock_details').stop().css({opacity: 0, display: "block"}).animate({opacity: 1}, function() {
					if(BBVars.isMsIE)
						this.style.removeAttribute("filter");
				});
		jQuery('#headerConnect_layer').stop().animate({opacity: 0}, function(){
			jQuery(this).css("display", "none");
		});
	});
	jQuery("#accountBlock_details").bind("mouseleave", function(event) {
		timer2 = setTimeout("block_mouseLeave('accountBlock_details', 'accountBlockInfos')", 3500);
	}).bind("mouseenter", function(event) {
		clearTimeout(timer2);
	});;
}

function BBcart_closeBBcart_layer() {
	jQuery('#BBcart_layer').fadeOut(function(){
		jQuery('#BBcart_layer').remove();
		jQuery('#basket_infos').css({height: 0});
	});
}

function BBcart_closeAlreadyAdd() {
	jQuery('.alreadyAdd_text').fadeOut(function(){
		jQuery('.alreadyAdd_text').remove();
		jQuery('#alreadyAdd_layer').animate({height: 0});

	});
}

function BBcart_closeNoStock() {
	jQuery('.NoStock_text').fadeOut(function(){
		jQuery('.NoStock_text').remove();
		jQuery('#NoStock_layer').animate({height: 0});

	});
}

function dspBasketDetail() {
	jQuery("#basket_block").bind("mouseenter", function(event) {
			jQuery("#BBdetails_layer").stop().css({opacity: 0, display: "block"}).animate({opacity: 1});
		});
	jQuery("#cartBlockLayer").bind("mouseleave", function(event) {
		jQuery("#BBdetails_layer").stop().animate({opacity: 0}, function() { jQuery(this).css("display", "none"); });
		
	});
}

/*------------------------------------------------------------------------------*/

/*--------------------------------- [COMPTE_SUIVI] ---------------------------------*/
function dspOrderDetails() {
	jQuery(".orderDetails_layer").attr("dsp", "false");
	
	jQuery(".orderDetails_layer").bind("click", function(event) {
		var CmdId = jQuery(this).attr("id");
		var state = jQuery(this).attr("dsp");
		jQuery(".closeDetails").css("display", "none");
		jQuery(".openDetails").css("display", "block");
	
		jQuery(".orderDetails_layer").removeClass("open");
		
		if(state == "false") {
			jQuery(this).addClass("open");
			jQuery(this).attr("dsp", "true");
			
			jQuery("#openDetails_" + CmdId).css("display", "none");
			jQuery("#closeDetails_" + CmdId).css("display", "block").stop().animate({opacity: 1});
			
			jQuery("#loader_layer_" + CmdId).css({opacity: 0, display: "block"}).animate({opacity: 0.90});
			
			jQuery.get(
				BBVars.pagesURL + "compte_suivi_detail.cfm?commande_id=" + CmdId,
				function(data) { BBTool_openMsgBox(data, true)}
			);
			
		} else {
			jQuery(".orderDetails_layer").attr("dsp", "false");
			jQuery("#order_details_" + CmdId).stop().animate({height: 0});
			jQuery(".orderDetail_table").remove();
			jQuery("#closeDetails_" + CmdId).css("display", "none");
			jQuery("#openDetails_" + CmdId).css("display", "block").stop().animate({opacity: 1});
		}
		
	});
}

/*------------------------------------------------------------------------------*/

/*--------------------------------- [COMPTE_PERSO] ---------------------------------*/
function add_newAdress(formulaire) {
	jQuery.get(
		BBVars.pagesURL + "compte_perso.cfm?change=name_livraison",
		function(data) { BBTool_openMsgBox(data, true)}
	);
}

function add_NewAdressOk() {
	var adress_name = jQuery("#popup_nom_adresse").val();
	if(adress_name != '') {
		window.location = BBVars.pagesURL + "compte_perso.cfm?change=new_livraison&adress_name=" + adress_name + "&contentID=1";
	} else {
		alert("BBLabels.label_requiredFields");
	}
}

function change_adresse(formulaire){
	if(jQuery("#adresse_livraison_id").val() != '') {
		window.location = 'compte_perso.cfm?adresse_livraison_id='+jQuery("#adresse_livraison_id").val() + '&contentID=1';
	}
}
/*------------------------------------------------------------------------------*/

/*--------------------------------- [COMPTE_PANIER] ---------------------------------*/
function initDeleteList() {
	jQuery(".checkBox").bind("click", function(evt) {
		var listId = jQuery(this).attr("id");
		
		evt.preventDefault();
		jQuery(this).toggleClass("checked");
		jQuery("#dd_" + listId).toggleClass("selected");
		
		if(jQuery("#dd_" + listId).attr("class") == "selected") {
			jQuery("#fade_" + listId).stop().animate({opacity: 0.2});
			jQuery("#add_" + listId).stop().animate({opacity: 0}, function(){jQuery(this).css("display", "none")});
			jQuery("#del_" + listId).css({display: "block"}).stop().animate({opacity: 1});
		} else {
			jQuery("#fade_" + listId).stop().animate({opacity: 1});
			jQuery("#add_" + listId).css({display: "block"}).stop().animate({opacity: 1});
			jQuery("#del_" + listId).stop().animate({opacity: 0}, function(){jQuery(this).css("display", "none")});
		}
	});
}

function deleteList(action, panier_id) {
	$.get(BBVars.pagesURL+"compte_panier.cfm?action="+action+"&panier_id=" + panier_id);
		jQuery("#wishlist_content_" + panier_id).animate({height: 0}, function() {
			jQuery(this).remove();
		});
}
/*------------------------------------------------------------------------------*/

/*--------------------------------- [CALLBACK] ---------------------------------*/

// Menu de gauche contenu
function updMenu( index ) {

	jQuery("ul#contentMenuList ol[selected=true] li").each( function(i) {
		if(i==eval(index)) jQuery(this).attr("class", "selected");
		else jQuery(this).attr("class", "");
	});

}

// Ferme la fenetre de confirmation d'ajout au panier
function BBcart_Addcallback(data) {
	jQuery("#basket_block").unbind("mouseenter");
	setTimeout("BBTool_closeMsgBox()",500);
	setTimeout("BBcart_closeBBcart_layer()",5000);
	setTimeout("dspBasketDetail()",5500);
}

// Efface le message "produit deja present dans le panier
function BBcart_alreadyAddcallback(data) {
	setTimeout("BBcart_closeAlreadyAdd()",3500);
}

// Efface le message "plus de stock"
function BBcart_NoStockcallback(data) {
	setTimeout("BBcart_closeNoStock()",3500);
}

function OrderDetails_callBack() {
	jQuery(".loader_layer").stop().animate({opacity: 0}, function(){jQuery(this).css("display", "none")});
}

function QuickBuyCallback(getOptions,product_formID,wishlist) {
	if(typeof wishlist != "undefined") 
		BBCart(getOptions,product_formID,null,3);
	else BBCart(getOptions,product_formID);
	
	BBTool_toolTip();
	BBGallery("build", "quickBuyGallery");
	fInitSymbols();
}

// Confirmation de login et mise a jour des blocks login et nouveau compte
function BBloginCallback_ok() {
	jQuery.get(
		BBVars.pagesURL + "ajax/login.cfm?formAction=checkClient",
		function(data) {BBTool_openMsgBox(data, true)}
	);
	setTimeout("BBTool_closeMsgBox()",1500);
	jQuery("#headerConnect_layer").stop().animate({opacity: 0}, function(){jQuery(this).css("display", "none")});
}


// Valide le formulaire avec la touche 'entree'
function keyLogin_callback() {
jQuery("#loginBlock_form :input").bind("keypress", function( event ) {
		if(event.keyCode == 13) {
			event.preventDefault();
			BBTool_formPost('loginBlock_form',true);
		}
	});
}

// Enleve le block dynamique nouveau compte si compte cr??
function newAccountCallback() {
	jQuery("#accountBlock_details").stop().animate({opacity: 0}, function(){jQuery(this).css("display", "none")});
	jQuery("#accountBlockInfos").unbind("click");
}

/*------------------------------------------------------------------------------*/
function changeOngletFiche(type,maxtype){
	for(i=1;i<=maxtype;i++){
		if(type!= i){
			jQuery("#OngletFiche" + i ).removeClass("active");
			jQuery("#blockOngletFiche" + i ).hide();
		}
		else {
			jQuery("#OngletFiche" + i ).addClass("active");
			jQuery("#blockOngletFiche" + i ).show();
			if(i==2) initRatingBar(jQuery("#ratingsPage1"), 100);
		}
	}
}
function BBchangeMagasin(pays,departement,ville){
	var addUrl = "";
	if(typeof pays != "undefined") addUrl += "?pays=" + pays;
	if(typeof departement != "undefined") addUrl += "&departement=" + departement;
	if(typeof ville != "undefined") addUrl += "&ville=" + ville;
	jQuery.get(
		((BBVars.https)?BBVars.pageURL:BBVars.pagesURL) + "ajax/magasins.cfm" + addUrl,
		function(data) {BBTool_openMsgBox(data, true)}
	);
	
}
function login_callback(data) {setTimeout("BBTool_closeMsgBox()",2000);}

function BBLogin() {
	jQuery.get(
		BBVars.pagesURL + "ajax/login.cfm?formAction=prompt",
		function(data) {BBTool_openMsgBox(data, true)}
	);
}
function BBStock() {
	jQuery.get(
		BBVars.pagesURL + "ajax/retour_en_stock.cfm?formAction=prompt&code_ean="+ BBVars.currentProdEAN,
		function(data) {BBTool_openMsgBox(data, true)}
	);
}
function BBOpenMagasin( storeID ) {
	jQuery.get(
		((BBVars.https)?BBVars.pageURL:BBVars.pagesURL) + "ajax/magasins.cfm?code_mag_livraion=" + storeID,
		function(data) {BBTool_openMsgBox(data, true)}
	);
}
function BBOpenMondial() {
	
	jQuery.get(
		((BBVars.https)?BBVars.pageURL:BBVars.pagesURL) + "ajax/mondial_relay.cfm?pays=" + document.shipping_infos_form.pays.value + "&ville_mondial_relay=" + document.shipping_infos_form.ville.value + 
			"&cp_mondial_relay=" + document.shipping_infos_form.cp.value+ "&adresse_mondial_relay=" + document.shipping_infos_form.adresse1.value + "&kiala_point_id=" + document.shipping_infos_form.kiala_point_id.value,
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function close_callback(data) {setTimeout("BBTool_closeMsgBox()",2500);}
function sendPwd_callback(data) {setTimeout("BBTool_closeMsgBox()",3000);}
function sendPwd() {
	jQuery.get(
		BBVars.pagesURL + "ajax/login.cfm?formAction=promptPwd",
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function getCGV() {
	jQuery.get(
		BBVars.pagesURL + "contenu/cgv.cfm?isCheckout=true",
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function BBChangeColor(colorSelected,listColor,item, isQuickbuy){

	if(typeof(isQuickbuy)=="undefined") {

		jQuery("#cross_layer a").unbind("click");
		jQuery("#cross_layer ul[dsp=true]").attr("dsp","false");
		var lstColor=listColor.split(',');
		jQuery.each(lstColor,function(index, color){
			
			if(colorSelected != parseInt(color)){
				jQuery("#lienColor" + color).removeClass();
				jQuery("#lienColor" + color).addClass("colorGrey");
				jQuery("#liTaille" + color).hide();
				if(typeof jQuery("#cross_prod_layer" + color) != "undefined")
					jQuery("#cross_prod_layer" + color).hide();
				
		  	}
		  	else{
		  		// avec un select 
				BBVars.currentColorID = color;
	
		  		//var row = jQuery("#taille"+color).val();
				var row = 0;
				
		  		jQuery("#lienColor" + color).removeClass();
				jQuery("#lienColor" + color).addClass("colorSelect");
				jQuery("#liTaille" + color).show();
				
				BBCart('setAttrib', item + row, setAttrib_callBackInit,1);
				
				if(typeof jQuery("#cross_prod_layer" + color) != "undefined")
					jQuery("#cross_prod_layer" + color).show();

				jQuery.get(
					BBVars.pagesURL 	+"ajax/photos.cfm"
					+"?prodID="			+((typeof(prodID)!="undefined")?prodID:BBVars.currentProdID)
					+"&colorID="		+color,
					function(data) { BBTool_openMsgBox(data, true);}
				);		
					
		  	}
		});
		
	} else {

		var lstColor=listColor.split(',');
		jQuery.each(lstColor,function(index, color){
			
			if(colorSelected != parseInt(color)){
				jQuery("#quickBuylienColor" + color).removeClass();
				jQuery("#quickBuylienColor" + color).addClass("colorGrey");
				jQuery("#quickBuyliTaille" + color).hide();
		  	}
		  	else{
		  		// avec un select 
				BBVars.currentColorID = color;
				//alert('');
		  		//var row = jQuery("#quickBuytaille"+color).val();
				var row = 0;
		  		BBCart('setAttrib', item + row, setAttrib_callBack,0);
		  		jQuery("#quickBuylienColor" + color).removeClass();
				jQuery("#quickBuylienColor" + color).addClass("colorSelect");
				jQuery("#quickBuyliTaille" + color).show();
				
				jQuery.get(
					BBVars.pagesURL 	+"ajax/photos.cfm"
					+"?prodID="			+BBVars.currentProdID
					+"&colorID="		+color
					+"&isQuickbuy=true",
					function(data) { BBTool_openMsgBox(data, true);}
				);	
					
		  	}
		});
	}
}

function DelWishlist( action ,panier_save_id) {
	
	$.get(BBVars.pagesURL+"compte_panier.cfm?action="+action+"&panier_save_id=" + panier_save_id);
		jQuery("#ligne" + panier_save_id).animate({height: 0}, function() {
			jQuery(this).remove();
		});
}
function trim(myString)
{
	return myString.replace(/^\s+/g,').replace(/\s+$/g,')
} 

function afficheListProd(prod){
		prod = trim(prod);
		var tab_prod = prod.split('|');

		var listProduit = tab_prod[0];
		var listColor = tab_prod[1];

		if(listProduit != "" && listColor != "")
			window.location = BBVars.pagesURL + "liste_produit.cfm?list_prod="+ listProduit + "&list_attrib=" + listColor + "&type=produitsVus";
}

function voirListProduit() {
	$.get(BBVars.pageURL+"ajax/liste_produits_vus.cfm?getList=1&type=produitsVus",
			function(data) {afficheListProd(data);})
}

function NumberFormat(nStr){
	nStr += '';
	x = nStr.split(',');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ' ' + '$2');
	}
	var r = x1 + "" + x2;
	return r.replace(".", ",");
}
/*-------------------- TRI PAR ATTRIBUT (UNIVERS) --------------------*/
function initFilter() {

	jQuery(".filter_layer").each( function( index ) {
		jQuery("ul", this).eq(0).css({display: "none", opacity: 0});
		jQuery(this).bind("mouseenter", function(event) {
			jQuery("ul",this).eq(0).css({display: "block"}).stop().animate({opacity: 1});
		}).bind("mouseleave", function(event) {
			jQuery("ul",this).eq(0).stop().animate({opacity: 0}, function() { jQuery(this).css("display", "none"); });
		});
	
	});

}

function sortList(type, value){
	if(type =='price') {
		document.product_form.price_origine.value = value;
	} else if(type == 'number') {
		document.product_form.maxrows.value = parseInt(document.product_form.maxrows.value) + 12*value; 
	}
	else if(type == 'tri') {
		document.product_form.tri.value = value; 
	}
	document.product_form.submit();
}

/*---------------------------------------------------*/

function sizeGuid( mainCatID, isPopup ) {
	jQuery.get(
		BBVars.pagesURL + "ajax/guide_tailles.cfm"
						+ "?isPopup=" + ( (typeof(isPopup)!="undefined") ? isPopup : "false")
						+ ( (typeof(mainCatID)!="undefined") ? ("&mainCatID=" + mainCatID) : ""),
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function cleanGuid(prodID) {
	$.get(
		BBVars.pagesURL + "ajax/guide_entretien.cfm?prodID=" + prodID,
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

/*------------------ ONGLETS POPUP GUIDE TAILLE -----------*/

function tab_dyn_sizeGuid (nb) {
	$("#tab_list_ul li").each(function(i) {
		if(nb==i) {
			$(this).removeClass();
			$(this).addClass("li_actif");
			$(this).animate({opacity:1}, function() {
				
				$("#tab_layer_"+i).css("display","block").animate({opacity:1}, function() {
					if(BBVars.isMsIE)
						this.style.removeAttribute("filter");
				});
			});
		} else {
			$(this).removeClass();
			$(this).addClass("li_none");
			$(this).animate({opacity:0.33}, function() {
				$("#tab_layer_"+i).animate({opacity:0}, function() {
					if(BBVars.isMsIE)
						this.style.removeAttribute("filter");
					$(this).css("display","none");
			
				});
			});
		}
	});
	
	BBTool_resize("#BBTool_msgBoxBody");
	
}

/*--------------------------------- CALLBACKS ---------------------------------*/

function BBGallery_callback() {

	BBGallery("build", "BBGallery_list");
}

function checkClient_callback(data) {}
function checkClient() {
	$.get(
		BBVars.pagesURL + "ajax/login.cfm?formAction=checkClient",
		function(data) {BBTool_openMsgBox(data, true)},
		"html"
	);
}

function login_callback(data) {setTimeout("BBTool_closeMsgBox()",2000);}
function BBLogin() {
	$.get(
		BBVars.pagesURL + "ajax/login.cfm?formAction=prompt",
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function sendPwd_callback(data) {setTimeout("BBTool_closeMsgBox()",2000);}
function sendPwd() {
	$.get(
		BBVars.pagesURL + "ajax/login.cfm?formAction=promptPwd",
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

/* on continue les achats et on envoi sur cross selling*/
function continuerAchat(){

	BBTool_closeMsgBox();

}
/* Affiche le cross sellling*/

function showCross(prodID,colorID){
	$.get(
		BBVars.pagesURL + "fiche_cross.cfm?produit_id=" + prodID + "&coul_att_detailID=" +colorID ,
		function(data) {BBTool_openMsgBox(data, true)}
	);
	
}


function initDebug() {

	jQuery("#debugLayer").css({position: "absolute", top: 0, left: 0});
	jQuery("#debugLayer code").each( function(i,d) {
	
		jQuery(this).click( function() { 
				(jQuery(this).next().next().css("display")=="none")
						? jQuery(this).next().next().slideDown()
						: jQuery(this).next().next().slideUp();
				})
			.next().next().slideUp()
	
	});

}

function initPromo() {
	//BBSettings.BBPopup.elementsSettings.width = "790px";
	//BBSettings.BBPopup.elementsSettings.height = "460px";
	
	$.get(
		BBVars.pagesURL + "ajax/promo.cfm",
		function(data) {BBTool_openMsgBox(data, true);}
	);
	
}



// COMPTE - A REVOIR
function getMyOrders() {
	
	jQuery.get(BBVars.pagesURL + "compte_suivi.cfm?isAjax", function(data) {jQuery("#myOrders_layer").html(data);});
	
}

/*--------------------------------------------------------------------*/
// silhouettes

var selectHover = false;
var selectOpened = false;

function openSelect() {

	if($("#silBlock_list").attr("display") != "block") {
		$("#silBlock_list").css("display","block");
		selectOpened = true;
	}
	

}

function closeSelect() {

	$("#silBlock_list").css("display","none");
	selectOpened = false;

}

function showZoom(dsp) {

	if(dsp) $("#silZoomLayer").BBFadeIn().css("display","block");
	else $("#silZoomLayer").BBFadeOut().css("display","none");

}


function viewDefil(videoSrc,action) {
	
	/*var dsp = ($("#view_defil").css("display")=="none"||$("#view_defil").css("display")==undefined) ? "block" : "none";
	$("#view_defil").css("display",dsp);
	var dsp = ($("#view_sil").css("display")=="none"||$("#view_sil").css("display")==undefined) ? "block" : "none";
	$("#view_sil").css("display", dsp);*/
		
	//$('#imgDspLayer').html("");
	
	if(action) {
	
		$('#styleVideoBtn').animate({opacity: 0}, function() {
			$('#styleImgBtn').css({opacity: 0, display: "block"}).animate({opacity: 1}, function() {
				if(BBVars.isMsIE) jQuery(this).css({opacity: 1, filter: "none"});
			});
		});
		$('#imgDspLayer #img').animate({opacity: 0}, function() {
			$('#imgDspLayer #flashLayer')
				.css({display: "block", opacity: 0})
				.flash({
					src: BBVars.pagesURL + 'ximg/flash/video.swf',
					width: 240,
					height: 420,
					wmode: 'transparent',
					allowScriptAccess: 'always',
					flashvars: {
						flvwidth: 240,
						flvheight: 420,
						flvname: videoSrc
					}
				})
				.animate({opacity: 1});
		});
	
	} else {
	
		$('#styleImgBtn').animate({opacity: 0}, function() {
			$(this).css("display","none");
			$('#styleVideoBtn').animate({opacity: 1});
		});
		$('#imgDspLayer #flashLayer').animate({opacity: 0}, function() {
			$('#imgDspLayer #img').animate({opacity: 1});
		});
	
	}
	
}


function getFiche( prodID, catID, colorID, panier_change_id,wishlist ) {
	var urlParam = "";
	if(typeof panier_change_id != "undefined" && panier_change_id != null) urlParam = urlParam + "&panier_change_id="	+ panier_change_id;
	if(typeof wishlist != "undefined") urlParam = urlParam + "&showWishlist=1"	;

	BBVars.currentColorID = colorID;

	jQuery.get(BBVars.pagesURL 		+ "fiche.cfm"
			+"?produit_id="			+ prodID
			+"&cat_id="				+ catID
			+"&coul_att_detailID="	+ colorID
			+ urlParam
			+"&isAjax="				+ "true"
			,function(data) {BBTool_openMsgBox(data, true);}
		);

	
}


function getFicheSil( selID ) {

	jQuery.get(BBVars.pagesURL 		+ "ajax/quick_silhouette.cfm?isAjax=true"
			+"&selection_id="			+ selID
			,function(data) {BBTool_openMsgBox(data, true);}
		);
}

function getFicheCross( prodID, catID, colorID, isCross ) {

	jQuery.get(BBVars.pagesURL 		+ "fiche.cfm?isAjax=true"
			+"&produit_id="			+ prodID
			+"&cat_id="				+ catID
			+"&coul_att_detailID="	+ colorID
			+"&attDspType=0"
			,function(data) {BBTool_openMsgBox(data, true);}
		);
}

function comparerID(page,href) {
	jQuery("#page").val(page);
	//jQuery("#product_form").attr("action", href);
	jQuery("#product_form").submit();
}

function valid_form() {

	document.forms['product_form'].submit();	
	
}

function reloadForm(maxrows) {
	document.forms['product_form'].elements['maxrows'].value = maxrows;
	document.forms['product_form'].submit();
}


// NOUVEAU COMPTE - Si "sms" est coche, verifier le champs mobile
function CheckMobile(value) {
	
	if (value == 1) {
		if (jQuery('#mobile').val() == '') {
			jQuery('#mobile').attr("required",true);
			jQuery("#hidden_asterisk").css({display: "inline"});
		}
	} else {
		jQuery('#mobile').attr("required",false);
		jQuery("#hidden_asterisk").css({display: "none"});
	}
}

// BLOCKS/MAILING - Affiche le bloc d'informations de newsletter
function initMailingBlock() {

	jQuery("#mail_ok").bind("click", function( event ) {
		event.preventDefault();
		jQuery(this).toggleClass("up");
		jQuery("#mailingHeader_layer").stop().slideToggle();
	});
	
	jQuery("#block_mailing :input").bind("keypress", function( event ) {
		if(event.keyCode == 13) {
			event.preventDefault();
			jQuery("#mail_ok").toggleClass("up");
			jQuery("#mailingHeader_layer").stop().slideToggle();
		}
	});

}

function hideMailingBlock() {

	if(jQuery("#mail_ok").attr("class") != "hideSpan") {
		jQuery("#mail_ok").removeClass("up");
		jQuery("#mailingHeader_layer").stop().slideUp();
	}

}

// CAT_SOUS_CAT_TP - Affiche les Cat disponibles
function initTPMenu() {

	jQuery("#catFilter_list").css({opacity: 0})

	jQuery("#headerList_title div").bind("mouseenter", function() {
		jQuery("#catFilter_list").css("display", "block").stop().animate({opacity: 1});
	}).bind("mouseleave", function() {
		jQuery("#catFilter_list").stop().animate({opacity: 0}, function() {jQuery(this).css("display", "none");});
	});

}


// FICHE - Pictos de reassurance
function InitPictoRea() {
	
	jQuery("#pictoRea_list li").each( function(i) {
		jQuery(this).hover( function(e) {
			jQuery("#pictoRea_img").css("background-position", -17-52*(3-i) +"px 100%");
			jQuery("#pictoRea_label").html(eval("BBLabels.label_pictoRea" + i));
		});
	});

}

function initComment() {

	if(jQuery(".ratingsContainerLayer").length!=0) {

		var layerHeight = jQuery(".ratingsContainerLayer").eq(0).css("height").replace("px","");
		jQuery("#allRatingsLayer").css({height: jQuery("#allRatingsLayer .ratingsContainerLayer").length*eval(layerHeight) + "px"});
		jQuery(".pageNav_list li").each( function( index ) {
			jQuery(this).bind("click", function( e ) {
				jQuery("#allRatingsLayer").stop().animate({top: (-(index-1)*layerHeight) + "px"}, function() {
					initRatingBar(jQuery("#ratingsPage"+index,this), 100);
				});
			});
		});
		
		jQuery("#opinion_form ul li a").bind("click", function( e ) {
			if(jQuery("#opinion_form .error").length>0) jQuery("#opinion_form").animate({opacity: 0.5});
		});
	}
	
	initRatingBar(jQuery("#mainRatingLayer"),60);
	
}

function initRatingBar( obj, width ) {

	jQuery(".mainRatingLayer img.ratingBar",obj).each( function( index ) {
		var backPos = Math.round((eval(jQuery(this).attr("alt")))*width/5)-width + "px";
		
		jQuery(this).animate({left: backPos}, "slow");
		
	});
	
}

function initRatingForm() {

	jQuery("ul.ratingsListBlock li img")
		.css({
			opacity:	0,
			display:	"block"
		});

	jQuery("li.ratingItem").each( function( mainIndex ) {
	
		var currentItem = jQuery(this);
		var currentVal = jQuery("ul.ratingsListBlock",this).attr("title");
		
		jQuery("ul.ratingsListBlock li", this).each( function(index) {
		
			jQuery(this).bind("mouseenter", function(e) {
				jQuery("ul.ratingsListBlock li img:lt("+eval(index+1)+")", currentItem).stop().animate({opacity: 1});
				
			}).bind("mouseleave", function(e) {
				if(eval(jQuery("#note_"+currentVal).val())==-1)
					jQuery("ul.ratingsListBlock li img:lt("+eval(index+1)+")", currentItem).stop().animate({opacity: 0});
				else 
					jQuery("ul.ratingsListBlock li img:gt("+eval(jQuery("#note_"+currentVal).val())+")", currentItem).stop().animate({opacity: 0});
					
			}).bind("click", function(e) {
				jQuery("#note_" + currentVal).val(eval(index));
				jQuery("ul.ratingsListBlock li img:lt("+eval(index+1)+")", currentItem).css("opacity", 1);
				jQuery("ul.ratingsListBlock li img:gt("+eval(jQuery("#note_"+currentVal).val())+")", currentItem).stop().animate({opacity: 0});
				
			});
		});
	
	});
	

}

function plus(prod) {
	document.forms['basketForm'].elements['action'].value = 'update';
	var qut = -1;
	eval("document.forms['basketForm'].elements['quantite_"+ prod +"'].value -= qut");
	document.forms['basketForm'].submit();
}
	
function moin(prod) {
	if(eval("document.forms['basketForm'].elements['quantite_"+ prod +"'].value -= 0")> 0) {
		document.forms['basketForm'].elements['action'].value = 'update';
		var qut = 1;
		eval("document.forms['basketForm'].elements['quantite_"+ prod +"'].value -= qut");
		document.forms['basketForm'].submit();
	}
}

function radioCheck(val){ 
	for (i=0;i<document.forms['frmModeLivraison'].elements['mode_livraison'].length;i++) { 
		if (document.forms['frmModeLivraison'].elements['mode_livraison'][i].value==val) { 
			document.forms['frmModeLivraison'].elements['mode_livraison'][i].checked = true;
		}
	}
}

function hideCheckoutStep( step ) {

	if(jQuery("#coupon_promo div").css("opacity")!=0) {
		jQuery("#cartLayer").animate({height: jQuery("#product_table").outerHeight() + 40 + "px"}, function() {
			jQuery("#cartLayer .checkoutOverlay")
				.css({display: "block", opacity: 0})
				.animate({opacity: 0.2, height: jQuery("#cartLayer").height()+"px"});
		});
		jQuery("#coupon_promo div").animate({opacity: 0});
	}
	
	if( step == 2 ) {
	
		jQuery("#formList li.item").each( function( index ) {
		
			jQuery("div.selectLayer", this).css({
				width:		jQuery("form",this).width()+19+"px",
				height:		jQuery("form",this).height()+19+"px",
				opacity:	0,
				marginLeft:	eval(jQuery("form",this).css("marginLeft").replace("px",""))-5 + "px"
			});
			
			jQuery(this).bind("mouseenter", function(event) {
		
				jQuery("div.selectLayer", this).css("display", "block").stop().animate({opacity: 1});
				jQuery("a.blue_btn", this).css("display", "block").stop().animate({opacity: 1});
		
			}).bind("mouseleave", function() {
			
				jQuery("div.selectLayer", this).stop().animate({opacity: 0}, function() { jQuery(this).css("display", "none"); });
				jQuery("a.blue_btn", this).stop().animate({opacity: 0}, function() { jQuery(this).css("display", "none"); });
			
			});
		});
	
	}
	
	jQuery(".checkoutBlockLayer:eq("+step+") h2.ttl_gray").attr("class", "ttl_blue");	
	jQuery(".checkoutBlockLayer:lt("+step+")").each( function(index) {
		if(index!=0) jQuery(this).animate({height: "32px"});
		jQuery("h2.ttl_blue", this).attr("class","ttl_gray");
		jQuery("a.modBtn", this).css({opacity: 0, display: "block"}).animate({opacity: 1});
	});

}

function checkoutStepMod( step ) {

	if(BBVars.https) {
	
		var pageName = "panier";
		if (step==1) pageName = "compte_perso";
		else if (step==2) pageName = "livraison";
	
		window.location = BBVars.pagesURL + "panier.cfm?isCheckout=true&pageName=" + pageName;
	
	} else {
	
		jQuery(".checkoutBlockLayer:eq("+step+") h2.ttl_gray").attr("class", "ttl_blue");
		jQuery(".checkoutBlockLayer:eq("+step+") a.modBtn").animate({opacity: 0}, function() {jQuery(this).css("display","none");});
		jQuery(".checkoutBlockLayer:gt("+step+")").each( function() {
			jQuery("h2.ttl_blue", this).attr("class","ttl_gray");
			jQuery("a.modBtn", this).animate({opacity: 0}, function() {jQuery(this).css("display","none");});
			jQuery(this).animate({height: "32px"}, function() { jQuery(".content", this).remove(); });
		});
		
		if( step == 0) {
		
			jQuery("#cartLayer .checkoutOverlay")
				.animate({opacity: 0, height: 0}, function() {
					jQuery(this).css({display: "none"});
					jQuery("#coupon_promo div").animate({opacity: 1});
					jQuery("#cartLayer").animate({height: jQuery("#basketForm").outerHeight() + 40 + "px"});
				});
				
		} else if ( step == 1) {
		
			jQuery("#accountLayer .content").remove();
	
			jQuery.get(
				((BBVars.https)?BBVars.pageURL:BBVars.pagesURL) + "compte_perso.cfm?isCheckout=true",
				function(data) {BBTool_openMsgBox(data, true)}
			);
		
		} else if ( step == 2) {
		
			jQuery.get(
				BBVars.pageURL + "livraison.cfm",
				function(data) {BBTool_openMsgBox(data, true)}
			);
		
		}
		
	}
	
}

function loadCheckoutPage( pageName ) {

	var BBTool_pageScroll = BBTool_getPageScroll();
		
	jQuery('<div id="loaderLayer">&nbsp;</div>')
		.css({
			width:					BBVars.pageWidth+"px",
			height:					BBVars.pageHeight+"px",
			position:				"absolute",
			top:					0,
			left:					0,
			zIndex:					9999,
			opacity:				0,
			backgroundColor:		"#fff",
			display:				"none",
			textAlign:				"center"
		}).appendTo("body");
	
	jQuery('<img src="'+BBVars.pageURL+'/ximg/loader.gif">')
		.css({
			position:		"relative",
			top:			BBTool_pageScroll[1] + (BBVars.windowHeight /2)+"px"
		}).appendTo("#loaderLayer");
		
	jQuery("#loaderLayer")
		.css("display", "block")
		.animate({opacity: 0.8}, function() {
			jQuery.get(
				BBVars.pagesURL + pageName + ".cfm?isCheckout=true",
				function(data) {BBTool_openMsgBox(data, true)}
			);
		});

}

function createAccount(compte) {
	var addUrl = "?isCheckout=true"
	if(compte == "true")
		addUrl +=  "&creacompte=1";
	else
		addUrl += "&creacompte=0";
	jQuery.get(
		BBVars.pagesURL + "nouveau_compte.cfm" + addUrl,
		function(data) {BBTool_openMsgBox(data, true)}
	);

}

function dspConfirm() {

	jQuery("#confirmContentLayer").css("height", "auto");
	//jQuery("#cartLayer").animate({height: "25px"}, function() {
		jQuery(".checkoutOverlay").animate({opacity: 0}, function() { jQuery(this).remove(); });
		jQuery("#cartContentLayer")
			.css({overflow: "hidden", height: 0, opacity: 0})
			.append(jQuery("#product_table"))
			.animate({opacity: 1, height: jQuery("#product_table").outerHeight()});
	//});

	var nextStepLayer = jQuery(".checkoutBlockLayer").eq(4);
	jQuery("h2.ttl_gray", nextStepLayer).attr("class", "ttl_blue");	
	jQuery(".checkoutBlockLayer:lt(4)").each( function() {
		jQuery(this).animate({height: "32px"});
		jQuery("h2.ttl_blue", this).attr("class","ttl_gray");
		jQuery("a.modBtn", this).css({opacity: 0, display: "block"}).animate({opacity: 0});
	});

}

function initOpHours() {

	jQuery(".OPHours").tooltip(function (el) {
			
			var hList = jQuery(el).attr("list").split(';');
			var tTipHTML = "<ul>";
			for(i=0;i<hList.length;i++)
				tTipHTML += "<li>" + hList[i] + "</li>";
			tTipHTML += "</ul>";
			
			return tTipHTML;
			
		}, {
			'tooltipID': BBSettings.defaultTTipName,
			'tTipHeight': 60,
			'tTipWidth': 60
	});
	
}

function hideDelivery() {
	
	jQuery("#delivery").val(jQuery("#freeDelivery").attr('checked'));
	
	if (jQuery("#freeDelivery").attr('checked')) {

		jQuery("#totalFDP").hide();
		jQuery("#totalSFDP").show();

		jQuery("#delivery_case").css({overflow: "hidden", height: "50px"});
		jQuery("#delivery_case td").animate({opacity:0, borderTopWidth: 0,borderRightWidth: 0,borderLeftWidth: 0,borderBottomWidth: 0, lineHeight: 0}, function() {
				jQuery("*",this).css({display: "none", height: 0});
				jQuery("#delivery_case").animate({height: 0});
			});

	} else {

		jQuery("#delivery_case").animate({height: "50px"}, function() {
			jQuery("td *",this).css({display: "block", height: "auto"});
			jQuery("td", this).animate({opacity: 1, borderRightWidth: "2px", borderTopWidth: "5px", lineHeight: "14px"});
		});

		jQuery("#totalFDP").show();
		jQuery("#totalSFDP").hide();
		
	}
}

function addToWhishList( prodID, colorID, ref, optionID ) {

	$.get(
		BBVars.pagesURL	+ "utils/addToWishlist.cfm?is_xml=true&frmaction=add_whishlist"
					+ "&produit_id=" 			+ prodID
					+ "&attribut_detail_id="	+ colorID 
					+ "&code_ean=" 				+ ref
					+ "&type_vente=" 			
					+ "&option_id="				+ optionID
					+ "&attribs=1",
		function(data) {BBTool_openMsgBox(data, true);}
	)

}

/*--------------------------------- [FICHE] ---------------------------------*/
function fInitSymbols() {
	
	jQuery(".pictos_list").each( function() {
		var currentLayer = jQuery(this);
		jQuery("li", currentLayer).bind("mouseenter", function(e) {
			jQuery(".alertBox", currentLayer).html(jQuery("span", this).html());
		});
	});

}

function zoomProduit() {
	jQuery.get(
		BBVars.pagesURL + "ajax/zoomProduit.cfm?"
						+ "produit_id=" + BBVars.currentProdID
						+ "&coul_att_detailID=" + BBVars.currentColorID,
		function(data) {BBTool_openMsgBox(data, true);}
	);
}
/*--------------------------------------------------------------------*/

function setShippingMode(formID, inputs, haltOnError, errorDsp) {

	jQuery("#"+formID+" input[name=mode_livraison]").val( jQuery("#shippingModeList input[name=mode_livraison]").val() );

}


function BBKiala( cp, pays ) {
	$.get(
		BBVars.pagesURL + "kiala/kiala.cfm?code_postal=" + cp + "&pays_kiala=" + pays,
		function(data) {BBTool_openMsgBox(data, true);}
	);
}

function BBMagasin( pays, departement, ville, region) {
		$.get(
			BBVars.pagesURL + "blocks/liste_magasins.cfm?pays=" + pays + "&departement=" + departement + "&ville=" + ville + "&livraison=1",
			function(data) {jQuery("#listMag").html(data);/*BBTool_openMsgBox(data, true);*/ jQuery("#listMag").css("display","block");}
		);

	if (ville == "")
	{
		$.get(
		BBVars.pagesURL + "ajax/getListeVille.cfm?pays=" + pays + "&departement=" + departement,
		function(data) {BBTool_openMsgBox(data, true);}
		);
	}
}

/* Popup ajout produit wishlist */
function PopupWish(prodID,couleur_id) {
	$.get(
		BBVars.pagesURL + "utils/addToWishlist.cfm?"
						+ "produit_id=" + prodID
						+ "&attribut_detail_id=" + couleur_id,
		function(data) {BBTool_openMsgBox(data, true);}
	);
}

/* ajout wishlist from liste*/
function AddWish(prodID,couleur_id){
	$.get(
					BBVars.pagesURL	+ "utils/addToWishlist.cfm?is_xml=true&frmaction=add_whishlist"
								+ "&produit_id=" + prodID
								+ "&attribut_detail_id=" + couleur_id 
								+"&type_vente=" 		+1
								+"&attribs=1",
					function(data) {BBTool_openMsgBox(data, true);}
				)
}

function PostFormLivraison () {
	var form_used = "";
	
	if (jQuery("#shippingModeList li input[id=mode_livraison_select1]").attr("checked"))
		{form_used = "frmFacturation";}
	else if (jQuery("#shippingModeList li input[id=mode_livraison_select2]").attr("checked"))
		{form_used = "formMagasin";}
	else if (jQuery("#shippingModeList li input[id=mode_livraison_select5]").attr("checked"))
		{form_used = "formKiala";}
	else {jQuery("#Erreur_livreur").css("display","block");}	
	
	if (jQuery("#checkCadeau").attr("checked"))
		{document.forms[form_used].info_cadeau.value = 1}
		
	if(typeof(pageTracker)!="undefined") pageTracker._linkByPost(document.forms[form_used], false);
	BBTool_formPost(form_used, false);
		
}

function ReloadLivraison (formulaire) {

	if (formulaire != 'formMagasin')
	{
		jQuery("#"+formulaire+" input[name=reload]").val("1");
		jQuery("#"+formulaire+" input[name=validation]").val("0");
		jQuery("#"+formulaire+" input[name=mode_livraison]").val( jQuery("#shippingModeList input[name=mode_livraison]").val() );
		PostFormLivraison();
	}
	else
	{ 	if (jQuery("#"+formulaire+" #pays_mag").val() == "FR")
			jQuery("#"+formulaire+" #p_departement").css("display","block");
		else
		{
			jQuery("#"+formulaire+" #p_departement").css("display","none");
			BBMagasin(jQuery('#shopAdrList #pays_mag').val(), jQuery('#shopAdrList #departement').val(), '');
		}
	}
	
	
}

function resetSearchBlock() {
	jQuery("#search_block_form input").val("");
	jQuery("#search_block_form").submit();
}

/* Verification des cheque cadeaux */
function Controle_cheque() {
	jQuery("#verifie_cheque").css({display: "none"});
	jQuery("#waiting").css({display: "block"});

	if (BBVars.https)
		var page_url = BBVars.pageURL;
	else
		var page_url = BBVars.pagesURL;

	$.get(
		page_url + "ajax/cheques_cadeaux.cfm?cheque_id=" + jQuery("#numero_cheque").val(),
		function(data) {	
							if (data.search(/ERROR_OVER/i) >= 0)
								jQuery("#erreur_cheque_existe_over").css({display: "block"});
								
							else if (data.length < 155)
								jQuery("#erreur_cheque_existe").css({display: "block"});							
								
							else
							{	jQuery("#erreur_cheque_existe_over").css({display: "none"});
								jQuery("#erreur_cheque_existe").css({display: "none"});
								jQuery("#liste_cheques_OK").html(data);
								jQuery("#liste_cheques_OK").css({display: "block"});
								jQuery("#Total_chequecadeaux").trigger("change");
							}
							jQuery("#verifie_cheque").css({display: "block"});
							jQuery("#waiting").css({display: "none"});
						}
	);
}

function supprimer_cheque(numero_cheque){
	if (BBVars.https)
		var page_url = BBVars.pageURL;
	else
		var page_url = BBVars.pagesURL;
		
	$.get(		page_url + "ajax/cheques_cadeaux.cfm?delete&cheque_id=" + numero_cheque,
				function(data) { 	jQuery("#erreur_cheque_existe_over").css({display: "none"});
									jQuery("#erreur_cheque_existe").css({display: "none"});
									jQuery("#liste_cheques_OK").html(data);
									jQuery("#Total_chequecadeaux").trigger("change");}
			);

}

/* Popup cheque cadeau index */
function popup_CKDO() {
	jQuery.get(
		BBVars.pagesURL + "blocks/popup_CKDO.cfm",
		function(data) { if(data.length > 0) BBTool_openMsgBox(data, true)}
	);

}

function popup_CallCKDO() {
	initBBCheckbox();
	jQuery("#popupCKDOMailForm :input").bind("keypress", function( event ) {
		if(event.keyCode == 13) {
			event.preventDefault();
			BBTool_formPost('popupCKDOMailForm',true);
		}
	});
}

/* Gestion quantite fiche cheque cadeaux */
function QtyCheque(action, itemID) {

	switch(action) {
		case "minus":
			var currentQty = eval(jQuery("#quantite_souhaitee_"+itemID).val());
			if(currentQty - 1 > 0) {
				currentQty -= 1;
				jQuery("#prodQty"+itemID).html(currentQty);
				jQuery("#quantite_souhaitee_"+itemID).val(currentQty);
			}
			break;
		case "plus":
			var currentQty = eval(jQuery("#quantite_souhaitee_"+itemID).val());
			
			if(currentQty + 1 <= BBSettings.prodMaxQty) {
				currentQty += 1;
				jQuery("#prodQty"+itemID).html(currentQty);
				jQuery("#quantite_souhaitee_"+itemID).val(currentQty);
			} 
			break;
	}
}
