//	JJ 101109
function Diapo(name,src,url,price){
	this.name = name;
	this.src = src;
	this.url = url;
	this.price = price + " &euro;";
}
//JJ 101109
/*
function Diapo(name,src,url){
	this.name = name;
	this.src = src;
	this.url = url;
}
*/
function Diaporama_getDiapo(i){
	if(i<this.diapos.length){
		return this.diapos[i];
	}else{
		return;
	}
}


function Diaporama_Randomize(source){

	work	= new Array();
	work 	= work.concat(this.diapos);

	arr 	= new Array();
	
	i	= 0;

	n 	= work.length;
	while(n > 0){
		/***************************/
		//recuperer un aleatoire entre 0 et n;

		rand = Math.floor(Math.random() * n);
		n--;

		/***************************/
		arr[i] = work[rand];
		i++;


		/***************************/

			for(j=rand ; j < n ; j++){
				work[j] = work[j+1]
			}

	}
	this.diapos = arr;
}

function Diaporama_addDiaposArray(diapos){
	this.diapos = this.diapos.concat(diapos);
}

function Diaporama_addDiapo(diapo){
	this.diapos[this.diapos.length] = diapo;
}

//	JJ 101109
function Diaporama_dump(){
	msg = "";
	for(i=0;i<this.diapos.length;i++){
		msg += this.diapos[i].name + "\n";
		msg += this.diapos[i].price + "\n";
	}
	alert(msg);
}
//JJ 101109

/*
function Diaporama_dump(){
	msg = "";
	for(i=0;i<this.diapos.length;i++){
		msg += this.diapos[i].name + "\n";
	}
	alert(msg);
}
*/
function Diaporama(id,title){

	this.id = id;
	this.title = title;

	this.diapos = new Array();




	this.addDiapo 			= Diaporama_addDiapo;
	this.dump 			= Diaporama_dump;
	this.addDiaposArray 		= Diaporama_addDiaposArray;
	this.randomize			= Diaporama_Randomize;
	this.getDiapo			= Diaporama_getDiapo;

}
