var selected_menu = 0;

function dspMenu(menuID,over) {

	var menu = document.getElementById("cat_"+menuID);
	var menuLink = document.getElementById("cat_link_"+menuID);

	if(over) {
		if(menu.innerHTML!="&nbsp;") {
			menu.style.display = "block";
			menu.style.left = ((menuLink.offsetWidth)/2) - (menu.offsetWidth/2) + "px";
		}
		if(menuLink.className == "selected" || menuLink.className == "onglet_important") selected_menu = menuID;
		else menuLink.className = "selected";
	} else {
		menu.style.display = "none";
		if(selected_menu!=menuID) menuLink.className = "";
	}

}

/* Fonctions du bloc panier */
function displayCart() {
	var cart = document.getElementById('cart_block_form');
	switch (cart.style.display) {
		case "none":
			cart.style.display = "block";
			break;
		case "block":
			cart.style.display = "none";
			break;
		default:
			cart.style.display = "none";
			break;
	}
}
function tri_nombres(a,b)
	{ return a-b; }
function tri_nombres_inv(a,b)
	{ return b-a; }
function tri_univer(type) {
	// click all 0
	// click price 1
	//nb_prod_a_aff = 16;
	
	if(!ordre_base[1]){
		for(ls_prod=1;ls_prod<=nb_prod_tot;ls_prod++){
			ordre_base[ls_prod] = getObj(list_cur+"_item_prod"+ls_prod).innerHTML;
		}
	}
	if(type==0){
		for(i=1;i< ordre_base.length ;i++){
			//alert(i);
			getObj(list_cur+"_item_prod"+i).innerHTML = ordre_base[i];
		}	
	}
	else{	
		if(type == 1){
			prix.sort(tri_nombres);
			getObj('sort_btn_down').className = "";
			getObj('sort_btn_up').className = "sel";
		}
		else {
			prix.sort(tri_nombres_inv);
			getObj('sort_btn_down').className = "sel";
			getObj('sort_btn_up').className = "";
		}
		tab_html = new Array();
		//nb_aff=0;
		//nb_prod_a_aff=16;
		/*if(!ordre_base[1]){
			for(ls_prod=1;ls_prod<=nb_prod_tot;ls_prod++){
				ordre_base[ls_prod] = getObj(list_cur+"_item_prod"+ls_prod).innerHTML;
			}
		}*/
		tab_html = ordre_base;
		for(i=0;i< prix.length - 1;i++){
			ind=i+1;
			getObj(list_cur+"_item_prod"+ind).innerHTML = tab_html[prod_ind[prix[i]]];
		}
	}
	//getObj('list_list_pages_nav').innerHTML = "";
	//build_list_nav_bar(list_cur,Math.ceil(nb_prod_tot/nb_prod_a_aff),nb_prod_tot,nb_prod_a_aff);
}
function verifie(ID,nb_prod_a_aff,type) {

	/*
	nb_aff = 0;
	nb_prod_critere = 0;
	if(ID==0) tri_univer(type);
	
	if(type == 10)
	{
		tab_list_choix_attrib = tab_list_taille_attrib;
	}
	else if (type == 20)
	{
		tab_list_choix_attrib = tab_list_couleur_attrib;
	}

	
	for(var cpt_att = 0; cpt_att < tab_list_choix_attrib.length; cpt_att++){
		//alert(cpt_att);
		getObj("list_item_prod_sel_a"+tab_list_choix_attrib[cpt_att]).className="";
		getObj("size_filter_list"+tab_list_choix_attrib[cpt_att]).className="";
	}
	if(ID!=0) getObj("list_item_prod_sel_a"+ID).className="selected";
	if(ID!=0) getObj("size_filter_list"+ID).className="selected";
	//alert(getObj("list_item_prod_sel_a"+ID).className);
	//alert(getObj("size_filter_list"+ID).className);

	getObj('list_list_pages_nav').innerHTML = "";
	for(ls_prod=1;ls_prod<=nb_prod_tot;ls_prod++){
		//alert(tab_attrib_list_taille[list_cur].length);
		//alert(tab_attrib_list_taille[list_cur][ls_prod].length);
		prod_ok=false;
		//alert(1);
		if(ID==0) prod_ok=true;
		else {
			if(type == 10)
			{
				for(var cpt_taille = 0; cpt_taille < tab_attrib_list_taille[list_cur][ls_prod].length; cpt_taille++){
				 
					 if(tab_attrib_list_taille[list_cur][ls_prod][cpt_taille] == ID){
						 prod_ok=true;
					 }
				 }
			}
			else if (type == 20)
			{
				for(var cpt_taille = 0; cpt_taille < tab_attrib_list_couleur[list_cur][ls_prod].length; cpt_taille++){
				 
					 if(tab_attrib_list_couleur[list_cur][ls_prod][cpt_taille] == ID){
						 prod_ok=true;
					 }
				 }
			}
		}
		 if(prod_ok){
		 	getObj(list_cur+"_item_prod"+ls_prod).className = "";
			 if(nb_aff < nb_prod_a_aff){ 
				
				getObj(list_cur+"_item_prod"+ls_prod).style.display = "block";
				//alert(getObj(list_cur+"_item_prod"+ls_prod).style.display);
				nb_aff++;
			 }
			 else getObj(list_cur+"_item_prod"+ls_prod).style.display = "none";
			 nb_prod_critere++;
		 } else {
			 getObj(list_cur+"_item_prod"+ls_prod).style.display = "none";
			 getObj(list_cur+"_item_prod"+ls_prod).className = "dont_show";
		 }
	}
	//alert(nb_aff);
	//alert(nb_prod_a_aff);
	//alert(nb_prod_critere);
	//alert(nb_prod_tot);
	if(nb_prod_critere > nb_prod_a_aff)
	build_list_nav_bar(list_cur,Math.ceil(nb_prod_critere/nb_prod_a_aff),nb_prod_critere,nb_prod_a_aff);*/
}

