// JavaScript Document

//Cycling Photos

	window.onload = initAll;
	
	var thisPhoto = 0;
	var photoCt = 8;
	
	
	function initAll() { 
		var tinyPhotos = document.getElementById("photos");        //finds div that contains all the tiny images
		var tinyImages = tinyPhotos.getElementsByTagName("img");  //finds the images within the div and creates an array
		for(i=0;i<tinyImages.length;i++) {
			tinyImages[i].onclick=fullImage;
		}
		
		rotate();
	}
	
	function rotate() {
		if (document.getElementById) {
			document.getElementById("homephotos").src="images/home" + thisPhoto + ".jpg";  // get the value, then increment it
			thisPhoto++;
			if (thisPhoto == photoCt) {
				thisPhoto = 0;
				}
				setTimeout("rotate()", 5 * 1000);  //5 seconds (5000 milliseconds)
			}
		}
		
	function fullImage() {
		var tinyName = this.src;
		var imgNumStart = tinyName.indexOf("tiny")+4;  //returns starting position of "tiny"+4 (end of tiny)
		var imgNumEnd = tinyName.indexOf(".", imgNumStart);  //starts looking after end of tiny for "."
		var imageNumber = tinyName.substring(imgNumStart, imgNumEnd);  //string after "tiny" and before "."
		newWindow = window.open("fullimagedisplay.htm?images/fullimage" + imageNumber + ".jpg", "newWin", "height=600,width=800");
		newWindow.focus();
		}
		
		
		
		/*var imageNumber = tinyName.substring(tinyName.indexOf("tiny")+4,tinyName.indexOf("."))    string starting after "tiny" and ending before the period - selects just the number of the tiny photo so it can be used to create the source for the fullimage with the same number -  note - this worked in dreamweaver but not on the internet because internet finds the dot that's part of the domain name*/<!-- 

 -->
