/*
EasyImageTour 1.0 Produced and Copyright by Koller Juergen
www.kollermedia.at | www.austria-media.at
Need Help? http://www.kollermedia.at/archive/2007/09/16/easyimagetour-a-free-and-easy-image-presentation-script/
You can use this Script for private and commercial Projects, but just leave these credit lines, thank you.
*/

//EasyImageTour 1.0 - SETTINGS
var imagepath = "img/home/"; // Set the path to your imagefolder
var startimage = 1;	//Set your Startimage
var autoplay = 1; // Should the images switch automatic on start?
var switchspeed = 3;  // If autoplay =1, set the time in seconds when the images should switch
 
//EasyImageTour functions - no need to edit something below
function easyimagetour(imagenr){
	var imagecount = document.getElementById("smallimages").getElementsByTagName("a");
	if (imagenr == "back") {
		if (lastimage == 1) {
			imagenr=imagecount.length;
		} 
		else {
			imagenr=parseInt(lastimage)-(1);
		} 
		lastimage = imagenr;
	}
	else if (imagenr == "next") {
		if (lastimage == imagecount.length) {
			imagenr=1;
		} 
		else {
			imagenr=parseInt(lastimage)+(1);
		} 
		lastimage = imagenr;
	} 
	else {
		lastimage = imagenr;
	}
	document.getElementsByName("bigimage")[0].src = imagepath+'big'+imagenr+'.jpg';
	for (var i=0;i<imagecount.length;i++){
		document.getElementById("smallimages").getElementsByTagName("a")[i].className="";
	}
	document.getElementById("smallimages").getElementsByTagName("a")[imagenr-1].className ="active";
	//document.getElementById("counter").innerHTML = imagenr;
	document.getElementById("description").innerHTML = document.getElementById("smallimages").getElementsByTagName("a")[imagenr-1].title;
}
	
var timer; 
counter=0;

function start_easyimagetour(){
	counter=counter+1;
	timer=setTimeout("start_easyimagetour()",1000);
	if (counter == switchspeed+1) {
		easyimagetour("next"); 
		restart_easyimagetour()
	}
}

function startstop_easyimagetour() {
	if(document.getElementById("autoplay").innerHTML == "Stop Autoplay") {
		clearTimeout(timer);
		counter=0;
		//document.getElementById("autoplay").innerHTML = "Start Autoplay";
	}
	else {
		clearTimeout(timer);
		counter=0;
		start_easyimagetour();
		//document.getElementById("autoplay").innerHTML = "Stop Autoplay";
	}
}

function restart_easyimagetour(){
	clearTimeout(timer);
	counter=0;
	start_easyimagetour();
}

function stop_easyimagetour(){
	clearTimeout(timer);
	counter=0;
}

window.onload=function(){
	easyimagetour(startimage); 
	if(autoplay!=0) {
		start_easyimagetour(); 
		//document.getElementById("autoplay").innerHTML = "Stop Autoplay";
	}
}