 $(document).ready(function() {
		
				// this number after page_ in the id. For the starting Slide.
				var startingPage = 1;
				// the text prefix in the id e.g. page_1
				var pageIdValues = "page_";
				// gives the last slide/page a class attribute dynamically
				$("div.page:last").addClass("lastSlide");
				
				// hides all the slides
				$("div.page").hide();
				// but makes the first slide visible
				$("div#"+pageIdValues+startingPage).show();
				
				// when a user clicks a div with .page as its class
				$("div.page").click(function(){
					
					// get the last slides id.
					var lastSlide = $("div.page:last").attr("id");
					// get the current slides id.
					var thisSlide = $(this).attr("id");
					
					// if the current slide is the last slide
					if( thisSlide == lastSlide){
						alert("Slide Show Finished");						
						// you could put a redirect here if you wanted to.
						// or alternatively you could re-start the slideshow
						
					// if the current slide is not the last slide
					} else {
						
						// setup some variables
						
						// time in miliseconds for animation to complete
						var timeToFade = 200;
						// this number after page_ in the id. For the starting Slide.
						var startingPage = 1;
						// same as above					
						var pageIdValues = "page_";
						// gets this slides id. E.g. what slide number is it?
						var theId = this.id;
						theId = theId.split(pageIdValues, 2);
						theId = theId[1]; 
						
						// animates the fading out of the current slide.							
			  			$("div.page").queue(function () {
							$(this).fadeOut();
							$(this).dequeue();
						});
				
		      			$("div.page").animate({ opacity: 1}, timeToFade );
		
						// makes the id equivalent to the next slide
						theId++;		

						// fades the next slide in.
			  			$(this).queue(function () {
							$("div#"+pageIdValues+theId).fadeIn();
							$("div#"+pageIdValues+theId).dequeue();
						});
						
					} // end of else statement			
				
			}); // end of click function
						
    }); // end of ready function
