// JavaScript Document
var curphoto=0;
var startphoto=0;
var blankthumb='/FreeFormCMS/images/transpixel.gif';
function display_thumbs() {
	var num=startphoto;
	for (i=0;i<6;i++) {
		num=startphoto+i;
		if (num<mypics.length) {
			document.getElementById('thumbnail'+i).src=mypics[num][0];
			if (mypics[num][2].length) {
				document.getElementById('thumbnail'+i).alt=mypics[num][2];
			} else {
				document.getElementById('thumbnail'+i).alt='&nbsp;';
			}
		} else {
			document.getElementById('thumbnail'+i).src=blankthumb;
			document.getElementById('thumbnail'+i).alt='&nbsp;';
		}
	}
}
function scroll_left() {
	startphoto=startphoto-6;
	if (startphoto<0) startphoto=0;
	display_thumbs();
	return false;
}
function scroll_right() {
	startphoto=startphoto+5;
	if (startphoto>=mypics.length) startphoto=mypics.length-5;  /* intentional:  photo thumbnails loop around so that we have full thumbnail rows at all times */
	if (startphoto<0) startphoto=0;
	display_thumbs();
	return false;
}
function swap_image(num) {
	imageObj = new Image();
	curphoto=num;
	if (num<mypics.length-1) imageObj.src=mypics[curphoto+1][1];
	document.getElementById('photo_large_pic').src=mypics[num][1];
	var tag = document.getElementById('curnum');
	if (tag.innerHTML) { tag.innerHTML = curphoto+1; } 
	else if (tag.innertext) { tag.innertext = curphoto+1; } 
	var text;
	if (mypics[num][2].length) {
		text=mypics[num][2];
	} else {
		text='&nbsp;';
	}
	var tag2 = document.getElementById('photo_caption');num+1;
	if (tag2.innerHTML) { tag2.innerHTML = text; } 
	else if (tag2.innertext) { tag2.innertext = text; } 
}
function next_image() {
	curphoto=1+curphoto;
	if (curphoto>=mypics.length) curphoto=0;
	swap_image(curphoto);
	return false;
}
function prev_image() {
	curphoto=curphoto-1;
	if (curphoto<0) curphoto=mypics.length-1;
	swap_image(curphoto);
	return false;
}
function showimage(imgnum) {
	swap_image(startphoto+imgnum);
}
var time_keeper;
function slideshow_start() {
	next_image();
	time_keeper=setInterval('next_image()',4000);
	document.getElementById('slideshow_button').style.display="none";
	document.getElementById('slideshow_pause').style.display="block";
}
function slideshow_stop() {
	clearTimeout(time_keeper);
	document.getElementById('slideshow_button').style.display="block";
	document.getElementById('slideshow_pause').style.display="none";
}