function Visionneuse(){
	this.widthImage = 0;
	this.heightImage = 0;
	this.nbColumn = 0;
	this.nbRow = 0;
	this.film = 0;
	
	this.page = 0;
	this.nbPageTotal = 0;
	
	this.loading = '';
	
	this.Images = new Array();
	
	this.addImage = function(url,width,height){
		width = Number(width);
		height = Number(height);
		var hisHeight;
		var hisWidth;
		// Si la largeur ou la hauteur depasse la taille maximale
		if ((height >= this.heightImage) || (width >= this.widthImage)) {
			// Si la largeur et la hauteur depasse la taille maximale
			if ((height >= this.heightImage) && (width >= this.widthImage)) {
				// On cherche la plus grande valeur
				if (height > width) {
					hisHeight = this.heightImage;
					// On recalcule la taille proportionnellement
					hisWidth = parseInt((width * hisHeight) / height, 10);
				}else {
					hisWidth = this.widthImage;
					// On recalcule la taille proportionnellement
					hisHeight = parseInt((height * hisWidth) / width, 10);
				}
			}
			else if ((height > this.heightImage) && (width < this.widthImage)) {
				hisHeight = maxHeight;
				// On recalcule la taille proportionnellement
				hisWidth = parseInt((width * hisHeight) / height, 10);
			}
			else if ((height < this.heightImage) && (width > this.widthImage)) {
				hisWidth = this.widthImage;
				// On recalcule la taille proportionnellement
				hisHeight = parseInt((height * hisWidth) / width, 10);
			}
		}else{hisHeight = height;hisWidth = width;}
		var nImg = new Image(hisWidth,hisHeight);
		nImg.src = url;
		this.Images.push(nImg);
	}
	
	this.generateTable = function(){
		var table = document.createElement("table");
		table.setAttribute("style","margin:auto;");
		//alert('table');
		for(i=0;i<this.nbRow;i++){
			//alert('row '+i);
			var tr = document.createElement("tr");
			for(j=0;j<this.nbColumn;j++){
				//alert('colonne '+j);
				if(this.Images[(j+i*this.nbColumn)]){
					var image = this.Images[(j+i*this.nbColumn)]
					var td = document.createElement("td");
					td.setAttribute("id","image"+(j+i*this.nbColumn));
					td.setAttribute("style","border:1px solid black;width:"+this.widthImage+"px;height:"+this.heightImage+"px;");
					
					var img = document.createElement("img");
					img.setAttribute("width",image.width);
					img.setAttribute("height",image.height);
					img.setAttribute("src",image.src);
					img.setAttribute("onclick","javascript:select_sous_menu('galP',100);javascript:modifie_ou('fiche_film');javascript:affiche_fichier('?module=photo_film&id="+this.film+"')");
					img.setAttribute("style","cursor:pointer;margin:auto;");
					
					td.appendChild(img);
					tr.appendChild(td);
				}
			}
			table.appendChild(tr);
		}
		//alert('table');
		this.nbPageTotal = j;
		return table;
	}
	
	this.nextPage = function(){
		row = Math.ceil(this.Images.length/this.nbColumn);
		nbPageMax = Math.floor(row/this.nbRow);
		//alert(this.page+' '+nbPageMax);
		if(this.page < nbPageMax ){
			this.page++;
			for(i=0;i<this.nbRow;i++){
				for(j=0;j<this.nbColumn;j++){
					var item = (j+i*this.nbColumn)+(this.page*this.nbColumn*this.nbRow);
					if(item < this.Images.length ){
						var image = this.Images[item];
						document.getElementById('image'+(j+i*this.nbColumn)).innerHTML = '';
						var img = document.createElement("img");
						img.setAttribute("width",image.width);
						img.setAttribute("height",image.height);
						img.setAttribute("src",image.src);
						img.setAttribute("onclick","javascript:select_sous_menu('galP',100);javascript:modifie_ou('fiche_film');javascript:affiche_fichier('?module=photo_film&id="+this.film+"')");
						img.setAttribute("style","cursor:pointer;");
						document.getElementById('image'+(j+i*this.nbColumn)).appendChild(img);
					}
					else{
						document.getElementById('image'+(j+i*this.nbColumn)).innerHTML = '';
					}
				}
			}
		}
	}
	
	this.prevPage = function(){
		row = Math.ceil(this.Images.length/this.nbColumn);
		if(this.page > 0 ){
			this.page--;
			for(i=0;i<this.nbRow;i++){
				for(j=0;j<this.nbColumn;j++){
					var item = (j+i*this.nbColumn)+(this.page*this.nbColumn*this.nbRow);
					//alert(item);
					if(item >= 0 ){
						var image = this.Images[item];
						document.getElementById('image'+(j+i*this.nbColumn)).innerHTML = '';
						var img = document.createElement("img");
						img.setAttribute("width",image.width);
						img.setAttribute("height",image.height);
						img.setAttribute("src",image.src);
						img.setAttribute("onclick","javascript:select_sous_menu('galP',100);javascript:modifie_ou('fiche_film');javascript:affiche_fichier('?module=photo_film&id="+this.film+"')");
						img.setAttribute("style","cursor:pointer;");
						document.getElementById('image'+(j+i*this.nbColumn)).appendChild(img);
					}
				}
			}
		}
	}
}