/* Javascript for the slideshow. */

//This creates an array of the images.
	 var myPix = new Array("picture1.jpg","picture6.jpg","picture7.jpg","picture8.jpg","picture9.jpg","picture10.jpg","picture11.jpg","picture2.jpg","picture3.jpg","picture4.jpg","picture5.jpg");
//This sets the beginning value in the code. 
	 var thisPic = 0;
//This is the number of elements in the array, making it easy to add more pictures later. The -1 is set to one less than the true value is the Javascript begins at 0
	 var imgCt = myPix.length - 1;
//This creates an array of the texts to go with the images.
   var captionText = new Array("The apartment building.","The lounge-diner-balcony offers the ideal place to sit and relax, with an aperitif before enjoying an evening meal.","The apartment offers satellite TV and music facilities. A high chair is available on request.","View of the lounge-diner.","The main bedroom sleeps two and has a double bed and an en-suite bathroom with a bath, bath shower and WC.","The second bedroom has two single beds. Cot available on request.","Balcony where you can bask in the Algarve sun.","Childrens and main pool.","View of the two pools.","Another pool view.","Lounge in the sun!")
// This operates the number of elements in the words array making it easier to add new slides or words later.
	 var imgCt = captionText.length;
	
	
//The function to create the slideshow with parameter to declare the direction.
	function newSlide(direction)  
	 {
//Check browser understands images
		if (document.images) 
		{
//thisPic, which starts at 0 is set to it's own value plus the direction parameter.
			thisPic = thisPic + direction;
//If the pic is less than 0.
			 if (thisPic < 0)
			 {
//Sets the value of this pic to the imgCt -1.
				thisPic = imgCt-1;
			 }
//If it was less than 0 then set imgCt.
				if (thisPic == imgCt)
			  {
// setting picture to 0
				 thisPic = 0;
			 }
//Starts the pictures by stating the document and the HTM name
			document.slideshow.src =myPix[thisPic];
// Starts the words to go with the slides.
			document.imgForm.imgText.value = captionText[thisPic];
		}
	}
	 
/* This script is based on scripts in the book JavaScript for the World Wide Web: 
Negrino & Smith.  The script is a combination of script 5.6 Building Wraparound Slideshows
and 16.6 A slideshow with captions. */
