// Create the array
photo = [
'IMG_1264.jpg', 'IMG_1265.jpg', 'IMG_1266.jpg', 'IMG_1271.jpg', 'IMG_1282.jpg', 'IMG_1295.jpg', 'IMG_1296.jpg', 'IMG_1309.jpg', 'IMG_1345.jpg', 'IMG_1354.jpg', 
'IMG_1373.jpg', 'IMG_1378.jpg', 'IMG_1385.jpg', 'IMG_1387.jpg', 'IMG_1391.jpg', 'IMG_1398.jpg', 'IMG_1403.jpg', 'IMG_1406.jpg', 'IMG_1411.jpg', 'IMG_1416.jpg', 
'IMG_1418.jpg', 'IMG_1429.jpg', 'IMG_1486.jpg', 'IMG_1530.jpg', 'IMG_1545.jpg', 'IMG_1553.jpg', 'IMG_1557.jpg', 'IMG_1562.jpg', 'IMG_1571.jpg', 'IMG_1597.jpg', 
'IMG_1604.jpg', 'IMG_1612.jpg', 'IMG_1623.jpg', 'IMG_1658.jpg', 'IMG_1663.jpg', 'IMG_1675.jpg', 'IMG_1690.jpg', 'IMG_1696.jpg', 'IMG_1703.jpg', 'IMG_1709.jpg', 
'IMG_1721.jpg', 'IMG_1727.jpg', 'IMG_1736.jpg', 'IMG_1738.jpg', 'IMG_1753.jpg'

];

// variable setup
var currentslide=0;
var numslides=photo.length-1;
var session = [0, 184, 289, 337, 367];
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";
	}
}