/* Javascript for the slideshow. */

//This creates an array of the images.
	 var myPix = new Array("picture1.jpg","picture2.jpg","picture3.jpg","picture4.jpg","picture5.jpg","picture6.jpg","picture7.jpg","picture8.jpg","picture9.jpg","picture10.jpg","picture11.jpg","picture12.jpg","picture13.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("This is the Magic Villa......lets take a look around. Use the next and previous keys below to move the slide on.","The house is fully air conditioned and provided with towels and bedding.  The cost is inclusive of cleaning.","Heated swimming pool and jacuzzi.  At night there is special lighting.","Good size patio to rest and relax on.","The relaxing area in the lounge.","Spacious lounge with cable TV and play station.","Fully equiped kitchen with electric cooker, American fridge freezer and microwave.","Within the kitchen area is a washing machine and tumble dryer.","Kitchen table for that casual breakfast.","The dining table for that more formal occasion.","Three master bedrooms with en-suite.  Two rooms have queen size beds and one room has a king size bed.","This is the twin room with an en-suite.","Through to one of the en-suite bathrooms.")
// 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. */
