//------------------------------------------------------------------------------
//---------------------------------- prechargement d'images --------------------
//------------------------------------------------------------------------------
function load() {
	if (document.images) {
		this.length=load.arguments.length;
		for (var i=0;i<this.length;i++) {
			this[i+1]=new Image();
			this[i+1].src=load.arguments[i];
		}
	}
}
//---------------------------------------------------------------------------
//---------------------------------- gestion des calques --------------------
//----------------------------------------------------------------------------
var timeout=new Array();
var delai = 500; // pour cache automatique des calque (
function getElement(id)
{
if (document.getElementById) return document.getElementById(id);
else if (document.all) return document.all[id];
else if (document.layers) return document.layers[id];
}
function colorMe(id,color) { getElement(id).style.color=color;}
function hideMe(id) {  getElement(id).style.display="none"; }
function showMe(id) { getElement(id).style.display="block";}
function showMee(id) { getElement(id).style.display="inline";}
function hideMe(id) {  getElement(id).style.display="none"; }
function changeMe(id) {getElement(id).style.display=(getElement(id).style.display=="block")?"none":"block"; }
function moveDiv(id,x,y)
{       
	if (y) getElement(id).style.top=y;
	if (x) getElement(id).style.left=x;
}
function afficherDiv(id)
{
	if (timeout[id]) clearTimeout(timeout[id]);
	getElement(id).style.visibility= 'visible';       
}
function cacherDiv(id)
{       
	getElement(id).style.visibility='hidden';
}
function cacherDelai(id) 
{
	 var cmd="cacherDiv('" + id + "')";
	 timeout[id] = setTimeout(cmd,delai);
}
//---------------------------------------------------------------------------
//---------------------------------- calques boutique -----------------------
//---------------------------------------------------------------------------
//----------------------
//  icone article
//----------------------
function fermerIcone(refID)
{
	addValDansCookieBoutique(refID);
	var id='icone' + refID;
	hideMe(id);
}
//------------------------
//  div menuProduit
//------------------------
function menuComplet()
{
	hideMe('menuPartiel');
	hideMe('bMenuComplet');
	showMe('menuComplet');
	showMe('bMenuPartiel');
}
function menuPartiel()
{
	showMe('menuPartiel');
	showMe('bMenuComplet');
	hideMe('menuComplet');
	hideMe('bMenuPartiel');
}
//---------------------------------------------------------------------------
//---------------------------------- outils boutique ------------------------
//---------------------------------------------------------------------------
//  lettre xxcycle
//----------------------
function testLettreXXcycle(form,val,defaut,txt)
{
	var email=form.EMAIL;
	if (email.value=='' || email.value==defaut) {alert (txt);}
	else {
	form.subscribe.value=val;
	form.submit(); 
	if (window.name != 'boutique' ) window.close();
	};
}
//--------------------------
//  choix item pour panier
//--------------------------
function ajouterSelectionDansPanierSELECT(txt,windowClose)
{
	var optselects=new Array(); var j=0;
	var opts=document.forms["formItem"].elements["choixItem"].options;

        for (var i=0;i < opts.length;i++) if(opts[i].selected){optselects[j]=opts[i].value;j=j+1;};
	
	if (optselects.length==0) {alert(txt);return;};
	
	if (windowClose) {
		popuppanier(optselects.join(),'ajouter');
		window.close();
		}
	else 	popuppanier(optselects.join(),'ajouter');
}
function ajouterSelectionDansPanier(txt,windowClose)
{
	var listeKeyChoisie=[];
	var liste=document.forms["formItem"].key;
	var length=liste.length;
	for (i=0; i<length; i++) 
		if (liste[i].checked)  	listeKeyChoisie.push(liste[i].value);
	if (listeKeyChoisie.length==0) {alert(txt);return;};
	if (windowClose) {
		popuppanier(listeKeyChoisie.join(),'ajouter');
		window.close();
		}
	else 	popuppanier(listeKeyChoisie.join(),'ajouter');
}
//---------------------------------------------------------------------------
//---------------------------------- popup et lien java ---------------------
//---------------------------------------------------------------------------
// rootLaBoutique .... variable js gllobal
function centrerWindow(page,target,h,w) {
  	var Left=screen.width/2-w/2;
  	var Top=screen.height/2-h/2;
	var prop= 'width=' + w + ', height=' + h + ',scrollbars,status=yes,resizable,left=' + Left + ',top=' + Top;
	var fenetre=window.open(page,target,prop);
	return fenetre.focus();
	}
function windowcenter(page,taille) {//pour lien quelconque
	return centrerWindow(page,'_blank',taille-200,taille);
	}
function popupcenter(key,taille) { // boutique/pagePopup
	var page= rootLaBoutique + 'pagePopup.php?nom=' + key;
	return centrerWindow(page,'_blank',taille-200,taille);
    	}
function popuppanier(key,action) {
    	var page= rootLaBoutique + 'page.php?nom=PANIER&key=' + key + '&action=' + action;
	var fenetre=window.open(page,'boutique','');
	return fenetre.focus();
    }
