/******************************************************************************
Copyright (C) Matteo Lucarelli - matteolucarelli@altervista.org

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
******************************************************************************/

//------------------------EDIT SECTION-----------------------------------------
// the image count
var imgcount=6;
// number of columns in thumbnails table
var colcount=3;
//-----------------------------------------------------------------------------

var current;
// returns the image name as string ('01','02'...'99')
function imgName(img){
	if (img<10) return '0'+String(img);
	else return String(img);
}

// build-up the thumbnails table
function addThumbs(){
	document.writeln('<table>')
	for (r=0;r<(imgcount/colcount);r++){
		document.writeln('<tr>')
		for (c=0;c<colcount;c++){
			cur=imgName(r*colcount+c+1);
			if (Number(cur)<=imgcount)
				document.writeln('<td><a href="./slideshow.htm?'+cur+'"><img src="photo/'+cur+'s.jpg" alt=""></a></td>');
		}
		document.writeln('</tr>')
	}
	document.writeln('</table>')
}

// load image in slideshow
function load(img){
	if (img<1) img=imgcount;
	if (img>imgcount) img=1;
	document['mainimg'].src = 'photo/'+imgName(img)+'.jpg';
	current=img;
}

// load the page with an image reading 
// parameter in a POST-like style (url?imagenum)
function loadfirst(){
	qstring=document.location.search.substring(1,255);
	load(Number(qstring));
}

// load next image
function nextimg(){
	load(current+1);
}

//load prev image
function previmg(){
	load(current-1);
}