//Script to change the main images


//create the GLOBAL arrays
MyImages  = new Array ();
imagesPreloaded  = new Array ();

//Function to load images - do not edit
function loadImages(theID,theNum)
{
	var NumberOfImages = theNum;	

	var i=0;
	for (i=0;i<=(NumberOfImages-1);i++)
	{		
		var imgNum = zeroPad(i+1,3);
		
		//Set the path for the new image
		MyImages[i] = 'img_samples/ourwork-' + theID + '-' + imgNum + '.jpg';	
	}
	
	//Preload them in
	for (var i = 0; i < MyImages.length; i++)
	{	
		imagesPreloaded[i] = new Image(630,368);
		imagesPreloaded[i].src = MyImages[i];
		//alert(MyImages[i]);
	}

}




//Function to add leading zeros to IDs - do not edit
function zeroPad(num,count)
{
	var numZeropad = num + '';
	while(numZeropad.length < count) {
	numZeropad = "0" + numZeropad;
	}
	return numZeropad;
}


//Text "image 1 of 8"
function writeImageNumber()
{
	oSpan=document.getElementById("sp1");
	oSpan.innerHTML="Image "+eval(currentIndx+1)+" of "+MyImages.length;
}

//Go Forward
function Nexter(){
	if (currentIndx<imagesPreloaded.length-1){
		currentIndx=currentIndx+1;
		document.getElementById('main_center_right_image_img').src=imagesPreloaded[currentIndx].src
	}
	else {
		currentIndx=0
		document.getElementById('main_center_right_image_img').src=imagesPreloaded[currentIndx].src
	}
	writeImageNumber();
}

//Go Back
function Backer(){
	if (currentIndx>0){
		currentIndx=currentIndx-1;
		document.getElementById('main_center_right_image_img').src=imagesPreloaded[currentIndx].src
	}
	else {
		 currentIndx=3
		document.getElementById('main_center_right_image_img').src=imagesPreloaded[currentIndx].src
	}
	writeImageNumber();
}

//Set the current img number
function setCurrentIndex()
{
	currentIndx=0;
	document.getElementById('main_center_right_image_img').src=MyImages[0];
	writeImageNumber();
}

//Advance automatically
function automatically() {
	/*
if (currentIndx<imagesPreloaded.length){
		currentIndx=currentIndx
	}
	else {
		currentIndx=0
	}
		writeImageNumber()
		document.getElementById('main_center_right_image_img').src=imagesPreloaded[currentIndx].src
		currentIndx=currentIndx+1;
		var delay = setTimeout("automatically()",10000)
*/
}


