function Diaporama(XMLFile) {
	
	this.XMLFile = XMLFile;
	this.currentIndex = 0;
	this.items = new Array();
	
	currentInstance = this;
	
	jQuery.ajax({
	  type: 'GET',
	  url: this.XMLFile,
	  dataType: 'xml',
		success: function(xml) {
			
			realisations = xml.getElementsByTagName('website');
			
			for(i = 0; i < realisations.length; i++) {
				
				myDate = new Date();
				
				website = new Object();
				
				website.client = realisations[i].getElementsByTagName('client')[0].firstChild.nodeValue;
				website.type = realisations[i].getElementsByTagName('type')[0].firstChild.nodeValue;
				website.duration = realisations[i].getElementsByTagName('duration')[0].firstChild.nodeValue;
				website.tools = realisations[i].getElementsByTagName('tools')[0].firstChild.nodeValue;
				website.infos = realisations[i].getElementsByTagName('infos')[0].firstChild.nodeValue;
				website.link = realisations[i].getElementsByTagName('link')[0].firstChild.nodeValue;
				website.img_large = realisations[i].getElementsByTagName('img_large')[0].firstChild.nodeValue + '?' + myDate.getTime();
				
				// Préchargement des images
				small_img = new Image();
				small_img.src = website.img_small;
				
				large_img = new Image();
				large_img.src = website.img_large;
				////////////////////////////
				
				currentInstance.addItem(website);
			}
			
			// Affichage de la première réalisation
			currentInstance.displayItem(currentInstance.items[0]);
		}
	});
	
	
	Diaporama.prototype.addItem = function(item) {
		this.items.push(item);
	}
	
	
	Diaporama.prototype.displayItem = function(item) {
	  
	  var origHeight = jQuery('#diaporama_details').height();
	  
	  jQuery('#diaporama_screenshot_thumb').hide('fold', {mode: 'hide'}, 900, function()
		{
      this.src = item.img_large;
      jQuery('#diaporama_screenshot_thumb').show('fold', {mode: 'hide'}, 900);
    });
	  
	  jQuery('#rea_link').fadeOut(500);
	  jQuery('#diaporama_navbox').fadeOut(500);
		
	  jQuery('#diaporama_details').animate({height: 0, opacity: 0}, 1320, 'easeOutExpo', function()
		{
      document.getElementById('rea_client').innerHTML = item.client;
  		document.getElementById('rea_website_type').innerHTML = item.type;
  		document.getElementById('rea_duration').innerHTML = item.duration;
  		document.getElementById('rea_tools').innerHTML = item.tools;
  		document.getElementById('rea_infos').innerHTML = item.infos;
  		
  		if (item.link != 'none') {
  		 document.getElementById('rea_link').innerHTML = 'Visiter le site';
  		 document.getElementById('rea_link').href = item.link;
  		}
  		else {
  		 document.getElementById('rea_link').innerHTML = '';
  		 document.getElementById('rea_link').href = '#';
  		}
  		
      jQuery(this).animate({height: origHeight, opacity: 1}, 1000, 'easeOutExpo');
      jQuery('#rea_link').fadeIn(1200);
      jQuery('#diaporama_navbox').fadeIn(1200);
    });
		
		/*
		jQuery('#diaporama_screenshot_thumb').fadeOut(1000, function()
		{
      this.src = item.img_large;
      jQuery(this).fadeIn(1000);
    });
    */
		
		/*
		Effect.Fade(screenshot_img, {
			queue: 'start',
			afterFinish: function() {
				screenshot_img.src = item.img_large;
				Effect.Appear(screenshot_img, {queue: 'end'});
			}
		});
		*/
	}
	
	Diaporama.prototype.getPrev = function() {
		
		if (this.currentIndex == 0) {
			this.currentIndex = this.items.length - 1;
			return this.items[this.currentIndex];
		}
		
		this.currentIndex--;
		
		return this.items[this.currentIndex];
	}
	
	Diaporama.prototype.getNext = function() {
		
		if ((this.items.length - 1) == this.currentIndex) {
			this.currentIndex = 0;
			return this.items[this.currentIndex];
		}
		
		this.currentIndex++;
		
		return this.items[this.currentIndex];
	}
	
	Diaporama.prototype.displayPrev = function() {
		myItem = this.getPrev();
		this.displayItem(myItem);
	}
	
	Diaporama.prototype.displayNext = function() {
		myItem = this.getNext();
		this.displayItem(myItem);
	}
}