
/*window.onload = slideshowinit; incorporated into multipleOnload */
var subtitle = new Array('Scenery','Scenery','Scenery','Scenery','Scenery','Scenery','Scenery','Scenery','Scenery','Sports','Sports','Sports','Sports','Sports','Sports','Sports','Sports','Candid Portrait','Candid Portrait','Candid Portrait','Candid Portrait','Candid Portrait','Candid Portrait');
var index = 0;//global variable used in multiple functions

function slideshowinit() {
	var imageContainer = document.getElementById("imageContainer");
	if(!document.getElementById) return;
	if(!document.getElementsByTagName) return;
	if(!imageContainer) return;
	preloader();

	var currentImage = imageContainer.getElementsByTagName("img");
	
	//Finds the arrow link and attach the functionality
	var portfolioArrows = document.getElementById("portfolioArrows");
	var arrowLinks = portfolioArrows.getElementsByTagName("a");
	arrowLinks[0].onclick = changePhotograph;
	arrowLinks[1].onclick = changePhotograph;
	
	//Finds the individual links to assign the functionality
	var linkContainer = document.getElementById("linkContainer");
	var currentLink = linkContainer.getElementsByTagName("a");	
	var counter = currentLink.length;
	var linkIndex;
	for(linkIndex=0; linkIndex<counter; linkIndex++){
		currentLink[linkIndex].onclick = linkPhotograph;
	}	
}

function changePhotograph(){//Used on the arrowLinks
	var increment = this.title;//The title is being used to increment or decrement
	var imageContainer = document.getElementById("imageHere");//finds the main image location
	var currentImage = imageContainer.getElementsByTagName("img");//gets the actual image 
	var currentImageHeight = currentImage[0].height;
	var currentImageWidth = currentImage[0].width;	

	var linkContainer = document.getElementById("linkContainer");//finds the link group
	var currentLink = linkContainer.getElementsByTagName("a");	//finds the link
	var lengthCurrentLink = currentLink.length;//Gets the length of the links array 
	if(index ==0 && increment == -1){//Resets the index to highest items when decrementing
		index= lengthCurrentLink;
	}
	if(index ==lengthCurrentLink && increment == 1){//Resets the index to highest items when decrementing
		index= 0;
	}		
	index = index + Number(increment);
	if(index ==lengthCurrentLink && increment == 1){//Resets the index to lowest item when incrementing
		index= 0;
	}		
	currentImage[0].src = currentLink[index].href;	//sets the image to the current index in the array
	var imageSubtitle = document.getElementById("subtitle");//finds the paragraph where the subtitle will go	
	var subtitleText = subtitle[index];	//creates the subtitle from the subtitle array based on the current index 
	imageSubtitle.innerHTML = "&#8226;&#8226;&#8226; " + subtitleText + " &#8226;&#8226;&#8226;";	
	return false;
}


function linkPhotograph(){//This works on the individual links
	var imageContainer = document.getElementById("imageHere");//finds the div where the image placeholder is
	var imageSubtitle = document.getElementById("subtitle");//finds the paragraph where the subtitle will go
	var subtitleText = subtitle[this.title];
	imageSubtitle.innerHTML = "&#8226;&#8226;&#8226; " + subtitleText + " &#8226;&#8226;&#8226;";
	var currentImage = imageContainer.getElementsByTagName("img");	//finds the actual image placeholder	
	currentImage[0].src = this.href;//Moves this link's href into the image placeholder
	index = Number(this.title);//Gives the current number of the image into the index to be used in other functions
	return false;
}

//Preloads images into page
function preloader() 

{
     // counter
     var i = 0;
     // create object
     var imageObj = new Image();
     // set image list
     var images = new Array();
     images[0]="images/photographs/image01.jpg"
     images[1]="images/photographs/image02.jpg"
     images[2]="images/photographs/image03.jpg"
     images[3]="images/photographs/image04.jpg"
     images[4]="images/photographs/image05.jpg"
     images[5]="images/photographs/image06.jpg"	
	 images[6]="images/photographs/image07.jpg"
	 images[7]="images/photographs/image08.jpg"
	 images[8]="images/photographs/image09.jpg"
	 images[9]="images/photographs/image10.jpg"
	 images[10]="images/photographs/image11.jpg"
	 images[11]="images/photographs/image12.jpg"
	 images[12]="images/photographs/image13.jpg"
	 images[13]="images/photographs/image14.jpg"
	 images[14]="images/photographs/image15.jpg"
	 images[15]="images/photographs/image16.jpg"
	 images[16]="images/photographs/image17.jpg"
	 images[17]="images/photographs/image18.jpg"
	 images[18]="images/photographs/image19.jpg"
	 images[19]="images/photographs/image20.jpg"
	 images[20]="images/photographs/image21.jpg"
	 images[21]="images/photographs/image22.jpg"
	 images[22]="images/photographs/image23.jpg"		 
     // start preloading
     for(i=0; i<=23; i++) 
     {
          imageObj.src=images[i];
     }
}




