
var imageIndex=1;
var newDiv, oldDiv;
var hold=false;
var holdTimeout;
var countDown = 10;
var ffImage=null;
var forceImage = false;
var showLabels = true;

function mdown(elem) {
    hideShow();
}

function mout(elem) {
}
function mover(elem) {
}
function setImage(n) {
    var div0 = document.getElementById("div0");
    div0.innerHTML = getImageLabel(n);
}

function play() {
    document.getElementById("stopButton").style.opacity = 1;
    document.getElementById("stopButton").style.MozOpacity = 1;
    document.getElementById("stopButton").style.filter="alpha(opacity=100)";
    document.getElementById("stopButton").style.border = "1px solid white";
    document.getElementById("playButton").style.opacity = 0.5;
    document.getElementById("playButton").style.MozOpacity = 0.5;
    document.getElementById("playButton").style.filter="alpha(opacity=50)";
    document.getElementById("playButton").style.border = "1px solid black";
    hold=false;
}
function stop() {
    document.getElementById("stopButton").style.opacity = 0.5;
    document.getElementById("stopButton").style.MozOpacity = 0.5;
    document.getElementById("stopButton").style.filter="alpha(opacity=50)";
    document.getElementById("stopButton").style.border = "1px solid black";
    document.getElementById("playButton").style.opacity = 1;
    document.getElementById("playButton").style.MozOpacity = 1;
    document.getElementById("playButton").style.filter="alpha(opacity=100)";
    document.getElementById("playButton").style.border = "1px solid white";
    hold=true;
}
function hideShow() {
    var div0 = document.getElementById("div0");
    if (showLabels) {
        document.getElementById("hideShowButton").style.opacity = .5;
        document.getElementById("hideShowButton").style.MozOpacity = .5;
        document.getElementById("hideShowButton").style.filter="alpha(opacity=50)";
        document.getElementById("hideShowButton").style.border = "1px solid black";
        div0.style.visibility="hidden";
        showLabels = false;
    } else {
        document.getElementById("hideShowButton").style.opacity = 1;
        document.getElementById("hideShowButton").style.MozOpacity = 1;
        document.getElementById("hideShowButton").style.filter="alpha(opacity=100)";
        document.getElementById("hideShowButton").style.border = "1px solid white";
        div0.style.visibility="";
        showLabels = true;
    }
}

function nextImage() {
    countDown--;
    if (!forceImage)
    if (countDown>0 || hold) {
        setTimeout("nextImage()",1000);
        return;
    }
    forceImage = false;
    oldDiv = document.getElementById("div"+imageIndex);
    document.getElementById("thu"+imageIndex).className = "imgThu";
    if (ffImage)
      imageIndex = ffImage;
    else
      imageIndex++;
    newDiv = document.getElementById("div"+imageIndex);
    if (!newDiv) {
        imageIndex=1;
        newDiv = document.getElementById("div"+imageIndex);
    }
    setImage("div"+imageIndex);
    
    
    
    newDiv.style.zIndex=20;
    oldDiv.style.zIndex=10;
    newDiv.style.filter="alpha(opacity=0)";
    newDiv.style.opacity=0;
    newDiv.style.MozOpacity=0;
    //alert(newDiv.style.filter);
    opacOld = 1;
    opac = 0;
    document.getElementById("div0").style.visibility = "hidden";
    animateTransition();
    countDown=10;
    ffImage=null;
}

function tdown(elem) {
    var str = elem.id;
    var id = str.substring(3);
    ffImage = id - 0;
    countDown=0;
    forceImage = true;
}

function animateTransition() {
    
    if (opacOld!=0) {
        opacOld -= 0.25;
        if (opacOld < 0) opacOld = 0;
        oldDiv.style.filter="alpha(opacity="+(opacOld*100)+")";
        oldDiv.style.opacity=opacOld;
        oldDiv.style.MozOpacity=opacOld;
    } else {
        opac += .25;
        if (opac >= 1) { //opac=1;
            //alert(newDiv.style.filter + " " + newDiv.style.visibility);
            newDiv.style.filter="alpha(opacity=100)";
            if (oldDiv) oldDiv.style.zIndex=9;
            newDiv.style.opacity=".99";
            newDiv.style.MozOpacity=".99";
            document.getElementById("thu"+imageIndex).className = "imgThuSel";
            setTimeout("nextImage()",1000);
            if (showLabels) document.getElementById("div0").style.visibility = "";
            return;
            
        }
        newDiv.style.filter="alpha(opacity="+(opac*100)+")";
        newDiv.style.opacity=opac;
        newDiv.style.MozOpacity=opac;
    }
    setTimeout("animateTransition()",1);
}


var divshade,img1,img2;
var opac,opacOld;
function animateLoad() {
    play();
    img1 = document.getElementById("div1");
    img2 = document.getElementById("div2");
    opac = 0;
    opacOld= 0;
    newDiv = img1;
    setImage("div1");

    newDiv.style.zIndex=20;
    oldDiv = null;
    //animateScroll();
    document.getElementById("div0").style.visibility = "hidden";
    animateTransition();
}

function installTheme2() {
    if (location.href.indexOf("fr.")>0) {
        if (window.InstallTrigger && InstallTrigger.installChrome)
            alert("Le theme n'est pas encore disponible, mais devrait l'etre tres prochainement");//InstallTrigger.installChrome(InstallTrigger.SKIN,'http://www.palmdrive.net/pierre/blueandwhite.jar','Black & Blue');
        else
            alert("Evidemment, pour voir le theme vous avez besoin de ce Browser...");
    } else {
        if (window.InstallTrigger && InstallTrigger.installChrome)
            alert("The theme is not available right now. Should be very soon though.");//InstallTrigger.installChrome(InstallTrigger.SKIN,'http://www.palmdrive.net/pierre/blueandwhite.jar','Black & Blue');
        else
            alert("You definitely need this browser I'm talking about to get the theme...");
    }
}

function installTheme() {
    if (location.href.indexOf("fr.")>0) {
        if (window.InstallTrigger && InstallTrigger.installChrome)
            InstallTrigger.installChrome(InstallTrigger.SKIN,'http://www.palmdrive.net/pierre/blueandwhite.jar','Blue & White');
        else
            alert("Evidemment, pour voir le theme vous avez besoin de ce Browser...");
    } else {
        if (window.InstallTrigger && InstallTrigger.installChrome)
            InstallTrigger.installChrome(InstallTrigger.SKIN,'http://www.palmdrive.net/pierre/blueandwhite.jar','Blue & White');
        else
            alert("You definitely need this browser I'm talking about to get the theme...");
    }
}

