function Timer1 (url){window.location=url;}
function changeCountry(url,value){window.location.replace(url+"?calculport_country_id="+value);}
function incdecchamp (champ,incdec){$("input[name$="+champ+"]").val(parseInt($("input[name$="+champ+"]").val())+incdec);if(parseInt($("input[name$="+champ+"]").val())<0)$("input[name$="+champ+"]").val(0);}
function incdecchampbrid (champ,incdec,max){$("input[name$="+champ+"]").val(parseInt($("input[name$="+champ+"]").val())+incdec);if(parseInt($("input[name$="+champ+"]").val())<0) $("input[name$="+champ+"]").val(0);if(parseInt($("input[name$="+champ+"]").val())>max) $("input[name$="+champ+"]").val(max);
		}
function couponpopupWindow(url){window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')}
function infobulle ( e, content ,image,posy){
	if(posy == 0) posx = $(window).width()-e.pageX-220;
	else posx = $(window).width()-e.pageX-posy;
	posy = $(window).height()-e.pageY+30; 
	picto = "";
	if( image != "" ) picto = "<img src='images/v2/"+image+"' style='top:5px;left:5px;float:left;margin:07px;'/>";
	div = "<div id='chronobulle' style='position:absolute;bottom:"+(posy)+"px;right:"+(posx)+"px;min-height:30px;min-width:100px;max-width:320px;border:1px solid #249cf3;background:#FFF;padding:5px;color:#000000;font-size:11px;font-family: Verdana, sans-serif;'><img src='images/v2/bitogno1.png' style='position:absolute;bottom:-16px;left:90px;'/>"+picto+content+"</div>";
	$("body").append(div);
}
function popupWoodies(url) {
	window.open(url, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=750,height=650,screenX=150,screenY=150,top=150,left=150');
}
function popupAssur(url) {
	window.open(url, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=985px,height=650,screenX=150,screenY=150,top=150,left=150');
}
function popupWindow(url) {
	window.open(url, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150');
}
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=600,left = 313,top = 177');");
}
function go(url, tool, menu, loc, scroll, resize, status, left, top, width, height) {
	OpenWin = this.open(url, "CtrlWindow", "toolbar=" + tool + ",menubar=" + menu + ",location=" + loc + ",scrollbars=" + scroll + ",resizable=" + resize + ",status=" + status + ",left=" + left + ",top=" + top + ",width=" + width + ",height=" + height);
}
function PopupCentrer(page, largeur, hauteur, options) {
	var top = (screen.height - hauteur) / 2;
	var left = (screen.width - largeur) / 2;
	window.open(page, "", "top=" + top + ",left=" + left + ",width=" + largeur + ",height=" + hauteur + "," + options);
}
function subscribe_newsletter ( formu )
{
	var html = $.ajax({
		type : 'POST',
		url: "news-letter.php",
		data : "email="+formu.email.value+"&format="+formu.format.value+"&liste="+formu.liste.value+"&action="+formu.action.value,
		async: false
	}).responseText;
	alert(html);
	formu.email.value = '';
	return false;
}     

function ClearNewsletter() {
	if (document.getElementById('email').value == "Inscription newsletter") {
		document.getElementById('email').value = "";
	}
}
function ClearSearch() {
	var msg = $('#inputString').val();
	if (msg == "Trouvez un article..." || msg == "Suche..." || msg == "Keyword..." || msg == "Buscar...") {
		// document.getElementById('inputString').value = "";
		$('#inputString').val("");
	}

}

function addHandler(object, event, handler) {
	if (typeof object.addEventListener != 'undefined') object.addEventListener(event, handler, false);
	else if (typeof object.attachEvent != 'undefined') object.attachEvent('on' + event, handler);
	else {
		var handlersProp = '_handlerStack_' + event;
		var eventProp = 'on' + event;
		if (typeof object[handlersProp] == 'undefined') {
			object[handlersProp] = [];
			if (typeof object[eventProp] != 'undefined') object[handlersProp].push(object[eventProp]);
			object[eventProp] = function (e) {
				var ret = true;
				for (var i = 0; ret != false && i < object[handlersProp].length; i++)
					ret = object[handlersProp][i](e);
				return ret;
			};
		}
		object[handlersProp].push(handler);
	}
}

var url_appel;
var Offset_X = -10;
var Offset_Y = -30;
var loadingImage = new Image();
var okImage = new Image();
var secure = document.domain.split('.');
if(secure[0] == "secure"){
        loadingImage.src = "https://secure.woodbrass.com/images/loading.gif";
        okImage.src = "https://secure.woodbrass.com/images/ok.gif";
}
else{
loadingImage.src = "/images/loading.gif";
okImage.src = "/images/ok.gif";
}
if (window.opera || (navigator.userAgent.indexOf('MSIE') > -1)) {
	getM_x = function () {
		return event.clientX + document.body.scrollLeft;
	};
	getM_y = function () {
		return event.clientY + document.body.scrollTop;
	};
} else {
	addHandler(document, 'mousemove', function (e) {
		x = e.pageX;
		y = e.pageY;
	});
	getM_x = function () {
		return x;
	};
	getM_y = function () {
		return y;
	};
}


var currentSelection = 0;
var currentUrl = '';
var rechLiId = 0;
var rechLi = -1;
function lookuplibrairie() {
	var var0 = $("input[name='attributs_valeur0']").val();
	var var1 = $("input[name='attributs_valeur1']").val();
	var var2 = $("input[name='attributs_valeur2']").val();
	alert('yo' + var0 + var1 + var2 + ''); 
	$.post("SearchSuggest.php", {
		queryString: "" + inputString + ""

	}, function (data) {
	}, function () {
	});
}
function lookupLi(str){
	if (str.length > 2){
		$.post("LSearch.php","search="+str,function(data){
			if(data.length>0){
				$("#RLSearch").empty().html(data).show();
				$("#RLSearch li").hover(function(){
					$("#RLSearch li").removeClass("itemhover");
					$(this).addClass("itemhover");
					rechLi = $(this).attr('pos');
					rechLiId = $(this).attr("id");
				},function(){
					$(this).removeClass("itemhover");
					rechLiId = 0;
				});
				$("#RLSearch li").click(function(){
					var aff = $("#RLSearch li").eq(rechLi).html();
					$("#LSearch").val(aff).attr("rech",rechLiId);
					$("#RLSearch").hide();
					$(".attr").trigger("change");				
				});
			}
		});
	} else {
		$("#RLSearch").hide();
		rechLiId = 0;
		$("#LSearch").attr("rech","");
	}

}
function lookup(inputString, inputcateg) {
	if (inputString.length < 2) {
		$('#suggestions').hide();
	} else {
		if (inputString.length > 1) {
			$.post("SearchSuggest.php", {
				queryString: "" + inputString + ""
			}, function (data) {
				if (data.length > 0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
					$("#autoSuggestionsList ul li").hover(function () {
						$(".boxImage").hide();
						$("#autoSuggestionsList ul li").removeClass("itemhover");
						$("#autoSuggestionsList ul li a").removeClass("itemhover");
						$("div", this).show('fast');
						$(this).addClass("itemhover");
						currentUrl = $("a", this).attr("href");
						currentSelection = $(this).attr("id").substring(2);
					}, function () {
						$(this).removeClass("itemhover");
						currentUrl = '';
					});
				}
			});
		}
	}
}

// FONCTION DE VALIDATION
function validate_coupon(customerId) {
	var inputString = $("input[name='gv_redeem_code']").val();
	if (inputString.length > 3) {
		$.post("validation_coupon.php", {
			queryString: "" + inputString + "",
			cid: "" + customerId + ""
		}, function (data) {
			if (data.length > 0) {
				$('.msgError').html(' ');
				$('.msgError1').html(data);
			}
		});
	} else $('.msgError1').html('');
}

var field_size = 2;
function bonmail(mailteste) {
	var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
	if (reg.test(mailteste)) {
		return (true);
	} else {
		return (false);
	}
}
function validate_referral(customerId) {
	var inputString = $("input[name='customer_referred']").val();
	if (inputString.length > 0) {
		$.post("validation_parrain.php", {
			referred: "" + inputString + "",
			cid: "" + customerId + ""
		}, function (data) {
			if (data.length > 0) {
				$('.msgError2').html(data);
			}
		});
	} else $('.msgError2').html('');
}
function fill(thisValue) {
	$('#inputString').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}

function refreshCartView(){
	$.ajax({
		url:"getShopping_cart.php?cont=headShopping",
		success:function(str){
		$("#headShopping").html(str);
	}       
	});
	$.ajax({
		url:"getShopping_cart.php?cont=CartUpdate",
		success:function(str){
		$("#CartUpdate").html(str);
	}
	});
}
/*
function refreshWoodies(){   // refresh aussi le total et les fdp
	var calculport=$("#PanierDroite select[name='calculport_country_id']").val();
	$.ajax({
		url:"getWoodies.php" ,
		data: "calculport_country_id=" + calculport ,
		success:function(woo){
		if(woo!=''){
			var arrayData = woo.split("--");
			$("#PanierGauche .blocWoodies").empty().html(arrayData[0]);
			$("#PanierGauche .livFree").empty().html(arrayData[1]);
			$("#MonPanierBas .sousTab21").empty().html(arrayData[2]);
			$("#MonPanierBas .sousTab22").empty().html(arrayData[3]);
		}
	}
	});
}
*/
function ChangeBackgroundHome(color,img) {
	$('body').css('background', '#'+color + ' url("'+img+'") no-repeat top center');
}

var id_tc;
var position=1; // postion de la diapo en cours
var color="#000";
imgSrc=new Array();  // on cree un tableau qui permettra de stocker les noms	
imgColor=new Array(); // et les noms des imgs
function change_diapo() {
	$('.apercu_diapo').css('opacity', '0.5');
	$('.apercu_diapo').css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)');
	$('.apercu_diapo').css('filter', 'alpha(opacity=50)');
	var nb_elem=$(".apercu_diapo").length;
	if (nb_elem>1) 
	{
		if(position==nb_elem) position=0;
		var cont=$(".cont_anime").eq(position).html();
		$("#Cont_new").html(cont);
		
		ChangeBackgroundHome(imgColor[position],imgSrc[position]);
		$(".apercu_diapo").eq(position).css('opacity', '1');
		$('.apercu_diapo').eq(position).css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)');
		$(".apercu_diapo").eq(position).css('filter', 'alpha(opacity=100)');
		position++;
	}
};

var position_pub=1;
var id_tpub;

function change_pub() {

	var nb_elem=$("#Corps input[name='nb_pub']").val();
	nb_elem++;

	if (nb_elem>0) 
	{
		if(position_pub==nb_elem)
		{
			position_pub=0;
			var cont=$("#Corps img.container_slim").attr('src');
			cont=cont.replace('_fr2.','_fr.');
			$("#Corps img.container_slim").attr('src',cont);
		} else {
			var cont=$("#Corps img.container_slim").attr('src');
			if (position_pub==2)cont=cont.replace('_fr1.','_fr2.');
			if (position_pub==1)cont=cont.replace('_fr.','_fr1.');
			$("#Corps img.container_slim").attr('src',cont);
		}
		position_pub++;	
	}	
};

function finish_diapo() {
	change_diapo();
	id_tc=setInterval(change_diapo,6000);
};
/*
function envoi_ticket_call() {
	var formArg=$("#FormCall>form[name='contact_us'] input")
	var returnString="";
	formArg.each(function(i){
		returnString+=escape($(this).attr('name'))+"="+escape($(this).val())+"&";
	});
	formArg=$("#FormCall>form[name='contact_us'] textarea");
	returnString+=escape(formArg.attr('name'))+"="+escape(formArg.val())+"&";
	formArg=$("#FormCall>form[name='contact_us'] select");
	returnString+=escape(formArg.attr('name'))+"="+escape(formArg.val());
	$.ajax({
		type:"POST",
		url:"ticket_call.php?action=send",
		data:returnString,
		success:function(str){
			$("#MsgAjout").html(str);
		}
	});
};
*/
var atime=0;
function compte(temps){
        if (atime==0)
        {
                var msconso=temps;
                atime=msconso;
        } else {
                var msconso=atime;
                var s_restantes = msconso; 
                var m_restantes = s_restantes / 60;
                var H_restantes = m_restantes / 60;
                s_restantes = Math.floor(s_restantes % 60); //Secondes restantes
                m_restantes = Math.floor(m_restantes % 60); //Minutes restantes
                H_restantes = Math.floor(H_restantes % 24); //Heures restantes

                var texte = +H_restantes+ "h" +m_restantes+ "mn" +s_restantes;
                $("#StupidDeal span.time").html(texte);
                $("#blocStupid span.time").html(texte);
        }
        atime=atime-1;
}

$(document).ready(function () {
	
	//GESTION PUB UNIVERS
	var tempo1=5000; // Temps entre chaque changement decontenuie
//	setInterval("change_pub()",tempo1);

	// AUTOCOMPLETE
	$("#inputString").attr('autocomplete', 'off');
	$("#txtSearch").attr('autocomplete', 'off');
	// AFFICHAGE PREMIER FOND HOME
	if($("#choix_cont img:first-child").length > 0 ) {
		var src1=$("#choix_cont img:first-child").attr("src").replace("small_","fond_");
		var color=$("#choix_cont input").eq(0).attr("value");
		ChangeBackgroundHome(color,src1);
	}
	var newHeight = $("#acceProduit").height()+243;
	if (!$("#acceProduit").length){newHeight -= 50;}
	// limite taille window 5 elements
	if (newHeight>740){
		newHeight = 740;
	}
	$("#FancyAcce").fancybox({
		'centerOnScroll'    : false,
		'hideOnContentClick': false,
		//'opacity': 0.5,
		'overlayOpacity': 0.9 ,
		'padding'           : 0,
		'frameWidth'        : 550,
		//'frameHeight'       : newHeight,
		'callbackOnShow'    : function(){
		$(".spr182").click(function(){$("#fancy_close").trigger("click");});
		$("#InfoProd .hidden").remove();
		$("#fancy_div").css({"background":"none"});
	}
	});
	
	$("#FancyForm").fancybox({
		'centerOnScroll'    : false,
		'hideOnContentClick': false,
		'padding'           : 10,
		'frameWidth'        : 830,
		'frameHeight'       : 400,
		'callbackOnShow'    : function(){
		$(".spr182").click(function(){$("#fancy_close").trigger("click");});
		$("#InfoProd .hidden").remove();
		$("#fancy_div").css({"background":"none"});
	}
	});
	/* PANIER AJAX */
	// PANIER AJOUTER
	// product_info
	
	$(".boxAjouter input[type='submit']").click(function(){
		if(($(".pDS").length)){	
			if(!(ConfirmStock())){
				return false;
			}
		}
		$.ajax({ 
			type: "GET", 
			url: "Ajax2.php",
			data: "products_id="+$("input[name='products_id']").val()+"&cart_quantity="+$("input[name='cart_quantity']").val()+"&action="+$("input[name='action']").val(),
			success:function(){
			refreshCartView();
			$.get("createWin.php?products_id="+$("input[name='products_id']").val()+"&qtte="+$("input[name='cart_quantity']").val(),function(content){
				var arraySplit = content.split("---");
//				var trip=arraySplit[0];
				
				if(($("#acceProduit").length)){
					if ($("#APCopy").length){
						$("#APCopy").remove();
					}
					var prep = '<div class="hidden"><div id="APCopy"><div id="MsgAjout"></div></div></div>';
					$(prep).appendTo("#InfoProd");	
					$(arraySplit[2]).appendTo("#MsgAjout");	
					var ok = '<img width="18px" height="18px" src="/images/v2/v.png" class="spr41 hidden" />';
					$("#APCopy .td6").append(ok);	
					var nBtn = '<a href="/shopping_cart.php"><img width="50px" height="50px" alt="panier" src="images/v2/bout_noir_pan.gif"></a>';
					var nbr = $("#APCopy tr").length;
					$("#APCopy tr").each(function(e){
						if (e>11&&e!=nbr-1){ // garde le tr av bouton panier
							$(this).remove();
						}
					});
				} else {
					var prep = '<div class="hidden"><div id="APCopy"><div id="MsgAjout"></div></div></div>';
					$(prep).appendTo("#InfoProd");
				}
				$("#MsgAjout").prepend(arraySplit[0]);
				if(!($("#acceProduit").length)){$("#ProdCons").remove();}
				$("#InsertQ").html($("input[name='cart_quantity']").val());
				$("#MsgAjout .td5 span span").remove();


				var size = 243+$("#acceProduit").height();
				if(size > 740 ) size = 740;
				
				//$("#MsgAjoutFd").css('height',(size+100)+'px');
				$("#FancyAcce").trigger("click");
				
			});
		}
		});	
		$(".headerReplace").fadeOut("normal");
		return false;
	});
	
/*   CONTACTER TELECONSEILLER A PARTIR FP	
	//CLICK TO MAIL
	$("#ClickToCall .CTCtab .mail,#ClickToCall .CTCtab").click(function(){
		var id_produit=$("#produit input[name='products_id']").val();
		var url_produit=$("#ref>a").attr('href');
		if (id_produit){
			$.ajax({ 
				type: "GET", 
				url: "ticket_call.php",
				data: "conseille="+$("#ClickToCall .conseillerCall input[name='conseiller']").val()+"&id_produit="+id_produit+"&url_produit="+url_produit,
				success:function(content){

				if (content.indexOf("content_redirect")==-1) {
					content=content.replace("content_ajax","");
					var prep = '<div class="hidden"><div id="APCopy"><div id="MsgAjoutFd" style="height:357px;background:#FFFFFF url(\'http://www.woodbrass.com/images/v2/px_popup_conseillers.jpg\') repeat-x left bottom;"></div><div id="MsgAjout">'+content+'</div></div></div>';
					$(prep).appendTo("#InfoProd");				
					$("#FancyAcce").trigger("click");
					//var size = $("#FormCall").height();
					//alert('size '+size);
				}else {
					var currentLocation =  document.location.href;
					var lcurr=currentLocation.length;
					currentLocation = currentLocation.substring( 0,(currentLocation.lastIndexOf( "/" )+1))+"login.php";					
					content=content.replace("content_redirect","");

					//var prep = '<div class="hidden"><div id="APCopy"><div id="MsgAjoutFd" style="height:100px;background:#FFFFFF url(\'http://woodbrass.com/images/v2/px_popup_panier.png\') repeat-x"></div><div id="MsgAjout">'+content+'</div></div></div>';
					var prep = '<div class="hidden"><div id="APCopy"><div id="MsgAjoutFd" style="height:100px;background:#FFFFFF url(\'http://www.woodbrass.com/images/v2/px_popup_conseillers.jpg\') repeat-x left bottom;"></div><div id="MsgAjout">'+content+'</div></div></div>';

					
					$(prep).appendTo("#InfoProd");				
					
					$("#FancyAcce").trigger("click");
					$("#fancy_outer").css('height','100px');
					setTimeout("window.location='"+currentLocation+"';",4000);
					///window.location=currentLocation+"login.php";
				}
			}
			});	
		}
	});
*/

// acceProduit apres ajout av FANCYBOX
	$("#fancy_div .td6 input,.boxAjouter input,input[name='cart_quantity[]']").live('keyup',function(e){
		switch(e.keyCode){
		case 40:
			e.preventDefault();
			$(this).val($(this).val()-1);
			if ($(this).val()<0){
				$(this).val(0);
			}
			break;
		case 38:
			e.preventDefault();
			$(this).val($(this).val()*1+1);
			break;
		default:
		}
	});
	$("form[name='cart_quantity']").submit(function(){
		if (!($.browser.msie)){ 
			$("input").blur();
			return false;
		}
	});
	// product_listing et advanced search result
	$(".blocPrix a").click(function(){
		if($(this).attr("class") == "pDS"){
			if(!(ConfirmStock())){
				return false;
			}
		}	
		var arrayData = $(this).attr("href").split("?");
		$.ajax({
			type: "GET",
			url: "Ajax2.php",
			data: arrayData[1],
			success:function(){
			refreshCartView();
			var prod_id = arrayData[1].split("&");
			var qtte = prod_id[2];
			qtte = qtte.replace("cart_quantity","qtte");
			prod_id = prod_id[1];			
			$.get("createWin.php?"+prod_id+"&"+qtte,function(content){
				var arraySplit = content.split("---");
				$("#acceProduit").html(arraySplit[2]);
				if(($("#acceProduit").length)){
					if ($("#APCopy").length){
						$("#APCopy").remove();
					}
					var prep = '<div class="hidden"><div id="APCopy"><div id="MsgAjout"></div></div></div>';
					$(prep).appendTo("#InfoProd");
					var ok = '<img width="18px" height="18px" src="/images/v2/v.png" class="spr41 hidden" />';
					$("#APCopy .td6").append(ok);
					var nBtn = '<a href="/shopping_cart.php" ><img width="50px" height="50px" alt="panier" src="images/v2/bout_noir_pan.gif"></a>';

					var nbr = $("#APCopy tr").length;
					$("#APCopy tr").each(function(e){
						if (e>12&&e!=nbr-1){ // garde le tr av bouton panier
							$(this).remove();
						}
					});
					
				} else {
					var prep = '<div class="hidden"><div id="APCopy"><div id="MsgAjoutFd" style="background:#FFFFFF url(\'images/v2/px_popup_panier.png\') repeat-x"></div><div id="MsgAjout"></div></div></div>';
					$(prep).appendTo("#InfoProd");
				}

				$("#MsgAjout").prepend(arraySplit[0]);
				if(!($("#acceProduit").length)){$("#ProdCons").remove();}
				if(!(arraySplit[2])){$("#ProdCons").remove();}
				$("#InsertQ").html($("input[name='cart_quantity']").val());
				$("#MsgAjout").append(arraySplit[2]);

/*
				var nbr = $("#APCopy tr").length;
				$("#APCopy tr").each(function(e){
					if (e>12&&e!=nbr-1){ // garde le tr av bouton panier
						$(this).remove();
					}
				});
*/

				$("#MsgAjout .td5 span span").remove();
				var size = 243+$("#acceProduit").height();
				if(size > 740 ) size = 740;
				//$("#MsgAjoutFd").css('height',size+'px');
				$("#FancyAcce").trigger("click");
			});

		}
		});
		$(".headerReplace").fadeOut();
		return false;
	});	
	$("#PanierGauche .blocPlusMoins span").live("click",function () {
		var id = $(this).parent().parent().attr("id");
		var quantity = $("#" + id + " input[name=cart_quantity[]]").val();
		var prix = $(this).closest("tr").find("td:last").html().replace(",","");
		var prixUnit = parseFloat(prix)/quantity;
		var devise = prix.charAt(prix.length-1);

		var products_id = $("#" + id + " input[name=products_id[]]").val();
		if ($(this).attr("class")=="spanPlus"){
			quantity++;
		} else {
			if (quantity > 1) {
				quantity--;
			}
		}
		$("#" + id + " input[name=cart_quantity[]]").val(quantity);	
		document.cart_quantity.submit();
		
	});
	/*
	$("input[name='cart_quantity[]']").live("focus",function(){
		$(this).attr("oldValue",$(this).val());
	});
	
	$("input[name='cart_quantity[]']").live("blur",function(){
		var quantity = $(this).attr("oldValue");
		var prix = $(this).closest("tr").find("td:last").html().replace(",","");
		var prixUnit = parseFloat(prix)/quantity;
		var devise = prix.charAt(prix.length-1);
		var ligne_temps = this;
		var products_id = $(this).parent().find("input[name=products_id[]]").val();
		quantity = $(this).val();
		if(quantity <= 0 || isNaN(quantity)) 
		{
			quantity = 1;
			$(this).val(quantity);
		}

		$.post("Ajax2.php?action=update_product",{"products_id[]":products_id,"cart_quantity[]":quantity},function(){
			if(! isNaN(prixUnit )){$(ligne_temps).closest("tr").find("td:last").html((prixUnit*quantity).toFixed(2) + devise);}
			refreshCartView();refreshWoodies();
		}); 
	});
	// LOGIN ajax
	$("#headLogin form[name='login']").submit(function(){
		$("#headLoad").fadeIn();
		$.ajax({
			type:"POST",
			url:"getLogin.php?action=process",
			data:"email_address="+$("input[name='email_address']",this).val()+"&password="+$("input[name='password']",this).val(),
			success:function(str){
			$("#headLoad div").html(str);
			if ($("#headLoad .deconnection").length){
				$(".welcome").html($("#headLoad .welcome").html());
				$(".deconnection").removeClass("spr3").removeClass("hOng").html($("#headLoad .deconnection").html());
				$("#headLoad .hOng").insertAfter(".deconnection");
				
			}
			$(".headerReplace").fadeOut();
			refreshCartView();
		}
		});
		return false;
	});
	*/
	footersize = $("#BrassMiddle").height();
	$('.sprX1').css({
		height: footersize + 'px'
	});
	$("#Langues").css({
		display: "none"
	});
	// GESTION CONTAINER HOME
	var tempo=7000; // Temps entre chaque changement decontenu
	var tempoft = 12000; // Temps avant premier changement
	var temps_stop = 60000; // Temps avant exec suite a un click
	var id_ts;
	if (document.getElementById("Cont_new")) {
	


	/** ** MARGIN SOLUTION FOR IE 7 *** */
	
	if ($.browser.msie==true && parseFloat($.browser.version) == 7)
	{
			var margin =  ( $('#Corps').offset().left) ;
			$('.new').css({'margin-left':(520+margin)+'px'});
			$('.prix').css({'margin-left':(520+margin)+'px'});
			$('.flash').css({'margin-left':(50+margin)+'px'});
			/*
			 alert('instruction 2 :: '+margin);
			$('.new').css({'margin-left':(50+margin)+'px'});
			$('.flash').css({'margin-left':(520+margin)+'px'});
			$('.prix').css({'margin-left':(50+margin)+'px'});*/
		//	$('.pro').css({'margin-left':(520+margin)+'px'});
			$('.calqueLien').css({'margin-left':(20+margin)+'px'});
	}
	/*********** END **************** */

	/* GESTION CONTAINER HOME */
		$('.apercu_diapo').css('opacity', '0.5');
		$('.apercu_diapo').css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)');
		$('.apercu_diapo').css('filter', 'alpha(opacity=50)');
		$(".apercu_diapo").eq(0).css('opacity', '1');
		$('.apercu_diapo').eq(0).css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)');
		$(".apercu_diapo").eq(0).css('filter', 'alpha(opacity=100)');
		imgLoad=new Array();
		$(".apercu_diapo").each(function(j){
			var src1=$(this).attr("src").replace("small_","fond_");
			var color=$("#Anime input").eq(j).attr("value");
			imgLoad[j]=new Image();
			imgLoad[j].src=src1;
			imgSrc[j]=src1;
			imgColor[j]=color;
		});

		$(".apercu_diapo").click(function () {
			clearTimeout(id_ts);
			clearInterval(id_tc);
			var index=$(".apercu_diapo").index($(this));
			var cont=$(".cont_anime").eq(index).html();
			$('.apercu_diapo').css('opacity', '0.5');
			$('.apercu_diapo').css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)');
			$('.apercu_diapo').css('filter', 'alpha(opacity=50)');
			$(this).css('opacity', '');
			$(this).css('-ms-filter', '');
			$(this).css('filter', '');
			$("#Cont_new").html(cont);
			ChangeBackgroundHome(imgColor[index],imgLoad[index].src,index);
			position=index+1;
			id_ts=setTimeout(function () {
				id_tc=setInterval(change_diapo,tempo)
			}
			,temps_stop);
		});
		$(".apercu_diapo").hover(function () {
			clearTimeout(id_ts);
			//clearInterval(id_tc);
			var index=$(".apercu_diapo").index($(this));
			var cont=$(".cont_anime").eq(index).html();
			$('.apercu_diapo').css('opacity', '0.5');
			$('.apercu_diapo').css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)');
			$('.apercu_diapo').css('filter', 'alpha(opacity=50)');
			$(this).css('opacity', '');
			$(this).css('-ms-filter', '');
			$(this).css('filter', '');
			$("#Cont_new").html(cont);
			ChangeBackgroundHome(imgColor[index],imgLoad[index].src,index);
			//position=index+1;
			/*id_ts=setTimeout(function () {
			
			id_tc=setInterval(change_diapo,tempo)
			}
			,tempoft);*/
		});
		
		id_ts=setTimeout(function () {
			id_tc=setInterval(change_diapo,tempo);
		}
		,tempoft);
	};
	/* FIN GESTION CONTAINER */
	
	/* GESTION HOME ET UNIVERS */
	if ( $(".corpsLeft").parent().attr("id") == "Corps") { // CAS DE LA HOME
		var h1 = $("#Corps .corpsLeft").eq(0).offset().top - 4;
		var h2 = $("#Corps .corpsLeft").eq(2).offset().top - 4;
		var h3 = $(".corpsSpecial").offset().top - 4 + 60;
		var h4 = $(".divLink").offset().top + 20;



		$(".new").css("top", h1 + "px");
		$(".flash,.prix").css("top", h2 + "px");
		$(".special").css("top", h3 + "px");
		$(".calqueLien").css("top", h4 + "px");
		$(".firstCalque").each(function () {
			var id = $(this).attr("id");
			var spl = id.split("_");
			clas = spl[0];
			id = spl[1];
			if ($(this).attr("class").indexOf("calqueLien") == -1 && $(this).attr("class").indexOf("special") == -1) {
				$("#" + id + " ." + clas).addClass("clrBleu");
				var top_categ = $("#" + id + " ." + clas).offset().top - $("#" + id).offset().top;
				$("#" + id + "  .spr167").css("display", "block");
				$("#" + id + " .spr167").css("top", top_categ + "px");
			}
		});
		$(".firstCalqueLien").each(function () {
			var id = $(this).attr("id");
			var spl = id.split("_");
			clas = spl[0];
			id = spl[1];
			var val_categ = $("#pro ." + clas).html();
			$(".nomUnivLien", this).html(val_categ);
		});
	}
	$(".tooltip").mouseover(function () {
		if ($(this).attr("title") == "") return false;
		$("#Wood").append('<span class="infobulle"></span>');
		var bulle = $(".infobulle:last");
		bulle.append($(this).attr("title"));
		$(this).attr("title", "");
		var posTop = $(this).offset().top - $(this).height() - 20;
		var posLeft = $(this).offset().left + $(this).width() / 2 - (bulle.width() / 2) - 185;
		if ($(this).is("span"))
			bulle.css({'background-color': '#fff', 'z-index':'120','border':'1px solid #000','padding':'5px 10px','font-family':'Verdana,sans-serif','font-size':'12px'});
		else
			bulle.css("background", " url(../images/v2/info_bulle.png) no-repeat bottom right");
		bulle.css({
			left: posLeft,
			top: posTop - 20,
			opacity: 0
		});
		
		bulle.animate({
			top: posTop - 10,
			opacity: 0.99
		});
	});

	$(".tooltip a,span.tooltip").mouseout(function () {
		var bulle = $(".infobulle:last");
		$(this).attr("title", bulle.text());
		bulle.animate({
			top: bulle.offset().top + 10,
			opacity: 0
		}, 500, "linear", function () {
			bulle.remove();
		});
	}); 


	/* GESTION DES 4 1ERES BOXES */
	var onclick = 0;
	$("#Corps .corpsLeft .lienBox a").click(function () {
		onclick = 1;
		var id = $(this).parent().attr("id");
		var top_categ = $(this).offset().top - $(this).parent().offset().top;
		var clas_categ = $(this).attr("class").replace(" clrBleu");
		// var val_categ = $(this).html();
		if ($(".corpsLeft").parent().attr("id") == "Corps") { // CAS DE LA HOME
			var link=$("#"+clas_categ+"_"+id+" table a").eq(0).attr('href');
			window.location.href=link;
		} 
	});
	// HOME LIEN
	$(".corpsLeft .lienBox a").hover(function () {
		
		var clas_categ = $(this).attr("class");
		var top_categ = $(this).offset().top;
		var id = $(this).parent().attr("id");
		top_categ = top_categ - $(this).parent().offset().top;		
		$("#"+id+" a").css("color","");		
		$(this).css("color","#219DF5");
		$("#" + id + " a").removeClass("clrBleu");
		$("#" + id + " .spr167").css("display", "block");
		$("#" + id + " .spr167").css("top", top_categ + "px");
		$("div." + id).css("z-index", "");
		$("#" + clas_categ + "_" + id).css("z-index", "5");
		$(".calqueLien").css("z-index", "");
		$("#" + clas_categ + "_lien").css("z-index", "5");
		
	});
	/* FIN GESTION HOME */
	
	// UNIVERS LIEN
	$("#corpsUniv .lienBox a").hover(function () {
		var clas_categ = $(this).attr("class");
		var top_categ = $(this).offset().top;
		var id = $(this).parent().attr("id");
		top_categ = top_categ - $(this).parent().offset().top + 12;
		$("#" + id + " .spr167").css("display", "block");
		$("#" + id + " .spr167").css("top", top_categ + "px");
		$("div." + id).css("z-index", "0");
		$("#" + clas_categ + "_" + id).css("z-index", "5");
		
	}); 
	/* GESTIOn MEGAPACK HOVER */
	$(".h100").hover(function () {
		$(".grisfond span",this).removeClass("clrBlanc");
		$(".grisfond",this).css({'background-color': '#EEE', 'font-weight':'700', 'color': '#299BEE'});
	}, function () {
		$(".grisfond span",this).addClass("clrBlanc");
		$(".grisfond",this).css({'background-color': '#797979', 'font-weight':'500'});
	});	
	$(".persoLangue").click(function () {
		$(".headerReplace").hide();
		$("#Devise").hide();
		$("#Dessdevise").hide();
		var leftLangue = $(".persoLangue").offset().left-12;
		$("#Langues").css({
			left: leftLangue + "px",
			zIndex: "50"
		});
		$("#DessousLangues").css({
			left: leftLangue + "px",
			zIndex: "49",
			opacity: "0.6"
		});
		
		if($("#Langues").css('display') == 'none'){
			$("#Langues").slideDown("fast");
			$("#DessousLangues").slideDown("fast");
		}else{
			$("#Langues").hide();
			$("#DessousLangues").hide();
		}
	});
	$("#Langues").hover(function() {}
	,function() {
		$("#Langues").slideUp("normal");
		$("#DessousLangues").slideUp("normal");
	});
	$(".persoDevise").click(function () {
		$(".headerReplace").hide();
		$("#Langues").hide();
		$("#DessousLangues").hide();
		var leftLangue = $(".persoDevise").offset().left-5;
		$("#Devise").css({
			left: leftLangue + "px",
			zIndex: "50"
		});
		$("#Dessdevise").css({
			left: leftLangue + "px",
			zIndex: "49",
			opacity: "0.6"
		});
		if($("#Devise").css('display') == 'none'){
			$("#Devise").slideDown("fast");
			$("#Dessdevise").slideDown("fast");
		}else{
			$("#Devise").hide();
			$("#Dessdevise").hide();
		}
		
	});	
	$("#Devise").hover( function() {}
	,function () {
		$("#Devise").slideUp("fast");
		$("#Dessdevise").slideUp("fast");
	});
	var id_t1;
	$("#Liens .o_pass").hover(function () {
		$("#Liens .o_act").removeClass("o_act");
		$(this).addClass("o_act");
	});
	$("#Liens a").hover(function () {
		id_t1 = setTimeout(function () {
			$(".liste").hide();
		}, 100);
	}, function () {
		clearTimeout(id_t1);
	});
	$("#Image, #Woodbrass").hover(function () {
		$("#Liens a").removeClass("o_act");
		$(".liste").hide();
		$("#Langues").slideUp("normal");
		$("#DessousLangues").slideUp("normal");
		$("#Devise").slideUp("fast");
		$("#Dessdevise").slideUp("fast");
	});
	var id_t;
	var show = 0;
	$("#Liens a").hover(function () {
		var numLiens = $(this).attr("id").substring(7);
		id_t = setTimeout(function () {
			$("#Liste" + numLiens).show();
		}, 300);
	}, function () {
		clearTimeout(id_t);
	});
	$(".persoDejaC, .persoDejaC>a").click(function () {
		$("#Devise").hide();
		$("#Dessdevise").hide();
		$("#Langues").hide();
		$("#DessousLangues").hide();
		//$("#headAccount").hide();
		//$("#headLogin").hide();
		$("#headShopping").hide();
		if($("#DejaConsult").css('display') == 'none'){
		$("#DejaConsult").show();
		}else $("#DejaConsult").hide();
	});
	/*
	$(".deconnection, .deconnection>a").click(function () {
		$("#Devise").hide();
		$("#Dessdevise").hide();
		$("#Langues").hide();
		$("#DessousLangues").hide();
		$("#DejaConsult").hide();
		$("#headAccount").hide();
		$("#headShopping").hide();
		if($("#headLogin").css('display') == 'none'){
			$("#headLogin").show();
		}else $("#headLogin").hide();
	});
	$(".persoCompte, .persoCompte>a").click(function () {
		$("#Devise").hide();
		$("#Dessdevise").hide();
		$("#Langues").hide();
		$("#DessousLangues").hide();
		$("#DejaConsult").hide();
		$("#headLogin").hide();
		$("#headShopping").hide();
		if($("#headAccount").css('display') == 'none'){
			//$("#headAccount").show();
		}else $("#headAccount").hide();
	});
	 
	$("#PersoDte .persopanier, #PersoDte .persopanier>a").click(function(){
		$("#Devise").hide();
		$("#Dessdevise").hide();
		$("#Langues").hide();
		$("#DessousLangues").hide();
		$("#headAccount").hide();
		$("#headLogin").hide();
		$("#DejaConsult").hide();
		if($("#headShopping").css('display') == 'none'){
			$("#headShopping").show();
		}else $("#headShopping").hide();
	});	
	*/
	
	$("#Corps>*").hover(function () {
		$(".headerReplace").slideUp("normal");
	});
	$("#Anime").hover(function () {
		$(".headerReplace").slideUp("normal");
	});
	$("#PanierGauche input").keydown(function (e) {
		if (e.keyCode == 13) {
			$("form[name=cart_quantity]").submit();
		}
	});	
	$("#PanierGauche .spanOk").click(function () {
		$("#PanierGauche .sousTab2 span").slideDown("fast");
	});
	$(".liste").hover(function () {
		$(this).show();
	}, function () {
		$(".liste").fadeOut("fast");
		$(".liste>a.o_act").removeClass("o_act");
	});
	var ancienPathImgProd = $("img[name='image_prod']").attr("src");
	$(".txt").click(function () {
		$(".FlecheBasAff").slideUp("normal");
		var posTd = $(this).attr("id").substring(5);
		if ($("#FlecheBasAff" + posTd).css("display") != "block") $("#FlecheBasAff" + posTd).css({
			opacity: "0.9"
		}).slideDown("normal");
	});
	$(".FlecheBasAff").click(function () {
		$(this).slideUp("normal");
	});
	boolCategOuvert = 0;
	$("#UnivDeployer").click(function () {
		if (boolCategOuvert == 1) {
			$("#CategsCachees").fadeOut("normal");
			boolCategOuvert = 0;
			$(this).find("span").css({
				top: '0px'
			});
		} else {
			$("#CategsCachees").css({
				overflow: 'visible',
				height: '146px'
			});
			$("#CategsCachees").slideDown("normal");
			boolCategOuvert = 1;
			$(this).find("span").css({
				top: '125px'
			});
		}
	});
	$("#Historymanuf img").click(function () {
		var disp = $("#HistoryHide").css("display");
		if (disp == "none") {
			$(".contientHistory span").css({
				display: 'none'
			});
			$("#HistoryHide").slideDown("normal");
		} else {
			$(".contientHistory span").css({
				display: 'block'
			});
			$("#HistoryHide").fadeOut("normal");
		}
	});
	boolOuvert = 0;
	$("#UnivMarques img").click(function () {
		if (boolOuvert == 1) {
			$("#UnivMarques ul .esp").fadeIn("fast");
			$(".contientMarques span").slideDown("fast");
			
			$("div.contientMarques").css({overflow:'hidden',height:''});
			boolOuvert = 0;
		} else {
			$("#UnivMarques ul .esp").fadeOut("fast");
			$("div.contientMarques").css({
				overflow: 'visible',
				height: 'auto'
			});
			
			$(".contientMarques>span").fadeOut("fast");
			boolOuvert = 1;
		}
	});
	$("#MarquesCachees").click(function () {
		$(this).slideUp("normal");
		boolOuvert = 0;
	});
	var id_ttop5;
	$(".top5").hover(function () {
		var numTop = $(this).attr("id").substring(3);
		id_ttop5 = setTimeout(function () {
			$("#Top" + numTop + ">table").animate({
				opacity: "0.3"
			}, 1000);
			$("#Top" + numTop + " div").fadeIn("slow");
		}, 300);
	}, function () {
		clearTimeout(id_ttop5);
		$("> table", this).animate({
			opacity: "1"
		}, 500);
		$("> div", this).fadeOut("fast");
	});
		
	$("a.refCall").click(function () {
		$(".msgRefCall").show();
	});
	var widthComp = $("div#Comparateur table").width();
	$("div#Comparateur table").css({
		margin: "auto",
		width: widthComp
	});

	$("#RapidLinkD").hover(function () {
		var to=$("#footer").offset().top;
		var ha=$("#RapidLink").height();
		var diff=to-ha;
		if ($.browser.msie==true && parseFloat($.browser.version) == 7)
		{
			var margin =  ( $('#Corps').position().left) ;
			$("#RapidLink").css('margin-left',margin+'px');
			$("#RapidLink").css('left',0);
		}
		$("#RapidLink").css('top',diff+'px');
		$("#RapidLink").css('display','block');

	});
	$("#RapidLink").hover(function () {
	} , function () {
		$("#RapidLink").css('display','none');
	});

	
	$("#Financement .contFinan .logoFinan img").click(function () {
		var src_mn_img = $(this).attr("src").replace("off", "on");
		$("#Financement .contFinan .logoFinan img").each(function () {
			var new_src = $(this).attr("src").replace("on", "off");
			$(this).attr('src', new_src);
		});
		$(this).attr('src', src_mn_img);
	});
	var haut = $("#presProduitRight").height();
	var options = {
			zoomType: 'reverse',
			zoomWidth: 337,
			zoomHeight: haut,
			position: 'right',
			showEffect: 'fadein',
			hideEffect: 'fadeout'
	};

	$("#zzoooomm").jqzoom(options).hover(function(){
		$("iframe").fadeOut();
	},function(){
		$("iframe").fadeIn();
	});

	var optionsFancy = {
			'hideOnContentClick': false,
			'titleShow': false,
			'autoScale': false,
			'callbackOnShow':function(){
		$("#fancy_title").hide();
	}
	};

	$("#zzoooomm").fancybox(optionsFancy);
	$("a.zzoooomm").fancybox(optionsFancy);
	$("a.group").fancybox(optionsFancy);
	// GESTION TAILLE BANDE MIDDLE
	// ---------------------------------------------------------------------
	var HCleft = $("#ColonneDbleGch").innerHeight();
	var HCright = $("#presProduit").innerHeight() + 20;
	if (HCleft > HCright) {
		$("#ColonneMiddle").css("height", HCleft + "px");
	} else {
		$("#ColonneMiddle").css("height", HCright + "px");
	}
	// GESTION DE LA BOX ONGLET FICHE PRODUIT
	// ------------------------------------------------------------------------------------------------
	$("#acceProduit,#memeProduit,#avisProduit,#marqProduit,#finiProduit").css("display", "none");
	var Hacce = $("#acceProduit").height() + 80;
	var HMacce = Hacce - 35;
	var Hmeme = $("#memeProduit").height() + 40;
	var HMmeme = Hmeme - 35;
	var Hdesc = $("#descProduit").height()+40; 
	var Havis = $("#avisProduit").height() + 30;
	var HavisAudio = $("#avisAudio").height() + 30;
	var Hmarq = $("#marqProduit").height() + 50;
	var Hfini = $("#finiProduit").height() + 50;
	if ($.browser.msie==true && parseFloat($.browser.version) == 7)
	{
		if (document.getElementById("memeProduit")) Hmeme = document.getElementById("memeProduit").scrollHeight + 40;
		if (document.getElementById("avisProduit")) Havis = document.getElementById("avisProduit").scrollHeight + 30;
	}
	if (document.getElementById("acceProduit")) {
		$("#acceProduit").css("display", "block");
		$("#InfoProd").css("height", Hacce + "px");
		$(".calqueBlanc").css("height", HMacce + "px");
	}
	else if (document.getElementById("memeProduit")) {
		$("#memeProduit").css("display", "block");
		$("#InfoProd").css("height", Hmeme + "px");
		$(".calqueBlanc").css("height", HMmeme + "px");
	}
	else if (document.getElementById("avisProduit")) {
		$("#avisProduit").css("display", "block");
		$("#InfoProd").css("height", Havis + "px");
		$(".calqueBlanc").css("height", "0px");
	} else {
		$("#marqProduit").css("display", "block");
		$("#InfoProd").css("height", "335px");
		$(".calqueBlanc").css("height", "0px");
	}
	$("#InfoProd li,#DescriProd li a").click(function () {
		var index_li = $(this).attr("class");
		$(".calqueInfo").each(function () {
			$(this).css("display", "none");
		});
		switch (index_li) {
		case 'fini':
			if ($("finiProduit")) {
				$("#InfoProd li").each(function () {
					$(this).css("background", "transparent");
					$(this).css("color", "#726C6C");
				});
				$(this).css("color", "#FFF");
				$(this).css("background", "transparent url(../images/v2/px_fp_noir.jpg) repeat-x scroll center bottom");
				$("#InfoProd").css("height", Hfini + "px");
				(".calqueBlanc").css("display", "none");
				$("#finiProduit").css("display", "block");
			}
			break;
		case 'avis':
			if ($("#avisProduit")) {
				$("#InfoProd li").each(function () {
					$(this).css("background", "transparent");
					$(this).css("color", "#726C6C");
				});
				$("#voirLesAvis").css("color", "#FFF");
				$("#voirLesAvis").css("background", "transparent url(../images/v2/px_fp_noir.jpg) repeat-x scroll center bottom");
				$("#InfoProd").css("height", Havis + "px");
				$(".calqueBlanc").css("display", "none");
				$("#avisProduit").css("display", "block");
			}
			break;
		case 'acce':
			if (e = document.getElementById("acceProduit")) {
				$("#InfoProd li").each(function () {
					$(this).css("background", "transparent");
					$(this).css("color", "#726C6C");
				});
				$("#voirAcce").css("color", "#FFF");
				$("#voirAcce").css("background", "transparent url(../images/v2/px_fp_noir.jpg) repeat-x scroll center bottom");
				$("#InfoProd").css("height", Hacce + "px");
				$(".calqueBlanc").css("display", "block");
				$(".calqueBlanc").css("height", HMacce + "px");
				$("#acceProduit").css("display", "block");
			}
			break;
		case 'meme':
			if (e = document.getElementById("memeProduit")) {
				$("#InfoProd li").each(function () {
					$(this).css("background", "transparent");
					$(this).css("color", "#726C6C");
				});
				$("#voirMeme").css("color", "#FFF");
				$("#voirMeme").css("background", "transparent url(../images/v2/px_fp_noir.jpg) repeat-x scroll center bottom");
				$("#InfoProd").css("height", Hmeme + "px");
				$(".calqueBlanc").css("display", "block");
				$(".calqueBlanc").css("height", HMmeme + "px");
				$("#memeProduit").css("display", "block");
			}
			break;
		case 'marq':
			if (e = document.getElementById("marqProduit")) {
				$("#InfoProd li").each(function () {
					$(this).css("background", "transparent");
					$(this).css("color", "#726C6C");
				});
				$("#voirMarque").css("color", "#FFF");
				$("#voirMarque").css("background", "transparent url(../images/v2/px_fp_noir.jpg) repeat-x scroll center bottom");
				$("#InfoProd").css("height", "335px");
				$(".calqueBlanc").css("display", "none");
				$("#marqProduit").css("display", "block");
			}
			break;
		}
	});
	// AFFICHAGE DES AVIS
	$("a#avisVoir").click(function () {
		if ($("#avisProduit")) {
			$("#InfoProd li").each(function () {
				$(this).css("background", "transparent");
				$(this).css("color", "#726C6C");
			});
			$(".calqueInfo").each(function () {
				$(this).css("display", "none");
			});
			$(".avis").css("color", "#FFF");
			$(".avis").css("background", "transparent url(../images/v2/px_fp_noir.jpg) repeat-x scroll center bottom");
			$("#InfoProd").css("height", Havis + "px");
			$(".calqueBlanc").css("display", "none");
			$("#avisProduit").css("display", "block");
		}
	});
	$("a#audioVoir").click(function () {
		if ($("#avisAudio")) {
			$("#InfoProd li").each(function () {
				$(this).css("background", "transparent");
				$(this).css("color", "#726C6C");
			});
			$(".avisAudio").css("color", "#FFF");
			$(".avisAudio").css("background", "transparent url(../images/v2/px_fp_noir.jpg) repeat-x scroll center bottom");
			$(".calqueInfo").each(function () {
				$(this).css("display", "none");
			});
			$("#InfoProd").css("height", HavisAudio + "px");
			$(".calqueBlanc").css("display", "none");
			$("#avisAudio").css("display", "block");
		}
	});

	// TOP 5 10
	$(".top10").hover(function(){
		var newHeight = $(this).parent().parent().height()-40;
		$(this).animate({"height":newHeight+"px"},500);
	},function(){
		$(this).animate({"height":"15px"},300);
	});
	

	// PLACEMENT PREMIERE BOX A DROITE DE LA BOX
	// ONGLET----------------------------------------------------------
	if (document.getElementById("memeProduit") ||( document.getElementById("acceProduit") && $(".calqueInfo .td12 img:first").attr("src") != null )) {
		// DELETE BY Duncan du if || document.getElementById("acceProduit")
		// AFFICHE L IMAGE DU PROD A DROITE DE LA BOX
		var FimgSrc = $(".calqueInfo .td12 img:first").attr("src").replace("woodbrass/", "LISTE/woodbrass/");
		FimgSrc = FimgSrc.replace("/MINI", "");
		var Falt = $(".calqueInfo .td12 img:first").attr("alt");
		var Flien = $(".calqueInfo .td12 img:first").parent().attr("href");
		var Fcontenu = "<a href='" + Flien + "'><img border='0' title='" + Falt + "' alt='" + Falt + "' src='" + FimgSrc + "'></a>";
		if ($.browser.msie==true && parseFloat($.browser.version) == 7) var offset = $(".calqueInfo .td12 img:first").parent().position().top - 61;
		else var offset = $(".calqueInfo .td12 img:first").offset().top - $("#AfficheProdList").offset().top - 61;
		$("#AfficheProdList").css("margin-top", offset + "px");
		$("#AfficheProdList .imgList tr td").html(Fcontenu);
		var heightBody = $("#footer").offset().top;
		if (heightBody != null) {} /* GESTION DYN DES IMG A DROITE DE LA BOX ONGLET	 */
		$("#acceProduit .tabAcc tr").hover(function () {
			var elem=$(".td12 img",this);
			if (elem.attr("src"))
			{
				var imgSrc = elem.attr("src").replace("woodbrass/", "LISTE/woodbrass/");
				var alt = elem.attr("alt");
				imgSrc = imgSrc.replace("/MINI", "");
				var lien = elem.parent().attr("href");
				var contenu = "<a href='" + lien + "'><img border='0' title='" + alt + "' alt='" + alt + "' src='" + imgSrc + "'></a>";
				if (navigator.userAgent.indexOf('MSIE 7') == -1) var offset = elem.parent().position().top - 61;
				else var offset = elem.offset().top - $("#AfficheProdList").offset().top - 61;
				$("#AfficheProdList").css("margin-top", offset + "px");
				$("#AfficheProdList .imgList tr td").html(contenu);
			}
		});
		$("#memeProduit .tabAcc tr").hover(function () {
			var elem=$(".td12 img",this);
			if (elem.attr("src"))
			{
				var imgSrc = elem.attr("src").replace("woodbrass/", "LISTE/woodbrass/");
				var alt = elem.attr("alt");
				imgSrc = imgSrc.replace("/MINI", "");
				var lien = elem.parent().attr("href");
				var contenu = "<a href='" + lien + "'><img border='0' title='" + alt + "' alt='" + alt + "' src='" + imgSrc + "'></a>";
				if (navigator.userAgent.indexOf('MSIE 7') == -1) var offset = elem.parent().position().top - 61;
				else var offset = elem.offset().top - $("#AfficheProdList").offset().top - 61;
				$("#AfficheProdList").css("margin-top", offset + "px");
				$("#AfficheProdList .imgList tr td").html(contenu);
			}
		});
	}
	$("#Account #MultiBox .contenuContour span").click(function () {
		if ($("#Account #MultiBox .contenuContour span").hasClass("clrBleu")) $("#Account #MultiBox .contenuContour span").removeClass("clrBleu");
		var class_span = $(this).attr("class");
		if (class_span) {
			$("#Corps .boxAccount").hide();
			$(this).addClass("clrBleu");
			switch (class_span) {
			case 'spanCmd':
				$("#Commandes").slideDown("fast");
				$("#BarreHaut").slideDown("fast");
				break;
			case 'spanSuiviCmd':
				$("#contTtesCmdes").slideDown("fast");
				break;
			case 'spanAvis':
				$("#DonnerAvis").slideDown("fast");
				break;
			case 'spanAnnonce':
				$("#MesAnnonces").slideDown("fast");
				break;
			case 'spanCpte':
				$("#MonCompte").slideDown("fast");
				break;
			case 'spanPts':
				$("#Parrainage").slideDown("fast");
				break;
			case 'spanFacture':
				$("#MesFactures").slideDown("fast");
				break;
			case 'spanContact':
				$("#MesContacts").slideDown("fast");
				break;
			case 'spanSAV':
				$("#ticketSAV").slideDown("fast");
				break;
			case 'spanCALL':
				$("#MesContactsCall").slideDown("fast");
				break;
			case 'spanDL':
				$("#telechargement").slideDown("fast");
				break;
			}
		}
	});
	if ($("input[name='link']").val()) {
		var valeur = $("input[name='link']").val();
		$("#Corps .boxAccount").hide();
		if ($("#Account #MultiBox .contenuContour span").hasClass("clrBleu")) $("#Account #MultiBox .contenuContour span").removeClass("clrBleu");
		$("#MultiBox img").eq(0).removeClass().addClass("spr120");
		$("#MultiBox img").eq(1).removeClass().addClass("spr111");
		$("#MultiBox img").eq(2).removeClass().addClass("spr123");
		$("#MultiBox img").eq(3).removeClass().addClass("spr110");
		$("#MultiBox img").eq(4).removeClass().addClass("spr115");
		$("#MultiBox img").eq(5).removeClass().addClass("spr119");
		$("#MultiBox img").eq(7).removeClass().addClass("spr122");
		switch (valeur) {
		case '2':
			$("#contTtesCmdes").slideDown("fast");
			$("#MultiBox img").eq(1).removeClass().addClass("spr109");
			$("#Account #MultiBox .contenuContour .spanSuiviCmd").addClass("clrBleu");
			break;
		case '3':
			$("#DonnerAvis").slideDown("fast");
			$("#MultiBox img").eq(2).removeClass().addClass("spr108");
			$("#Account #MultiBox .contenuContour .spanAvis").addClass("clrBleu");
			break;
		case '4':
			$("#MonCompte").slideDown("fast");
			$("#MultiBox img").eq(3).removeClass().addClass("spr112");
			$("#Account #MultiBox .contenuContour .spanCpte").addClass("clrBleu");
			break;
		case '5':
			$("#Parrainage").slideDown("fast");
			$("#MultiBox img").eq(4).removeClass().addClass("spr114");
			$("#Account #MultiBox .contenuContour .spanPts").addClass("clrBleu");
			break;
		case '6':
			$("#MesFactures").slideDown("fast");
			$("#MultiBox img").eq(5).removeClass().addClass("spr113");
			$("#Account #MultiBox .contenuContour .spanFacture").addClass("clrBleu");
			break;
		case '7':
			$("#MesContacts").slideDown("fast");
			$("#MultiBox img").eq(7).removeClass().addClass("spr118");
			$("#Account #MultiBox .contenuContour .spanContact").addClass("clrBleu");
			break;
		}
	}
	$(".Livraison").click(function () {
		$(".Livraison div").slideUp("fast");
	});
	$("#tabDesc tr:odd").css({
		backgroundColor: "#eceeed"
	});
	/* RECHERCHE */

	
	// RECHERCHE PRINCIPALE
	$("input#inputString").keyup(function (e) {
		if (e.keyCode == 40 || e.keyCode == 38) {} else {
			lookup($(this).val(), $("select#SelectedOption").val());
		}
	});
	// RECHERCHE LIBRAIRIE
	$("#LSearch").keyup(function(e){
		switch(e.keyCode){
		case 40:
			e.preventDefault();
			navLi('down');
			break;
		case 38:
			e.preventDefault();
			navLi('up');
			break;
		case 13:
			e.preventDefault();
			if (rechLiId != 0) {
				var aff = $("#RLSearch li").eq(rechLi).html();
				$("#LSearch").val(aff).attr("rech",rechLiId);
				$("#RLSearch").hide();
				$(".attr").trigger("change");
			}
			if (rechLiId == 0) {
				var aff = $("#RLSearch li").eq(0).html();
				var id = $("#RLSearch li").eq(0).attr("id");
				$("#LSearch").val(aff).attr("rech",id);
				$("#RLSearch").hide();
				$(".attr").trigger("change");
			}
			break;
		default:
			e.preventDefault();
		lookupLi($(this).val());
		}
	});
	function DoSearch(){
		$("#Loader").show();
		$("#contentRight").empty();
		var var0 = $("input[name='attributs_valeur0']").attr("rech");
		var var1 = $("select[name='attributs_valeur1']").val();
		var var2 = $("select[name='attributs_valeur2']").val();
		var var3 = $("select[name='attributs_valeur3']").val();
		var var4 = $("select[name='attributs_valeur4']").val();
		var var5 = $("select[name='attributs_valeur5']").val();
		var var6 = $("select[name='attributs_valeur6']").val();
		var var7 = $("select[name='attributs_valeur7']").val();
		var var8 = $("select[name='attributs_valeur8']").val();
		var var9 = $("select[name='attributs_valeur9']").val();
		var var10 = $("input[name='var10']").val();
		var order =  'var0=' + var0 + '&var1=' + var1 + '&var2=' + var2 + '&var3=' + var3 +  '&var4=' + var4 + '&var5=' + var5 + '&var6=' + var6 + '&var7=' + var7 + '&var8=' + var8 + '&var9=' + var9 + '&var10=' + var10;
		$.post("SearchLibrairie.php", order, function(theResponse){
			if(theResponse!=''){
				$("#contentRight").html(theResponse);
			} else {
				$("#contentRight").html(nosearch);
			}
			$("#Loader").hide();
		});
	}
	// RECHERCHE LIBRAIRIE
	var nosearch = "<span class='clrNoir'>S&eacute;lectionnez vos crit&egrave;res pour lancer une nouvelle recherche.</span>";
	// CHANGE SELECT
	$(".attr").change(function(){
		var s = $(this).val();
		if (s!='') {$(this).css({'background-color': '#000', 'color' : '#fff'});}
		else{$(this).css({'background-color': 'transparent', 'color' : '#000'});}
		DoSearch();
	});
	// CHANGE TEXT LIBRE		
	$(".attrlib").click(function(){
		var str = $("input[name='var10']").attr("rel");
		if( $("input[name='var10']").val() == str){
			$("input[name='var10']").val('');
		}
		$(this).addClass("hasvalue");
	});
	$(".attrlib").blur(function(){
		
		var str = $("input[name='var10']").attr("rel");
		if($("input[name='var10']").val().length == 0){
			$(this).removeClass("hasvalue");
			$("input[name='var10']").val(''+str+'');
		}
	});
	$(".attrlib").keyup(function(){
		DoSearch();
	});
	// CHANGE TEXT AUTEUR
	$(".attrlib2").click(function(){
		var str = $("input[name='attributs_valeur0']").attr("rel");
		if($("input[name='attributs_valeur0']").val() == str){
			$("input[name='attributs_valeur0']").val('');
		}
		$(this).addClass("hasvalue");
	});
	$(".attrlib2").blur(function(){		
		var str = $("input[name='attributs_valeur0']").attr("rel");
		if($("input[name='attributs_valeur0']").val().length == 0){
			$(this).removeClass("hasvalue");
			$("input[name='attributs_valeur0']").val(''+str+'');
		}
	});
	$(".attrlib2").keyup(function(){
		
		var var0 = $("input[name='attributs_valeur0']").val();
		if(var0.length == 0  ){
			$("#LSearch").val('').attr("rech",'');
			DoSearch();
		} else {
			DoSearch();
		}
	});
	$("input#inputString").blur(function () {
		fill();
	});
	$("input#inputString").keydown(function (e) {
		switch (e.keyCode) {
		case 40:
			e.preventDefault();
			navigate('down');
			break;
		case 38:
			e.preventDefault();
			navigate('up');
			break;
		case 27:
			e.preventDefault();
			$("#inputString").val("");
			break;
		case 13:
			e.preventDefault();
			if (currentUrl != '') {
				window.location = currentUrl;
			}
			if (currentUrl == '') {
				document.quick_find1.submit();
			}
			break;
		}
	});

	/** *************** ROLLOVER UNEURO ************* */
	$('.Financement #unEuro, #infoUnEuro').hover(function(){
		$('#infoUnEuro').css({
			display: 'block'
		});
	},function() {
		$('#infoUnEuro').css({
			display: 'none'
		});
	});
}); // FIN DOC READY


