function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function OuvrePlan() {
  var haut=(screen.height-800)/2;
  var gauche=(screen.width-565)/2;
  w=open("plan.html",'popup','top=0'+',left='+gauche+',width=565,height=800,toolbar=no,scrollbar=yes,resizable=yes');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}


function ObjGetPosition(obj_){
  var PosX = null;
  var PosY = null;
  var Obj  = document.getElementById( obj_);
  //-- Si l'objet existe
  if( Obj){
    //-- Recup. Position Objet
    PosX = Obj.offsetLeft;
    PosY = Obj.offsetTop;
    //-- Si propriete existe
    if( Obj.offsetParent){
      //-- Tant qu'un parent existe
      while( Obj = Obj.offsetParent){
        if( Obj.offsetParent){ // on ne prend pas le BODY
          //-- Ajout position Parent
          PosX += Obj.offsetLeft;
          PosY += Obj.offsetTop;
        }
      }
    }
  }
  //-- Retour des positions
  return([PosX, PosY]);
}
//-----------------------------
function ObjGetDimension( obj_){
  var Larg = 0;
  var Haut = 0;
  var Obj = document.getElementById( obj_);
  if( Obj){
    Larg = Obj.offsetWidth;
    Haut = Obj.offsetHeight;
  }
  return([Larg, Haut]);
}
//---------------------
function ObjHide( obj_){
  var Obj = document.getElementById( obj_);
  if( Obj){
    Obj.style.visibility= "hidden";
    Obj.style.zIndex = 0;
  }
  return(true);
}
//-------------------------
function ObjShow( obj_, z_){
  var Obj = document.getElementById( obj_);
  if( Obj){
    Obj.style.visibility = "visible";
    if( arguments[1] != null)
      Obj.style.zIndex = z_;
    else
      Obj.style.zIndex = 1;
  }
  return(true);
}
/////////////////////////////////
// PARTIE POUR EFFET SUR IMAGE //
/////////////////////////////////
//-------------------------
function GetDimImage( div_){
  var Larg = 0;
  var Haut = 0;
  var Obj = document.getElementById( div_);
  if( Obj){
    var Img  = Obj.getElementsByTagName('img');
    if( Img[0]){
      Larg = Img[0].clientWidth;
      Haut = Img[0].clientHeight;
      if( Larg < 1) // pour NetScape
        Larg = Img[0].width;
      if( Haut < 1) // pour NetScape
        Haut = Img[0].height;
    }
  }
  return( [Larg, Haut]);
}
//--------------------------------------
function Show_Image( div_, img_, where_){
  var L_Deb;     // Largeur de debut de l'IMG
  var H_Deb;     // Hauteur de debut de l'IMG
  var L_Fin;     // Largeur de fin de l'IMG
  var H_Fin;     // Hauteur de fin de l'IMG
  var PosDebX;   // Position X depart
  var PosDebY;   // Position Y depart
  var PosFinX;   // Position X arrivee
  var PosFinY;   // Position Y arrivee

  //-- Creation Image dans DIV cache --
  var Obj = document.getElementById( 'D_TEMP');
  if( !Obj) return(false);
  Obj.innerHTML = szDeb + '<img src="' +img_ +'">' +szFin;

  //-- Recup Position Image Finale --
  Obj = document.getElementById( where_);
  if( !Obj) return(false);

  var Dim = ObjGetDimension( where_);
  var Pos = ObjGetPosition( where_);
  PosFinX = Pos[0] +( Dim[0] >>1);
  PosFinY = Pos[1] +( Dim[1] >>1);

  //-- Recup Position Image Depart --
  Pos  = ObjGetPosition( div_);
  PosDebX = Pos[0];
  PosDebY = Pos[1];

  //-- Recup Taille Image Depart --
  Dim = GetDimImage( div_);
  L_Deb = Dim[0];
  H_Deb = Dim[1];

  //-- Recup. taille Image Finale --
  Dim = GetDimImage( 'D_TEMP');
  L_Fin = Dim[0];
  H_Fin = Dim[1];

  //-- Recup. taille affichage final
  Dim  = ObjGetDimension( 'D_TEMP');

  //-- Recalage position de fin
  PosFinX -= ( Dim[0] >>1);
  PosFinY -= ( Dim[1] >>1);

  //-- Calcul parametres deplacement --
  var Rap_X = ( L_Fin - L_Deb) / NbTrame;
  var Rap_Y = ( H_Fin - H_Deb) / NbTrame;
  var Inc_X = ( PosFinX - PosDebX) / NbTrame;
  var Inc_Y = ( PosFinY - PosDebY) / NbTrame;

  //-- Stop si en cours
  clearTimeout(ID_Timer);

  //-- Init des DIV de transitions
  for( i =0; i<NbTrame-1; i++){
    Obj = document.getElementById( 'D_' +i );
    if( Obj){
      //-- Calcul positions et dimensions
      Pos[0] = PosDebX  +parseInt( (i+1) *Inc_X);
      Pos[1] = PosDebY  +parseInt( (i+1) *Inc_Y);
      Dim[0] = L_Deb    +parseInt( (i+1) *Rap_X);
      Dim[1] = H_Deb    +parseInt( (i+1) *Rap_Y);

      //-- Initialisation des DIVs
      Obj.innerHTML  = szDeb  +'<img src="' +img_ + '" width=' +Dim[0] +' height='+ Dim[1] +'>' +szFin;
      Obj.style.left = Pos[0] +"px";
      Obj.style.top  = Pos[1] +"px";
      Obj.style.visibility = "hidden";
    }
  }
  //-- Init DIV de fin
  var szTmp = '<img src="' +img_ +'" border=0  alt="Feux d\'artifice" title="Feux d\'artifice">';
  if( !ModeAuto)
    Html = '<a href="#" Onclick="Show_ZoomMoins(' +NbTrame +');return(false);">'+ szTmp +'<\/a>';
  else
    Html = '<img src="' +img_ +'">';

  var Obj = document.getElementById( 'D_' +i );
  if( Obj){
    Obj.innerHTML  = szDeb +Html +szFin;
    Obj.style.left = PosFinX +"px";
    Obj.style.top  = PosFinY +"px";
    Obj.style.visibility = "hidden";
  }
  //-- Lance l'animation
  Show_ZoomPlus( 0);

  //-- return false pour evenement onclick
  return( false);
}
//----------------------------
function Show_ZoomMoins( num_){
  //-- Stop si en cours
  clearTimeout(ID_Timer);
  //-- Masque le precedent
  ObjHide( 'D_' +num_);
  //-- Affiche le nouveau
  ObjShow( 'D_' +(num_ -1), 10 +num_);
  if( num_ > 0){
    num_--;
    ID_Timer = setTimeout("Show_ZoomMoins("  +num_ +")", Delay);
  }
}
//---------------------------
function Show_ZoomPlus( num_){
  //-- Stop si en cours
  clearTimeout(ID_Timer);
  //-- Affiche le nouveau
  ObjShow( 'D_' +num_ , 10 +num_);
  //-- Masque le precedent
  ObjHide( 'D_' +(num_ -1));
  if( num_ < NbTrame-1){
    num_++;
    ID_Timer = setTimeout("Show_ZoomPlus("  +num_ +")", Delay);
  }
  else{
    if( ModeAuto)
      ID_Timer= setTimeout( "Show_ZoomMoins(" +NbTrame +")", DelayAuto);
  }
}
///////////////////////////
// PARTIE INITIALISATION //
///////////////////////////
//-------------------------------------------------
// Creation d'un div lorsque le document est charge
//-------------------------------------------------
function AddDIV( div_, txt_){
  var Html ="";
  var NewDiv;
  if( document.createElement){
    NewDiv = document.createElement('div');
    with( NewDiv){
      id               = div_;
      innerHTML        = txt_ ? txt_ :'';
      style.position   = "absolute";
      style.left       = "0px";
      style.top        = "0px";
      style.width      = "auto";
      style.height     = "auto";
      style.visibility = "hidden";
      style.zIndex     = 0;
    }
    document.body.appendChild(NewDiv);
  }
}
//-----------------
function InitPage(){
  //-- Ajout d'un DIV reception image finale
  AddDIV( 'D_TEMP');
  //-- Ajout des DIV translation image
  for( i =0; i< NbTrame; i++)
   AddDIV( 'D_'+ i);
}
//---------------------------------------------
function Add_Event( obj_, event_, func_, mode_){
  if( obj_.addEventListener)
    obj_.addEventListener( event_, func_, mode_? mode_:false);
  else
    obj_.attachEvent( 'on'+event_, func_);
}




