window.onload = initLinks;


var frame1_picture_collection = new Array();
var max_frame1 = 4;<!--     Change this value to the number of 'events' slides in the folder --------------------->
var frame1_idx = 0;
var frame2_picture_collection = new Array();
var max_frame2 = 35;<!--    Change this value to the number of 'celebs' slides in the folder -------------------->
var frame2_idx = 0;
var frame3_picture_collection = new Array();
var max_frame3 = 118;<!--     Change this value to the number of 'locals' slides in the folder --------------------->
var frame3_idx = 0;
var frame4_picture_collection = new Array();
var max_frame4 = 22;<!-- 22    Change this value to the number of 'Take Jake' slides in the folder --------------------->
var frame4_idx = 0;
function initLinks() {
	if (max_frame1 > 0) {
	for (var i=1; i<=max_frame1; i++) {
		frame1_picture_collection[i-1]=["images/slides/events" + i + ".jpg"];
	}}
	if (max_frame2 > 0) {
	for (var i=1; i<=max_frame2; i++) {
		frame2_picture_collection[i-1]=["images/slides/Celebs" + i + ".jpg"];
	}}
	if (max_frame3 > 0) {
	for (var i=1; i<=max_frame3; i++) {
		frame3_picture_collection[i-1]=["images/slides/locals" + i + ".jpg"];
	}}
	if (max_frame4 > 0) {
	for (var i=1; i<=max_frame4; i++) {
		frame4_picture_collection[i-1]=["images/slides/takejake" + i + ".jpg"];
	}}
	
	document.getElementById("frame1_prevLink").onclick = frame1_processPrevious;
	document.getElementById("frame1_nextLink").onclick = frame1_processNext;
	document.getElementById("frame1_firstLink").onclick = frame1_processFirst;
	document.getElementById("frame1_lastLink").onclick = frame1_processLast;
	frame1_processFirst();
	
	document.getElementById("frame2_prevLink").onclick = frame2_processPrevious;
	document.getElementById("frame2_nextLink").onclick = frame2_processNext;
	document.getElementById("frame2_firstLink").onclick = frame2_processFirst;
	document.getElementById("frame2_lastLink").onclick = frame2_processLast;
	frame2_processFirst();
	
	document.getElementById("frame3_prevLink").onclick = frame3_processPrevious;
	document.getElementById("frame3_nextLink").onclick = frame3_processNext;
	document.getElementById("frame3_firstLink").onclick = frame3_processFirst;
	document.getElementById("frame3_lastLink").onclick = frame3_processLast;
	frame3_processFirst();
	
	document.getElementById("frame4_prevLink").onclick = frame4_processPrevious;
	document.getElementById("frame4_nextLink").onclick = frame4_processNext;
	document.getElementById("frame4_firstLink").onclick = frame4_processFirst;
	document.getElementById("frame4_lastLink").onclick = frame4_processLast;
	frame4_processFirst();
}
function frame1_processFirst(){
	frame1_idx = 0;
	document.getElementById("frame1_picture").src = frame1_picture_collection[frame1_idx];
	document.getElementById("photo_count_1").innerHTML = (frame1_idx + 1) + " of " + (frame1_picture_collection.length);
	preload_frame1(frame1_idx + 1);
	return false;
}
				  
function frame1_processLast(){
	frame1_idx = frame1_picture_collection.length - 1;
	document.getElementById("frame1_picture").src = frame1_picture_collection[frame1_idx];
	document.getElementById("photo_count_1").innerHTML = (frame1_idx + 1) + " of " + (frame1_picture_collection.length);
	preload_frame1(frame1_idx - 1);
	return false;
}

	
function frame1_processPrevious() {
	if (frame1_idx == 0) {frame1_idx = frame1_picture_collection.length;}
	frame1_idx--;
	document.getElementById("frame1_picture").src = frame1_picture_collection[frame1_idx];
	document.getElementById("photo_count_1").innerHTML = (frame1_idx + 1) + " of " + (frame1_picture_collection.length);
	preload_frame1(frame1_idx - 1);
	return false;
}

function frame1_processNext() {
	frame1_idx++;
	if (frame1_idx == frame1_picture_collection.length) {frame1_idx = 0;}
	document.getElementById("frame1_picture").src = frame1_picture_collection[frame1_idx];
	document.getElementById("photo_count_1").innerHTML = (frame1_idx + 1) + " of " + (frame1_picture_collection.length);
	preload_frame1(frame1_idx + 1);
	return false;
}
function preload_frame1(idx) {
	//alert ("1  " + idx);
	if (idx == frame1_picture_collection.length) {idx=0};
	//alert ("2  " + idx);
	if (idx < 0) {idx=frame1_picture_collection.length - 1};
	//alert ("3  " + idx);
	document.getElementById("preload_frame1").src=frame1_picture_collection[idx];
	//alert ("4  " + idx);
	return false;
}
function frame2_processFirst(){
	frame2_idx = 0;
	document.getElementById("frame2_picture").src = frame2_picture_collection[frame2_idx];
	document.getElementById("photo_count_2").innerHTML = (frame2_idx + 1) + " of " + (frame2_picture_collection.length);
	preload_frame2(frame2_idx + 1);
	return false;
}

