
var timer; 
var current_location = 0;
var timeout_value =  5 * 1000;
var photo_urls = new Array;
var photo_captions = new Array;
var photo_descriptions = new Array;
var playing = 0;
var lblImageIndex;
var lblName;
var lblDescription;
var txtId;
var imgMain;


var SkipFirstImage = false;

function preload_complete(){
}

function reset_timer() {
    clearTimeout(timer);
    if (playing){
        timer = setTimeout('go_to_next_photo()', timeout_value);
    }
}

function go_to_next_photo() {
	//doTransistions = true;
	//alert(doTransistions);
	//doTransistions=1;
	if (SkipFirstImage){
		current_location++;
		SkipFirstImage = false;
		reset_timer();
	}
	else
	{
		var browserName=navigator.appName;
		current_location++;
	    
		if (current_location > photo_count){
			current_location = 1;
		}
	    document.getElementById(lblImageIndex).innerHTML = current_location;		
		document.getElementById(lblName).innerHTML = photo_captions[current_location];
		document.getElementById(lblDescription).innerHTML = photo_descriptions[current_location];
		
		document.getElementById(txtId).value = current_location - 1;
	    
		if (doTransistions){
			if(browserName=="Microsoft Internet Explorer"){
				document.getElementById(imgMain).filters.blendTrans.apply()    
				document.getElementById(imgMain).src = photo_urls[current_location].src;
				document.getElementById(imgMain).filters.blendTrans.play()
			}
			else{
				document.getElementById(imgMain).src = photo_urls[current_location].src;
			}
			reset_timer();
		}
		else{
			document.getElementById(imgMain).src = photo_urls[current_location].src;
		}
		
    }
}

function TogglePlay(val){
	if (playing){
		if (document.getElementById("imgAutoPlay") != null){
			document.defaultForm.imgAutoPlay.src = "/images/btn_slide_play.gif";
		}
		playing  = 0;
		clearTimeout(timer);
	}
	else{
		if (document.getElementById("imgAutoPlay") != null){
			document.defaultForm.imgAutoPlay.src = "/images/btn_slide_pause.gif"; 
		}
		playing  = 1;
		go_to_next_photo();
	}
}

function TogglePlayNew(val){
	if (document.getElementById("imgAutoPlay") != null){
		document.defaultForm.imgAutoPlay.src = "/images/btn_slide_play.gif";
	}
	playing  = 0;
	clearTimeout(timer);
}


function nextPic(val){
	current_location++;	
	if (current_location > photo_count){
		current_location = 1;
	}
	
	if (playing){
		if (document.getElementById("imgAutoPlay") != null){
			document.defaultForm.imgAutoPlay.src = "/images/btn_slide_play.gif";
		}
		playing  = 0;
		document.getElementById(lblImageIndex).innerHTML = current_location;		
		document.getElementById(lblName).innerHTML = photo_captions[current_location];
		document.getElementById(lblDescription).innerHTML = photo_descriptions[current_location];
		document.getElementById(imgMain).src = photo_urls[current_location].src;
		clearTimeout(timer);
	}
	else{
		playing  = 0;
		document.getElementById(lblImageIndex).innerHTML = current_location;		
		document.getElementById(lblName).innerHTML = photo_captions[current_location];
		document.getElementById(lblDescription).innerHTML = photo_descriptions[current_location];
		document.getElementById(imgMain).src = photo_urls[current_location].src;
		clearTimeout(timer);
	}
}



function prePic(val){
	current_location--;	
	if (current_location < 1){
		current_location = photo_count;
	}
	
	if (playing){
		if (document.getElementById("imgAutoPlay") != null){
			document.defaultForm.imgAutoPlay.src = "/images/btn_slide_play.gif";
		}
		playing  = 0;
		document.getElementById(lblImageIndex).innerHTML = current_location;		
		document.getElementById(lblName).innerHTML = photo_captions[current_location];
		document.getElementById(lblDescription).innerHTML = photo_descriptions[current_location];
		document.getElementById(imgMain).src = photo_urls[current_location].src;
		clearTimeout(timer);
	}
	else{
		playing  = 0;
		document.getElementById(lblImageIndex).innerHTML = current_location;		
		document.getElementById(lblName).innerHTML = photo_captions[current_location];
		document.getElementById(lblDescription).innerHTML = photo_descriptions[current_location];
		document.getElementById(imgMain).src = photo_urls[current_location].src;
		clearTimeout(timer);
	}
}

