/* Jabascript qui random les images sur la page d'accueil */

function paragraphDisplayer( destinationElementID, contenuArray, imagesBasePath ) {
	// Properties
	this.eDestination   = document.getElementById(destinationElementID);
	this.aPara        = contenuArray;
	this.aParaBank    = this.aPara;
	this.imagesBasePath = imagesBasePath;
	
	// Methods
	this.shuffleArray = paraDisplayer_ShuffleArray;
	this.restoreArray = paraDisplayer_RestoreArray;
	this.addImages    = paraDisplayer_Addpara;
}



function paraDisplayer_ShuffleArray() {
	var imagesCount = this.aParaBank.length;
	if ( imagesCount ) {
		while ( --imagesCount ) {
			var randomImage = Math.floor( Math.random() * ( imagesCount + 1 ) );
			var tempArray1 = this.aParaBank[imagesCount];
			var tempArray2 = this.aParaBank[randomImage];
			this.aParaBank[imagesCount] = tempArray2;
			this.aParaBank[randomImage] = tempArray1;
		}
	}
}



function paraDisplayer_RestoreArray() {
	this.aParaBank = this.aPara;
}


function paraDisplayer_Addpara(paraToShow) {
	for (var cCount = 0; cCount < paraToShow; cCount++) {
		if ( this.aParaBank.length ) {
			var pObject = this.aParaBank.shift();
			
			var monP = document.createElement("p");

				var ePara = document.createTextNode(pObject.contenu);
				this.eDestination.appendChild(monP);
				monP.appendChild(ePara);
			
		}
	}
}

