
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 ).css({opacity: 0, display: "block"}).animate({opacity: 1});
			if(i==2) initRatingBar(jQuery("#ratingsPage1"), 100);
		}
	}
}
function BBchangeMagasin(livraison,pays,departement,ville){
	var addUrl = "";
	addUrl += "?livraison=" + livraison;
	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?livraison=1&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()",2000);}
function sendPwd_callback(data) {setTimeout("BBTool_closeMsgBox()",2000);}
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();
	
		  		BBCart('setAttrib', item + row, setAttrib_callBack,1);
		  		
		  		jQuery("#lienColor" + color).removeClass();
				jQuery("#lienColor" + color).addClass("colorSelect");
				jQuery("#liTaille" + color).show();
				
				if(typeof jQuery("#cross_prod_layer" + color) != "undefined")
					jQuery("#cross_prod_layer" + color).show();
				
				jQuery.get(
					BBVars.pagesURL 	+"ajax/photos.cfm"
					+"?prodID="			+BBVars.currentProdID
					+"&colorID="		+color,
					function(data) { BBTool_openMsgBox(data, true);}
				);		
				
				jQuery("#social_layer .link_fb").css("display", "none");
				jQuery("#FBL"+colorSelected).css("display", "block");
					
		  	}
		  	
		});
		
	} 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;
	
		  		var row = jQuery("#quickBuytaille"+color).val();
	
		  		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);
	if(jQuery("#wishDetail_table tr").length<=3) {
		jQuery("#whishListLayer").animate({height: 0}, function() {
			jQuery(this).remove();
		});
		jQuery("#emptyWhishListLayer").css({opacity: 0, display: "block"}).animate({opacity: 1});
	} else
		delTR("#ligne"+panier_save_id, "55px");

}
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 BBTab_switchDsp ( tabN ) {


}