function submitform()
{
var verif;
verif="";
 
if (document.getElementById("nom").value == "") {
	verif = verif + "- Nom" + "\n";
}
if (document.getElementById("prenom").value == "") {
	verif = verif + "- Prénom" + "\n";
}
if (document.getElementById("adresse").value == "") {
	verif = verif + "- Adresse" + "\n";
}
if (document.getElementById("cp").value == "") {
	verif = verif + "- Code postal" + "\n";
}
if (document.getElementById("ville").value == "") {
	verif = verif + "- Ville" + "\n";
}
if (document.getElementById("email").value == "") {
	verif = verif + "- Email" + "\n";
}
if (document.getElementById("tel").value == "") {
	verif = verif + "- Téléphone" + "\n";
}
 
// Vérif champs obligatoires
if (verif==""){
	document.myform.submit();
}	
else{
	alert("Attention les champs suivant sont obligatoires :" + "\n" +verif);
}
 
}


function Play_Son(s_son)
{
var s_html = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='1' height='1' "+
"id='dewplayer' align='middle'><param name='allowScriptAccess' value='always' />"+
"<param name='movie' value='dewplayer.swf?mp3=" + s_son + "&autostart=1' />"+
"<param name='quality' value='high' />"+
"<param name='bgcolor' value='#ffffff' />"+
"<param name='wmode' value='transparent' />"+
"<embed src='dewplayer.swf?mp3=" + s_son + "&autostart=1' wmode='transparent' quality='high' bgcolor='#ffffff' width='1' height='1' name='dewplayer' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' ></embed></object>";
document.getElementById("my_dewplayer").innerHTML = s_html;
}

