function Diaporama (){

/******************************************/
/**********DECLARATION DE PROPRIETE********/
/******************************************/
	this.content = new Array ();
	this.current_index = 0;
	this.old_index = 0;
	this.dir = "";

/******************************************/
/**********DECLARATION DE METHODE**********/
/******************************************/
	this.initDiaporama = function(arr_content, str_dir) {
		
		this.content = arr_content;
		this.dir = str_dir;
		this.current_index = 0;
		
		this.open();
		
	}
	
	this.open = function() {
		this.setDiaporama();
		this.setPhoto();		
		replaceDiaporama();
		var div = $('diapo');
		div.show();
		var div_fermer = $('diapo_fermer');
		div_fermer.show();	
		hideBt();	
	}
	
	this.close = function() {
		var div = $('diapo');
		div.hide();
		var div_fermer = $('diapo_fermer');
		div_fermer.hide();
		showBt();
	}
	
	this.hideDiapo = function() {
		var div = $('diapo');
		div.hide();
		var div_fermer = $('diapo_fermer');
		div_fermer.hide();
	}
		
	this.setDiaporama = function() {
	
		var str_html = "";
		str_html+="<div id =\"navig_diapo\">/";
		
		for (var i=0; i<this.content.length; i++) {
			str_html+="<a id = \"linkmedia_" +i +"\" class=\"";
			str_html += (i == this.current_index) ? "on" : "off";
			str_html+="\"href=\"javascript:void(0);\" ";			
			str_html+="onClick=\"oDiaporama.changeIndex(" + i + ")\">";
			str_html+=i+1;
			str_html+="</a>";
			str_html+="/";
		}
		
		str_html+="</div>";
		str_html+="<div id=\"media_content\" ";
		if (this.content.length>1) str_html+="style=\"cursor:pointer\" ";
		str_html+="></div>";
		str_html+="<div id=\"media_titre\"></div>";
		str_html+="<div id=\"media_chapeau\"></div>";
		str_html+="<div id=\"media_texte\"></div>";
		
		var div_diapo = $('diapo');
		div_diapo.update(str_html);
		this.old_index = this.current_index;
		
	}
	
	this.setPhoto = function() {
		
		$("linkmedia_" + this.old_index).removeClassName('on');
		$("linkmedia_" + this.old_index).addClassName('off');
		$("linkmedia_" + this.current_index).removeClassName('off');
		$("linkmedia_" + this.current_index).addClassName('on');
		
		var str_html = "";
		str_html = "<div style=\"height:"+this.content[this.current_index].hauteur+"px\"><img src=\"" + this.dir + "photos/" + this.content[this.current_index].fichier + "\" onClick=\"oDiaporama.changeIndex(-1)\"/></div>";			
		var media = $('media_content');
		media.update(str_html);
		
		$('media_titre').update(this.content[this.current_index].titre);
		$('media_chapeau').update(this.content[this.current_index].chapeau);
		$('media_texte').update(this.content[this.current_index].texte);
		
	}
	
	this.changeIndex = function (new_index) {
		if (new_index == -1) {
			new_index = this.current_index + 1;
		}
		this.old_index = this.current_index;
		if (new_index  < this.content.length) {
			this.current_index = new_index;
			this.setPhoto();
		} else if (new_index > this.content.length -1){
			this.current_index = 0;
			this.setPhoto();
		} else if (new_index  < 0) {
			alert ('index inferieur à 0');
		}
	}
	
}