// Create the array
photo = [
'FAST BRW 072009 001.jpg', 'FAST BRW 072009 002.jpg', 'FAST BRW 072009 003.jpg', 'FAST BRW 072009 006.jpg', 'FAST BRW 072009 009.jpg', 'FAST BRW 072009 015.jpg', 'FAST BRW 072009 018.jpg', 'FAST BRW 072009 021.jpg', 'FAST BRW 072009 027.jpg', 'FAST BRW 072009 029.jpg', 
'FAST BRW 072009 031.jpg', 'FAST BRW 072009 034.jpg', 'FAST BRW 072009 035.jpg', 'FAST BRW 072009 037.jpg', 'FAST BRW 072009 039.jpg', 'FAST BRW 072009 041.jpg', 'FAST BRW 072009 046.jpg', 'FAST BRW 072009 051.jpg', 'FAST BRW 072009 052.jpg', 'FAST BRW 072009 053.jpg', 
'FAST BRW 072009 055.jpg', 'FAST BRW 072009 058.jpg', 'FAST BRW 072009 061.jpg', 'FAST BRW 072009 063.jpg', 'FAST BRW 072009 066.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";
	}
}