function popupproduit(key) { // peut être redimentionne si deux images
	var width=800;var height=400;
	//var prop= 'width=' + width + ', height=' + height + ',status=yes,scrollbars,resizable,left=1,top=1';
	var prop= 'width=' + width + ', height=' + height + ',status=yes,scrollbars,resizable';
    	var page= rootLaBoutique + 'PRODUIT.php?key=' + key;
	var fenetre=window.open(page,'_blank',prop);
	return fenetre.focus();
        }
function resizeProdLarge() {
	window.resizeTo(800,500);
	}
function resizeProd() {
	window.resizeTo(700,500);
	}
function popupboutique(page){
	var fenetre=window.open(page,'boutique','');
	return fenetre.focus();
	}
function popuppuzzle(page) { //redimentionnee a l'ouverture
	//return centrerWindow(page,'',400,500);
	return window.open(page,'','');
    	}
//-----------------------------------------------------
//  outils pour tous les cookies
//-------------------------------------------------------
function isCookie(nomCookie) { if (getCookie(nomCookie)) return true;  else return false; }
function getCookie(nomCookie)
{
  	var valeur="";
	if (document.cookie.length > 0)
	{
  		var texte=nomCookie + "=";
  		var table=document.cookie.split(/;/);
  		for (i=0;i<table.length;i++)
		{
    		if (table[i].indexOf(texte)!= -1) valeur = table[i].substring(Number(texte.length + table[i].indexOf( texte)), table[i].length);
  		}
	}
	return unescape(valeur);
}
function setCookie(nomCookie,txt) {
	var argv=setCookie.arguments;
	var argc=setCookie.arguments.length;
	var expiration=(argc > 2) ? argv[2] : null;
	var str =nomCookie + "=" + txt;
	str +=(expiration==null) ? "" : ("; expires="+expiration.toGMTString());
	str += "; " + "path=/";
	document.cookie = str;
	}
function getTabDansCookie(nom) {
	//les éléments sont des séparé par des &
	var txt=getCookie(nom);
	var tab=txt.split('&');
	return tab;
	}
function setTabDansCookie(nom,tab) {
	//les éléments sont séparé par des &
	var argv=setTabDansCookie.arguments;
	var argc=setTabDansCookie.arguments.length;
	var expiration=(argc > 2) ? argv[2] : null;
	
	var txt=tab.join('&');
	if (expiration==null) 	setCookie(nom,txt);
	else 			setCookie(nom,txt,expiration);
}
//-----------------------------------------------------
//  cookie boutique
//-------------------------------------------------------
function setTabDansCookieBoutique(tab) {setTabDansCookie('cookieBoutique',tab);}
function getTabDansCookieBoutique() {return getTabDansCookie('cookieBoutique');}
function addValDansCookieBoutique(val) {
	//uniquement si la valeur n'y est pas 
	tab=getTabDansCookieBoutique();
	for(i = 0 ; i < tab.length ; i++) if (tab[i]==val) return;
	tab[tab.length]=val;setTabDansCookieBoutique(tab);
	}
function supValDansCookieBoutique(val) {
	var newtab=Array();var j=0;
	tab=getTabDansCookieBoutique();
	for(i = 0 ; i < tab.length ; i++)
	{
	   if (tab[i]==val) continue;
	   newtab[j]=tab[i]; j=j+1;
	 };
	setTabDansCookieBoutique(newtab);
	}
//-----------------------------------------------------
//  cookie langue
//-------------------------------------------------------
function setCookieLangue(txt) {
	var la_date=new Date;
	la_date.setFullYear(la_date.getFullYear()+1);
	setCookie('lang',txt,la_date); 
	}
//-----------------------------------------------------
//  cookie menu
//-------------------------------------------------------
function setTabDansCookieMenu(tab) {setTabDansCookie('cookieMenu',tab);}
function getTabDansCookieMenu() {return getTabDansCookie('cookieMenu');}
function initCookieMenu() {
	var tab=new Array();
	var txt;
	txt='nouveautes';			txt=txt + '&' + 'on';
	txt=txt + '&' + 'selections';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'bestof';		    txt=txt + '&' + 'off';
	txt=txt + '&' + 'pub';		    	txt=txt + '&' + 'off';
	txt=txt + '&' + 'menuProduit';		txt=txt + '&' + 'on';
	txt=txt + '&' + 'menuMarque';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'catmarque';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'reduction';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'catalogue';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'modeDemploi';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'monXXcycle';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'lettreXXcycle';	txt=txt + '&' + 'off';
	txt=txt + '&' + 'services';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'clubs';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'bernard';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'chariot';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'optionsAffichage';	txt=txt + '&' + 'off';
	txt=txt + '&' + 'rechercheAvance'; 	txt=txt + '&' + 'off';
	txt=txt + '&' + 'willyIcone';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'produitsDejaVus';		txt=txt + '&' + 'off';
	txt=txt + '&' + 'planDuSite';		txt=txt + '&' + 'off';

	setCookie("cookieMenu",txt);
	}
