<!--
// Variables de détection du navigateur
var ua = navigator.userAgent.toLowerCase();
isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)); 
isGecko = (ua.indexOf("gecko") != -1);
isNetscape = (ua.indexOf("netscape") != -1);
finua = ua.substring(ua.indexOf("msie")+5,ua.length);
versionIE = finua.substring(0,finua.indexOf(";"));
expire = 100000;

function SetStatusBar(StatusText) {
  if ((OldStatus == "") && (ShowStatus == true)){
    window.status = StatusText;
  }
  else {
    OldStatus = StatusText;
  }
}

function StartSlideShow(categorie,urlbase) {

  Running = true;
  document.bouton_lecture_pause.src = urlbase + "/image/photo/" + categorie + "/pause.gif";
  if (isIE || isGecko) {
  	if (isIE && versionIE < 5.50) {
  		texte_bouton.innerHTML='<font color="white">Pause</font>';
  	} else {
  		document.getElementById("texte_bouton").innerHTML='<font color="white">Pause</font>';
  	}
  } else {
  	if (isNetscape) {
  		document.texte_bouton.document.write('<font color="white">Pause</font>');
  	} else {
  		document.texte_bouton.document.write('<font color="white">Pause</font>');
  	}
  }
  SetStatusBar("Lecture automatique du diaporama en cours");
  WriteCookie("DefilementStoppe", "false", expire);
}

function StopSlideShow(categorie, urlbase) {
  Running = false;
  document.bouton_lecture_pause.src = urlbase + "/image/photo/" + categorie + "/lecture.gif";
  if (isIE || isGecko) {
  	if (isIE && versionIE < 5.50) {
  		texte_bouton.innerHTML='<font color="white">Animer</font>';
  	} else {
  		document.getElementById("texte_bouton").innerHTML='<font color="white">Animer</font>';
  	}
  } else {
  	if (isNetscape) {
  		document.texte_bouton.document.write('<font color="white">Animer</font>');
  	} else {
  		document.texte_bouton.document.write('<font color="white">Animer</font>');
  	}
  }
  SetStatusBar("Lecture automatique du diaporama arrêtée");
  WriteCookie("DefilementStoppe", "true", expire);
}

function StartStop(categorie, urlbase) {
  if (Running == false) {
    StartSlideShow(categorie, urlbase);
  }
  else {
    StopSlideShow(categorie, urlbase);
  }
}

function CountDown() {
  if (Running == true) {

    if (SecondsLeft > 0) {
      SecondsLeft--;
    }
    else {
      Running = false;
      document.location = NextImagePage;
    }
  }

  setTimeout("CountDown()",1000);
}

function ReadCookie(name, DefaultValue) {

  var cookieValue = escape(DefaultValue);
  var search = name + "=";

//alert("read : taille du cookie "+name+": "+document.cookie.length);
  if(document.cookie.length > 0) {

    offset = document.cookie.indexOf(search);
    if (offset != -1) {

      offset += search.length;
      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))
    }

  }

//alert("readCookie("+ DefaultValue +") : "+cookieValue);

  return cookieValue;
}

function WriteCookie(name, value, expire) {
//alert("writeCookie ("+name+" : "+value);
var date = new Date((new Date()).getTime() + expire);
var expdate = date.toGMTString();
document.cookie = name+ '=' +escape(value)+ ';expires='+expdate+';path=/;';
}

function InitializePage(url_suivante, categorie, urlbase) {

  NextImagePage = url_suivante;

  if (ReadCookie("DefilementStoppe", "true") == "true") {
    StopSlideShow(categorie, urlbase);
  }
  else {
    StartSlideShow(categorie, urlbase);
  };

  CountDown();
}

function PageLoaded(url_suivante, categorie, urlbase) {
  InitializePage(url_suivante, categorie, urlbase);
}
//-->