var topMenu = new Object();
function init_rubriques() {
  var a = new Array("boitesgamme");
  var i = 0;
  for (i; i < a.length; i++) {
    var el = document.getElementById(a[i]);
    if (el) {
      //dimensionnement des mosaiques à la taille max
      var list = getElementsByClassName("mosaique","div",el);
      var max = 0;
      var j = 0;
      for (j; j<list.length; j++) {
        if (list[j].firstChild.offsetHeight > max) max = list[j].firstChild.offsetHeight;
      }
      var j = 0;
      for (j; j<list.length; j++) {
          list[j].style.height = max+"px";
          getElementsByClassName("corps","div",list[j])[0].style.height=(max-50)+"px";
          list[j].firstChild.style.height = max+"px";
          list[j].style.visibility = "visible";
      }
    }
  }
}

function coordZone (obj) {
  var coord = new Object();
  coord.x=0;
  coord.y=0;
  coord.w=obj.offsetWidth;
  coord.h=obj.offsetHeight;
  do {
    coord.x+=obj.offsetLeft;
    coord.y+=obj.offsetTop;
    obj=obj.offsetParent;
  } while(obj);
  return coord;
}

function init_boutique()
{
  init_search();
}

function getElmt(elmt) {
  return document.getElementById(elmt);
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
  var i = 0;
	for(i; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

//affiche/cache le détail de tous les produits
function prod_detailAll (bool) {
  var list = getElementsByClassName("prod","div",document.getElementById("boitesproduit"));
  var i = 0;
  for (i ; i < list.length; i++) {
    prod_detail(bool,list[i].id);
  }
}

function prod_detail(open,id) {
  var el = getElmt(id);
  var enteteMin = getElementsByClassName("prodentetemin","div",el)[0];
  var enteteMax = getElementsByClassName("prodentetemax","div",el)[0];
  var contenu = getElementsByClassName("prodcontenu","div",el)[0];
  var slideshow = getElementsByClassName("yui-sldshw-displayer","a",el)[0];
  var btnshow = getElementsByClassName("btn detail show","div",el)[0];
  var btnhide = getElementsByClassName("btn detail hide","div",el)[0];
  if (open && enteteMax.className == "prodentetemax hidden") {
    enteteMin.className = "prodentetemin hidden";
    enteteMax.className = "prodentetemax";
    if (slideshow)
      slideshow.className = "yui-sldshw-displayer";
    btnshow.className="btn detail show hidden";
    btnhide.className = "btn detail hide";
    contenu.style.display = "block";
  }
  else if (!open && enteteMin.className == "prodentetemin hidden") {
    enteteMin.className = "prodentetemin";
    enteteMax.className = "prodentetemax hidden";
    if (slideshow)
      slideshow.className = "yui-sldshw-displayer invisible";
    btnshow.className="btn detail show";
    btnhide.className = "btn detail hide hidden";

    contenu.style.display = "none";
  }
}

function prod_unselectOnglets (ref) {
  var classname = "btn ongletprod";
  var onglets = getElementsByClassName(classname,"a",getElmt(ref));
  var i;
  if (onglets.length) {
    i = 0;
    for (i ; i<onglets.length ; i++) {
      onglets[i].className = classname;
    }
  }
}

/**
*  affichage d'un onglet
*/
function prod_infos (me,type,ref) {
  var el = getElementsByClassName(type,"div",getElmt(ref))[0];
  var onglets = getElementsByClassName("onglet","div",getElmt(ref));
  prod_unselectOnglets (ref);
  me.className += " selected";
  if (el) {
    var i = 0;
    for (i ; i<onglets.length ; i++) {
      if (onglets[i]==el) onglets[i].className = "onglet " + type;
      else  onglets[i].className = onglets[i].className + " hidden";
    }
  }
}

/**
*  affichage du diaporama
*/


/* function old site*/
/**
*  appel au survol d'1 ligne de la grille de prix
*/
function prod_roll (obj,action) {
  if(top.document.URL.indexOf('initiatives-creations',1)!=-1){
	var url1 = 'url(/boutique/imgs/grille_tarifs_creations/grille_survol.gif)';
	var url2 = 'url(/boutique/imgs/grille_tarifs_creations/grille_selection.gif)';
  }else{
	var url1 = 'url(/boutique/imgs/grille_survol.gif)';
	var url2 = 'url(/boutique/imgs/grille_selection.gif)';
  }
  if (action=='over') {
    if (obj.getAttribute('sel')!=1) obj.style.backgroundImage = url1;
  }
  else if (action=='out') {
    if (obj.getAttribute('sel')!=1) obj.style.backgroundImage = 'none';
  }
  else if (action=='click') {
    var cn = obj.parentNode.childNodes;
    var i = 0;
    for (i;i<cn.length;i++) {
      if (cn[i].tagName=='TR') {
        cn[i].style.backgroundImage = 'none';
        cn[i].setAttribute('sel',0);
      }
    }
    obj.style.backgroundImage = url2;
    obj.setAttribute('sel',1);
  }
}

function prod_popup(url,title) {
	try {w.focus()} catch(e) {}
	w = window.open('','img','width=780,height=500,scrollbars,resizable,');
	w.document.write("\
		<html><head><title>"+title+"</title>\
		</head>\
		<body onLoad='focus();'>\
		<table height=100% width=100%><tr><td align=center valign=middle>\
		<img src='"+url+"' border=0>\
		</table>\
		</body></html>\
	");
	w.document.close();
}

function prod_popupLot(ref) {
	try {w.focus()} catch(e) {}
	w = window.open('','img','width=780,height=500,scrollbars,resizable,');
	w.document.write("\
		<html><head><title>Lot tombola</title>\
		</head>\
		<body onLoad='focus();'>\
		<table height=100% width=100%><tr><td align=center valign=middle>\
		<img src='/imgs/sccore/composants/"+ref+".jpg' border=0>\
		</table>\
		</body></html>\
	");
	w.document.close();
}

/**
* gere les appels synchrone asynchrone
 * @param  url  du script appele
  * @param  request chaine de valeur envoye ce script
  * @param  callback fonction appele en retour (pour asynchrone)
 */
function execHttpRequest(url, request, callback) {
  //fction httprequest
  var httpRequest = null;
  var async = (arguments.length==3)?true:false;
  if (window.XMLHttpRequest)
    httpRequest = new XMLHttpRequest();
  else if (window.ActiveXObject) {
    try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
       try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {}
    }
  }
  else {
    alert ("Votre navigateur ne supporte pas l'objet XMLHTTP.");
    return false;
  }
  if (async) httpRequest.open('POST', url, true);
  else httpRequest.open('POST', url, false);
   httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
//   if (httpRequest.overrideMimeType) httpRequest.setRequestHeader("Connection", "close");
  if (async) {
     var f = function() {
     // readyState
     // 0 (uninitialized)  non initialise
     // 1 (loading)  debut du transfert des donnes
     // 2 (loaded)  donnes transferes
     // 3 (interactive)  les donnes rues sont accessibles en partie
     // 4 (complete)  les donnes sont completement accessibles
     if (httpRequest.readyState==4) {
       try {
         //alert(httpRequest.responseText);
       if (httpRequest.status==200) callback(httpRequest.responseText,httpRequest.status);
       else alert (httpRequest.status+"erreur lors du chargement de la page")
       } catch (ex) {alert ("problème de connexion au serveur !");}
       }
    }
    httpRequest.onreadystatechange = f;
  }
  httpRequest.send(request);
  if (!async) {
    if (httpRequest.readyState==4) {
     try {
       if (httpRequest.status==200)  return httpRequest.responseText;
       else alert (httpRequest.status);
     }
     catch (ex) {
       //alert (ex.message);
     alert ("problème de connexion au serveur !");
     }
   }
 }
}


function qtChange () {
  var id = null;
  var nb = null;
  var ref = null;
  var v = new Object();
  var r = null;
  var errorEl = null;
  var classerror = null;
  if (arguments[0] instanceof Object) {
    id = arguments[0].id;
    nb = arguments[0].nb;
	ref = arguments[0].ref;
  }
  else {
    id = arguments[0];
    nb = arguments[1];
    ref = arguments[2];
  }

  if(ref && document.getElementById("error")){
  	errorEl = document.getElementById("error");
	classerror = "errorrefg";
  }else{
  	errorEl = document.getElementById("error_"+id);
	classerror = "error";
  }

   r = execHttpRequest("/boutique/index.php5","action=produitlinecmd&c=Rubrique&method=json&produit="+id+"&quantite="+nb);
   if (r) {
    r = r.parseJSON();
    if (!r.error) {
      prod_changeLineCmd(id,r.ligne);
      return true;

    }
    else {
      errorEl.innerHTML = r.error;
      errorEl.className = classerror;
    }
  }
  else {
    errorEl.innerHTML = "impossible d'exécuter la requête";
    errorEl.className = classerror;
  }
  return false;
}

function prod_commander(fname) {
  var f = document.forms[fname];
  var qte = f.quantite.value;
  var ref = fname.split("_")[1];
  if (qtChange(ref,qte))
  {
    f.submit();
  }
}

function prod_remplacer(fname,key) {
  var key = key.split("_")[1];
  document.forms[fname].key.value = key;
  var f = document.forms[fname];
  var qte = f.quantite.value;
  var ref = fname.split("_")[1];
  if (qtChange(ref,qte))
  {
    f.submit();
  }
}

function showBoxKit(fname,m){
  var height=$(document).height();
  var width=$(document).width();
  $(document).scrollTop(0);
  var message = m;
  document.getElementById("box_filter").style.height=height+"px";
  document.getElementById("box_filter").style.width=width+"px";
  document.getElementById("box_filter").style.display = "block";
  document.getElementById("box_kit").style.display = "block";
  if(message == 'm1'){
  	document.getElementById("box_haut1").style.display = "block";
  }else if(message == 'm2'){
  	document.getElementById("box_haut2").style.display = "block";
  }

  var listlien = getElementsByClassName("change","a",getElmt("box_kit"));
  var i = 0;
  var id;
  var ref;
  for (i; i<listlien.length; i++) {
    document.getElementById(listlien[i].id).onclick = function () {prod_remplacer(fname,this.id);};
  }
  return false;
}

function prod_changeLineCmd(id,ligne) {
  var qtEl = getElmt("qt_"+id);
  var puEl = getElmt("pu_"+id);
  var montantEl = getElmt("montant_"+id);
  var benefEl = getElmt("benef_"+id);
  var errorEl = getElmt("error_"+id);

  qtEl.value = ligne.quantite.toString();
  puEl.innerHTML = ligne.prix.toString();
  montantEl.innerHTML = ligne.montantTTC;
  if (benefEl) {
   benefEl.innerHTML = ligne.benefice;
  }

  errorEl.className = "error hidden";
}

function prod_changerDeviseBtnAll (devise) {
  var classname = "devise";
  var onglets = getElementsByClassName(classname,"a",getElmt("boutique"));
  var i;
  if (onglets.length) {
    i = 0;
    for (i ; i<onglets.length ; i++) {
      onglets[i].className = onglets[i].className.replace("selected","");
      if (onglets[i].className.match(devise)) {
        onglets[i].className += "selected";
      }
    }
  }
}

/*
* modifier la devise sur les produits affichés
*/
function prod_changerDeviseAll(devise) {
  var list = getElementsByClassName("prod","div",getElmt("boitesproduit"));
  var i = 0;
  prod_changerDeviseBtnAll(devise);
  for (i; i < list.length; i++) {
    prod_changerDevise(list[i].id,devise);
  }
}

/*
* appel ajax pour modifier la devise sur 1 produit
*/
function prod_changerDevise(idProd,devise) {
  var v = new Object();
  var r = null;
  var produit;
  var linecmd;
  var line;
  var pu;
  var prix;
  var benef;
  var prixrevente;
  var quantitecmd;

  quantitecmd = getElmt("qt_"+idProd);

  r = execHttpRequest("/boutique/index.php5","action=changerdevise&c=Rubrique&method=json&produit="+idProd+"&devise="+devise+"&quantite="+quantitecmd.value);
  if (r) {
    r = r.parseJSON();
    if (!r.error) {
      produit = r.produit;
      //maj du tableau de prix
      var i = 0;
      for (i; i<produit.tabprix.length; i++) {
        line = produit.tabprix[i];
        pu = getElmt("pu_"+idProd+"_"+line.quantite);
        prix = getElmt("prix_"+idProd+"_"+line.quantite);
        benef = getElmt("benef_"+idProd+"_"+line.quantite);

        pu.innerHTML = line.prix;
        prix.innerHTML = line.montantTTC;
        if (benef)
          benef.innerHTML = line.benefice;
      }

      //maj prix min
      var listPrix = getElementsByClassName("prix","span",getElmt(idProd));
      var i = 0;
      for (i; i<listPrix.length; i++) {
        listPrix[i].innerHTML = produit.prix;
      }

      //maj prix revente
      prixrevente = getElmt("prixrevente_"+idProd);
      if (prixrevente)
        prixrevente.innerHTML = produit.prixrevente;

      prod_changeLineCmd(idProd,r.ligne);
    }
    else alert (r.error);
  }
}

/*
* appel ajax pour modifier la devise du panier
*/
function panier_changerDevise(devise) {
  var v = new Object();
  var r = null;
  var lignes = null;
  var ligne = null;
  var idLigne = null;
  var btneuro = null;
  var btnfranc = null;
  r = execHttpRequest("/boutique/index.php5","action=changerdevise&c=Panier&method=json&devise="+devise);
  if (r) {
    r = r.parseJSON();
    if (!r.error) {
      btneuro = getElmt("btneuro");
      btnfranc = getElmt("btnfranc");
      if (devise=="franc") {
        btneuro.className = "btn rouge";
        btnfranc.className = "btn blanc";
      }
      else {
        btneuro.className = "btn blanc";
        btnfranc.className = "btn rouge";
      }
      //chgmt des lignes panier
      lignes = getElementsByClassName("ligne","div",getElmt("contentPanier"));
      var i = 0;
      for (i ; i < lignes.length; i++) {
        idLigne = lignes[i].id;
        ligne = r.lignespanier[idLigne];
        if (getElmt("p_"+idLigne))
          getElmt("p_"+idLigne).value = ligne.quantite;
        if (getElmt("pu_"+idLigne))
          getElmt("pu_"+idLigne).innerHTML = ligne.prix;
        if (getElmt("m_"+idLigne))
          getElmt("m_"+idLigne).innerHTML = ligne.montantTTC;
      }

      if (getElmt("m_avcat"))
        getElmt("m_avcat").innerHTML = r.avantageCatalogue.montant;

      getElmt("fdp").innerHTML = r.fdp.prixTTC;
      getElmt("montantTVA").innerHTML = r.totalTVA;
      getElmt("montantTTC").innerHTML = r.totalTTC;
    }
  }
}

function panier_quantite(id,quantite){
	var id = id;
	var nb = quantite;
	r = execHttpRequest("/boutique/index.php5","action=quantite&c=Panier&method=json&produit="+id+"&quantite="+nb);
}

function panier_continuer() {
  var f = document.f_panier;
  f.c.value='Publication';
  f.action.value='';
  f.submit();
}

function panier_valider() {

  if(document.f_panier.nbParticipant){
  	var nbParticipant = document.f_panier.nbParticipant.value.replace(/[\r\n\t]/g,'');
  	nbParticipant = nbParticipant.replace(/(^ +)|( +$)/g,'');
  }

  if(document.f_panier.nbParticipant && (nbParticipant<1 || !nbParticipant.match(/^\d+$/))){
	document.getElementById("erreurbulle").style.display = "block";
	document.getElementById("kit").style.paddingLeft = "25px";
	document.getElementById("kittable").style.width = "640px";
	$(document).scrollTop(0);
	return false;
  }else{
  	var f = document.f_panier;
  	f.c.value='Panier';
  	f.action.value='valider';
  	f.submit();
  }
}

function panier_recalculer() {
  var f = document.f_panier;
  f.action.value="recalculer";
  f.submit();
}

/*
* visible/invisible adresse livraison
*/
/* function cmd_showLiv (b) {
  document.getElementById("tabliv").className=(b)?"":"hidden";
  document.getElementById("tabemptyliv").className=(b)?"hidden":"";
} */

/*
* gestion du formulaire liv qd ds form fact
*/
/* function cmd_chfac(el) {
	var name = el.name.replace('fac_','liv_');
	if (!document.form_coords[name]) return;
	var alter = document.form_coords[name];
	if (alter.getAttribute('dontchange')) return;
	if (el.tagName=='SELECT') setValue(alter.name,el.value);
	else alter.value=el.value;
} */

/*
* qd un elmt du form liv modifi passe en dit
*/
/* function cmd_chliv(el) {
	el.setAttribute('dontchange',1);
	el.style.backgroundColor='white';
} */

function cmd_choosAddr(el,t) {
  var elsR = getElementsByClassName("required","p",t);
  var elsdR = getElementsByClassName("required","div",t);
  var elsO = getElementsByClassName("optional","p",t);
  var elsdO = getElementsByClassName("optional","div",t);
  var iR = 0;
  var iO = 0;
  var idR = 0;
  var idO = 0;
  if (el.value=="eta") {
    for (iR;iR<elsR.length;iR++) elsR[iR].className = "required";
    for (iO;iO<elsO.length;iO++) elsO[iO].className = "optional hidden";
    for (idR;idR<elsdR.length;idR++) elsdR[idR].className = "required";
    for (idO;idO<elsdO.length;idO++) elsdO[idO].className = "optional hidden";
  }
  else if (el.value=="new") {
    for (iR;iR<elsR.length;iR++) elsR[iR].className = "required";
    for (iO;iO<elsO.length;iO++) elsO[iO].className = "optional";
    for (idR;idR<elsdR.length;idR++) elsdR[idR].className = "required";
    for (idO;idO<elsdO.length;idO++) elsdO[idO].className = "optional";
  }
  else {
    for (iR;iR<elsR.length;iR++) elsR[iR].className = "required hidden";
    for (iO;iO<elsO.length;iO++) elsO[iO].className = "optional hidden";
    for (idR;idR<elsdR.length;idR++) elsdR[idR].className = "required hidden";
    for (idO;idO<elsdO.length;idO++) elsdO[idO].className = "optional hidden";
  }
}

/*
* slection d'un type d'adresse facturation
*/
function cmd_chooseFact(el) {
  cmd_choosAddr(el,getElmt("facttable"));
}

/*
* slection d'un type d'adresse livraison
*/
function cmd_chooseLiv(el) {
  cmd_choosAddr(el,getElmt("livtable"));
}

/*
* si coche enlevement
*/
function cmd_chooseEnlevement(v) {
  if (v)
  {
    cmd_checkreglement("a_enlevement");
  }

}

/*
* chargement des infos clients en fction de l'authentification
*/
function cmd_loadInfosClient() {
  var client = null;
  var codeaction = null;
  var cp = null;
  var randomString = null;
  var v = new Object();
  var r = null;
  var error = null;

  client = getElmt("cmd_client").value;
  //codeaction = getElmt("cmd_codeaction").value;
  cp = getElmt("cmd_cp").value;
  randomString = getElmt("randomString").value;
  r = execHttpRequest("/boutique/index.php5","c=Commande&action=chargerinfosclient&method=json&cmd_client="+client+"&cmd_cp="+cp+"&randomString="+randomString);
  if (r) {
    r = r.parseJSON();
    error = (r.error)?r.error:r.erreurUtilisateur;

    if (!error) {
      cmd_getInfosClient(r);
    }
    else {
      alert (error);
    }
  }
  else {
    alert("impossible d'exécuter la requête");
  }
}

/*
*  chargement ds les formulaires des infos clients
*/
function cmd_getInfosClient(o) {
  var eta = o.adresseetablissement;
  var fac = o.adressefacturation;
  var liv = o.adresselivraison;

  if (eta) {
    if (!getElmt("eta_nom").value && eta.etablissement)
      getElmt("eta_nom").value = eta.etablissement;
    if (!getElmt("eta_adresse1").value && eta.adresse1)
      getElmt("eta_adresse1").value = eta.adresse1;
    if (!getElmt("eta_adresse2").value && eta.adresse2)
      getElmt("eta_adresse2").value = eta.adresse2;
    if (!getElmt("eta_cp").value && eta.cp)
      getElmt("eta_cp").value = eta.cp;
    if (!getElmt("eta_ville").value && eta.ville)
      getElmt("eta_ville").value = eta.ville;
    if (!getElmt("eta_pays").value && eta.pays)
      getElmt("eta_pays").value = eta.pays;
  }

  if (fac) {
    if (getElmt("fac_fonction").value && fac.fonction)
      getElmt("fac_fonction").value = fac.fonction;
/*     if (getElmt("discipline").value)
      getElmt("discipline").value = ; */
    if (!getElmt("fac_civilite").value && fac.civilite)
      getElmt("fac_civilite").value = fac.civilite;
    if (!getElmt("fac_nom").value && fac.nom)
      getElmt("fac_nom").value = fac.nom;
    if (!getElmt("fac_prenom").value && fac.prenom)
      getElmt("fac_prenom").value = fac.prenom;
    if (!getElmt("fac_tel").value && fac.tel)
      getElmt("fac_tel").value = fac.tel;
    if (!getElmt("fac_gsm").value && fac.gsm)
      getElmt("fac_gsm").value = fac.gsm;
    if (!getElmt("fac_fax").value && fac.fax)
      getElmt("fac_fax").value = fac.fax;
    if (!getElmt("fac_email").value && fac.email)
      getElmt("fac_email").value = fac.email;
  }

/*   if (liv) {
    if (!getElmt("liv_civilite").value && liv.civilite)
      getElmt("liv_civilite").value = liv.civilite;
    if (!getElmt("liv_nom").value && liv.nom)
      getElmt("liv_nom").value = liv.nom;
    if (!getElmt("liv_prenom").value && liv.prenom)
      getElmt("liv_prenom").value = liv.prenom;
    if (!getElmt("liv_etablissement").value && liv.etablissement)
      getElmt("liv_etablissement").value = liv.etablissement;
    if (!getElmt("liv_adresse1").value && liv.adresse1)
      getElmt("liv_adresse1").value = liv.adresse1;
    if (!getElmt("liv_adresse2").value && liv.adresse2)
      getElmt("liv_adresse2").value = liv.adresse2;
    if (!getElmt("liv_cp").value && liv.cp)
      getElmt("liv_cp").value = liv.cp;
    if (!getElmt("liv_ville").value && liv.ville)
      getElmt("liv_ville").value = liv.ville;
    if (!getElmt("liv_pays").value && liv.pays)
      getElmt("liv_pays").value = liv.pays;
    if (!getElmt("liv_tel").value && liv.tel)
      getElmt("liv_tel").value = liv.tel;
    if (!getElmt("liv_gsm").value && liv.gsm)
      getElmt("liv_gsm").value = liv.gsm;
  } */
}

function cmd_checkEtranger() {
  var fac_cp = getElmt("fac_cp").value;
  var fac_pays = getElmt("fac_pays").value;
  var liv_cp = getElmt("liv_cp").value;
  var liv_pays = getElmt("liv_pays").value;

	if (fac_cp.match(/^9[7-8]/) || liv_cp.match(/^9[7-8]/)  || fac_pays!='FR' || liv_pays!='FR') {
    alert("Les commandes hors France métropolitaine sont soumissent à des frais de ports et/ou des taxes spécifiques.\nEn fonction de votre adresse de livraison nous vous transmettrons les informations concernant les frais de ports et la livraison\nVeuillez renseigner au mieux les délais de livraison pour que nous puissions vous fournir les infos nécessaires.\nDe manière générale, il faut ajouter 6 à 8 semaines aux délais indiqués");
  }
  return true;
}

function cmd_validCoords() {
  return cmd_checkEtranger();
}

function cmd_checkreglement(v,k) {
 //'B030N' 'C008N' 'C030N'
 v = v.match(/^([^_]+)_(.+)$/);
 var reg = v[1];
 var typeReg = v[2];
 //a la cmd ou enlèvement
 if (typeReg == "commande") {
  getElmt("chequeregle").className="";
  getElmt("autreregle").className="hidden";
  getElmt("enlevementregle").className="hidden";
  getElmt("rib1").value='';
  getElmt("rib2").value='';
  getElmt("rib3").value='';
  getElmt("rib4").value=''
 }
 else if (typeReg == "livraison") {
  getElmt("chequeregle").className="hidden";
  getElmt("enlevementregle").className="hidden";
  getElmt("autreregle").className="";
 }
 else {
  getElmt("chequeregle").className="hidden";
  getElmt("autreregle").className="hidden";
  getElmt("enlevementregle").className="";
 }
}

function persoLaunch(id,frombdc) {
  /////modif pour obtenir le bon id de la perso
  //qd il existe déja une perso, celle-ci a 1 id différente de produit
  //du coup appel ajax pour retourné l'id du fichier à ouvrir
  //vérification si la quantite valide sinon ne pas ouvrir la perso
  var c = (frombdc)?"Panier":"Rubrique";
  var v = new Object();
  var r = null;
  r = execHttpRequest("/boutique/index.php5","action=getpersoid&method=json&c="+c+"&produit="+id);

  if (r) {
    r = r.parseJSON();
    if (!r.error) {
      persoOpen(r.id,frombdc);
    }
    else {alert("erreur de chargement : "+r.error);}
  }
}

function persoOpen (id,frombdc) {

	frombdc = (frombdc)?1:0;
	if (!(swfobject.getFlashPlayerVersion().major>=6)) {
		if (confirm("Pour utiliser l'interface de personnalisation, vous devez disposer de flash player version 6 ou supérieur\nSouhaitez-vous être redirigé maintenant sur la page de téléchargement ?\n\nRemarque: l'installation est rapide même avec une connexion bas débit\n(Nous vous conseillons de décocher l'option \"Google toolbar\", si elle vous est proposée)")) document.location="http://www.macromedia.com/go/getflashplayer";
		return;
	}
	  //alert(swfobject.getFlashPlayerVersion().major);
//alert (top.window.moveTo);
	//top.window.moveTo(0,0);
	if (document.all) {
    try {
      window.moveTo(0,0);
  		window.resizeTo(screen.availWidth,screen.availHeight);
    }
    catch (e){}

	}
	else if (document.layers||document.getElementById) {
    top.window.moveTo(0,0);
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth) {
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
	document.body.scrollTop = 0;
  document.documentElement.scrollTop = 0;

	var w = document.body.clientWidth-20;
	var h = document.body.clientHeight-20;
	if (!document.getElementById('persoMasque')) {
		var persoMasque = document.createElement('DIV');
		persoMasque.id = "persoMasque";
		persoMasque.style.position = "absolute";
		persoMasque.style.top = 0+"px";
		persoMasque.style.left = 0+"px";
		persoMasque.style.zIndex = 1000;
		persoMasque.style.width = (document.body.offsetWidth>document.body.scrollWidth) ? document.body.offsetWidth+"px" : document.body.scrollWidth+"px";
		persoMasque.style.height = (document.body.offsetHeight>document.body.scrollHeight) ? document.body.offsetHeight+"px" : document.body.scrollHeight+"px";
		persoMasque.style.backgroundColor = "black";
		if (!(navigator.userAgent.indexOf('Macintosh')!=-1 && navigator.userAgent.indexOf('Gecko')!=-1 && navigator.userAgent.indexOf('Safari')==-1)) persoMasque.style.opacity = 0.6;
		persoMasque.style.filter = "alpha(opacity=60)";
		document.body.appendChild(persoMasque);
	}
	document.getElementById('persoMasque').style.visibility = "visible";

	if (!document.getElementById('persoPreloder')) {
		var persoPreloder = document.createElement('DIV');
		persoPreloder.innerHTML = "Chargement de l'interface en cours...";
		persoPreloder.id = "persoPreloder";
		persoPreloder.style.padding = 15+"px";
		persoPreloder.style.background = 'white';
		persoPreloder.style.color = 'orange';
		persoPreloder.style.fontSize = 15+"px";
		persoPreloder.style.position = "absolute";
		persoPreloder.style.visibility = "visible";
		persoPreloder.style.zIndex = 10001;
		document.body.appendChild(persoPreloder);
	}
 	document.getElementById('persoPreloder').style.top = (document.body.clientHeight/2 - document.getElementById('persoPreloder').offsetHeight/2)+"px";
 	document.getElementById('persoPreloder').style.left = (document.body.clientWidth/2 - document.getElementById('persoPreloder').offsetWidth/2)+"px";

	if (!document.getElementById('persoLayer')) {
		var persoLayer = document.createElement('DIV');
		persoLayer.id = "persoLayer";
		persoLayer.style.position = "absolute";
		persoLayer.style.visibility = "visible";
		persoLayer.style.top = (-4000)+"px";
		persoLayer.style.left = 20+"px";
    persoLayer.style.margin = "0";
    persoLayer.style.padding = "0";
		persoLayer.style.zIndex = 10002;
		//persoLayer.style.width = "100%";
		//persoLayer.style.height = "100%";
		document.body.appendChild(persoLayer);
	}
	var flash_ratio = 800/500;
	var w = (document.documentElement.clientWidth-20);
	var h = (document.documentElement.clientHeight-20);
	if (flash_ratio > (w/h) ) {
		h = Math.round(w/flash_ratio);
	}
	else {
		w = Math.round(h*flash_ratio);
	}



	document.getElementById('persoLayer').innerHTML = '\
	<OBJECT WIDTH='+w+' HEIGHT='+h+' ALIGN="top" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ID="test_layer">\
	 <PARAM NAME=movie VALUE="'+urlPerso+'perso.swf?id='+id+'&frombdc='+frombdc+'">\
	 <PARAM NAME=quality VALUE=high>\
	 <PARAM NAME=salign VALUE=LT>\
	 <PARAM NAME=bgcolor VALUE=#FFFFFF>\
	 <PARAM NAME=align VALUE=top>\
	 <EMBED src="'+urlPerso+'perso.swf?id='+id+'&frombdc='+frombdc+'" quality=high salign=LT bgcolor=#FFFFFF WIDTH='+w+' HEIGHT='+h+' swLiveConnect=true ID="test_layer" NAME="test_layer" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>\
	</OBJECT>\
	';

	if (!document.getElementById('persoUpload')) {
		var persoUpload = document.createElement('DIV');
		persoUpload.id = "persoUpload";
		persoUpload.style.position = "absolute";
		persoUpload.style.top = (-500)+"px";
		persoUpload.style.left = (-500)+"px";
		persoUpload.style.zIndex = 10003;
		persoUpload.style.backgroundColor = "#e8e4d5";
		persoUpload.style.color = "black";
		persoUpload.style.border = "1px solid #a5a398";
		persoUpload.style.fontSize = "13px";
		persoUpload.style.fontFamily = "arial";
		persoUpload.style.width = "550px";
		persoUpload.style.padding = "10px";
		document.body.appendChild(persoUpload);
	}
	document.getElementById('persoUpload').innerHTML = "\
		<p style='font-weight:bold;color:black;font-size:18px'>Choix d'une image sur votre ordinateur</p>\
		<form method=post enctype='multipart/form-data' name=formupload target=bg onsubmit=\"document.formupload.telecharger.disabled = true;startUploadMonitor()\">\
		<input type=hidden name=id>\
		<input type=hidden name=width>\
		<input type=hidden name=height>\
		<input type=hidden name=minres>\
		<input type=hidden name=bordure>\
		<input type=hidden name=zoom>\
		<table>\
		<tr valign=top>\
		<td>\
		<div style='width:30px;height:30px;font-family:arial;color:white;text-align:center;font-size:20px;font-weight:bold;line-height:30px;background-image:url(/boutique/imgs/fond_etage.gif)'>1</div>\
		</td>\
		<td style='color:black;font-size:12px'>\
		Cliquez sur le bouton ci-dessous pour sélectionner l'image sur votre ordinateur<br><br>\
		<center><input type=file name=image style='margin-bottom:10px;'></center>\
		</td>\
		</tr>\
		<tr valign=top>\
		<td>\
		<div style='width:30px;height:30px;font-family:arial;color:white;text-align:center;font-size:20px;font-weight:bold;line-height:30px;background-image:url(/boutique/imgs/fond_etage.gif)'>2</div>\
		</td>\
		<td style='color:black;font-size:12px'>\
		Cliquez ensuite sur le bouton \"Télécharger\" et attendre jusqu'à la fin de téléchargement<br>\
		<small>(A titre indicatif pour une image de 1000 Ko (=1Mo), le temps de téléchargement est de cinq minutes avec un modem et une minute en ADSL)</small><br><br>\
		<center>\
		<input type=submit name=telecharger value=Télécharger onclick=\"if (!document.formupload.image.value) {alert('Vous devez d\\'abord sélectionner votre image');return false}\">&nbsp;<input type=button name=annuler value=Annuler onclick=\"frames['bg'].location.href=urlPerso+'upload.php?annuler=1&id='+document.formupload.id.value\">\
		<div style='background:#eeeeee;width:200px;height:10px;text-align:left;margin-top:15px'><div id=progressbar style='background:green;width:0px;height:100%'></div></div>\
		<div id=progressbarinfo></div>\
		</center>\
		</td>\
		</tr>\
		</table>\
	";

}

/*
*  gestion de la perso
*/
var urlPerso ="/boutique/perso/";
var uploadok=false;

function persoLoaded() {
	document.getElementById('persoLayer').style.top = 20+"px";
	document.getElementById('persoPreloder').style.visibility = "hidden";
	moveY('persoLayer',-(document.body.clientWidth/(800/500))-20,20,50,50);
}

function moveY (id,start,end,step,interval) {
	if (start%step) start = Math.round(start/step)*step;
	start += step;
	document.getElementById(id).style.top = start+"px";
	if ( step>0 && (start+step) >= end ) document.getElementById(id).style.top = end+"px";
	else if ( step<0 && (start+step) <= end ) document.getElementById(id).style.top = end+"px";
	else setTimeout("moveY('"+id+"',"+start+","+end+","+step+","+interval+")",interval);
}

function persoClose (produit,commander) {
  var quantite = 0;
  var query = window.location.href;
  var a =  query.match(/(\d+)\.html/);
  var idPage = ""; /*on doit recup l'id de la page pour bigbang2*/
  if (a) {
    idPage = a[1];
  }
  else {
    //si l'url n'est pas réécrite par ex dans le cas de
    //l'ajout d'une ligne  on récupère le num page autrement
    query = window.location.search;
    a =  query.match(/idPage=(\d*)/);
    idPage = a[1];
  }
  var rub = null;

	document.getElementById('persoMasque').style.visibility = "hidden";
	document.getElementById('persoPreloder').style.visibility = "hidden";
	document.getElementById('persoLayer').style.top = (-4000)+"px";
	//if (document.location.toString().indexOf('id=58')!=-1) document.bdc.submit();
  //si on est dans panier on réaffiche juste le panier après perso
  //si ds produit on ajouter la quantité mini

	if (commander) {
    rub = (getElmt("rubrique"))?getElmt("rubrique").value:getElmt(produit).getAttribute("rub");
    if (query.match("\/public"))
      document.location = "/public/index.php5?c=Panier&action=ajouterligne&rubrique="+rub+"&produit="+produit+"&quantite=&idPage="+idPage;
    else
      document.location = "/index.php5?c=Panier&action=ajouterligne&rubrique="+rub+"&produit="+produit+"&quantite=&idPage="+idPage;
  }
	//else document.location.reload(true);
}


function persoUploadStart(id,width,height,minres,bordure,zoom) {
	uploadok=false;

	//document.getElementById('persoLayer').style.top = -4000;
	moveY('persoLayer',document.getElementById('persoLayer').offsetTop,-(document.body.clientWidth/(800/500))-20,-50,50);

	document.getElementById('progressbar').style.width=0+"px";
	document.getElementById('progressbarinfo').innerHTML='';
	document.formupload.telecharger.disabled=false;
	//document.formupload.telecharger.style.display = 'inline';
	document.formupload.action='/cgi-bin/upload.cgi?uploadid='+id+"&scripturl="+escape(urlPerso+"upload.php");
	document.formupload.id.value = id;
	document.formupload.width.value = width;
	document.formupload.height.value = height;
	document.formupload.minres.value = minres;
	document.formupload.bordure.value = bordure;
	document.formupload.zoom.value = zoom;
	//document.getElementById('upload').style.visibility='visible';
	var obj = document.getElementById('persoUpload');
	obj.style.left = (document.body.clientWidth/2 - obj.offsetWidth/2)+"px";
	obj.style.top = "100px";
}

function persoUploadEnd() {
	uploadok=true;
	document.getElementById('persoUpload').style.top=(-500)+"px";
	document.getElementById('persoUpload').style.left=(-500)+"px";
	//document.getElementById('persoLayer').style.top=20;
	moveY('persoLayer',-(document.body.clientWidth/(800/500))-20,20,50,50);
}

function startUploadMonitor() {
	if (navigator.userAgent.indexOf('MSIE')!=-1 && navigator.userAgent.indexOf('PowerPC')!=-1) {
		document.getElementById('persoUpload').style.top=(-500)+"px";
		document.getElementById('persoUpload').style.left=(-500)+"px";
		return;
	}
	if (uploadok) return;
	if (document.getElementById('progressbarjs')) document.body.removeChild(document.getElementById('progressbarjs'));
	var s = document.createElement('SCRIPT');
	s.setAttribute('id','progressbarjs');
	s.setAttribute('src','/boutique/perso/uploadmonitor.php?uploadid='+document.formupload.id.value+'&rand='+Math.random());
	document.body.appendChild(s);
	window.setTimeout("startUploadMonitor()",4000);
}

function setProgressbarValues (done,total,starttime,time) {
	var pc = Math.round(100*done/total);
	document.getElementById('progressbar').style.width=pc+'%';
	document.getElementById('progressbarinfo').innerHTML=pc+'% transféré (vitesse '+Math.round(done/(time-starttime)/100)/10+' ko/s)';
}

function openCalendarConfs (ref) {
  var pl    = document.getElementById('persoLayer');

 	moveY('persoLayer',pl.offsetTop,-(document.body.clientWidth/(800/500))-20,-50,50);

  var r = execHttpRequest("/sites/initiatives/modules/CalendrierPlanning/CalendrierPlanning.php5","refcalendrier="+ref);
  if (r) {

    function callback() {
	  var popup = document.getElementById('popup');
      popup.style.display = "";
      popup.innerHTML = r;
      popup.style.left = (document.body.clientWidth/2 - popup.offsetWidth/2)+"px";
      popup.style.top = "100px";
    }


  if(!document.getElementById('popup')){
  //création d'une zone d'affichage de popup
		var popup = document.createElement('DIV');
		popup.id = "popup";
		popup.style.position = "absolute";
		popup.style.top = (-500)+"px";
		popup.style.left = (-500)+"px";
		popup.style.zIndex = 10004;
		popup.style.backgroundColor = "#FFFFFF";
		popup.style.color = "black";
		popup.style.border = "1px solid #a5a398";
		popup.style.fontSize = "13px";
		popup.style.fontFamily = "arial";
		popup.style.width = "800px";
		popup.style.padding = "10px";
		document.body.appendChild(popup);

    var listJs = new Array (
      //"/js/yui_2_4_0/calendar/calendar-min.js",
      "/sites/initiatives/modules/CalendrierPlanning/CalendrierPlanning.js",
      "/sites/initiatives/modules/CalendrierPlanning/CalendrierPlanning.css",
      //"/js/yui_2_4_0/calendar/assets/calendar.css",
      "/js/yui_2_4_0/container/assets/container.css"
    );
    new loadScripts(listJs,callback,1);
	}else{
	callback();
	}


  }
  else {
    alert("impossible d'exécuter la requête");
  }
}

function closeCalendarConfs() {
  var popup = document.getElementById('popup');
  popup.innerHTML = "";
  popup.style.display = "none";
  moveY('persoLayer',-(document.body.clientWidth/(800/500))-20,20,50,50);
};

// code swfobject V2
var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();

function showProd(numrub){
	document.getElementById('popup'+numrub).style.display="block";
}

function hideProd(numrub){
	document.getElementById('popup'+numrub).style.display="none";
}

function hideAlert(){
	document.getElementById('box_filter').style.display="none";
	document.getElementById('box_panier').style.display="none";
	document.getElementById('box_kit').style.display="none";
	document.getElementById("box_haut1").style.display = "none";
	document.getElementById("box_haut2").style.display = "none";
}

function imgChange(numrub,numprod){
	var elt = document.getElementsByTagName("div");
	for(var x=0; x <elt.length; x++){
		if(elt[x].className=='changeimg'+numrub){
			elt[x].style.display='none';
		}
	}
	document.getElementById('imgprod'+numrub+numprod).style.display="block";
}

var currentelt;
var eltid;

function getElement(e) {
 	if (window.event) e = window.event;
 	var currentelt = e.srcElement? e.srcElement : e.target;
	//currentelt = e.target;

	while(currentelt.className.indexOf('moslien',0) == -1){
		currentelt=currentelt.parentNode;
	}
	eltid = currentelt.id;
}