var currentPhoto=0;
var linkornot=0;
var imagePlaceholder;

var preloadedimages=new Array();

for (i=0;i<photos.length;i++){
    preloadedimages[i]=new Image();
    preloadedimages[i].src=photos[i];
}

function applyeffect(){
    if (document.all && imagePlaceholder.filters){
        imagePlaceholder.filters.revealTrans.Transition=6;
        imagePlaceholder.filters.revealTrans.stop();
        imagePlaceholder.filters.revealTrans.apply();
    }
}

function playeffect(){
    if (document.all && imagePlaceholder.filters)
        imagePlaceholder.filters.revealTrans.play();
}

function keeptrack(){
    $('arrows_text').innerHTML = "Image " + (currentPhoto+1) + " of " + photos.length;
}

function changephoto() {
    imagePlaceholder.src="images/spacer.gif";
    applyeffect();
    imagePlaceholder.src=photos[currentPhoto];
    $('download').href = photos[currentPhoto];
    playeffect();
    keeptrack();
    //$('arrow_left').className = currentPhoto==0 ? 'dead' : 'active';
    //$('arrow_right').className = currentPhoto==photos.length-1 ? 'dead' : 'active';
}

function backward(){
    if (currentPhoto>0){
        currentPhoto--;
        changephoto();
    } else 
        if(currentPhoto == 0) {
            currentPhoto = photos.length-1;
            changephoto();
        }
}

function forward(){
    if (currentPhoto<photos.length-1){
        currentPhoto++;
        changephoto();
    } else
        if(currentPhoto == photos.length-1) {
            currentPhoto = 0;
            changephoto();
        }
}

addEvent(window,"load",function() {
    imagePlaceholder = $('photoslider');
	currentPhoto = 0;
	changephoto();
});