function frame2_processLast(){
	frame2_idx = frame2_picture_collection.length - 1;
	document.getElementById("frame2_picture").src = frame2_picture_collection[frame2_idx];
	document.getElementById("photo_count_2").innerHTML = (frame2_idx + 1) + " of " + (frame2_picture_collection.length);
	preload_frame2(frame2_idx - 1);
	return false;
}

function frame2_processPrevious() {
	if (frame2_idx == 0) {frame2_idx = frame2_picture_collection.length;}
	frame2_idx--;
	document.getElementById("frame2_picture").src = frame2_picture_collection[frame2_idx];
	document.getElementById("photo_count_2").innerHTML = (frame2_idx + 1) + " of " + (frame2_picture_collection.length);
	preload_frame2(frame2_idx - 1);
	return false;
}

function frame2_processNext() {
	frame2_idx++;
	if (frame2_idx == frame2_picture_collection.length) {frame2_idx = 0;}
	document.getElementById("frame2_picture").src = frame2_picture_collection[frame2_idx];
	document.getElementById("photo_count_2").innerHTML = (frame2_idx + 1) + " of " + (frame2_picture_collection.length);
	preload_frame2(frame2_idx + 1);
	return false;
}

function preload_frame2(idx) {
	if (idx == frame2_picture_collection.length) {idx=0};
	if (idx < 0) {idx=frame2_picture_collection.length - 1};
	document.getElementById("preload_frame2").src=frame2_picture_collection[idx];
	return false;
}

function frame3_processFirst(){
	frame3_idx = 0;
	document.getElementById("frame3_picture").src = frame3_picture_collection[frame3_idx];
	document.getElementById("photo_count_3").innerHTML = (frame3_idx + 1) + " of " + (frame3_picture_collection.length);
	preload_frame3(frame3_idx + 1);
	return false;
}

function frame3_processLast(){
	frame3_idx = frame3_picture_collection.length - 1;
	document.getElementById("frame3_picture").src = frame3_picture_collection[frame3_idx];
	document.getElementById("photo_count_3").innerHTML = (frame3_idx + 1) + " of " + (frame3_picture_collection.length);
	preload_frame3(frame3_idx - 1);
	return false;
}

function frame3_processPrevious() {
	if (frame3_idx == 0) {frame3_idx = frame3_picture_collection.length;}
	frame3_idx--;
	document.getElementById("frame3_picture").src = frame3_picture_collection[frame3_idx];
	document.getElementById("photo_count_3").innerHTML = (frame3_idx + 1) + " of " + (frame3_picture_collection.length);
	preload_frame3(frame3_idx - 1);
	return false;
}

function frame3_processNext() {
	frame3_idx++;
	if (frame3_idx == frame3_picture_collection.length) {frame3_idx = 0;}
	document.getElementById("frame3_picture").src = frame3_picture_collection[frame3_idx];
	document.getElementById("photo_count_3").innerHTML = (frame3_idx + 1) + " of " + (frame3_picture_collection.length);
	preload_frame3(frame3_idx + 1);
	return false;
}

function preload_frame3(idx) {
	if (idx == frame3_picture_collection.length) {idx=0};
	if (idx < 0) {idx=frame3_picture_collection.length - 1};
	document.getElementById("preload_frame3").src=frame3_picture_collection[idx];
	return false;
}

function frame4_processFirst(){
	frame4_idx = 0;
	document.getElementById("frame4_picture").src = frame4_picture_collection[frame4_idx];
	document.getElementById("photo_count_4").innerHTML = (frame4_idx + 1) + " of " + (frame4_picture_collection.length);
	preload_frame4(frame4_idx + 1);
	return false;
}

function frame4_processLast(){
	frame4_idx = frame4_picture_collection.length - 1;
	document.getElementById("frame4_picture").src = frame4_picture_collection[frame4_idx];
	document.getElementById("photo_count_4").innerHTML = (frame4_idx + 1) + " of " + (frame4_picture_collection.length);
	preload_frame4(frame4_idx - 1);
	return false;
}

function frame4_processPrevious() {
	if (frame4_idx == 0) {frame4_idx = frame4_picture_collection.length;}
	frame4_idx--;
	document.getElementById("frame4_picture").src = frame4_picture_collection[frame4_idx];
	document.getElementById("photo_count_4").innerHTML = (frame4_idx + 1) + " of " + (frame4_picture_collection.length);
	preload_frame4(frame4_idx - 1);
	return false;
}

function frame4_processNext() {
	frame4_idx++;
	if (frame4_idx == frame4_picture_collection.length) {frame4_idx = 0;}
	document.getElementById("frame4_picture").src = frame4_picture_collection[frame4_idx];
	document.getElementById("photo_count_4").innerHTML = (frame4_idx + 1) + " of " + (frame4_picture_collection.length);
	preload_frame4(frame4_idx + 1);
	return false;
}

function preload_frame4(idx) {
	if (idx == frame4_picture_collection.length) {idx=0};
	if (idx < 0) {idx=frame4_picture_collection.length - 1};
	document.getElementById("preload_frame4").src=frame4_picture_collection[idx];
	return false;
}