function removePanier(prod) {
	document.cart_block_form.action.value = "update";
	eval("document.cart_block_form.quantite_"+ prod +".value = 0");
	document.cart_block_form.submit();
}
function switchBasketDisplay() {
	var basketArea = document.getElementById('cart_block_form');
	switch (basketArea.style.display) {
		case "block":
			basketArea.style.display = 'none';
			break;
		case "none":
			if (nb_produits_panier > 0 && document.getElementById('cart_block_added').style.display == 'none') {
				basketArea.style.display = 'block';
			}
			break;
		default:
			basketArea.style.display = 'none';
			break;
	}
	return true;
}

function switchHeaderBlockDisplay(blockID,over) {

	/*getObj('cart_block_form').style.display = 'none';*/
	getObj('cs_submenu').style.display = 'none';
	getObj('wishlist_block_form').style.display = 'none';
	
	if(over) {
		switch (blockID) {
			case 1:
				getObj('cs_submenu').style.display = 'block';
				break;
			case 2:
				if(nb_produits_wishlist > 0) {
					getObj('wishlist_block_form').style.display = 'block';
				}
				break;
			case 3:
				if(nb_produits_panier > 0) {
					getObj('cart_block_form').style.display = 'block';
				}
				break;
			default:
				return false;
		}
	}
	return true;

}

function change_prod_attribs( panierID, prodID, codeEAN, wishlist) {

	var prod_frame = document.getElementById('cart_prod_fiche');

	prod_frame.src = pagesURL + "fiche.cfm?panier_id=" + panierID + "&produit_id=" + prodID + "&code_ean=" + codeEAN;
	if(wishlist) prod_frame.src += "&wishlist=1";
	dspPopUp( 1, "poped_content_cart_prod");
	
	void(0);

}

/* Bascule l'affichage d'un block */
function switchBlockDisplay(bloc) {
	var area = document.getElementById(bloc);
	switch (area.style.display) {
		case "block":
			area.style.display = 'none';
			break;
		case "none":
			area.style.display = 'block';
			break;
		default:
			area.style.display = 'block';
			break;
	}
}

function showPreview(imgID) {

	var preview = getObj('img'+imgID);
	var preview_layer = getObj('cart_preview_img');
	
	preview_layer.getElementsByTagName('img')[0].src = preview.src;
	preview_layer.style.top = (30 + 99*imgID) + "px"; 
	
	switch (preview_layer.style.display) {
		case "block":
			preview_layer.style.display = 'none';
			break;
		case "none":
			preview_layer.style.display = 'block';
			break;
		default:
			preview_layer.style.display = 'block';
			break;
	}
	
}
function  dspMainImgNav() {
	var next_btn = getObj("main_img_next_btn");
	var prev_btn = getObj("main_img_prev_btn");
	if(!next_btn.style.visibility || next_btn.style.visibility=='hidden') {
		next_btn.style.visibility = "visible";
		prev_btn.style.visibility = "visible";
	} else {
		next_btn.style.visibility = "hidden";
		prev_btn.style.visibility = "hidden";
	}
}

function getStyle(itemID) {
	return document.getElementById(itemID).style;
}
function getObj(objID) {
	return document.getElementById(objID);
}
function postForm(formID, check) {
	if(check) check_form();
	else document.getElementById(formID).submit();
}
function resetInput(obj) {
	obj.value = "";
	void(0);
}

