url_images="";

lesSources=new Array();
lesLegendes=new Array();

//initialisation
i=0;

//on initialise l'arrêt à false pour la pause
arret=false;

// on initialise la position du message qui defilera
var position = 0;

function boutonanime(message) {
var k = ( 60 / message.length ) + 1;
for ( i = 0; i <= k; i++ ) message += " " + message;

// le nombre de caractere affiches en meme temps : 20
document.formulaire.bouton.value = message.substring(position,position + 60);
if ( position++ == message.length ) position = 0;

// vitesse de defilement du message
setTimeout("boutonanime()",150);
}



function montre(idDivAMontrer, idSousRubrique) {
  dd=document.body.getElementsByTagName("dd");
  for (var i = 0; i < dd.length; i++) {
    dd[i].style.display='none';
  }
  
  MaDivAMontrer=document.getElementById(idDivAMontrer);
if(MaDivAMontrer){
  MaDivAMontrer.style.display='block';
  changeCouleurSousRubrique(idSousRubrique);
}
}

function changeCouleurSousRubrique(idSousRubrique){
  sousRubrique=document.getElementById(idSousRubrique);
  sousRubrique.style.color="#C9252C";
}


function afficheDansContenu(web){
  var im=document.getElementById("im");
  var premierEnfant=im.firstChild;
  if(premierEnfant){im.removeChild(premierEnfant);}
  image=document.createElement("img");
  //image.setAttribute("src","http://127.0.0.1/quaidesarts/photos/"+web);
  image.setAttribute("src","http://www.quaidesarts-pornichet.fr/photos/"+web);
  im.appendChild(image);
}

function diaporama(){//alert(lesSources.length);
  timer=setTimeout("diaporama()", 1500);
  MonIm=document.getElementById("im");
  source=lesSources[i].replace(/(icone)/, "web");
  MonIm.src=source;
  MaDiv=document.getElementById("reservoir");
  MaDiv.style.visibility="visible";
  if(i==(lesSources.length-1)){
    i=0;
  }
  else{
    i++;
    im=new Image;
    im.src=source;
  }
}

function lancerdiapo(codepho, legendes){
  lesSources=new Array();
  lesLegendes=new Array();
  var code=codepho.split(',');
  for(j=0;j<code.length;j++){
    lesSources.push(code[j]);
  }
  var legende=legendes.split(',');
  for(k=0;k<legende.length;k++){
    lesLegendes.push(legende[k]);
  }
  
  diapo();
}

function diapo(){
  timer=setTimeout("diapo()", 2500);
  MonIm=document.getElementById("im");
  MonH3=document.getElementById("monH3");
  //source="http://127.0.0.1/rencarts/photos/photo"+lesSources[i]+"_web.jpg";
  source="http://rencarts.fr/photos/photo"+lesSources[i]+"_web.jpg";
  legende=lesLegendes[i];
  MonIm.src=source;
  var premierEnfant=MonH3.firstChild;
  MonH3.removeChild(premierEnfant);
  texte=document.createTextNode(legende);
  MonH3.appendChild(texte);
  MaDiv=document.getElementById("reservoir");
  MaDiv.style.visibility="visible";
  if(i==(lesSources.length-1)){
    i=0;
  }
  else{
    i++;
    im=new Image;
    im.src=source;
  }
}

function afficheFormulaire(){;
  form=document.getElementById("formulaireDiapo");
  form.style.display="block";
  
  chpSaisie=document.createElement("div");
  chpSaisie.setAttribute("class","chpSaisie");
  form.appendChild(chpSaisie);
  //Le tableau de photos
  
  for(i=0;i<(lesSources.length);i++){
    var re=/[A-Z0-9]{4}/;
    code=re.exec(lesSources[i]);
    cache=document.createElement("input");
    cache.setAttribute("type","hidden");
    cache.setAttribute("name","diapos[]");
    cache.setAttribute("value",code);
    chpSaisie.appendChild(cache);
  }
  
}


function stop(){
  clearTimeout (timer);
  //on rajoute le if -- else pour faire la pause
  if(!arret){
    arret=true;
    div=document.getElementById("pause");
    }else{
    diapo();
    arret=false;
  }
  //on enlève ce qui suit pour faire la pause
  /*    maDiv=document.getElementById("reservoir");
  maDiv.style.visibility="hidden";*/
}

function my_DropFunc () {
  if ((dd.obj.x < 510) && (dd.obj.x > 350)){
    lesSources.push(dd.obj.src);
    }else{
    dd.obj.moveTo(dd.obj.defx,dd.obj.defy);
    for(j=0;j<lesSources.length;j++) {
      if (lesSources[j]==dd.obj.src) {
        lesSources.splice(j,1);
      }
    }
  }
}


function arreter(){
  clearTimeout(timer);
  MaDiv=document.getElementById("reservoir");
  MaDiv.style.visibility="hidden";
}

function go(source, x, y){
  fenetre=window.open(source, 'mairie', 'resizable=yes, screenX=0, screenY=0, width=150px ,height=180px, top=50px, left=150px, scrollbars=yes');
  fenetre.resizeTo(x, y);
  fenetre.focus();
}

function ouvreFenetre(source){
  fenetre=window.open(source, 'mairie', 'resizable=yes, screenX=0, screenY=0, width=600px ,height=640px, top=50px, left=400px, scrollbars=yes');
  fenetre.focus();
}

function zoom(source){
  fenetre=window.open(source, 'zoom', 'resizable=yes, screenX=0, screenY=0, width=580px ,height=400px, top=100px, left=150px, scrollbars=yes');
  fenetre.focus();
}

var imagesDanielLeSaux=new Array("belloJacketEtSonMatelot", "jeannotLesLongsBras","betchetteEtCarralette","exVotoDeLaMarieToto","exVotoDeLaMarieToto2","jambeDeLune","martinsPecheurs","petiteHistoireAvecLaMer","petiteHistoireAvecLaMer2","petiteHistoireAvecLaMer3","PorteursDeGodaille");
var legendesDanielLeSaux=new Array("Bello jacket et son matelot", "Jeannot les longs bras","Betchette et carralette","Ex voto de la Marie Toto","Ex voto de la Marie Toto","Jambe de lune","Martins pêcheurs","Petite histoire avec la mer","Petite histoire avec la mer","Petite histoire avec la mer","Porteurs de godaille");
var p=0;
function afficheImagePrecedente(){
  if(p-1>=0){
    p--;
    image=document.getElementById("imageDanielLeSaux");
    image.setAttribute("src","../images/"+imagesDanielLeSaux[p]+".gif");
    
    divLegende=document.getElementById("legendeDanielLeSaux");
    texteLegende=document.createTextNode(legendesDanielLeSaux[p]);
    
    var premierEnfant=divLegende.firstChild;
    divLegende.removeChild(premierEnfant);
    
    divLegende.appendChild(texteLegende);
  }
}

function afficheImageSuivante(){
  if(p+1<imagesDanielLeSaux.length){
    p++;
    image=document.getElementById("imageDanielLeSaux");
    image.setAttribute("src","../images/"+imagesDanielLeSaux[p]+".gif");
    
    divLegende=document.getElementById("legendeDanielLeSaux");
    texteLegende=document.createTextNode(legendesDanielLeSaux[p]);
    
    var premierEnfant=divLegende.firstChild;
    divLegende.removeChild(premierEnfant);
    
    divLegende.appendChild(texteLegende);
  }
}

