// Create the array
photo = [
'IMG_1243.jpg', 'IMG_1244.jpg', 'IMG_1245.jpg', 'IMG_1246.jpg', 'IMG_1247.jpg', 'IMG_1248.jpg', 'IMG_1249.jpg', 'IMG_1250.jpg', 'IMG_1251.jpg', 'IMG_1253.jpg', 
'IMG_1254.jpg', 'IMG_1255.jpg', 'IMG_1257.jpg', 'IMG_1258.jpg', 'IMG_1259.jpg', 'IMG_1260.jpg', 'IMG_1261.jpg', 'IMG_1262.jpg', 'IMG_1264.jpg', 'IMG_1265.jpg', 
'IMG_1266.jpg', 'IMG_1267.jpg', 'IMG_1268.jpg', 'IMG_1270.jpg', 'IMG_1271.jpg', 'IMG_1272.jpg', 'IMG_1275.jpg', 'IMG_1276.jpg', 'IMG_1278.jpg', 'IMG_1279.jpg', 
'IMG_1281.jpg', 'IMG_1282.jpg', 'IMG_1283.jpg', 'IMG_1284.jpg', 'IMG_1285.jpg', 'IMG_1286.jpg', 'IMG_1287.jpg', 'IMG_1289.jpg', 'IMG_1290.jpg', 'IMG_1291.jpg', 
'IMG_1293.jpg', 'IMG_1294.jpg', 'IMG_1295.jpg', 'IMG_1296.jpg', 'IMG_1297.jpg', 'IMG_1299.jpg', 'IMG_1301.jpg', 'IMG_1302.jpg', 'IMG_1303.jpg', 'IMG_1304.jpg', 
'IMG_1305.jpg', 'IMG_1306.jpg', 'IMG_1307.jpg', 'IMG_1308.jpg', 'IMG_1309.jpg', 'IMG_1310.jpg', 'IMG_1311.jpg', 'IMG_1313.jpg', 'IMG_1314.jpg', 'IMG_1315.jpg', 
'IMG_1318.jpg', 'IMG_1319.jpg', 'IMG_1323.jpg', 'IMG_1325.jpg', 'IMG_1326.jpg', 'IMG_1327.jpg', 'IMG_1329.jpg', 'IMG_1330.jpg', 'IMG_1331.jpg', 'IMG_1333.jpg', 
'IMG_1334.jpg', 'IMG_1335.jpg', 'IMG_1337.jpg', 'IMG_1338.jpg', 'IMG_1339.jpg', 'IMG_1340.jpg', 'IMG_1343.jpg', 'IMG_1344.jpg', 'IMG_1345.jpg', 'IMG_1346.jpg', 
'IMG_1349.jpg', 'IMG_1350.jpg', 'IMG_1351.jpg', 'IMG_1353.jpg', 'IMG_1354.jpg', 'IMG_1355.jpg', 'IMG_1358.jpg', 'IMG_1361.jpg', 'IMG_1362.jpg', 'IMG_1363.jpg', 
'IMG_1366.jpg', 'IMG_1369.jpg', 'IMG_1373.jpg', 'IMG_1374.jpg', 'IMG_1375.jpg', 'IMG_1376.jpg', 'IMG_1377.jpg', 'IMG_1378.jpg', 'IMG_1379.jpg', 'IMG_1380.jpg', 
'IMG_1381.jpg', 'IMG_1382.jpg', 'IMG_1383.jpg', 'IMG_1384.jpg', 'IMG_1385.jpg', 'IMG_1387.jpg', 'IMG_1388.jpg', 'IMG_1390.jpg', 'MVN Last Ditch 012010 003.jpg', 'MVN Last Ditch 012010 004.jpg', 
'MVN Last Ditch 012010 008.jpg', 'MVN Last Ditch 012010 011.jpg', 'MVN Last Ditch 012010 013.jpg', 'MVN Last Ditch 012010 015.jpg', 'MVN Last Ditch 012010 017.jpg', 'MVN Last Ditch 012010 018.jpg', 'MVN Last Ditch 012010 020.jpg', 'MVN Last Ditch 012010 024.jpg', 'MVN Last Ditch 012010 025.jpg', 'MVN Last Ditch 012010 030.jpg', 
'MVN Last Ditch 012010 032.jpg', 'MVN Last Ditch 012010 033.jpg', 'MVN Last Ditch 012010 036.jpg', 'MVN Last Ditch 012010 037.jpg', 'MVN Last Ditch 012010 042.jpg', 'MVN Last Ditch 012010 045.jpg', 'MVN Last Ditch 012010 047.jpg', 'MVN Last Ditch 012010 048.jpg', 'MVN Last Ditch 012010 053.jpg', 'MVN Last Ditch 012010 057.jpg', 
'MVN Last Ditch 012010 060.jpg', 'MVN Last Ditch 012010 065.jpg', 'MVN Last Ditch 012010 068.jpg', 'MVN Last Ditch 012010 070.jpg', 'MVN Last Ditch 012010 071.jpg', 'MVN Last Ditch 012010 078.jpg', 'MVN Last Ditch 012010 081.jpg', 'MVN Last Ditch 012010 091.jpg', 'MVN Last Ditch 012010 092.jpg', 'MVN Last Ditch 012010 096.jpg', 
'MVN Last Ditch 012010 099.jpg', 'MVN Last Ditch 012010 102.jpg', 'MVN Last Ditch 012010 104.jpg', 'MVN Last Ditch 012010 105.jpg', 'MVN Last Ditch 012010 108.jpg', 'MVN Last Ditch 012010 111.jpg', 'MVN Last Ditch 012010 113.jpg', 'mvn-Last Ditch 012010 001.jpg', 'mvn-Last Ditch 012010 005.jpg', 'mvn-Last Ditch 012010 008.jpg', 
'mvn-Last Ditch 012010 009.jpg', 'mvn-Last Ditch 012010 010.jpg', 'mvn-Last Ditch 012010 016.jpg', 'mvn-Last Ditch 012010 017.jpg', 'mvn-Last Ditch 012010 018.jpg', 'mvn-Last Ditch 012010 020.jpg', 'mvn-Last Ditch 012010 024.jpg', 'mvn-Last Ditch 012010 027.jpg', 'mvn-Last Ditch 012010 032.jpg', 'mvn-Last Ditch 012010 035.jpg', 
'mvn-Last Ditch 012010 038.jpg', 'mvn-Last Ditch 012010 040.jpg', 'mvn-Last Ditch 012010 041.jpg', 'mvn-Last Ditch 012010 044.jpg', 'mvn-Last Ditch 012010 047.jpg', 'mvn-Last Ditch 012010 048.jpg', 'mvn-Last Ditch 012010 052.jpg', 'mvn-Last Ditch 012010 054.jpg', 'mvn-Last Ditch 012010 059.jpg', 'mvn-Last Ditch 012010 061.jpg', 
'mvn-Last Ditch 012010 069.jpg', 'mvn-Last Ditch 012010 073.jpg', 'mvn-Last Ditch 012010 078.jpg', 'mvn-Last Ditch 012010 085.jpg', 'mvn-Last Ditch 012010 092.jpg', 'mvn-Last Ditch 012010 093.jpg', 'mvn-Last Ditch 012010 101.jpg', 'mvn-Last Ditch 012010 102.jpg', 'mvn-Last Ditch 012010 106.jpg', 'mvn-Last Ditch 012010 108.jpg', 
'mvn-Last Ditch 012010 109.jpg', 'mvn-Last Ditch 012010 110.jpg', 'mvn-Last Ditch 012010 111.jpg', 'mvn-Last Ditch 012010 113.jpg', 'mvn-Last Ditch 012010 114.jpg', 'mvn-Last Ditch 012010 124.jpg', 'mvn-Last Ditch 012010 125.jpg', 'mvn-Last Ditch 012010 128.jpg', 'mvn-Last Ditch 012010 136.jpg', 'mvn-Last Ditch 012010 139.jpg', 
'mvn-Last Ditch 012010 142.jpg', 'mvn-Last Ditch 012010 145.jpg', 'mvn-Last Ditch 012010 148.jpg', 'mvn-Last Ditch 012010 150.jpg'

];

// variable setup
var currentslide=0;
var numslides=photo.length-1;
var session = [0, 108, 147, 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";
	}
}