function cart_block_remove(prod) {
	getObj("cart_block_form").action.value = "update";
	eval("getObj('cart_block_form').quantite_"+ prod +".value = 0");
	postForm(cart_block_form);
}
// Gestion du tri par prix sur la page de recherche
function sortResult(action) {

	if(action==1) document.getElementById('tri').value = "prixC";
	else document.getElementById('tri').value = "prixD";
	
	postForm("search_form_layer");

}
/*----------------------- GESTION D LISTING DE TP DE LA FICHE PRODUIT ---------------------------*/


function listTP_dsp() {
	
	var TP_layer = getObj("list_tp_back_layer");
	
	if(TP_layer.style.display=="none") {
	
		TP_layer.style.display = "block";
		
		getObj("list_tp_layer").style.backgroundImage = "url("+pageURL+"/ximg/list_tp_back.png)";
		getObj("list_tp_layer").style.zIndex = 100;
		
		getObj("all_prod_btn").className = "selected";
		
	} else {
	
		TP_layer.style.display = "none";
		
		getObj("list_tp_layer").style.backgroundImage = "url()";
		getObj("list_tp_layer").style.zIndex = 0;
		
		getObj("all_prod_btn").className = "";
	}

}

function ScrollBar(Name, imgScrollLeft, imgScrollRight, imgScrollBackground, Width, Height, ButtonWidth){
	this.Obj = null;
	this.Name = Name;
	
	this.down = false;
	
	this.objX = 0;
	this.initX = 0;
	this.parentX = 0;
	
	this.imgScrollLeft = imgScrollLeft;
	this.imgScrollRight = imgScrollRight;
	this.imgScrollBackground = imgScrollBackground;
	
	this.Min = 0;
	this.Max = 0;
	
	this.Width = Width;
	this.Height = Height;
	this.ButtonWidth = ButtonWidth;
	
	this.moveCallback = "";
	this.Position = 0;
	
	this.oldMouseMove = "";
	this.oldMouseUp = "";
	this.oldSelectStart = "";
	this.oldBodyClick = "";
}

/************************************************/
/* methodes de deplacement de la scrollbar      */
ScrollBar.prototype.getPosition = function(e){
	var X = 0;
	var Y = 0;
	if(e.pageX){
		X = e.pageX;
		Y = e.pageY;
	}else if(e.clientX){
		X = e.clientX;
		Y = e.clientY;
	}else{
		X = e.x;
		Y = e.y;
	}
	return new Array(X, Y);
}

ScrollBar.prototype.MouseDown = function (e){
	this.down = true;
	
	var Pos = this.getPosition(e);
	this.initX = Pos[0];
	this.objX = this.Obj.offsetLeft;
	
	this.oldMouseMove = document.body.onmousemove;
	this.oldMouseUp = document.body.onmouseup;
	this.oldSelectStart = document.onselectstart;
	var obj = this;
	if(document.all){
		document.body.onmousemove = function(){ obj.Drag(); };
	}else{
		document.body.onmousemove = function(e){ obj.Drag(e); };
	}
	document.body.onclick = function(){ obj.MouseUp(); };
	document.body.onmouseup = function(){ obj.MouseUp(); };
	document.onselectstart = function () { return false; };
	
	return false;
}

ScrollBar.prototype.MouseUp = function (){
	this.down = false;
	
	document.body.onmousemove = this.oldMouseMove;
	document.body.onmouseup = this.oldMouseUp;
	document.onselectstart = this.oldSelectStart;
}

ScrollBar.prototype.Drag = function (e){
	if(!this.down) return;

	if(!e) e = window.event;

	var Pos = this.getPosition(e);
	var X = Pos[0] - this.initX;
	var nX = (this.objX + X);
	
	if(nX < this.parentX || nX + this.ButtonWidth > this.Width)
		return;
		
	this.Position = Math.floor((nX / (this.Width - this.ButtonWidth) * this.Max) + 1);
	if(this.Position < this.Min) this.Position = this.Min;
	if(this.Position > this.Max) this.Position = this.Max;
	
	this.Obj.style.left = nX + "px";
	
	if(this.moveCallback != ""){
		eval(this.moveCallback);
	}
	return false;
}


/***********************************************/
/* methode de fabrication de la scrollbar      */
ScrollBar.prototype.SetInterval = function (Min, Max){
	this.Min = Min;
	this.Max = Max;
}

ScrollBar.prototype.SetCallBackMove = function (callbackname){
	this.moveCallback = callbackname;
}

