/*
Slish (SlideShow) for SimpleJS
------------------------------
Slish is developed by Christophe "Dyo" Lefevre (http://bleebot.com/)
*/
var SlishCache = new Array();
function $slish(id, str, time) {
   slishnum = 1;
   slishid = id;
   slishtime = time;
   slishdelay = false;
   slishmax = str.match(/[;]/g).length;
   for (var i = 0; i < slishmax; i++) {
        pos = str.indexOf(";");
        SlishCache.push(str.substring(0, pos));
        str = str.substring(pos + 1, str.length);
        }
   }
function $slishPLAY(time) {
	if (slishdelay == false) {
   	   slishdelay = time;
   	   $slishAUTO();
	   }
   }
function $slishSTOP() {
   slishdelay = false;
   }
function $slishAUTO() {
   if (slishdelay != false) {
   if (slishnum < slishmax) slishnum += 1;
   else slishnum = 1;
   num2 = slishnum - 1;
   id = slishid;
   $opacity(id, 100, 0, slishtime); 
   STO("$opacity('" + id + "', 0, 100, " + slishtime + ")", slishtime);
   STO("$('" + id + "').src='" + SlishCache[num2] + "'", slishtime);
   STO("$slishAUTO()", slishdelay);
  $majLabel( SlishCache[num2],SlishCache[num2+1]);
      }
   }
function $slishNEXT() {
   if (slishnum < slishmax)slishnum += 1;
   else slishnum = 1;
   $slishToNum(slishnum);
   }
function $slishPREV() {
   if (slishnum > 1)slishnum -= 1;
   else slishnum = slishmax;
   $slishToNum(slishnum);
   }
function $slishToNum(num) {
   slishdelay = false;
   slishnum = num;
   num2 = num - 1;
   id = slishid;
   $opacity(id, 100, 0, slishtime);
   STO("$opacity('" + id + "', 0, 100, " + slishtime + ")", slishtime);
   STO("$('" + id + "').src='" + SlishCache[num2] + "'", slishtime);
   $majLabel( SlishCache[num2],SlishCache[num2+1]);
   }
   
//edit par zpicaut : ajout d'une fonction qui affiche le nom de l'image
// dans un span id=dynLabel
function $majLabel(str,srcimg){
tmp=document.URL;
var recherche = /galerie/g;
document.getElementById("mypicture2").src = srcimg;
if (recherche.test(tmp)==true)
{
toto=str.replace(/\/400/g,"");
document.getElementById("lien").href = toto.replace(/\.jpg/g,".JPG");
document.getElementById("lien").target = "new";
str=str.substring(str.lastIndexOf("/")+1,str.lastIndexOf("."));
str=str.replace(/%20/g," ");
str=str.replace(/%26/g,"&");
str=str.replace(/%28/g,"(");
str=str.replace(/%29/g,")");
str=str.replace(/%2C/g,",");
str=str.replace(/%2D/g,"-");
str=str.replace(/%3A/g,":");
str=str.replace(/%3F/g,"?");
str=str.replace(/%80/g,"€");
str=str.replace(/%8C/g,"Œ");
str=str.replace(/%9C/g,"œ");
str=str.replace(/%C7/g,"Ç");
str=str.replace(/%C8/g,"È");
str=str.replace(/%C9/g,"É");
str=str.replace(/%CA/g,"Ê");
str=str.replace(/%CB/g,"Ë");
str=str.replace(/%D9/g,"Ù");
str=str.replace(/%E0/g,"à");
str=str.replace(/%E7/g,"ç");
str=str.replace(/%E8/g,"e");
str=str.replace(/%E9/g,"é");
str=str.replace(/%EA/g,"ê");
str=str.replace(/%EF/g,"ï");
str=str.replace(/%F1/g,"ñ");
str=str.replace(/%F4/g,"ô");
str=str.replace(/%F9/g,"ù");
str=str.replace(/%FC/g,"ü");
str=str.replace(/%FB/g,"û");
str=str.replace(/%27/g,"'");
str=str.replace(/\(\d\)/g,"");
dynLabel.innerHTML=str;
}
}
