
// ----- FONCTIONS POUR PRÉCHARGER LES IMAGES : ---------------------------------------------------------------------------------------
// --- (non utilisée) ---
function preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
// ------------------------------------------------------------------------------------------------------------------------------------

// ----- FONCTION POUR OUVRIR UN POPUP : ----------------------------------------------------------------------------------------------
var fenetre;
function popup(lurl, larg, haut, scrol, resize){
  largeur   = larg   == '' ? 700 : larg;
  hauteur   = haut   == '' ? 500 : haut;
  scrollval = scrol  == '' ? 'no': scrol;
  resizeval = resize == '' ? 'no': resize;
  if ((fenetre)&&(!fenetre.closed)) { fenetre.close() };
  var param = 'resizable=no,'
               + 'scrollbars='+scrollval+','     // yes, no
               + 'width='+largeur+','
               + 'height='+hauteur+','
               + 'resizable='+resizeval+','     // yes, no
               + 'status=no,'
               + 'location=no,'
               + 'titlebar=no,'
               + 'toolbar=no,'
               + 'menubar=no,'
               + 'dependent=yes,'  ;
              //--------position sur l'écran---------------------
      if ( navigator.appName.indexOf("Microsoft") >= 0 ){
        param += 'left=100, top=50 ;'  ;
      }else {
        param += 'screenX=100,screenY=50 ;'   ;
      }
  fenetre=window.open(lurl, 'lafenetre', param);
}
// ------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR AFFICHER OU MASQUER ALTERNATIVEMENT UN SOUS-MENU : --------------------------------------------------------------
function j_show_hide(qui,nblignes){
  for (i=0; i<nblignes; i++){
    unediv = document.getElementById(i);
    if (unediv != undefined){
      unediv.style.display = 'none';
    }
  }
  thisdiv = document.getElementById(qui);
  thisdiv.style.display = 'inline';
}
// ------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR ALLUMER UN SOUS-MENU : ------------------------------------------------------------------------------------------
function  sbmover(qui){
  qui.style.backgroundColor='#D2E1D0';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR ÉTEINDRE UN SOUS-MENU : -----------------------------------------------------------------------------------------
function  sbmout(qui){
  qui.style.backgroundColor='#FFFFFF';
}
//-------------------------------------------------------------------------------------------------------------------------------------


// ----- TESTE SI LA SAISIE EST BIEN UN ENTIER : --------------------------------------------------------------------------------------
function j_controlint(champ){
  num = champ.value;
  if ((isNaN(num)) || (num < 1) || (num != Math.round(num))){
    alert ("La quantité saisie est incorrecte !\nThe specified quantity is inadequate !");
    champ.focus();
    return false;
  }else{
    return true;
  }
}
// ------------------------------------------------------------------------------------------------------------------------------------


// ----- RÉCUPÈRE LA TAILLE ET LE COLORIS SÉLECTIONNÉS : ------------------------------------------------------------------------------
function j_taillecouleur(){
  for (i=0; i<document.formstd.specifs.length; i++){
    if (document.formstd.specifs.options[i].selected == true){
      chaine = document.formstd.specifs.options[i].text;
      t_chaine = chaine.split(' - ');
      if (t_chaine[1]){
        document.formstd.taille.value  = t_chaine[0];
        document.formstd.coloris.value = t_chaine[1];
      }else{
        document.formstd.taille.value  = 'null';
        document.formstd.coloris.value = 'null';
      }
    }
  }
}
// ------------------------------------------------------------------------------------------------------------------------------------


// ----- FONCTION qui recale la page en haut  : ---------------------------------------------------------------------------------------
function j_remonte(){
  window.scrollTo (0,0);
}
// ------------------------------------------------------------------------------------------------------------------------------------










// ----- FONCTION JAVASCRIPT QUI TRAITE LE FORMULAIRE D'AJOUT DU ZOOM AU PANIER  : ----------------------------------------------------
// --- (non utilisée) ---
function j_succes(){
  window.document.zoomform.submit();
}
// ------------------------------------------------------------------------------------------------------------------------------------


// -------- FONCTION JAVASCRIPT QUI SOUMET LE FORMULAIRE DES DIMENSIONS STANDARDS : ---------------------------------------------------
// --- (non utilisée) ---
function submit_stdr(what){
  if (j_controlint(what.qte)){
    what.submit();
  }
}
// ------------------------------------------------------------------------------------------------------------------------------------


// ----- FONCTION POUR AFFICHER LA DIV ZOOMARTICLE : ----------------------------------------------------------------------------------
// --- (non utilisée) ---
function showzoomart(){
  Yinit   = parseInt(10);
  Yscroll = parseInt(parent.document.body.scrollTop);
  toppos = Yscroll + Yinit;
  eval("parent.document.getElementById('zoomarticle').style.top = '" + toppos + "px'");
  parent.document.getElementById('zoomarticle').style.zindex = 99;
  parent.document.getElementById('zoomarticle').style.visibility = 'visible';
}
// ------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR HIGHLIGHTER LE MENU DE 2eme NIVEAU CHOISI : ---------------------------------------------------------------------
// --- (non utilisée) ---
function colore2(qui){
  //alert (qui);
  document.getElementById(qui).style.backgroundColor='#D57180';
  document.getElementById(qui).style.color='white';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR HIGHLIGHTER LE MENU DE 3eme NIVEAU CHOISI : ---------------------------------------------------------------------
// --- (non utilisée) ---
function colore3(qui){
  document.getElementById(qui).style.backgroundColor='#D57180';
  document.getElementById(qui).style.color='white';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR SOULIGNER UN ÉLÉMENT DU MENU 1 : --------------------------------------------------------------------------------
// --- (non utilisée) ---
function souligne1(qui){
  document.getElementById(qui).style.color='white';
  document.getElementById(qui).style.textDecoration='underline';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR SOULIGNER UN ÉLÉMENT DU MENU 2 : --------------------------------------------------------------------------------
// --- (non utilisée) ---
function souligne2(qui){
  //document.getElementById(qui).style.color='white';
  document.getElementById(qui).style.textDecoration='underline';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR SOULIGNER UN ÉLÉMENT DU MENU 3 : --------------------------------------------------------------------------------
// --- (non utilisée) ---
function souligne3(qui){
  //document.getElementById(qui).style.color='white';
  document.getElementById(qui).style.textDecoration='underline';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR NE PLUS SOULIGNER UN ÉLÉMENT DU MENU 1 : ------------------------------------------------------------------------
// --- (non utilisée) ---
function stopsouligne1(qui){
  document.getElementById(qui).style.color='#895F69';
  document.getElementById(qui).style.textDecoration='none';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR NE PLUS SOULIGNER UN ÉLÉMENT DU MENU 2 : ------------------------------------------------------------------------
// --- (non utilisée) ---
function stopsouligne2(qui){
  //document.getElementById(qui).style.color='#895F69';
  document.getElementById(qui).style.textDecoration='none';
}
//-------------------------------------------------------------------------------------------------------------------------------------


//----- FONCTION POUR NE PLUS SOULIGNER UN ÉLÉMENT DU MENU 3 : ------------------------------------------------------------------------
// --- (non utilisée) ---
function stopsouligne3(qui){
  //document.getElementById(qui).style.color='#895F69';
  document.getElementById(qui).style.textDecoration='none';
}
//-------------------------------------------------------------------------------------------------------------------------------------


// ----- FONCTIONS POUR AFFICHER UNE INFOBULLE : --------------------------------------------------------------------------------------
// --- (non utilisée) ---
var div_Style = null

function pop_on(idd,evt){

  var Xmouse, Ymouse, Xdiv, Ydiv, Lpage, Yscroll, element = null;
  var offset   = 30;        // --- decalage par defaut
  div_Style    = null;
  Lpage        = document.body.clientWidth;
  element      = document.getElementById(idd);
  Xmouse       = evt.clientX;
  Ymouse       = evt.clientY;

  Xdiv         = Xmouse;
  Ydiv         = Ymouse	;

  if(evt.pageX) Xdiv = evt.pageX ; // --- (pour FIREFOX) ---
  if(evt.pageY) Ydiv = evt.pageY ; // --- (pour FIREFOX) ---

  Yscroll     = document.body.scrollTop;

  if(!evt.pageX) Ydiv = Ydiv + Yscroll; // --- (pour IE) ---
	//alert (Ydiv + 'px');

  div_Style = element.style;
	//alert (div_Style.height);

  div_Width  = parseFloat(div_Style.width);
	//alert (div_Width);
  div_Height = parseFloat(div_Style.height);

  //---- ON MET LA BULLE À DROITE DU POINTEUR (SI C'EST POSSIBLE) : ----
	//alert (Xmouse + offset);
	//alert (Lpage - div_Width);
  if (Xmouse + offset < Lpage - div_Width){
    Xdiv = Xmouse + offset;
  }else{
    Xdiv = Lpage - div_Width - offset;
    offset = offset + 30; // --- (décalera la div vers le haut pour qu'elle ne soit pas sur la souris)
  }
	//alert (Xdiv + 'px');

  /*
  //---- ON MET LA BULLE EN HAUT DU POINTEUR SI ON EST ASSEZ BAS DANS L'ÉCRAN : ----
  if (Ymouse > div_Height + offset){
    Ydiv = Ydiv - div_Height - offset;
  }else{
    Ydiv = Ydiv + offset;
  }
  */
  Ydiv = Ydiv - (div_Height + 30) - offset;

	//alert (Xdiv + 'px');
  div_Style.left = Xdiv + 'px';
  div_Style.top  = Ydiv + 'px';

  div_Style.visibility = "visible";
  div_Style.zIndex     = "99";
  //newhtml = 'Xdiv : ' + Xdiv + ' , Xmouse : ' + Xmouse;
  //document.getElementById(idd).innerHTML  = newhtml;
}

function pop_off(){
  div_Style.visibility="hidden";
}
// ------------------------------------------------------------------------------------------------------------------------------------


// ----- FONCTIONS POUR FORMATER LES PRIX À 2 CHIFFRES APRÈS LA VIRGULE : -------------------------------------------------------------
// --- (non utilisée) ---
function j_formate ( nombredecimal ){
  var floa, inte, ch, len, i, enti, cent ;
  floa = nombredecimal * 100 ;
  inte  = Math.round ( floa ) ;
  inte == 0 ? ch = "000" : ch = inte.toString (10) ;
  ch = ch.length < 2 ? '0' + ch : ch ;
  len  = ch.length ;
  enti = ch.slice ( 0, len-2 ) ;
  if(enti=='')enti='0';
  cent = ch.slice (len-2, len ) ;
  for ( i = 0 ; i < Math.floor ( ( enti.length-(1+i))/3) ; i++ ){
    enti = enti.substring ( 0, enti.length - (4*i+3) ) + ' ' + enti.substring ( enti.length - (4*i+3) ) ;
  }
  return enti + "," + cent ;
}
// ------------------------------------------------------------------------------------------------------------------------------------

// -------- FONCTION JAVASCRIPT QUI TRAITE LE FORMULAIRE D'AJOUT DU ZOOM AU PANIER : --------------------------------------------------
// --- (non utilisée) ---
function submit_zoom(what,iscaddy,nbarts){
  // --- rectangulaire, ovale ou ronde : ---
  var laforme
  t_forme = what.forme;
  for (i=0; i<t_forme.length; i++){
    if (t_forme[i].checked){
      laforme = t_forme[i].value;
    }
  }
  what.libf3.value = "nappe " + laforme;
  what.forme.value = "laforme";
  // --- si le zoom est déjà dans le caddy : ---
  if ((iscaddy == 1) && (nbarts > 0)){
    document.getElementById('warning').style.visibility='visible';
  }else{
    if (nbarts > 0){
      // --- appelle dans un IFRAME la page qui va soumettre tous les formulaires d'ajout d'articles supplémentaires au caddy : ------      
      j_zoomiframe(what);
    }else{
      j_succes();
    }
  }
}
// ------------------------------------------------------------------------------------------------------------------------------------

// ----- FONCTION POUR OUVRIR LE POPUP DU PRODUIT ASSOCIÉ : ---------------------------------------------------------------------------
// --- (non utilisée) ---
var fenetre2;
function j_openasso(codeprod){
  lurl  = "ficheasso.php?";
  lurl += "cd=" + codeprod;
  largeur =  680 ;
  hauteur =  450 ;
  if ((fenetre2)&&(!fenetre2.closed)) { fenetre2.close() };
  var param = 'resizable=no,'
               + 'scrollbars=yes,'     // yes, no
               + 'width='+largeur+','
               + 'height='+hauteur+','
               + 'resizable=yes,'
               + 'status=no,'
               + 'location=no,'
               + 'titlebar=no,'
               + 'toolbar=no,'
               + 'menubar=no,'
               + 'dependent=yes,'  ;
              //--------position sur l'écran---------------------
      if ( navigator.appName.indexOf("Microsoft") >= 0 ){
        param += 'left=120, top=70 ;'  ;
      }else {
        param += 'screenX=120,screenY=70 ;'   ;
      }
  fenetre2=window.open(lurl, 'lepopup', param);
}
// ------------------------------------------------------------------------------------------------------------------------------------

// --- FONCTION QUI LANCE DANS UN IFRAME LA PAGE D'AJOUT AU CADDY POUR LES COMPOSANTS ADDITIONNELS DU ZOOM : --------------------------
// --- (non utilisée) ---
var lurl;
function j_zoomiframe(what){
  params = '';
  nb_comp = what.nb_comp.value;
  for (i=0; i<nb_comp; i++){
    art = eval("what.art_" + i + ".value");
    qte = eval("what.qte_" + i + ".value");
    params += art + "&";
    params += qte + "&";
  }
  params += "nb_comp=" + nb_comp;
  lurl  = "ajoutzoom.php?" + params;
  document.getElementById('scriptiframe').src = lurl;
}
//-------------------------------------------------------------------------------------------------------------------------------------

// ----- FONCTION QUI REPRODUIT L'ÉQUIVALENT DU NUMBER_FORMAT DE PHP : ----------------------------------------------------------------
function j_number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}