function Stop_Son()
{
document.getElementById("my_dewplayer").innerHTML = "";
}

function checkForm(els){
    var els = els.elements; // éléments du formulaire
    var regEx =/^test-(.+)/; // expression régulière testant si le champs est à valider
      for ( var i = 0 ; i < els.length ; i++ ) { // on boucle sur les éléments du formulaire
        if(regEx.test(trim(els[i].name.toString()))){ // test si le champs est à valider
             switch(els[i].type){ //Chaque élément à son test personnalisé

             //test des champs de type text
                case "text":
                    if(trim(els[i].value).length <= 0){
                        alert("vous devez remplir le champs de text");
                        els[i].focus();
                        return false;
                    }else{ // test si c'est un champs contenant un email
                        regExEmail = /^test-email-(.+)/;
                        if(regExEmail.test(trim(els[i].name.toString()))){
                            if(!isEmail(els[i].value)){
                                alert("l'email saisie est invalide");
                                els[i].focus();
                                return false;
                            }
                        }
                    }
                 break;


              //test des champs de type textarea
                case "textarea":
                    if(trim(els[i].value).length <= 0){
                        alert("vous devez remplir le champs de text");
                        els[i].focus();
                        return false;
                    }
                 break;

              //test des champs de type file
                case "file":
                    if(trim(els[i].value).length <= 0){
                        alert("vous devez envoyer un fichier");
                        els[i].focus();
                        return false;
                    }else{
                        //test si l'extention est valide
	                        if( /^(.+)\.(pdf|jpg|gif|avi)/i.test(trim(els[i].value.toLowerCase())) == false){
                            alert("vous n'avez pas choisi le bon type de fichier");
                            els[i].focus();
                            return false;
                        }
                    }
                 break;


              //test des champs de type radio
                case "radio": // test pour les champs radio
                    var test = false;
                    var nom_champ = els[i].name; // si des champs radio se suivent et ne porte pas le même nom on les traites séparément
                    // on boucle sur les champs radio pour savoir si au moins un champs est sélectionné
                        while(els[i].type == "radio" && nom_champ == els[i].name){
                            if(els[i].checked){
                                test = true;
                            }
                            i++;
                        }
                        i--;
                    if(!test){
                        alert("vous devez sélectionner une option radio");
                        els[i].focus();
                        return false;
                    }
                 break;


            //test des champs de type checkbox
                case "checkbox":
                    if(!els[i].checked){
                        alert("vous devez sélectionner une option chekbox");
                        els[i].focus();
                        return false;
                    }
                 break;


            //test des champs de type select où une seul sélection est possible
                case "select-one":
                    var test = false;
                    for(var x=0; x < els[i].length; x++){
                        if(els[i][x].selected && els[i][x].value != '-1'&& trim(els[i][x].value) != ''){
                            test = true;
                        }
                    }
                    if(!test){
                        alert("vous devez sélectionner une option dans la liste déroulante");
                        els[i].focus();
                        return false;
                    }
                 break;


            //test des champs de type select où plusieurs sélections sont possible
                case "select-multiple":
                    var test = false;
                    for(var x=0; x < els[i].length; x++){
                        if(els[i][x].selected && els[i][x].value != '-1'&& trim(els[i][x].value) != ''){
                            test = true;
                        }
                    }
                    if(!test){
                        alert("vous devez sélectionner une option dans la liste multipe");
                        els[i].focus();
                        return false;
                    }
                 break;
             } // fin du switch
          } // fin du for
        } // fin du if
        if(test){
            return false;
        }
}


function isEmail(strSaisie) {
    var verif = /^[^@]+@(([\w\-]+\.){1,4}[a-zA-Z]{2,4}|(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5]))$/
    return ( verif.test(strSaisie) );
}

//fonction trouvé à l'adresse suivante
//http://anothergeekwebsite.com/fr/2007/03/trim-en-javascript
function trim(aString) {
    var regExpBeginning = /^\s+/;
    var regExpEnd       = /\s+$/;
    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}

