// JavaScript Document
/********************************************************************************************************
PHOTO SLIDESHOW - By: Felix Bruce Smith (fbruce_smith@yahoo.com) & Tettey Mante (paatmante@yahoo.com)
*********************************************************************************************************/

var photos=new Array()
var photo_desc=new Array()
var photoslink=new Array()
var which=0
var photoslider = '';
var desc_place_holder = '';
var Pause = false ;
setInterval('forward()',10000);
//define images. You can have as many as you want:
function CreatePhotos(path,photos,desc){
	//photos = photoList.split(',');
	photo_desc = desc;
	for(i=0;i<photos.length;i++)
		photos[i] = path + "/" + photos[i];
}


//Specify whether images should be linked or not (1=linked)
var linkornot=0

//Set corresponding URLs for above images. Define ONLY if variable linkornot equals "1"
photoslink[0]=""
photoslink[1]=""
photoslink[2]=""

//do NOT edit pass this line

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 && photoslider.filters){
		photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*1)
		photoslider.filters.revealTrans.stop()
		photoslider.filters.revealTrans.apply()
	}
}
function getName(n){
	return document.getElementsByName(n);	
}

function start(){
	photoslider = document.getElementById("photoslider");
	desc_place_holder = document.getElementById("dc");
	desc_place_holder.innerHTML = photo_desc[0]
}



function playeffect(){
	if (document.all && photoslider.filters)
		photoslider.filters.revealTrans.play()
}

function keeptrack(){
	window.status="Image "+(which+1)+" of "+photos.length
}


function enablePreviousBTN(state){
	if(state){
		getName('previous')[0].src = "../images/gallery_navigation/previous.png";
		getName('previous')[1].src = "../images/gallery_navigation/previous.png";
	}else{
		getName('previous')[0].src = "../images/gallery_navigation/previous_disabled.png";
		getName('previous')[1].src = "../images/gallery_navigation/previous_disabled.png";
	}
}

function enableNextBTN(state){
	if(state){
		getName('next')[0].src = "../images/gallery_navigation/next.png";
		getName('next')[1].src = "../images/gallery_navigation/next.png";
	}else{
		getName('next')[0].src = "../images/gallery_navigation/next_disabled.png";
		getName('next')[1].src = "../images/gallery_navigation/next_disabled.png";
	}
}

function enableFirstBTN(state){
	if(state){
		getName('first')[0].src = "../images/gallery_navigation/first.png";
		getName('first')[1].src = "../images/gallery_navigation/first.png";
	}else{
		getName('first')[0].src = "../images/gallery_navigation/first_disabled.png";
		getName('first')[1].src = "../images/gallery_navigation/first_disabled.png";
	}
}

function enableLastBTN(state){
	if(state){
		getName('last')[0].src = "../images/gallery_navigation/last.png";
		getName('last')[1].src = "../images/gallery_navigation/last.png";
	}else{
		getName('last')[0].src = "../images/gallery_navigation/last_disabled.png";
		getName('last')[1].src = "../images/gallery_navigation/last_disabled.png";
	}
}



function backward(){
	if (which > 0){
		which--
		applyeffect()
		photoslider.src=photos[which]
		desc_place_holder.innerHTML = photo_desc[which]
		playeffect()
		keeptrack()
		enableLastBTN(true);
		enableNextBTN(true);
		if(which<=0){enablePreviousBTN(false);enableFirstBTN(false);}
		
	}
}

function Next(){
	if (which < photos.length-1){
		which++
		applyeffect()
		desc_place_holder.innerHTML = photo_desc[which]
		photoslider.src = photos[which]
		playeffect()
		keeptrack()
		enablePreviousBTN(true);
		enableFirstBTN(true);
		if (which >= photos.length-1){
			enableLastBTN(false);enableNextBTN(false);
		}
	}
}

function First(){
		applyeffect()
		desc_place_holder.innerHTML = photo_desc[0]
		photoslider.src = photos[0]
		playeffect()
		keeptrack()
		which = 0
		enableLastBTN(true);
		enableNextBTN(true);
		enablePreviousBTN(false);
		enableFirstBTN(false);
}

function Last(){
		applyeffect()
		desc_place_holder.innerHTML = photo_desc[photo_desc.length-2]
		photoslider.src = photos[photos.length-1]
		playeffect()
		keeptrack()
		which = photos.length-1
		enableLastBTN(false);
		enableNextBTN(false);
		enablePreviousBTN(true);
		enableFirstBTN(true);
}

function forward(){
	if(Pause)return 0;
	if(which > photos.length-1)
		which = 0;
	if (which <= photos.length-1){
		applyeffect()
		desc_place_holder.innerHTML = photo_desc[which]
		photoslider.src = photos[which]
		playeffect()
		keeptrack()
		which++
	}
}

function transport(){
	window.location=photoslink[which]
}
function PlayPause(e){
	i = document.getElementById(e);
	ii = document.getElementById(e + '1');
	if(Pause){
		Pause = false;
		i.src = "../images/gallery_navigation/pause.png"
		i.alt = "(PLAYING) Click to Pause"
		
		ii.src = "../images/gallery_navigation/pause.png"
		ii.alt = "(PLAYING) Click to Pause"
	}
	else{
		Pause = true;
		i.src = "../images/gallery_navigation/play.png"
		i.alt = "(PAUSED) Click to Play"
		
		ii.src = "../images/gallery_navigation/play.png"
		ii.alt = "(PAUSED) Click to Play"
		
	}
}