ScrollBar.prototype.Display = function (){
	document.write("<div id='sliderBar' style='width:"+this.Width+"px;' id='"+this.Name+"_parent'>");
	
		document.write("<div style='height:"+this.Height+";background:url(\""+this.imgScrollBackground+"\") repeat-x bottom;position:relative;' id='"+this.Name+"' ");
		document.write(" onMouseDown='"+this.Name+".MouseDown(event)' ");
		document.write(" onMouseUp='"+this.Name+".MouseUp()' ");
		//document.write(" onMouseOut='"+this.Name+".MouseUp()' ");
		//document.write(" onMouseMove='"+this.Name+".Drag(event)' ");
		document.write(">");

		document.write("<img src='"+this.imgScrollLeft+"' align=left border=0 ");
		document.write(" onMouseDown='"+this.Name+".MouseDown(event)' ");
		document.write(" onMouseUp='"+this.Name+".MouseUp()' ");
		//document.write(" onMouseOut='"+this.Name+".MouseUp()' ");
		//document.write(" onMouseMove='"+this.Name+".Drag(event)' ");
		document.write(">");
		
		document.write("<img src='"+this.imgScrollRight+"' align=right border=0 ");
		document.write(" onMouseDown='"+this.Name+".MouseDown(event)' ");
		document.write(" onMouseUp='"+this.Name+".MouseUp()' ");
		//document.write(" onMouseOut='"+this.Name+".MouseUp()' ");
		//document.write(" onMouseMove='"+this.Name+".Drag(event)' ");
		document.write(">");
		
		document.write("</div>");
	
	document.write("</div>");
	
	this.Obj = document.getElementById(this.Name);
	this.Obj.style.height = (this.Height-2) + "px";
	this.Obj.style.width = this.ButtonWidth + "px";
	
	var p = document.getElementById(this.Name + "_parent");
	if(p)
		this.parentX = document.getElementById(this.Name + "_parent").offsetLeft;
}

/*----------------------- GESTION DE LA POPUP TRANSPARENTE --------------------------------------*/
var isPopup = false;

function dspPopUp(action, layer, url) {

	// popUp - Layer contenant l image transparente
	var popUp = getObj("opac_layer");
	
	// On definit l alpha de la popup et son display
	if(action==1) {
		action = "block";
		alpha = 5;
		if(layer) isPopup =  true;
		var taille = document.body.clientHeight;
		var divopac = document.getElementById('opac_layer');
		divopac.style.height = taille+"px";
	} else {
		action = "none";
		alpha = 0;
		isPopup =  false;
	}
	popUp.style.display = action;
	// Set de l alpha pour Firefox
	popUp.style.opacity = alpha/10;
	// Set de l alpha pour IE
	popUp.style.filter = 'alpha(opacity=' + alpha*10 + ')';
	
	// Affichage du contenu de la popup
	if(layer) getObj(layer).style.display = action;
	else getObj("poped_content").style.display = action;
	
	if(url) getObj(layer).getElementsByTagName('iframe')[0].src = pagesURL + url;
}

function adjustPopupSize() {
	getObj("popup_fitguide_layer").style.width = getObj("fitguide_img").width + "px";
}

// function setOpacity(value) {}

/*------------------------- GESTION DE LA GALERIE DE LA FICHE PRODUIT ----------------------*/
var GalContainerBase = "";

function build_gal_thumbnail(pID) {

	if(typeof tab_gal_fiche[pID][tab_gal_fiche_color_id] == "undefined") return;
	
	// pID - produit ID - permet de differencier les galeries quand on visionne les fiches resumees du cross selling
	
	var tmp_HTML = "";
	// Tableau utilise pour la galerie popup
	var tmp_HTML_gal = new Array();
	var nbImg = tab_gal_fiche[pID][tab_gal_fiche_color_id].length-1; // -1 Parceque le tableau contient l image courante
	
	for(i=1;i<= nbImg;i++) {
	
		// galerie fiche
		if(i==1) tmp_HTML += '<li class="selected_Img"><a href="javascript:showProdImg(\'' + pID + '\', ' + i;
		else tmp_HTML += '<li><a href="javascript:showProdImg(\'' + pID + '\', ' + i;
		tmp_HTML += ');"><img src="' + gal_base_path + tab_gal_fiche[pID][tab_gal_fiche_color_id][i][0] + '" alt="' + tab_gal_fiche[pID][tab_gal_fiche_color_id][i][3] + '"></a></li>';
		
		// galerie popup
		if(!isPopup) {
			if(i==1) tmp_HTML_gal[nbImg+1-i] = '<li class="selected_Img"><a href="javascript:showProdImg(\'' + pID + '\', ' + i;
			else tmp_HTML_gal[nbImg+1-i] = '<li><a href="javascript:showProdImg(\'' + pID + '\', ' + i;
			tmp_HTML_gal[nbImg+1-i] += ');"><img src="' + gal_base_path + tab_gal_fiche[pID][tab_gal_fiche_color_id][i][0] + '" alt="' + tab_gal_fiche[pID][tab_gal_fiche_color_id][i][3] + '"></a></li>';
		}
		
	}
	
	if(GalContainerBase == "")
		GalContainerBase = getObj('thumbnail_'+pID).innerHTML;
	// Affichage de la galerie de la fiche
	getObj('thumbnail_'+pID).innerHTML = GalContainerBase + tmp_HTML;
	
	// Affichage de la galerie de la popup
	// On met les images dans le bon ordre pour l affichage en float right (a l envers donc ^^)
	if(!isPopup) {
		tmp_HTML = "";
		for(i=1;i<= nbImg;i++) tmp_HTML += tmp_HTML_gal[i];
		if(getObj('thumbnail_gal_'+pID)){
		getObj('thumbnail_gal_'+pID).innerHTML = tmp_HTML;
		// On affiche la premiere image de la galerie en background du 'ul'
		getObj('thumbnail_gal_'+pID).style.background = "url(" + gal_base_path + tab_gal_fiche[pID][tab_gal_fiche_color_id][nbImg][2] + ") no-repeat center";
		}
	}
	
	tab_gal_fiche[pID]["currentImg"] = 1;
	showProdImg(pID,1,2);
}

