<!-- //

var start;
var finish;

function init(img,end) {
	setTimeout("startShow("+ img +")",1);
	start = img;
	finish = end;
}

function startShow(img,view) {
	if(img > finish){
		img = start;
	}
	if(img < start){
		img = finish;
	}

	var next = img + 1;
	if(img < 10){
		img = "0" + img;
	}
	document.getElementById('img_container').innerHTML = "<img name=\"the_img\" src=\"./images/galleryimages/img_"+ img +".jpg\" />";
	if(view == true){
		clearTimeout( timer );
		timer = setTimeout("startShow("+ next +",false)",5000);
		return;
	}
	
	timer = setTimeout("startShow("+ next +",false)",5000);
}

function getImgNum(){
	var cur_img = document.images.the_img.src;
	cur_img = parseInt(cur_img.slice(cur_img.length - 6, cur_img.length - 4));
	return cur_img;
}

function show(way) {
	var show_img;

	if(way == "prev"){
		show_img = getImgNum() - 1;
	} else if(way == "next"){
		show_img = getImgNum() + 1;
	}
	clearTimeout( timer );
	setTimeout("startShow("+ show_img +",true)",1);
	return;
}


function play(img){
	setTimeout("startShow("+ img +",true)",1);
	document.getElementById("action").innerHTML = "<a class=\"control\" href=\"#bottom\" onclick=\"pause()\"><img src=\"./images/galleryimages/Pause.gif\" /></a>";
	return;
}

function pause(){
	clearTimeout( timer );
	var img = getImgNum() + 1;
	document.getElementById("action").innerHTML = "<a class=\"control\" href=\"#bottom\" onclick=\"play("+ img +")\"><img src=\"./images/galleryimages/Play.gif\" /></a>";
	return;
}

// -->
