var numImages;
var dimages = new Array();
var counter;

function startSlideshow(num)
{
	//load images in array
	numImages = num;
	for (i=0; i<numImages; i++)
	{
		var img = new Image();
		img.src = "_images/slideshow/oregon"+(i)+".jpg";
		dimages[i] = img;
	}
	
	//set counter for swap method - skip first image (zero based numbering) because it is default image that shows on load
	counter = 1; 
	
	//call swap method to start in 1 second
	setTimeout("swapPicture()", 1000);
}

function swapPicture()
{
	if (document.images) {
		//reset counter if past number of images
		counter = (counter >= numImages)? 0: counter;
		
		//if image is ready...
		if (dimages[counter] && dimages[counter].complete) {
			
			//get target
			var target = 0;
			if (document.images.imgOregon)
				target = document.images.imgOregon;
			if (document.all && document.getElementById("imgOregon"))
				target = document.getElementById("imgOregon");
 
			// if target is valid, set target and increment counter
			if (target) {
				target.src = dimages[counter].src;
				counter = counter + 1;
			}
			//set next swap to happen in 3 seconds
			setTimeout("swapPicture()", 3000);
		}
		else {	
			//if image is not ready, wait half a second and try again
			setTimeout("swapPicture()", 500); 
		}
	}
}


