//Arrays containing information on the images		
		var imageList = new Array();
		var urlList = new Array();
		var imageNamesList = new Array();
		var listIndex=new Array();
		
		//Set of variables
		var lastRan = -1;
		var numberImages=0;
		var numberImagesDisplayed=3;
		var imageSize=100;
		var carouselSize=6;
		var carouselIncrementation=1;
		/*Describes how many images have been used*/
		var imagesDisplayed=0;
		
		/**
		 * Since carousel.addItem uses an HTML string to create the interface
		 * for each carousel item, this method formats the HTML for an LI.
		 **/
		var fmtItem = function(imgUrl, url, title) {
			var innerHTML="";
			if (url==""){
				innerHTML='<img src="'+imgUrl+'" width="' +imageSize +'" height="' +imageSize+'">' +title +'</img>';
			}
			else {
				innerHTML = '<a href="'+url+'" target="_blank"><img src="'+imgUrl+'" width="' +imageSize +'" height="' +imageSize+'"/>' +title +'<\/a>';
			}
			return innerHTML;
		};
		
		/**
		 * Custom inital load handler. Called when the carousel loads the initial
		 * set of data items. Specified to the carousel as the configuration
		 * parameter: loadInitHandler
		 **/
		var loadInitialItems = function(type, args) {
			var start = args[0];
			var last = args[1];
			load(this, start, last, true);    
		};
		
		/**
		 * Custom load next handler. Called when the carousel loads the next
		 * set of data items. Specified to the carousel as the configuration
		 * parameter: loadNextHandler
		 **/
		var loadNextItems = function(type, args) {    
			var start = args[0];
			var last = args[1]; 
			var alreadyCached = args[2];
			
			if(!alreadyCached) {
				load(this, start, last, false);
			}
		};
		
		/**
		 * Custom load previous handler. Called when the carousel loads the previous
		 * set of data items. Specified to the carousel as the configuration
		 * parameter: loadPrevHandler
		 **/
		var loadPrevItems = function(type, args) {
			var start = args[0];
			var last = args[1]; 
			var alreadyCached = args[2];
			
			if(!alreadyCached) {
				load(this, start, last, false);
			}
		};
	
		var load = function(carousel, start, last, first_time) {
			for(var i=start;i<=last;i++) {
				imagesDisplayed++;
				if(i >(last-carouselIncrementation) || first_time ) {
					if (imagesDisplayed==imageList.length) {
						imagesDisplayed=0;
						for (i=0;i<imageList.length;i++) {
							listIndex[i]=true;
						}
					}
				
					var randomIndex = getRandom(numberImages,i);
					carousel.addItem(i,fmtItem(imageList[randomIndex],urlList[randomIndex],imageNamesList[randomIndex]));
				}

			}
			imagesDisplayed = imagesDisplayed - numberImagesDisplayed +carouselIncrementation;
			//Adjust the size of each image according to the value read in the pageLoad variable
			$(".carousel-component .carousel-list li").css("width",imageSize+20);
		};
		
		var getRandom = function(max, currentIndex) {
			var randomIndex;
			do {
				randomIndex = Math.floor(Math.random()*max);
			} while(!listIndex[randomIndex]);
			listIndex[randomIndex]=false;
			return randomIndex;
		};
		
		/**
		 * You must create the carousel after the page is loaded since it is
		 * dependent on an HTML element (in this case 'dhtml-carousel'.) See the
		 * HTML code below.
		 **/
	
		var pageLoad = function() {

			$("#carousel #carousel-img p").each( function () {                 
				//Each image's address is read in the HTML document and put into the array
				var imageAddress = $(this).text(); 
				imageList=imageList.concat(imageAddress);         
			});
			
			$("#carousel #carousel-links p").each( function () {         
				//Each image's link is read in the HTML document and put into the array         
				var imageLink = $(this).text();
				urlList=urlList.concat(imageLink);   
			}); 
			
			$("#carousel #carousel-names p").each( function () {         
				//Each image's description is read in the HTML document and put into the array        
				var imageName = $(this).text();
				imageNamesList=imageNamesList.concat(imageName);   
			});
			
			$("#carousel #carousel-number-images-displayed p").each( function () {         
				//This is necessary to configure how many images to display at a time      
				numberImagesDisplayed = parseInt($(this).text());
				if(isNaN(numberImagesDisplayed)){
					numberImagesDisplayed=0;
				} 
			});
			
			$("#carousel #carousel-number-images p").each( function () {         
				//This is necessary to know (to calculate the random place of the image in the array)         
				numberImages = parseInt($(this).text()); 
			}); 
			
			$("#carousel #carousel-image-size p").each( function () {         
				//This is necessary to configure the dimension of the CSS in the load function         
				imageSize = parseInt($(this).text()); 
				if(isNaN(imageSize)){
					imageSize=100;
				}	
			});
			
			$("#carousel #carousel-size p").each( function () {         
				//This is necessary to define the size of the bounded carousel (how many images it contains)       
				carouselSize = parseInt($(this).text()); 
				if(isNaN(carouselSize)){
					carouselSize=10;
				}	
			} ) ;
			
			$("#carousel #carousel-incrementation p").each( function () {         
				//This is necessary to define how many images to swipe at a time        
				carouselIncrementation = parseInt($(this).text());
				if(isNaN(carouselIncrementation)){
					carouselIncrementation=2;
				}	 
			}); 
	
			//Set the length of the indeex table the same as other tables
			for (i=0;i<imageList.length;i++) {
				listIndex[i]=true;
			}
			//The information concernin the carousel is hidden on the HTML page
			$("#carousel").hide();
			
			var carousel = new YAHOO.extension.Carousel("dhtml-carousel", {
							numVisible:        numberImagesDisplayed,
							animationSpeed:    0.8,
							scrollInc:         carouselIncrementation,
							navMargin:         40,
							size:				carouselSize,
							wrap:true,
							prevElement:       "prev-arrow",
							nextElement:       "next-arrow",
							loadInitHandler:   loadInitialItems,
							loadNextHandler:   loadNextItems,
							loadPrevHandler:   loadPrevItems,
							prevButtonStateHandler:   handlePrevButtonState,
							nextButtonStateHandler:   handleNextButtonState,
							autoPlay :	6000
						}
				);	
	
		};