/*  Redirection */

function AllerURL(formulaire)
  {
  if (formulaire.ListeUrl.selectedIndex != 0)
    {
    location.href = formulaire.ListeUrl.options[formulaire.ListeUrl.selectedIndex].value;
    }
  }




/*  Diaporama */

var slideshow2_noFading = false;
var slideshow2_timeBetweenSlides = 3000; // (1000 = 1 seconde)
var slideshow2_fadingSpeed = 5;  // Vitesse de transition (plus le nombre est bas, plus la vitesse est rapide)


var slideshow2_stats = new Array();

var slideshow2_slideIndex = new Array();
var slideshow2_slideIndexNext = new Array();
var slideshow2_imageDivs = new Array();
var slideshow2_currentOpacity = new Array();
var slideshow2_imagesInGallery = new Array();
var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
function createParentDivs(imageIndex,divId)
{
  if(imageIndex==slideshow2_imagesInGallery[divId]){  
    showGallery(divId);
  }else{
    var imgObj = document.getElementById(divId + '_' + imageIndex); 
    if(Opera)imgObj.style.position = 'static';
    if(!slideshow2_imageDivs[divId])slideshow2_imageDivs[divId] = new Array();
    slideshow2_imageDivs[divId][slideshow2_imageDivs[divId].length] =  imgObj;

    imgObj.style.visibility = 'hidden'; 
    imageIndex++;
    createParentDivs(imageIndex,divId); 
  }   
}

function showGallery(divId)
{
  if(slideshow2_slideIndex[divId]==-1)slideshow2_slideIndex[divId]=0; else slideshow2_slideIndex[divId]++;
  if(slideshow2_slideIndex[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndex[divId]=0;
  slideshow2_slideIndexNext[divId] = slideshow2_slideIndex[divId]+1;
  if(slideshow2_slideIndexNext[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndexNext[divId] = 0;

  slideshow2_currentOpacity[divId]=100;
  
  slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'visible';
  if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'inline';
  if(navigator.userAgent.indexOf('Opera')<0){
    slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.visibility = 'visible';
  }
  
  if(document.all){ // IE rules
    slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity=100)';
    slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity=1)';
  }else{
    slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = 0.99; // On ne peut pas utiliser 0 et 1 à cause de l'écran de FF
    slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = 0.01;
  }   
  

  setTimeout('revealImage("' + divId + '")',slideshow2_timeBetweenSlides);    
}

function revealImage(divId)
{

  if(slideshow2_noFading){
    slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';
    if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';
    showGallery(divId);
    return;
  }
  slideshow2_currentOpacity[divId]--;
  if(document.all){
    slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity='+slideshow2_currentOpacity[divId]+')';
    slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity[divId])+')';
  }else{
    slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = Math.max(0.01,slideshow2_currentOpacity[divId]/100);
    slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity[divId]/100)));
  }
  if(slideshow2_currentOpacity[divId]>0){
    setTimeout('revealImage("' + divId + '")',slideshow2_fadingSpeed);
  }else{
    slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';  
    if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';    
    showGallery(divId);
  }
}

function initImageGallery(divId)
{
  var slideshow2_galleryContainer = document.getElementById(divId);
  
  
  slideshow2_slideIndex[divId] = -1;
  slideshow2_slideIndexNext[divId] = false;
  
  var galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
  for(var no=0;no<galleryImgArray.length;no++){
    galleryImgArray[no].id = divId + '_' + no;
  }
  
  slideshow2_imagesInGallery[divId] = galleryImgArray.length;
  createParentDivs(0,divId);    
  
}

/* Pop */

function EstCoche(id){
      if(document.getElementById(id).checked == false){
        alert("L'acceptation des conditions générales de vente est nécessaire.");
      } else {
        window.location="purchase.php";
      }
    }

function visibilite(thingId){
  var targetElement;
  targetElement = document.getElementById(thingId);
  
  if (targetElement.style.display == "none") {
  targetElement.style.display = "" ;
  } else {
  targetElement.style.display = "none" ;
  }
}

function hideAllDiv(){
  for (i=0; i<document.getElementsByName("paiement").length; i++)
  hideDiv(document.getElementsByName("paiement")[i].id);
}

function hideDiv(divId){
  // document.getElementById(divId).style.visibility="hidden";
  document.getElementById(divId).style.display="none";
}

function showDiv(divId){
  hideAllDiv(); 
  // document.getElementById(divId).style.visibility="visible";
  document.getElementById(divId).style.display="inline";
}

function DialogBox(htmlContents) {

  var dialogBackground = document.createElement('div');
  dialogBackground.className = "dialogBackground";
  dialogBackground.setAttribute("id", "dialogBackground");
  var dialogBox = document.createElement('div');
  dialogBox.className = "dialogBox";
  dialogBox.setAttribute("id", "dialogBox");
  // create contents of the dialog box
  var dialogBoxContents = "";
  dialogBoxContents += "<iframe src='"+ htmlContents + "' frameborder='0' height='420' width='466' scrolling='no'></iframe>";
  dialogBox.innerHTML = dialogBoxContents;
  document.body.appendChild(dialogBox);
  document.body.appendChild(dialogBackground);

}

function closeDialogBox() {
  document.body.removeChild(document.getElementById('dialogBackground'));
  document.body.removeChild(document.getElementById('dialogBox'));
}