function navigate(direction) {
	if ($("#autoSuggestionsList ul .itemhover").size() == 0) {
		currentSelection = -1;
	}
	if (direction == 'up' && currentSelection != -1) {
		if (currentSelection != 0) {
			currentSelection--;
		} else {
			currentSelection = $("#autoSuggestionsList ul li").size() - 1;
		}
	} else if (direction == 'down') {
		if (currentSelection != $("#autoSuggestionsList ul li").size() - 1) {
			currentSelection++;
		} else {
			currentSelection = 0;
		}
	}
	setSelected(currentSelection);
}
function navLi(dir){
	if ($("#RLSearch .itemhover").size() == 0) {
		rechLi = -1;
	}
	if (dir == 'up' && rechLi != -1) {
		if (rechLi != 0) {
			rechLi--;
		} else {
			rechLi = $("#RLSearch li").size() - 1;
		}
	} else if (dir == 'down') {
		if (rechLi != $("#RLSearch li").size() - 1) {
			rechLi++;
		} else {
			rechLi = 0;
		}
	}
	setRechId(rechLi);
}

function setSelected(menuitem) {
	$(".boxImage").hide();
	$("#autoSuggestionsList ul li a").removeClass("itemhover");
	$("#autoSuggestionsList ul li").removeClass("itemhover");
	$("#autoSuggestionsList ul li a").eq(menuitem).addClass("itemhover");
	$("#autoSuggestionsList ul li a").eq(menuitem).next().show();
	currentUrl = $("#autoSuggestionsList ul li a").eq(menuitem).attr("href");
}
function setRechId(rechLi){
	$("#RLSearch li").removeClass("itemhover");
	$("#RLSearch li").eq(rechLi).addClass("itemhover");
	rechLiId = $("#RLSearch li").eq(rechLi).attr("id");
}
function ChangeBackgroundPerPage(nb,cl) {
	var color = '#' + cl;
	var path = "../images/v2/univers/";
	$('body').css('background', color + ' url("' + path + nb +'") no-repeat top center');
}
function ChangeBackgroundPerZoom(nb,cl) {
	var color = '#' + cl;
	var path = "";
	$('body').css('background', color + ' url("' + path + nb +'") no-repeat top center');

}
function ChangeBackground(nb, lg, cl) {
	var color = '#' + cl;
	var path ='';
	switch (lg) {
	case 1:
		path = "../images/v2/container/";
		break;
	case 2:
		path = "../images/v2/container/en/";
		break;
	case 3:
		path = "../images/v2/container/de/";
		break;
	case 4:
		path = "../images/v2/container/es/";
		break;
	}
	switch (nb) {
	case 1:
		$('body').css('background', color + ' url("' + path + 'fond1.jpg") no-repeat top center');
		break;
	case 2:
		$('body').css('background', color + ' url("' + path + 'fond2.jpg") no-repeat top center');
		break;
	case 3:
		$('body').css('background', color + ' url("' + path + 'fond3.jpg") no-repeat top center');
		break;
	case 4:
		$('body').css('background', color + ' url("' + path + 'fond4.jpg") no-repeat top center');
		break;
	case 5:
		$('body').css('background', color + ' url("' + path + 'fond5.jpg") no-repeat top center');
		break;
	case 6:
		$('body').css('background', color + ' url("' + path + 'fond6.jpg") no-repeat top center');
		break;
	case 7:
		$('body').css('background', color + ' url("' + path + 'fond7.jpg") no-repeat top center');
		break;
	case 8:
		$('body').css('background', color + ' url("' + path + 'fond8.jpg") no-repeat top center');
		break;
	}
} /** **************** GESTION ANCRE ******************** */
var scrolling = function () {
	var speed = 1000;
	jQuery('a[href*="#"]').bind('click', function () {
		var id = jQuery(this).attr('href');
		if (id == '#' || id == '#APCopy');// goTo('body');
		else goTo(id.substring(id.indexOf('#', 0)));
		return (false);
	});
	function goTo(ancre) {
		jQuery('html,body').animate({
			scrollTop: jQuery(ancre).offset().top - $('#carre').height()
		//}, speed, 'swing', function () {
		}, speed,  function () {
			jQuery(ancre).attr('tabindex', '-1');
			jQuery(ancre).removeAttr('tabindex');
		});
	}
};
jQuery(function () {
	scrolling();
});