// Gestion de l affichage des images de la galerie
function showProdImg(pID,imgID, a) {

	index_popup = tab_gal_fiche[pID][tab_gal_fiche_color_id].length-1;

	if( a != 2)
	{
		getObj('thumbnail_'+pID).getElementsByTagName('li')[tab_gal_fiche[pID]["currentImg"]].className = "";
		if(!isPopup) getObj('thumbnail_gal_'+pID).getElementsByTagName('li')[index_popup-tab_gal_fiche[pID]["currentImg"]].className = "";
		
		tab_gal_fiche[pID]["currentImg"] = imgID;
	
		
		getObj("main_img").src = gal_base_path + tab_gal_fiche[pID][tab_gal_fiche_color_id][imgID][1];
		getObj('thumbnail_'+pID).getElementsByTagName('li')[imgID].className = "selected_Img";
		if(!isPopup) {
			getObj('thumbnail_gal_'+pID).getElementsByTagName('li')[index_popup-imgID].className = "selected_Img";
			getObj('thumbnail_gal_'+pID).style.background = "url(" + gal_base_path + tab_gal_fiche[pID][tab_gal_fiche_color_id][imgID][2] + ") no-repeat center";
		}
	}	
	
	if(tab_gal_fiche[pID]["currentImg"] < tab_gal_fiche[pID][tab_gal_fiche_color_id].length-1) {
		getObj('main_img_next_btn').href = "javascript:showProdImg(" + pID + "," + (imgID+1) + ");";
		getObj('main_img_next_btn').style.display = 'block';
	} else getObj('main_img_next_btn').style.display = 'none';
	
	
	
	if(imgID > 1) {
		getObj('main_img_prev_btn').href = "javascript:showProdImg(" + pID + "," + (imgID-1) + ");";
		getObj('main_img_prev_btn').style.display = 'block';
	} else getObj('main_img_prev_btn').style.display = 'none';
	
}

/*----------------------- FONCTIONS DU LISTING DE PRODUIT ----------------------------------*/
//var current_index = 0;
// Tableau contenant les liste d attributs pour chaque produit
var tab_attrib_list = new Array();

// OLD VERSION //
//this.getElementsByTagName("a")[0].style.border = "2px solid #338ED5";
//this.getElementsByTagName("div")[0].style.display = "block";

function show_prod_color(prodID,imgID,list_name, attId, title) {
	
	var pictoArray = getObj(list_name+"_picto_list_"+prodID).getElementsByTagName("a");
	
	getObj(list_name+"_img_prod_"+prodID).src = tab_attrib_list[list_name][prodID][imgID][0];
	getObj(list_name+"_img_prod_"+prodID).title = title;
	getObj(list_name+"_att_prod_"+prodID).value = attId;
	
	for(i=0; i<pictoArray.length; i++) {
		if(pictoArray[i].getElementsByTagName("img")[1].className!="dispo_color") {
			if(i==imgID-1) pictoArray[i].getElementsByTagName("img")[1].style.display = "block";
			else pictoArray[i].getElementsByTagName("img")[1].style.display = "none";
		}
	}
	
}
function item_over(evt) {
	this.getElementsByTagName("div")[0].className += " over";
	if(this.has_color) this.getElementsByTagName("div")[1].style.display = "block";
}
function item_out(evt) {

	tmp_className = this.getElementsByTagName("div")[0].className;
	//alert(tmp_className);
	if(tmp_className.length>26) { 
		//alert(tmp_className.charAt(tmp_className.length));
		
		if(tmp_className.charAt(tmp_className.length-6)== "2") this.getElementsByTagName("div")[0].className = "list_attrib_prod_layer cat_2";
		if(tmp_className.charAt(tmp_className.length-6)== "1") this.getElementsByTagName("div")[0].className = "list_attrib_prod_layer cat_1";
	} else this.getElementsByTagName("div")[0].className = "list_attrib_prod_layer";
	
	if(this.has_color) this.getElementsByTagName("div")[1].style.display = "none";
}


