/*photoShow.js -- this script manages the forward and back of the photo show links
*photos should all have the same name with a number appended to count up and down the collection
*photos should all have the same file type
*photo dimensions are 300 x 200
HTML Source - put in #mainContent and add link to element_classes.css to style
image element with 
<div id="photo" class="photoFrame">
					<img id="cphoto" num="1" src="../images/news/centennial/cphoto1.jpg" name="cphoto" alt="Centennial Photo" height="150">
					<div><a href="javascript:nextPhoto(imgCtl,dir,min,max,path,filetype);" onmouseover="javascript:window.status='';return true;">&lt;&lt;</a>
						&nbsp;&nbsp;photos&nbsp;&nbsp;
						<a href="javascript:nextPhoto(imgCtl,dir,min,max,path,filetype);" onmouseover="javascript:window.status='';return true;">&gt;&gt;</a>
					</div>
				</div>	

arguments for this function
imgCtl - string: the id of the image element on the page
dir- string: either + or - to indicated which way through the set to move
min- int: smallest number appended to a file name in the photo collection
max- int: largest number appended to a file name in the collection
path- string: folder path relative to the page ending with \	
filetype- string: file extension of image

attributes of the image tag to set
src: path to first photo in set
name=base name of photos in set
alt= base alt text

*/

function nextPhoto(imgCtl,dir,min,max,path,filetype){
		if (document.getElementById) {
		//only for IE and DOM compliant browsers for now, if later use document.layers and reference outer div
		var curNum;
		var nextNum;
		var newphoto = new Image(150,150);
		var ctl = document.getElementById(imgCtl);
		curNum = ctl.attributes('num').value;
		/*
		if (dir=='+') {
			if (curNum==max) {
				nextNum=min;
			}
			else {
				nextNum = parseInt(curNum) + 1;
			}
		}
		else {
			if (curNum==min) {
				nextNum=max;
			}
			else {
				nextNum = parseInt(curNum) - 1;
			}
		}*/
		nextNum = getNextNumber(curNum,dir,min,max);
		ctl.src = path + imgCtl + nextNum + '.' + filetype;
		ctl.attributes('num').value = nextNum;
	}
}

function getNextNumber(curNum, dir, min, max) {
		if (dir=='+') {
			if (curNum==max) {
				nextNum=min;
			}
			else {
				nextNum = parseInt(curNum) + 1;
			}
		}
		else {
			if (curNum==min) {
				nextNum=max;
			}
			else {
				nextNum = parseInt(curNum) - 1;
			}
		}
		return nextNum;
}