function sizeGuid() {
	$.get(
		BBVars.pagesURL + "ajax/guide_tailles.cfm",
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function cleanGuid(prodID) {
	$.get(
		BBVars.pagesURL + "ajax/guide_entretien.cfm?prodID=" + prodID,
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function makingOf() {
	$.get(
		BBVars.pagesURL + "ajax/making_of.cfm",
		function(data) {BBTool_openMsgBox(data, true)}
	);
}

function jeux_MPA() {
	$.get(
		BBVars.pagesURL + "ajax/jeux_MPA.cfm",
		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");
}

var iteration = 0;

function getOptions_callback(data) {
	BBVars.currentProdQty = 1;
	BBCart('setAttrib', 'item'+$(".sizesList", data).attr("prodID")+'_1',1,'', setAttrib_callBack);
}

function QuickBuyCallback(getOptions,product_formID) {
	BBCart(getOptions,product_formID);
	BBTool_toolTip();
	BBGallery("build", "quickBuyGallery");
}

function setAttrib_callBack(data) {

}

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 newAccountCallback( error ) {

	jQuery("#new_account_form").attr("check", 
			(jQuery("#new_account_form .error").length>0) ? false : true
	)
	
	var dspError = !(jQuery("#new_account_form").attr("check")=="true") ? true : false;

	if(dspError) jQuery("#btn_layer div.next_btn").BBFadeOut();
	else jQuery("#btn_layer div.next_btn").BBFadeIn();
	
}

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);}
	);
	
}

function initListMenu( target, alpha, obj ) {

	var html = "<ul class='menuList'>";
		html += "<li><a href='javascript:getFicheSil("+obj.attr("rev")+")'>"+BBLabels.label_buy+"</a></li>";
		html += "<li><a href='"+obj.attr("href")+"'>"+BBLabels.label_discover+"</a></li>";
		html += "<li><a href='"+BBVars.pagesURL+"silhouettes.cfm'>"+BBLabels.label_inspire+"</a></li>";
		html += "<li><a href='javascript: BBSendMail(\"select\", "+obj.attr("rev")+")'>"+BBLabels.label_share+"</a></li>";
		html += "</ul>";
		
	target.append(jQuery(html).css("opacity", ((typeof(alpha)=="undefined"||alpha==0)?0:1)));
	jQuery("ul.menuList a", target).css("backgroundColor", "#"+obj.attr("rel"));

}

function initMainMenu() {

	jQuery(".mainCatLayer").css({opacity: 0})
	jQuery(".mainCatLayer .searchLayer").append( jQuery("form#search_block_form").clone() );

	var nextXPos = new Array();
		nextXPos[0] = 7;
		
	jQuery(".mainCat").each( function( index ) {
		
		if(jQuery(".mainCatLink", this).attr("id")=="catLink0"||jQuery(".mainCatLink", this).attr("id")=="catLink13") {
			jQuery(this).remove();
		} else {
			jQuery(this).bind("mouseenter", function( event ) {
				jQuery('embed, object, select').css({ 'visibility' : 'hidden' });
				jQuery(".mainCatLayer", this)
						.css({
							display: 	"block",
							left: 		"-" + nextXPos[index] + "px"
						})
						.stop().animate({opacity: 1});
				jQuery(this).css({backgroundColor: "#b4b5b7"});
			}).bind("mouseleave", function( event ) {
				jQuery(".mainCatLayer", this).stop().animate({opacity: 0}, function() {jQuery(this).css("display", "none");});
				jQuery(this).css({backgroundColor: "#939598"});
				jQuery('embed, object, select').css({ 'visibility' : 'visible' });
			});
			
			nextXPos[index+1] = nextXPos[index] + eval(jQuery(this).outerWidth());
			
		}
		
	});

}

/*--------------------------------- INIT FUNCTIONS ---------------------------------*/

$(document).ready(function() {
	
	
	if(BBVars.currentPageName!="paiement") {
		checkClient();
		BBCart("check");
		BBTool_flash();
	}
	
	initMainMenu();
	//initDebug();
	BBTool_initRTForms();
	BBTool_toolTip();
	initTPMenu();
	initMailingBlock();
	initFilter();
	initCheckMail();
	initNavBtn();
	
	var BBTool_pageSizes 			= BBTool_getPageSize();
	var BBTool_pageScroll 			= BBTool_getPageScroll();
	
		BBVars.pageWidth 			= BBTool_pageSizes[0];
		BBVars.pageHeight 			= BBTool_pageSizes[1];
		BBVars.windowWidth 			= BBTool_pageSizes[2];
		BBVars.windowHeight 		= BBTool_pageSizes[3];
		BBVars.pageScrollX 			= BBTool_pageScroll[0];
		BBVars.pageScrollY 			= BBTool_pageScroll[1];
		
		BBVars.dataSendContentID	= ($(".dataSend").length>0) ? $(".dataSend").attr("id") : "";
	
	if(BBVars.currentPageName=="univers" || BBVars.currentPageName=="selection") {
	
		initComment();
	
	} else if(BBVars.currentPageName=="index") {
	
		homepageInit();
		//jeux_MPA();
		
	} else if(BBVars.currentPageName=="fiche") {
		
		jQuery("#FBL"+BBVars.currentColorID).css("display", "block");
		
		InitPictoRea();
		initComment();
		jQuery("#gallery li.BBTool_galMainImg").bind("mouseenter", function() {
			jQuery("#zoom_label").stop().animate({opacity: 0}, 100, function() {jQuery(this).css("display", "none");});
		}).bind("mouseleave", function() {
			jQuery("#zoom_label").css("display", "block").stop().animate({opacity: 1});
		});

	} else if(BBVars.currentPageName=="panier") {
		
		hideDelivery();
		
	} else if(BBVars.currentPageName=="livraison") {
	
		hideCheckoutStep(2);
		
	} else if(BBVars.currentPageName=="compte_perso") {
		var options = {
			header:			'strong', 
			autoheight:		false,
			active: 		false
		}
		$("#account_list").accordion(options);
		
	} else if(BBVars.currentPageName=="paiement") {

		jQuery("#factAdrBtn").bind("click", function(e) {
			e.preventDefault();	
			jQuery("#factAdrBtn, #formValidation span.adressContent").stop().animate({opacity: 0}, function() { jQuery(this).css("display", "none"); });
			jQuery("a#factAdrCancelBtn, a#factAdrOKBtn, #addressInfo .input").css("display", "block").stop().animate({opacity: 1});
		});
		
		jQuery("a#factAdrCancelBtn").bind("click", function(e) {
			e.preventDefault();
			jQuery("#factAdrBtn, #formValidation span.adressContent").css("display", "block").stop().animate({opacity: 1});
			jQuery("a#factAdrCancelBtn, a#factAdrOKBtn, #addressInfo .input").stop().animate({opacity: 0}, function() { jQuery(this).css("display", "none"); });
		});
	}
});

// COMPTE - A REVOIR
function getMyOrders() {
	
	jQuery.get(BBVars.pagesURL + "compte_suivi.cfm?isAjax", function(data) {jQuery("#myOrders_layer").html(data);});
	
}

function updCiv() {
	jQuery('#civilite').val(jQuery('#addressInfo input:checked').val());
}

function updFactAdr( upd ) {

	var inputs = jQuery("#formValidation .input:neq(.radio)");
	var radioValue = jQuery("#formValidation .radio:checked").next().html();
	var labels = jQuery("#formValidation span.adressContent");

	if( upd ) {
		inputs.each( function(i,el) {
			labels.eq(i).text( jQuery(this).attr("value") );
		});
		jQuery("#civ").html(radioValue);
		jQuery("a#factAdrCancelBtn").trigger("click");
	}

	setTimeout("jQuery('#accountErrorMsgLayer').animate({opacity: 0})", 2000)

}

/*--------------------------------------------------------------------*/
// 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 ) {

	if(typeof panier_change_id != "undefined") {
		jQuery.get(BBVars.pagesURL 		+ "fiche.cfm?isAjax=true"
				+"&produit_id="			+ prodID
				+"&cat_id="				+ catID
				+"&coul_att_detailID="	+ colorID
				+"&panier_change_id="	+ panier_change_id
				,function(data) {BBTool_openMsgBox(data, true);}
			);
	}else {
		jQuery.get(BBVars.pagesURL 		+ "fiche.cfm?isAjax=true"
				+"&produit_id="			+ prodID
				+"&cat_id="				+ catID
				+"&coul_att_detailID="	+ colorID
				
				,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) {
	//alert('1');
	document.forms['product_form'].elements['page'].value = page;
	if(document.location) document.forms['product_form'].action = document.location;
	document.forms['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("mandatory",true);
			jQuery("#hidden_asterisk").css({display: "inline"});
		}
	} else {
		jQuery('#mobile').attr("mandatory",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(".pageNav_list li").removeClass("selected");
				jQuery(this).addClass("selected");
				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 change_adresse(formulaire){
	if(document.forms[formulaire].elements['infos_adresse_livraison'].value != '') {
		window.location = 'livraison.cfm?adresse='+document.forms[formulaire].elements['infos_adresse_livraison'].value;
	}
}

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);}
	)

}

function initCheckMail() {
	var initChecked = jQuery("#block_mailing input:checkbox:checked").length;
	if(initChecked == 0) {
		jQuery("#block_mailing input:checkbox").bind("click", function(event) {
			var testChecked = jQuery("#block_mailing input:checkbox:checked").length;
			if(testChecked != 0) {
				jQuery("#mailing_options a.white_btn").css({display: "block"});
			} else {
				jQuery("#mailing_options a.white_btn").css({display: "none"});
			}
		});
	} else {
		jQuery("#mailing_options a.white_btn").css({display: "block"});
	}
	
}

function initNavBtn() {

	jQuery(".navBtn").bind("click", function( e ) {
		e.preventDefault();
		jQuery('html,body').stop().animate({scrollTop: jQuery("#"+jQuery(this).attr("target")).offset().top-35}, "slow");
	
	});

}
