var a_photos=new Array();
var a_leg=new Array();
var a_videos=new Array()
a_photos.push("photos/ph-danse1.jpg");
a_photos.push("photos/ph-danse2.jpg");
a_leg["photos"]="le cours de danse";

a_leg["videos/spectacle/09/diapo"]="Diaporama du spectacle 2009<br /><b>Diaporama silencieux</b>: A vous de choisir la musique !";
a_leg["videos"]="En association avec l'Espace Musical 25";

a_videos.push("videos/spectacle/09/diapo/spectacle.conf");
a_videos.push("videos/batterie.conf");

/*
    Fonctions d'affichage des photos et videos
    Attention, ce javascript doit etre precede de la definition des varaibles:
    a_leg, a_photos, a_videos
    cf. le script generer_javascript.pl pour les details
*/

var ph_ind = -1;
var vd_ind = -1;

/* Incremente ph_ind et affiche la photo */
function photo_suivante()
{
    var p;
    ph_ind += 1;
    if (ph_ind==a_photos.length) {ph_ind=0};
    affiche_photo(ph_ind);
}

/* Décrémente ph_ind et affiche la photo */
function photo_precedente()
{
    var p;
    ph_ind -= 1;
    if (ph_ind==-1) {ph_ind=a_photos.length};
    affiche_photo(ph_ind);
}

/* Affiche la photo dont l'indice est passé en paramètres */
function affiche_photo(ind)
{
    var p = a_photos[ind];
    var last_slash = p.lastIndexOf("/");
    var last_point = p.lastIndexOf(".");
    var dir = p.substring(0,last_slash);
    var nom = p.substring(last_slash+1,last_point);
    var e_leg = document.getElementById("legende_photo");
    e_leg.innerHTML = a_leg[dir];
    var e_photo = document.getElementById("photo");
	e_photo.innerHTML = "<img src=\""+ p +"\" />";
}

/* Incremente vd_ind et affiche la video */
function video_suivante()
{
    var p;
    vd_ind += 1;
    if (vd_ind==a_videos.length) {vd_ind=0};
    affiche_video(vd_ind);
}

/* Décrémente vd_ind et affiche la video */
function video_precedente()
{
    var p;
    vd_ind -= 1;
    if (vd_ind==-1) {vd_ind=a_videos.length};
    affiche_video(vd_ind);
}

/* Affiche la video dont l'indice est passé en paramètres */
function affiche_video(ind)
{
    var p = a_videos[ind];
    var last_slash = p.lastIndexOf("/");
    var last_point = p.lastIndexOf(".");
    var dir = p.substring(0,last_slash);
    var nom = p.substring(last_slash+1,last_point);
    var e_leg = document.getElementById("legende_video");
    e_leg.innerHTML = a_leg[dir];
    var e_video = document.getElementById("video");
    var inhtml;
	inhtml = "<object type=\"application/x-shockwave-flash\" data=\"player_flv_maxi.swf\" width=\"320\" height=\"240\">\n";
	inhtml += "<param name=\"movie\" value=\"player_flv_maxi.swf\" />\n";
	inhtml += "<param value=\"true\" name=\"allowFullScreen\" />\n";
	inhtml += "<param name=\"FlashVars\" value=\"config=" + p + "\" />\n";
	inhtml += "</object>\n";
	e_video.innerHTML = inhtml;
}

/* init_js() - Appele dans onload 
   Appelle photo_suivante() et video_suivante() afin de charger les premieres photos et videos
   fait un dislpay:block sur zone_photo et zone_video, qui ne snt pas affichees si javascript n'est pas acitve
*/

function init_js()
{
     var p = document.getElementById("zone_photo");
     var v = document.getElementById("zone_video");
     p.style.display="block";
     v.style.display="block";

     photo_suivante();
     video_suivante();
}
   