function changeMenuDansCookieMenu(id) {
	//tab=array(id1,val1,id2,val2......); val=on or off 
	tab=getTabDansCookieMenu();
	for(i = 0 ; i < tab.length ; i=i+2) 
		if (tab[i]==id) {	
			tab[i+1]=(tab[i+1]=='on')?'off':'on';
			setTabDansCookieMenu(tab);
			return;
			};
	}
function setCookieWillyIcone(val) {
	//val=on or off 
	tab=getTabDansCookieMenu();
	for(i = 0 ; i < tab.length ; i=i+2) 
		if (tab[i]=='willyIcone') {	
			tab[i+1]=val;
			setTabDansCookieMenu(tab);
			return;
			};
	}
function isWillyOn() {
	tab=getTabDansCookieMenu();
	for(i = 0 ; i < tab.length ; i=i+2) 
		if (tab[i]=='willyIcone') {
			return (tab[i+1]=='off')?false:true;
			};
	return false;
	}
function isMenuHide(id) {
	tab=getTabDansCookieMenu();
	for(i = 0 ; i < tab.length ; i=i+2) 
		if (tab[i]==id) return (tab[i+1]=='off')?true:false;
	return true;
	}
//-----------------------------------------------------
//  cookie panier
//-------------------------------------------------------
function setCookiePanier(txt) {
	var la_date=new Date;
	la_date.setDate(la_date.getDate()+3); //+ 3 jours
	setCookie('panier',txt,la_date);
	}
function isPanierVide() {
	if (!getCookie('panier')) return true;
	}
//-----------------------------------------------------
//  cookie puzzle
//-------------------------------------------------------
function setCookiePuzzle(txt) {
	var la_date=new Date;
	setCookie('cookiePuzzle',txt);
	}
//-----------------------------------------------------
//  cookie referrer
//-------------------------------------------------------
function setCookieReferrer(){
 	var cookieName='referrer';
 	var cookieValue;

 	if (document.referrer != null ) cookieValue = document.referrer;
 	else cookieValue = 'Bookmark';
 	var fin=new Date();
 	fin.setTime(fin.getTime() + ( 60*60*1000 ) );
 	setCookie(cookieName, cookieValue, fin);
	}
//-------------------------------------------------------
//   positionnement
//-------------------------------------------------------
function getTop(MyObject)
//Fonction permettant de connaître la position d'un objet
//par rapport au bord haut de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
    {
    if (MyObject.offsetParent)
        return (MyObject.offsetTop + getTop(MyObject.offsetParent));
    else
        return (MyObject.offsetTop);
    }
function getLeft(MyObject)
//Fonction permettant de connaître la position d'un objet
//par rapport au bord haut de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
    {
    if (MyObject.offsetParent)
        return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
    else
        return (MyObject.offsetLeft);
    }
//----------------------------------------------------------
// menuOnglet
//----------------------------------------------------------
function OngletDown(onglet) {
		lien='lienOnglet'+ onglet;
		onglet='onglet'+ onglet;
		
		onglet=getElement(onglet);
		onglet.style.backgroundColor='';
		onglet.style.color='#41352C';
		lien=getElement(lien);
		if (lien) lien.style.color='#41352C';
		}
function OngletUp(onglet) {
		lien='lienOnglet'+ onglet;
		onglet='onglet'+onglet;
		onglet=getElement(onglet);
		onglet.style.backgroundColor='#54534B';
		onglet.style.color='white';
		lien=getElement(lien);
		if (lien) lien.style.color='white';
		}
function sousMenu(menu) {
	if (ongletPage!='' && ongletPage!=menu && menu!='vide') OngletDown(ongletPage); 
	if (menu==menuCourant) return;
	if (menuCourant!='vide') {
		lastMenu='sousMenu'+menuCourant;
		hideMe(lastMenu);
		OngletDown(menuCourant);
		};
	menuCourant=menu;
	if (menuCourant!='vide') {
		newMenu='sousMenu'+menuCourant;
		showMe(newMenu);
		OngletUp(menuCourant);
		}
	else {
	 if (ongletPage!='') OngletUp(ongletPage);
	 }
}
//----------------------------------------------------------
// menu couleur
//----------------------------------------------------------
function actionCalquesAccueil(ID) {
	hideMe('calquepromo');
	hideMe('calquenew');
	//hideMe('calquelook');
	hideMe('calqueshop');
	//hideMe('calquevide');
	//hideMe('calquedeja');
	moi='calque'+ID;
	showMe(moi);
}
function moveFleche(left) {
	showMe('flecheMenuCouleur');
	moveDiv('flecheMenuCouleur',left,'')
}
//----------------------------------------------------------
// tri rayon
//----------------------------------------------------------
function choixTriRAYONenCours(formulaire) { 
	$lien=formulaire.SELECTchoixTriPageEnCours.options[formulaire.SELECTchoixTriPageEnCours.selectedIndex].value;
	if ($lien!= "" ) window.open($lien,'_self');
}