// PAGE NAVIGATION
// ----------------------------------------------------------
nrOfPages = 40;
currentPage = 1;
imgSrcPrefix = "images/pages/page1-";
imgSrcThumbPrefix = "images/thumbs/page1-";
firstImgNrShift = 998;

function showPage (pageNr) {

	// update page navigation
	$('currentPage').update(pageNr);
	
	// hide current image and load new image
	Effect.Fade('imgBig', {
		afterFinish: (function() {
 
			// show loading progress
			$('imgContainer').setStyle({background: '#fff url(images/shared/loader.gif) no-repeat center center'});
			
			// load image
			var newImage = null;
			newImage = new Image();
			newImage.onload = function() {
				 // alert("geladen " + this.src + " / alt = " + $('imgBig').src);   
				// hide loading progress
				$('imgContainer').setStyle({'background-image': 'none'});
				// set new image
				$('imgBig').src = this.src;
				// show image
				Effect.Appear('imgBig');
				
			};
			newImage.src = imgSrcPrefix + (currentPage + firstImgNrShift) + "-full.jpg";
			//alert("geladen " + newImage.src); 
		})
    });
	
	currentPage = pageNr;

}


function nextImg() {
	if (currentPage < nrOfPages) {
		currentPage++;
		showPage(currentPage);
	}
}


function prevImg() {
	if (currentPage > 1) {
		currentPage--;
		showPage(currentPage);
	}
}


// PAGE OVERVIEW
// ----------------------------------------------------------
function writePictFrames() {
	for (var i= 999; i< nrOfPages + firstImgNrShift + 1; i++) {
		$('pictContainer').insert({bottom: '<div class="pictFrame"><a href="index.php?currentpage='+ (i - firstImgNrShift) +'" title="enlargement"><img src="' + imgSrcThumbPrefix + i + '-full.jpg" alt="enlargement" /></a></div>'});
	}
}