// Initialisation des attributs des produits de la liste
function build_list_attrib(list_name,nb_prod,currentCat) {

	// list_name - Entete de IDs des produits dans la liste
	// nb_prod - Nombre de produits
	
	//tab_attrib_list[list_name] = new Array();
	if(!list_name) list_name = "list";
	if(!nb_prod) nb_prod = 8;

	// Initialisation des rollOvers des produits de la liste
	for(i=1; i<= nb_prod; i++) {
		var tmp_Obj = getObj(list_name+"_item_prod"+i);
		//current_index = i;
		
		if(tab_attrib_list[list_name][i]) tmp_Obj.has_color = true;
		else tmp_Obj.has_color = false;

		tmp_Obj.onmouseover = item_over;
		tmp_Obj.onmouseout = item_out;

		//}
	}

}

function build_list_refresh_attrib(list_name,currentPage,nb_prod_page,total_prod) {

	start_index = 1 + currentPage*nb_prod_page;
	end_index = currentPage*nb_prod_page + nb_prod_page;
	for(i=start_index; i<= end_index && i<= total_prod; i++) {
		var tmp_Obj = getObj(list_name+"_item_prod"+i);
		if(tab_attrib_list[list_name][i]) tmp_Obj.has_color = true;
		else tmp_Obj.has_color = false;
		tmp_Obj.onmouseover = item_over;
		tmp_Obj.onmouseout = item_out;
	}

}

function build_list_refresh_attrib_test(list_name,currentPage,nb_prod_page,total_prod,nb_homme) {

	start_index = 1 + currentPage*nb_prod_page;
	end_index = currentPage*nb_prod_page + nb_prod_page;
	nb = nb_homme; 
	for(i=start_index; i<= end_index && i<= total_prod; i++) {
		if(i == 17)	{i=nb}
		
		var tmp_Obj = getObj(list_name+"_item_prod"+i);
		if(tab_attrib_list[list_name][i]) tmp_Obj.has_color = true;
		else tmp_Obj.has_color = false;
		tmp_Obj.onmouseover = item_over;
		tmp_Obj.onmouseout = item_out;
	}

}

// Gestion des tabs pour le listing de produit
function switch_List_Tab(tabID) {

	var list_tab = getObj("tri_tab_list").getElementsByTagName("li");
	if(tabID != 3) {
		getObj('asc_desc').style.display="none";
		getObj('list_prod_ul').style.top="0";
	}
	
	for(i=0;i<list_tab.length;i++) {
		if(list_tab[i].className != "cat_title") {
			if(i==tabID) list_tab[i].className = "selected";
			else list_tab[i].className = "";
		}
	}
		
	switch (tabID) {
		case 2:
			getStyle("size_filter_list").display = 'block';
			getStyle("color_filter_list").display = 'none';
			break;
		case 3:
			getStyle("size_filter_list").display = 'none';
			getStyle("color_filter_list").display = 'none';
			getObj('asc_desc').style.display="block";
			getObj('list_prod_ul').style.top="30px";
			break;
		case 4:
			getStyle("color_filter_list").display = 'block';
			getStyle("size_filter_list").display = 'none';
			break;
		default:
			getStyle("size_filter_list").display = 'none';
			getStyle("color_filter_list").display = 'none';
			break;
	}
	
}

/*----------------------- GESTION DE LA NAVIG PAR PAGE DES BLOCKS --------------------------*/
// Tableau contenant les differentes barre de navigation
var tabNav = new Array();

