// JavaScript Document

function putIframe(UL, ifr) {

	ifr.style.display = 'block';
  ifr.style.zIndex = 10;

    ifr.style.width = UL.offsetWidth;
  	ifr.style.height = UL.offsetHeight;
  	ifr.style.top = UL.offsetTop; // 35 : Hauteur des onglets
  	ifr.style.left = UL.offsetLeft;

}

/*
function hover(obj){
  if(document.all){
    UL = obj.getElementsByTagName('ul');
    if(UL.length > 0){
      sousMenu = UL[0].style;
      if(sousMenu.display == 'none' || sousMenu.display == ''){
        sousMenu.display = 'block';
      }else{
        sousMenu.display = 'none';
      }
    }
  }
}
*/

function hover(obj, ifr) {
  if (document.all) {
    var UL = obj.getElementsByTagName('ul');
    if (UL.length > 0) {
      var sousMenu = UL[0].style;
      if(sousMenu.display == 'none' || sousMenu.display == '') {
        sousMenu.display = 'block';
        putIframe(UL[0], ifr);
      }
      else {
        sousMenu.display = 'none';
        ifr.style.display = 'none';
      }
    }
  }
}
/*
function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  for(i=0; i < nLI; i++){
    LI[i].onmouseover = function(){
      hover(this);
    }
    LI[i].onmouseout = function(){
      hover(this);
    }
  }
}*/

function setHover() {
  var nav = navigator.userAgent;
  var op = "Opera";
  if(nav.indexOf(op)==-1){
  
    var LI = document.getElementById('menu').getElementsByTagName('li');
    var nLI = LI.length;
  
    var m_ifr = document.getElementById('menuIFrame');
    var m_ifr2 = document.getElementById('menuIFrame2');
  
    for (var i = 0; i < nLI; i++) {
      // Cas ou l'on souhaite afficher la 2? iframe
      if (LI[i].className == 'ssmenu') {
        LI[i].onmouseover = function() {
          this.imselected = true;
          hover(this, m_ifr2);
        }
      }
      else {
        LI[i].onmouseover = function() {
          hover(this, m_ifr);
        }
      }
      // Cas ou l'on souhaite cacher la 2? iframe
      if (LI[i].className == 'ssmenu') {
        LI[i].onmouseout = function() {
          this.imselected = false;
          hover(this, m_ifr2);
        }
      }
      else {
        LI[i].onmouseout = function() {
          hover(this, m_ifr );
        }
      }
    }
  }
}

function chargeURL(adresse){
 window.location.href=adresse;
}

function ouvFen(url, w, h)
{
var top=Math.floor((screen.height-h)/2);
var left=Math.floor((screen.width-w)/2);
window.open(url,"","top="+top+",left="+left+",width="+w+",height="+h+",toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=1, copyhistory=0, menuBar=0");
}

function ouvFenScroll(url, w, h)
{
var top=Math.floor((screen.height-h)/2);
var left=Math.floor((screen.width-w)/2);
window.open(url,"","top="+top+",left="+left+",width="+w+",height="+h+",toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=0, menuBar=0");
}

function ouvFenStatique(url, w, h)
{
var top=Math.floor((screen.height-h)/2);
var left=Math.floor((screen.width-w)/2);
window.open(url,"","top="+top+",left="+left+",width="+w+",height="+h+",toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0");
}

function ouvFenStatiqueAsc(url, w, h)
{
var top=Math.floor((screen.height-h)/2);
var left=Math.floor((screen.width-w)/2);
window.open(url,"","top="+top+",left="+left+",width="+w+",height="+h+",toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, copyhistory=0, menuBar=0");
}

/*******************************************************/
/*  Fonction openit(url,largeur,hauteur)               */
/*  nom = url de l'image avec son extension            */
/*  largeur = largeur de l'image ?uvrir                */
/*  hauteur = hauteur de l'image ?uvrir                */
/*                                                     */
/*  Fonction openit                                    */
/*  pour ouvrir un fenetre avec image sans creer       */
/*  de fichier html                                    */
/*  Auteur : Herve Eibes                               */
/*  herve.eibes@free.fr                                */
/*                                                     */
/*******************************************************/

function openit(nom,url,largeur,hauteur) 
{
var fen="fen"+nom;
fen=open("","","scrollbars=no,width="+largeur+",height="+hauteur);
fen.document.open();
fen.document.write("<HTML><BODY><HEAD><TITLE>ZOOM - Cliquez sur l'image pour fermer</TITLE></HEAD>");
fen.document.write("<body bgcolor='#ffffff' leftmargin='0' bottommargin='0' marginheight='0' marginwidth='0' rightmargin='0' topmargin='0'>");
fen.document.write("<a href='javascript:self.close();'>");
fen.document.write("<img src='"+url+"' border='0'>");
fen.document.write("</a>");
fen.document.write("</BODY></HTML>");
fen.document.close();

}

function openitwithcomments(nom,url,largeur,hauteur,commentaire) 
{
var fen="fen"+nom;
fen=open("","","scrollbars=no,width="+largeur+",height="+hauteur);
fen.document.open();
fen.document.write("<HTML><BODY><HEAD><TITLE>ZOOM - Cliquez sur l'image pour fermer</TITLE></HEAD>");
fen.document.write("<body bgcolor='#ffffff' leftmargin='0' bottommargin='0' marginheight='0' marginwidth='0' rightmargin='0' topmargin='0'>");
fen.document.write("<a href='javascript:self.close();'>");
fen.document.write("<img src='"+url+"' border='0'>");
fen.document.write("</a>");
fen.document.write("<div style='padding-left:20px;padding-right:20px;'>"+commentaire+"</div>");
fen.document.write("</BODY></HTML>");
fen.document.close();

}

function majuscule(obj)
  {
    var minus = "aàâäbcçdeéèêëfghiîïjklmnoôöpqrstuùûvwxyz"
    var majus = "AAAABCCDEEEEEFGHIIIJKLMNOOOPQRSTUUUVWXYZ"
    var entree = obj.texte.value;
    var sortie = "";
    for (var i = 0 ; i < entree.length ; i++)
      {
        var car = entree.substr(i, 1);
        sortie += (minus.indexOf(car) != -1) ? majus.substr(minus.indexOf(car), 1) : car;
      }
    obj.texte.value = sortie;
   }

/*********************************************************/
/*    fonction pour validation multiple de formulaire    */
/*********************************************************/

function multiValidation(nomFormulaire,commande,valeur) {
  document.forms[nomFormulaire].elements[commande].value=valeur;
  document.forms[nomFormulaire].submit();
}

function SAVeffacerproduit(url)
{
if(confirm('Voulez-vous effacer ce produit de la demande de retour SAV ?')) 
  {
    window.location.href=url;
  }
}

function confirmation(texte,nomFormulaire)
{
if(confirm(texte)) 
  {
    document.forms[nomFormulaire].submit();
  }
}

function confirmationURL(texte,url)
{
if(confirm(texte)) 
  {
    window.location.href=url;
  }
}


function verifdemandesav() {
valide=false;
for(i = 0; i < document.forms['choixpaiement'].modePaiement.length; i++)
{	if(document.forms['choixpaiement'].modePaiement[i].checked) valide=true;}
if(valide) document.forms['choixpaiement'].submit();
else  alert("Veuillez choisir un mode de paiement !")

}

