//javascript
//contact: valen16@trypill.org
//kphotools     --        2004
var img_id = delineate(window.location);
var slide_count = parseInt(img_id,10);
if(slide_count == "")
	slide_count = 0;
	
if(img_id == "")img=0000;
//create output for navigation
var current_image = format_curImg(img_id);
var navi = "";
var paused = false;
if(current_image-1 != 0)
{
	
	navi += '<A href="show.html?img='+form_id(current_image-2)+'">&lt; &lt;</A> ';
}
navi += ' <A href="index.html?offset='+eval(roundTowardsZero((current_image/9)-1))+'">index</A> ';
if(current_image != img_count)
{
	
	navi += ' <A href="show.html?img='+form_id(current_image)+'">&gt; &gt;</A>';
}
document.getElementById('navigation').innerHTML=navi;
document.getElementById('current_img').innerHTML = current_image;
document.getElementById('img_count').innerHTML = img_count;
document.getElementById('slideshow').innerHTML = '<A name="" onClick="next_slide()">slideshow</A>';


function load(){
	document.getElementById('img').src = images.src;
}
function loadnone()
{
	document.getElementById('img').src = "nofile.png";
}
images = new Image;
images.src = "images/"+base_name+""+img_id+"."+type;
images.onload=document.getElementById('img').src=images.src;//load(img_id);
function format_curImg(imgid)
{
	while(imgid[0]=="0")
		imgid = imgid.substr(1);
	imgid = imgid-1+2;
	return imgid;
}
function next_slide()
{
	if(!paused)
	{
		var time = document.getElementById('timetowait').value;
		document.getElementById('slideshow').innerHTML = '<A name="" onClick="pause()">pause</A>';
		slide_count++;
		if(img_count <= slide_count)
		{
			slide_count = 0;
		}
		images = new Image;
		slide_id = form_id(slide_count);
		
		images.src = "images/"+base_name+""+slide_id+"."+type;
		images.onload=document.getElementById('img').src=images.src;//load(img_id);
		setTimeout("next_slide()",time*1000);
		document.getElementById('current_img').innerHTML = slide_count+1;
	}
	else
	{
		paused=false;
	}
}
function pause()
{
	paused = true;
	document.getElementById('slideshow').innerHTML = '<A name="" onClick="next_slide()">slideshow</A>';
}