function build_list_refresh_nav_bar(list_name,url,currentPage,nb_pages,nb_prod) {

	tabNav[list_name] = new Array();
	tabNav[list_name]["nb_pages"] = nb_pages;
	tabNav[list_name]["nb_prod"] = nb_prod;
	IPPage = 4;
	var js_dblDsp = IPPage;
	
	for(i=0;i<nb_pages;i++) {
		if(i==0) li_class = "first";
		else li_class = "";
		if(i==currentPage) document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='"+li_class+"' id='"+list_name+"_item_"+i+"'><a class='selected' href='"+url+"&currentPage="+i+"'>"+(i+1)+"</li>";
		else document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='"+li_class+"' id='"+list_name+"_item_"+i+"'><a href='"+url+"&currentPage="+i+"'>"+(i+1)+"</li>";
	}

	if(currentPage==0) document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li id='"+list_name+"_prev_btn' class='prev_btn'><a href='javascript: void(0);' class='disabled' style='display:none;'>&nbsp;</a></li>";
	else document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li id='"+list_name+"_prev_btn' class='prev_btn'><a href='"+url+"&currentPage="+eval(currentPage-1)+"'>&nbsp;</a></li>";
	if(currentPage==nb_pages-1) document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='next_btn' id='"+list_name+"_next_btn'><a href='javascript: void(0);' class='disabled' style='display:none;'>&nbsp;</a></li>";
	else document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='next_btn' id='"+list_name+"_next_btn'><a href='"+url+"&currentPage="+eval(currentPage+1)+"'>&nbsp;</a></li>";

}


// Construction de la barre de navig et initialisation des boutons suivant et precedent
function build_list_nav_bar(list_name,nb_pages,nb_prod,IPPage,dblDsp,list_name2) {

	// list_name - Nom du ul qui va contenir la barre de navig
	// nb_pages - Nombre de page 
	// nb_prod - Nombre de produit 
	// IPPage - Nom de produit a afficher par page
	// js_dblDsp - Utilise pour la gestion du double affichage

	tabNav[list_name] = new Array();
	tabNav[list_name]["current_page"] = 0;
	tabNav[list_name]["nb_pages"] = nb_pages;
	tabNav[list_name]["nb_prod"] = nb_prod;
	if(!IPPage) IPPage = 4;
	var js_dblDsp = IPPage;
	
	// Construction de la naviagtion du bas de page
	if(dblDsp && list_name2) {
		js_dblDsp +=  ",1,\"" + list_name2 + "\"";
		for(i=0;i<nb_pages;i++) {
			if(i==0) document.getElementById(list_name2+'_list_pages_nav').innerHTML += "<li class='first' id='"+list_name2+"_item_"+i+"'><a class='selected' href='javascript: goToPage(\""+list_name+"\", "+i+","+js_dblDsp+");'>"+(i+1)+"</li>";
			else document.getElementById(list_name2+'_list_pages_nav').innerHTML += "<li id='"+list_name2+"_item_"+i+"'><a href='javascript: goToPage(\""+list_name+"\", "+i+","+js_dblDsp+");'>"+(i+1)+"</li>";
		}
		document.getElementById(list_name2+'_list_pages_nav').innerHTML += "<li id='"+list_name2+"_prev_btn' class='prev_btn'><a href='javascript: void(0);' class='disabled'>&nbsp;</a></li>";
		document.getElementById(list_name2+'_list_pages_nav').innerHTML += "<li class='next_btn' id='"+list_name2+"_next_btn'><a href='javascript: goToPage(\""+list_name+"\", 1,"+js_dblDsp+");'>&nbsp;</a></li>";
	}
	
	// Construction de la liste de page
	
	// Background si banner de categorie
	//if(list_name=='list') document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='border_left'>&nbsp;</li>";

	for(i=0;i<nb_pages;i++) {
		if(i==0) document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='first' id='"+list_name+"_item_"+i+"'><a class='selected' href='javascript: goToPage(\""+list_name+"\", "+i+ ","+js_dblDsp+");'>"+(i+1)+"</li>";
		else document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li id='"+list_name+"_item_"+i+"'><a href='javascript: goToPage(\""+list_name+"\", "+i+","+js_dblDsp+");'>"+(i+1)+"</li>";
	}
	
	// Initialisation des boutons suivant et precedent
	document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li id='"+list_name+"_prev_btn' class='prev_btn'><a href='javascript: void(0);' class='disabled'>&nbsp;</a></li>";
	document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='next_btn' id='"+list_name+"_next_btn'><a href='javascript: goToPage(\""+list_name+"\", 1,"+js_dblDsp+");'>&nbsp;</a></li>";

	// Background si banner de categorie
	//if(list_name=='list') document.getElementById(list_name+'_list_pages_nav').innerHTML += "<li class='border_right'>&nbsp;</li>";
	
}

