//basis variabelen:

var imgDir = "images/fotos/";

var imageNum = 1;

var totalImages = 0;

var fotoDir = "";

var timechange = 5000;

var theTimer;

//pagina = "pag4";

//bgImage = imgDir +pagina +"_bg.jpg";



//array met foto's:

/*theImages = new Array()

for(i = 1; i <= totalImages; i++) {

	theImages[i] = new Image();

	theImages[i].src = imgDir +fotoDir +i +".jpg";

}*/



//functies:

function changeImage(which) {

	document.foto.src = theImages[which].src;

}



function resetImage() {

	document.groot.src = bgImage;

}



function forward() {

	imageNum++;

	if(imageNum > totalImages) {

		imageNum = 1;

	}

	document.foto.src = theImages[imageNum].src;

}



function backward() {

	imageNum--;

	if(imageNum < 1) {

		imageNum = totalImages;

	}

	document.foto.src = theImages[imageNum].src;

}



function playImageSequence() {

	forward();

	theTimer = setTimeout("playImageSequence()",timechange);

}



//Foto's in pagina's:

var totalLargeImages = 0;

var currentLargeImage;

var largeWindow = null;





function next(baseurl) {

	var nr = (currentLargeImage < totalLargeImages) ? currentLargeImage+1 : 1;

	currentLargeImage = nr;

	var url = baseurl+'large/'+nr+'.jpg';

	largeWindow.document.getElementById('largePic').src = url;

}



function previous(baseurl) {

	var nr = (currentLargeImage != 1) ? currentLargeImage-1 : totalLargeImages;

	currentLargeImage = nr;

	var url = baseurl+'large/'+nr+'.jpg';

	largeWindow.document.getElementById('largePic').src = url;

}



//sluit venster:

function closeLargeWindow() {

	if (largeWindow != null) {

		largeWindow.close();

		largeWindow = null;

	}

}



//reset venster:

function resetLargeWindow() {

	largeWindow = null;

}



//nieuw venster:

function showLarge(baseurl,nr,total) {

	if (nr == null && total == null) {

		nr = imageNum;

		total = totalImages;

	}

	totalLargeImages = total;

	currentLargeImage = nr;

	var url = baseurl+'large/'+nr+'.jpg';

	var newcontent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n';

	newcontent += '<html>\n';

	newcontent += '<head>\n';

	newcontent += '<title>Peter Klerkx Groentechnisch Bureau - Foto\'s</title>\n';

	newcontent += '<style type="text/css" media="all">@import "http://www.gtbk.nl/css/main.css";</style>\n';

	newcontent += '</head>\n';

	newcontent += '<body onUnload="self.opener.resetLargeWindow()" style="background-color: #E5EAEE; margin: 0px; text-align: center">\n';

	newcontent += '<table style="width: 720px; border: 0px">\n';

	newcontent += '	<tr height="428">\n';

	newcontent += '<tr>\n';

	newcontent += '<td style="width: 20px; text-align: center"><a href="#" onClick="self.opener.previous(\''+baseurl+'\')"><img src="http://www.pk-gca.com/images/gui/terug.gif" width="5" height="9" border="0" /></a></td>\n';

	newcontent += '<td style="padding: 10px" colspan="2" align="center"><img id="largePic" src="'+url+'" style="border: 1px solid #1D7701"></td>\n';

	newcontent += '<td style="width: 20px; text-align: center"><a href="#" onClick="self.opener.next(\''+baseurl+'\')"><img src="http://www.pk-gca.com/images/gui/verder.gif" width="5" height="9" border="0" /></a></td>\n';

	newcontent += '	</tr>\n';

	newcontent += '</table>\n';

	newcontent += '<p style=\"margin-top: 5px; font-size: 11px\">[<a href="javascript:window.close();">sluit venster</a>]</p>\n';

	newcontent += '</body>\n';

	newcontent += '</html>';

	var winheight = 10+480+10+50;

	var properties = "left=0,top=0,width=720,height="+winheight;

	if (largeWindow != null) {

		largeWindow.focus();

	} else {

		largeWindow = window.open("","largeWin",properties);

	}

	largeWindow.document.open();

	largeWindow.document.write(newcontent);

	largeWindow.document.close();

}

