function imageList(){
	
	this.alias 			 			= "";
	this.quantity		 			= 3;
	this.arrImagenes 			= null;
	this.data 			 			= null;
	this.posMin		   			= 0;
	this.posMax		   			= 2;
	this.struct			 			= 2;
	this.linkpopup   			= 1;
	this.optionspopup   	= "";
	this.refreshTime 			= 0;
	this.refreshFunction 	= "";
	this.idActualPosition = "";
	this.idQuantity       = "";
	this.isPlaying        = 0;
	this.intervar					= null;
	this.callback 				= null;
	this.callback_flag 		= false;
	
	this.setAlias = function ( alias ){
		this.alias  = alias;
	}
	
	this.setRefreshTime = function ( refreshTime ){
		this.refreshTime  = refreshTime * 1000;
	}
	
	this.setRefreshFunction = function ( refreshFunction ){
		this.refreshFunction  = refreshFunction;
	}
	
	this.setIdActualPosition = function (idActualPosition){
		this.idActualPosition = idActualPosition;
	}
	
	this.setActualPositionHTML = function(){
		if(this.idActualPosition && $(this.idActualPosition)){
			$(this.idActualPosition).innerHTML = Number(this.posMin) + Number(1);
		}
	}
	
	this.setActualPositionHTML = function(){
		if(this.idActualPosition && $(this.idActualPosition)){
			$(this.idActualPosition).innerHTML = Number(this.posMin) + Number(1);
		}
	}
	
	this.setIdPlay = function (idPlay){
		this.idPlay = idPlay;
	}
	
	this.setPlayHTML = function (msg){
		if(this.idPlay && $(this.idPlay)){
			$(this.idPlay).innerHTML = msg;
		}
	}
	
	this.setIdQuantity = function (idQuantity){
		this.idQuantity = idQuantity;
	}
	
	this.setQuantityHTML = function(){
		if(this.idQuantity && $(this.idQuantity)){
			$(this.idQuantity).innerHTML = this.arrImagenes.length;
		}
	}
	
	this.play = function(){
		if(!this.isPlaying){
			this.intervar = setInterval( this.refreshFunction , this.refreshTime );
			this.isPlaying = 1;
			this.setPlayHTML("STOP");
		}else{
			this.isPlaying = 0;
			this.setPlayHTML("PLAY");
			clearInterval(this.intervar);
		}
	}
	
	this.setLinkPopup = function (linkpopup){
		this.linkpopup = linkpopup	
	}
	
	this.setOptionsPopup = function (optionspopup) {
		this.optionspopup = optionspopup;
	}
	
	this.setStruct = function (struct){
		this.struct =  struct ;
	}
	
	this.setQuantity = function ( quantity ){
		this.quantity = quantity;
		this.posMax		= quantity - 1;
	}

	this.setCallback = function ( fncallback ) {
		this.callback_flag = "true";
		this.callback = fncallback;
	} 
	
	this.setData = function(data){
		this.data = data;
	}
	
	this.init = function(){
		var arrTemp = new Array();		var arr = unserialize(base64_decode(this.data));
		for( var i = 0 ; i < arr.length ; i += this.struct  ){
			arrTemp = new Array();
			for( var j = 0 ; j < this.struct ; j++ ){
				arrTemp[j] = arr[i+j];
			}
			this.addImage(arrTemp);
		}
		this.showImages();
		this.setActualPositionHTML();
		this.setQuantityHTML();
	}
		
	this.addImage = function( arr ){
		if(this.arrImagenes == null){
			this.arrImagenes = new Array();
		}
		this.arrImagenes[this.arrImagenes.length] = arr;
	} 
	
	this.getCallback = function(){ 
		if(this.callback_flag == "true"){
			return albums.callback;
		} else if(this.linkpopup){
			return function() { window.open(this.link,"new_window",this.optionspopup); }
		} else {
			return function() { window.location = this.link; }
		} 
	}; 
	
	
	
	
	/**
	 * La estructura actual del array es
	 * arr[0] = url de la imagen
	 * arr[1] = link
	 * arr[2] = epigrafe
	 * arr[3] = idAdjunto
	 * arr[4] = visitas
	 * arr[5] = puntos
	 * arr[6] = votos
	 */
	
	this.showImages = function(){
		for(var i = this.posMin ; i <= this.posMax ; i++){
			if(this.arrImagenes && typeof(this.arrImagenes[i]) != "undefined" ){
				//URL de la imagen
				$(this.alias+(i - this.posMin)).src = this.arrImagenes[i][0];
				
				//Link
				if(this.arrImagenes[i][1].length){
					$(this.alias+(i - this.posMin)).link				 				= this.arrImagenes[i][1];
					$(this.alias+(i - this.posMin)).linkpopup		 				= this.linkpopup;
					$(this.alias+(i - this.posMin)).optionspopup 				= this.optionspopup;
					//$(this.alias+(i - this.posMin)).onclick  		 				= this.getCallback();
					// Para una estructura donde se le quiera agregar un download, habilitar ésta línea.
					$(this.alias+(i - this.posMin)+"_download").href 		= "javascript:Download('"+this.arrImagenes[i][1]+"')";
					//$(this.alias+(i - this.posMin)).style.cursor = "pointer";
				}

				//Epigrafe
				if( typeof(this.arrImagenes[i][2]) != "undefined" && this.arrImagenes[i][2] ){
					$(this.alias+(i - this.posMin)+"_epigrafe").innerHTML	= this.arrImagenes[i][2];
				}
				
				//idAdjunto
				if( typeof(this.arrImagenes[i][3]) != "undefined" && this.arrImagenes[i][3] ){
					$(this.alias+(i - this.posMin)+"_idAdjunto").value	= this.arrImagenes[i][3];
				}
				
				//Visitas
				if( typeof(this.arrImagenes[i][4]) != "undefined" && this.arrImagenes[i][4] ){
					$(this.alias+(i - this.posMin)+"_visitas").value	= this.arrImagenes[i][4];
				}
				
				//puntos
				if( typeof(this.arrImagenes[i][5]) != "undefined" && this.arrImagenes[i][5] ){
					$(this.alias+(i - this.posMin)+"_puntos").value	= this.arrImagenes[i][5];
				}
				
				//votos
				if( typeof(this.arrImagenes[i][6]) != "undefined" && this.arrImagenes[i][6] ){
					$(this.alias+(i - this.posMin)+"_votos").value	= this.arrImagenes[i][6];
				}
				
				//alt
				if( typeof(this.arrImagenes[i][7]) != "undefined" && this.arrImagenes[i][7] ){
					$(this.alias+(i - this.posMin)).alt	= this.arrImagenes[i][7];
					$(this.alias+(i - this.posMin)).title	= this.arrImagenes[i][7];
				}
			}
		}
	}
	
	this.nextAutoPlay  = function(){
		if( this.arrImagenes && typeof(this.arrImagenes.length) != "undefined" ){
			if( this.posMax < this.arrImagenes.length - 1 ){
				this.posMax++;
				this.posMin++;
				this.showImages();
				this.setActualPositionHTML();
			}else if( this.refreshTime ){
				this.posMax = this.quantity - 1;
				this.posMin = 0 ;
				this.showImages();
				this.setActualPositionHTML();
			}
		}
	}
		
	this.next  = function(){
		if(!this.isPlaying){
			if( this.posMax < this.arrImagenes.length - 1 ){
				this.posMax++;
				this.posMin++;
				this.showImages();
				this.setActualPositionHTML();
			}
		}
	}
	
	this.prev  = function(){
		if(!this.isPlaying){
			if( this.posMin ){
				this.posMax--;
				this.posMin--;
				this.showImages();
				this.setActualPositionHTML();
			}
		}
	}
}