	// seperate js file doesn't work
	// book 1 = 27 pics
	// book 2 = 37 pics
	// book 3 = 0 pics
	var picCounts = [ 25, 25, 25, 25];
	var currentBook = 4;
	var currentPhoto = 1;
	var FREERIDER_TIME = 90000;
	var FREERIDER_START_DELAY = 20000;
	var FREERIDER_DURATION = 5000;

	var hideMe = false;

	function showCurrentBookPointer(visible) {
		var bookName = new String(currentBook);
		bookName = bookName.length == 1 ? "0" + bookName : bookName; 
		var pointer  = document.getElementById("pointer" + bookName);
		if (visible){
			pointer.style.display = 'inline';
		} else {
			pointer.style.display = 'none';
		}
	}

	function freeriderLoaded() {
		setTimeout("hideFreerider()", FREERIDER_DURATION);
	}

	function onPageLoaded() {
		showFreeriderStart();
		changePhoto();
		showCurrentBookPointer(true);
	}

	function showFreeriderStart() {
		setTimeout("showFreerider()", FREERIDER_START_DELAY);
// timeout to show books AFTER first ride 
		setTimeout("document.getElementById('header').style.display = 'block'", 1);
	}
	function showFreerider() {
		document.getElementById("freerider").style.display = 'block';
		document.getElementById("freeriderPic").src = 'pics/berg/freerider.gif';
		hideMe = true;
	}

	function hideFreerider() {
		document.getElementById("freerider").style.display = 'none';
		document.getElementById("freeriderPic").src = 'pics/dot.gif';
		if (hideMe) {
			setTimeout("showFreerider()", FREERIDER_TIME);
			hideMe = false;
		}
	}

	function showThumbs(book) {
		showCurrentBookPointer(false);
		currentBook = new Number(book);
		showCurrentBookPointer(true);

		while (document.getElementById("thumbs").childNodes.length) {
			document.getElementById("thumbs").removeChild(document.getElementById("thumbs").childNodes[0]);
		}

		var bookName = new String(currentBook);
		bookName = bookName.length == 1 ? "0" + bookName : bookName; 
		for(var i = 1; i <= picCounts[currentBook - 1];i++) {
			var photoName = new String(i);
			photoName = photoName.length == 1 ? "0" + photoName  : photoName; 
			var link = document.createElement("a"); 
			link.href = "";
			link.onclick = new Function("clickThumb(" + i + "); return false;");
			var pic = document.createElement("img");
			pic.id = "photo" + photoName;
			pic.src = "pics/berg/thumbs/" + bookName + "/" + photoName + ".jpg";
			pic.className = "thumb";
			link.appendChild(pic);
			document.getElementById("thumbs").appendChild(link);
		}
		document.getElementById("photo").style.display = 'none';
		document.getElementById("arrowLeft").style.display = 'none';
		document.getElementById("arrowRight").style.display = 'none';
		document.getElementById("thumbs").style.display = 'inline';
		document.getElementById("thumbs").style.overflow = 'auto';
		return false;
	}

	function showPhoto() {
		changePhoto();
		document.getElementById("thumbs").style.display = 'none';
		document.getElementById("arrowLeft").style.display = 'inline';
		document.getElementById("arrowRight").style.display = 'inline';
		return false;
	}

	function picLoaded() {
		document.getElementById("photo").style.display = 'inline';
	}

	function changePhoto() {
		// sprintf in js!?!!?!
		var bookName = new String(currentBook);
		bookName = bookName.length == 1 ? 0 + bookName : bookName; 
		var photoName = new String(currentPhoto);
		photoName = photoName.length == 1 ? 0 + photoName  : photoName; 
		document.getElementById("currentPic").src = "pics/berg/gallery/" + bookName + "/" + photoName + ".jpg";
	}
	
	function nextPhoto() {
	 if (currentPhoto == picCounts[currentBook - 1]) {
		currentPhoto = 1;
	 } else {
		 currentPhoto++;
	 }
		changePhoto();
	}
	
	function prevPhoto() {
		if  (currentPhoto == 1) {
			currentPhoto = picCounts[currentBook - 1];
		} else {
			currentPhoto--;
		}
		changePhoto();
	 }
	
	function clickThumb(photoId){
		currentPhoto = photoId;
		showPhoto();
	}