// Gestion du changement de page
function goToPage(list_name,pageID,IPPage,dblDsp,list_name2) {
	
	current_page = tabNav[list_name]["current_page"] = pageID;
	nb_pages = tabNav[list_name]["nb_pages"];
	nb_prod = tabNav[list_name]["nb_prod"];
	if(!IPPage) IPPage = 4;
	var js_dblDsp = IPPage;
	
	// Gestion du double affichage - Mise a jour des infos de la deuxieme barre de navig
	if(dblDsp && list_name2) {
		js_dblDsp +=  ",1,\"" + list_name2 + "\"";
		if(current_page>=nb_pages-1) document.getElementById(list_name2+'_next_btn').innerHTML = "<a href='javascript: void(0);' class='disabled'>&nbsp;</a>";
		else document.getElementById(list_name2+'_next_btn').innerHTML = "<a href='javascript: goToPage(\""+list_name+"\","+(current_page+1)+","+js_dblDsp+");'>&nbsp;</a>";
		if(current_page==0) {
			document.getElementById(list_name2+'_prev_btn').innerHTML = "<a href='javascript: void(0);' class='disabled'>&nbsp;</a>";
			document.getElementById(list_name2+'_item_0').className = "first";
		} else document.getElementById(list_name2+'_prev_btn').innerHTML = "<a href='javascript: goToPage(\""+list_name+"\","+(current_page-1)+","+js_dblDsp+");'>&nbsp;</a>";
		for(i=0;i<nb_pages;i++) {
			if(i==current_page) document.getElementById(list_name2+'_item_'+i).getElementsByTagName("a")[0].className = "selected";
			else document.getElementById(list_name2+'_item_'+i).getElementsByTagName("a")[0].className = "";
		}
	}
	
	// Mise a jour du bouton suivant
	if(current_page>=nb_pages-1) document.getElementById(list_name+'_next_btn').innerHTML = "<a href='javascript: void(0);' class='disabled'>&nbsp;</a>";
	else document.getElementById(list_name+'_next_btn').innerHTML = "<a href='javascript: goToPage(\""+list_name+"\","+(current_page+1)+","+js_dblDsp+");'>&nbsp;</a>";
	
	// Mise a jour du bouton precedent
	if(current_page==0) {
		document.getElementById(list_name+'_prev_btn').innerHTML = "<a href='javascript: void(0);' class='disabled'>&nbsp;</a>";
		document.getElementById(list_name+'_item_0').className = "first";
	} else document.getElementById(list_name+'_prev_btn').innerHTML = "<a href='javascript: goToPage(\""+list_name+"\","+(current_page-1)+","+js_dblDsp+");'>&nbsp;</a>";
	
	// Mise a jour de la liste des pages - selection de la page courante
	for(i=0;i<nb_pages;i++) {
		if(i==current_page) document.getElementById(list_name+'_item_'+i).getElementsByTagName("a")[0].className = "selected";
		else document.getElementById(list_name+'_item_'+i).getElementsByTagName("a")[0].className = "";
	}
	
	// Reaffichage des produits - selection de la page courante
	nb=1;
	for(i=1;i<=nb_prod;i++) {
		//alert(nb);
		//alert(document.getElementById(list_name+'_item_prod'+nb).style.display);
		while (getObj(list_name+"_item_prod"+nb).className == "dont_show" ) {
			nb++;
			
		}
		if( (i>=(current_page*IPPage)+1) && (i<=((current_page+1)*IPPage)) ) {
			document.getElementById(list_name+'_item_prod'+nb).style.display = 'block';
		}
		else document.getElementById(list_name+'_item_prod'+nb).style.display = 'none';
		nb++;
	}
	
}

/*---------------- FONCTION PREHOME -----------------------*/
/*
function setPaysID(value) {
	document.getElementById('prehome_form').pays_ID.value = value;
	if(value>4) {
	
	}
}

function ph_nextStep() {
	getStyle(message).display = "block";
}
*/


/*---------------- FONCTION FICHE PRODUIT -----------------------*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*--------------- fonction pour changement de langue avec drapeaux dans header.cfm -----------------------*/
function changelangue (languesel,languesite)
{
	var S_url = document.location.href;
	S_url = S_url.replace("?languesite="+languesite, "?");
	S_url = S_url.replace("&languesite="+languesite, "&");
	
	if(S_url.charAt(S_url.length-1) == "?" || S_url.charAt(S_url.length-1) == "&")
	{
		window.location.href=S_url+'languesite='+languesel;
	}
	else if(((S_url.charAt(S_url.length-4) == "." || S_url.charAt(S_url.length-5) == ".") && S_url.indexOf("?target",0) == -1) || (S_url.indexOf(".cfm",0) == -1 && S_url.indexOf(".htm",0) == -1))
	{
		window.location.href=S_url+'?languesite='+languesel;
	}
	else
	{
		window.location.href=S_url+'&languesite='+languesel;
	}
}
			
			