// Create the array
photo = [
'Spring JO 002.jpg', 'Spring JO 005.jpg', 'Spring JO 014.jpg', 'Spring JO 015.jpg', 'Spring JO 016.jpg', 'Spring JO 018.jpg', 'Spring JO 019.jpg', 'Spring JO 020.jpg', 'Spring JO 022.jpg', 'Spring JO 026.jpg', 
'Spring JO 029.jpg', 'Spring JO 031.jpg', 'Spring JO 032.jpg', 'Spring JO 033.jpg', 'Spring JO 035.jpg', 'Spring JO 043.jpg', 'Spring JO 044.jpg', 'Spring JO 048.jpg', 'Spring JO 059.jpg', 'Spring JO 060.jpg', 
'Spring JO 065.jpg', 'Spring JO 071.jpg', 'Spring JO 074.jpg', 'Spring JO 075.jpg', 'Spring JO 078.jpg', 'Spring JO 081.jpg', 'Spring JO 082.jpg', 'Spring JO 083.jpg', 'Spring JO 084.jpg', 'Spring JO 086.jpg', 
'Spring JO 093.jpg', 'Spring JO 095.jpg', 'Spring JO 097.jpg', 'Spring JO 098.jpg', 'Spring JO 099.jpg', 'Spring JO 101.jpg', 'Spring JO 102.jpg', 'Spring JO 106.jpg', 'Spring JO 108.jpg', 'Spring JO 109.jpg', 
'Spring JO 110.jpg', 'Spring JO 111.jpg', 'Spring JO 114.jpg', 'Spring JO 115.jpg', 'Spring JO 116.jpg', 'Spring JO 117.jpg', 'Spring JO 118.jpg', 'Spring JO 119.jpg', 'Spring JO 123.jpg', 'Spring JO 125.jpg'


];

// variable setup
var currentslide=0;
var numslides=photo.length-1;
var session = [0, 30, 0, 0, 0];
var portraitnumber = 500;
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";
	}
}