function testId(baliseId)
{
	if (document.getElementById && document.getElementById(baliseId) != null)
	{
		if (document.getElementById(baliseId).style.display!='block')
		{
			document.getElementById(baliseId).style.visibility='visible';
			document.getElementById(baliseId).style.display='block';
		}
		else
		{
			document.getElementById(baliseId).style.visibility='hidden';
			document.getElementById(baliseId).style.display='none';
		}
	}
}


/***************************** GESTION DES COOKIES * ********************************/
function Set_Cookie(name, value, expires, path, domain, secure){
	var today = new Date();
	today.setTime(today.getTime());	
	if (expires){
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + (expires));
	document.cookie = name + "=" +escape(value) + ((expires) ? ";expires=" + expires_date.toGMTString() : "") + ((path) ? ";path=" + path : "" ) + ((domain) ? ";domain=" + domain : "" ) + ((secure) ? ";secure" : "" );
}
function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false;
	for (i = 0; i < a_all_cookies.length; i++){
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if (cookie_name == check_name){
			b_cookie_found = true;
			if (a_temp_cookie.length > 1){
				cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ){
		return null;
	}
}

function Delete_Cookie(name, path, domain) {
	if (Get_Cookie(name)) 
		document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function verifComparateur(minCompare, maxCompare){
	var myForm = document.forms['comparateur'].elements;
	var nbCheckbox = 0;
	for(i=0;i<myForm.length;i++){
		if(myForm[i].checked) nbCheckbox++;
	}
	if(nbCheckbox>1 && nbCheckbox<=8){
		document.forms['comparateur'].submit();
	}
	else if(nbCheckbox == 0){
		alert(minCompare);
	}
	else if(nbCheckbox>8){
		alert(maxCompare);
	}
}

