// Create the array
photo = [
'ORCA RW SC 001.jpg', 'ORCA RW SC 003.jpg', 'ORCA RW SC 004.jpg', 'ORCA RW SC 005.jpg', 'ORCA RW SC 007.jpg', 'ORCA RW SC 008.jpg', 'ORCA RW SC 009.jpg', 'ORCA RW SC 010.jpg', 'ORCA RW SC 011.jpg', 'ORCA RW SC 018.jpg', 
'ORCA RW SC 021.jpg', 'ORCA RW SC 022.jpg', 'ORCA RW SC 024.jpg', 'ORCA RW SC 025.jpg', 'ORCA RW SC 028.jpg', 'ORCA RW SC 029.jpg', 'ORCA RW SC 033.jpg', 'ORCA RW SC 034.jpg', 'ORCA RW SC 037.jpg', 'ORCA RW SC 039.jpg', 
'ORCA RW SC 042.jpg', 'ORCA RW SC 047.jpg', 'ORCA RW SC 049.jpg', 'ORCA RW SC 050.jpg', 'ORCA RW SC 055.jpg', 'ORCA RW SC 056.jpg', 'ORCA RW SC 066.jpg', 'ORCA RW SC 067.jpg', 'ORCA RW SC 069.jpg', 'ORCA RW SC 072.jpg', 
'ORCA RW SC 073.jpg', 'ORCA RW SC 076.jpg', 'ORCA RW SC 077.jpg', 'ORCA RW SC 082.jpg', 'ORCA RW SC 083.jpg', 'ORCA RW SC 087.jpg', 'ORCA RW SC 090.jpg'
];

// variable setup
var currentslide=0;
var numslides=photo.length-1;
var session = [0, 0, 0, 0, 0];
var portraitnumber = 999;
var slidesize = 500;


// setup screen
window.onload = function() {
        document.getElementById("setphoto").onclick = SetPhoto;
        
        document.getElementById("set1").onclick = function(evt) { setSessionPhoto( session[0] ); };
//        document.getElementById("set2").onclick = function(evt) { setSessionPhoto( session[1] ); };
//        document.getElementById("set3").onclick = function(evt) { setSessionPhoto( session[2] ); };
//        document.getElementById("set4").onclick = function(evt) { setSessionPhoto( session[3] ); };
//        document.getElementById("set5").onclick = function(evt) { setSessionPhoto( session[4] ); };
//        document.getElementById("set6").onclick = function(evt) { setSessionPhoto( session[5] ); };

        document.getElementById("prevphoto").onclick = PrevPhoto;
        document.getElementById("nextphoto").onclick = NextPhoto;
        document.getElementById("set500").onclick = Set500;
        document.getElementById("set1000").onclick = Set1000;
        
        document.getElementById("photomax").readOnly=true;
        document.getElementById("photomax").value=numslides+1;
        document.getElementById("set500").style.background = "#00FFFF";
        document.getElementById("set1000").style.background = "#00FFFF";
        
        document.getElementById("photosel").value = session[0]+1;
        SetPhoto();
        Set500();
}

function CheckSize() {
	if (slidesize=500) {
		Set500();
	} else {
		Set1000();
	}
}

function NextPhoto() {
	currentslide++;
	if (currentslide > numslides) {
		currentslide = 0;
	}
	document.getElementById("photo1").src = photo[currentslide];
	document.getElementById("photosel").value = currentslide+1;
	CheckSize();
}

function PrevPhoto() {
	currentslide--;
	if (currentslide < 0) {
		currentslide = numslides;
	}
	document.getElementById("photo1").src = photo[currentslide];
	document.getElementById("photosel").value = currentslide+1;
	CheckSize();
}

function SetPhoto() {
	currentslide = document.getElementById("photosel").value-1;
	if (currentslide < 1) currentslide = 0;
	if (currentslide > numslides) currentslide = numslides;
	document.getElementById("photo1").src = photo[currentslide];
	document.getElementById("photosel").value = currentslide+1;
	CheckSize();
}

function setSessionPhoto(sessionStart) {
	currentslide = sessionStart;
	document.getElementById("photo1").src = photo[currentslide];
	document.getElementById("photosel").value = currentslide+1;
	CheckSize();
}

function Set1000() {
	slidesize=1000;
	if (currentslide < portraitnumber) {
		document.getElementById("photo1").width = "1000";
		document.getElementById("photo1").height = "750";
	} else {
		document.getElementById("photo1").width = "750";
		document.getElementById("photo1").height = "1000";
	}
}

function Set500() {
	slidesize=500;
	if (currentslide < portraitnumber) {
		document.getElementById("photo1").width = "500";
		document.getElementById("photo1").height = "375";
	} else {
		document.getElementById("photo1").width = "375";
		document.getElementById("photo1").height = "500";
	}
}