// JavaScript Document

//below - array beign created which stores the images which will appear in the image gallery
var myPix=new Array("images/pr_creativity/a-MCA-2.jpg","images/pr_creativity/a-MCA-3.jpg","images/pr_creativity/a-MCA-4.jpg","images/pr_creativity/MCA-031.jpg","images/pr_creativity/MCA-041.jpg","images/pr_creativity/MCA-042.jpg","images/pr_creativity/MCA-066.jpg","images/pr_creativity/MCA-067.jpg","images/pr_creativity/MCA-074.jpg","images/pr_creativity/MCA-089.jpg","images/pr_creativity/MCA-093.jpg");

var thisPic = 0; //variable which stores the current position in the array, it always begins at the first image in the array
var imgCt = myPix.length-1;                  //imgCt is the value of the position of the last image in the array
var direction;                               //variable which takes the users input of the direction the user wants to move through the array 

function chgSlide(direction){                //function which changes the image to the next image in the array, which direction is determined by the direction variable
                                             //it also is on a continuous loop, so the when the end is reached the images just start from the beginning again 				 
   if(document.images){ 
   		var imgName = document.myPicture.src
		for (i=0; i<imgCt; i++) {
			if ('http://www.frocomm.com.au/'+myPix[i] == imgName) {
				thisPic = i;
			}
		}
	    thisPic=thisPic + direction;           //the next position in the array equals the current position plus the direction chosen (either 1 or -1).
	    if(thisPic>imgCt){                     //if the current position is greater than the position of the last image in the array, 
		   thisPic=0;                          //then start the array from the beginning 
		}
		if(thisPic<0){                         //same as above, but goes to the end when the value is less than the first image in the array
		thisPic=imgCt;
		}
		document.myPicture.src=myPix[thisPic]; //the image displayed in the img tag is the current position value in the array myPix  
	}
}

function imageGallery (image){
	displayImage = new Image;
	displayImage.src = "images/pr_creativity/"+image;
	newWindow = window.open('image_pr07Sydney.html','imageWindow','width=700,height=654');
	setTimeout("newWindow.document.myPicture.src = displayImage.src",1000)
	newWindow.focus()
}