var oGaleria = new function Galeria(){
	//PROPs
	var eBg = $('galBg');
	var ePrev = $('galPrev');
	var eBgAnim = $('galBgAnim');
	var eLoad = $('galLoad');
	var eImg = $('galImg');
	var eMini = $('galMini');
	var eEpi = $('galEpi');
	var eGri = $('galGri');
	var eInfo = $('galInfo');
	var eModo = $('galModo');
	var eVerEpi = $('galVerEpi');
	var eImgAnt = $('galImgAnt');
	var eImgSig = $('galImgSig');
	var ePagAnt = $('galPagAnt');
	var ePagSig = $('galPagSig');
	var eCerrar = $('galCerrar');
	
	
	//
	var eVotCont = $('galVotCont');
	var eEst = $('galEst');
	var eVot = $('galVot');
	var eEst1 = $('galEst1');
	var eEst2 = $('galEst2');
	var eEst3 = $('galEst3');
	var eEst4 = $('galEst4');
	var eEst5 = $('galEst5');
	var eRatCont = $('galVotRating');
	var eRatTxt = $('galVotRatTxt');
	//
	var bOpen = false;
	var eDoc = null;
	var eDivAct = null;
	var wImgAct = 0;
	var hImgAct = 0;
	var iEventRedim = 0;
	var bImgLoad = false;
	var iPag = 0;
	var iImg = 0;
	var iTotPag = 0;
	var iTotImgXPag = 0;
	var iTotImg = 0;
	var bAbieto = false;
	var iTime = 0;
	var indiceActual = 0;
	//
	var sModo = '';
	var bVerEpi = false;
	var oIdsImgs = null;
	var iIdImg = 0;
	var sAction = '';
	var oInfoImg = null;
	var bReady = true;
	var bVotAct = false;
	
	
	//OBJs
	var req = new Request();
	
	
	//METs
	this.abrir = function(file, e,indice){
		bOpen = true;
		if(!!e) StopEvent(e);
		if(indice)indiceActual = indice;
		else indiceActual = 0;
		//
		oIdsImgs = new Object;
		//
		AddEvent(window, 'resize', this.acomodar);
		AddEvent(window, 'scroll', this.acomodar);
		AddEvent(document, 'mousemove', this.mostrarHerramientas);
		AddEvent(document, 'keyup', this.verTeclado);
		AddEvent(eImg, 'load', this.imagenCargada);
		//
		this.acomodar();
		//
		ePrev.style.lineHeight = HScreen() + 'px';
		eModo.style.display = eVerEpi.style.display = eLoad.style.display = eMini.style.display = ePrev.style.display = 
		eCerrar.style.display = eBg.style.display = 'block';
		//
		this.cargar(URL_ROOT+file);
	}.closure(this);
	
	this.cerrar = function(){
		bOpen = false;
		RemEvent(window, 'resize', this.acomodar);
		RemEvent(window, 'scroll', this.acomodar);
		RemEvent(document, 'mousemove', this.mostrarHerramientas);
		RemEvent(document, 'keyup', this.verTeclado);
		RemEvent(eImg, 'load', this.imagenCargada);
		
		ePagSig.style.display = ePagAnt.style.display = eImgSig.style.display = eImgAnt.style.display = 
		eMini.style.display = ePrev.style.display = eCerrar.style.display = eGri.style.display = 
		eModo.style.display = eVerEpi.style.display = eBg.style.display = eLoad.style.display = 'none';
		this.verVotacion(false);
		
		eMini.innerHTML = sModo = '';
		eDoc = eDivAct = oInfoImg = null;
		wImgAct = hImgAct = iEventRedim = iIdImg = 0;
		bImgLoad = false;
		eImg.src = URL_ROOT+"img/1x1b.gif";
	}.closure(this);
	
	this.acomodar = function(){
		ePrev.style.top = YPos() + 'px';
		ePagAnt.style.top = ePagSig.style.top = eMini.style.top = (HScreen() + YPos() - 60) + 'px';
		if(Nav.esSa) eMini.style.top = (parseInt(eMini.style.top)  - 50) + 'px';
		eModo.style.top = eImgSig.style.top = (Math.floor(HScreen() / 2) + YPos() - 60) + 'px';
		eVerEpi.style.top = eImgAnt.style.top = (Math.floor(HScreen() / 2) + YPos()) + 'px';
		eLoad.style.top = (Math.floor(HScreen() / 2) + YPos() - 98 + 50) + 'px';
		eGri.style.top = eCerrar.style.top = (YPos() + 8) + 'px';
		//
		eBg.style.left = eMini.style.left = ePrev.style.left = XPos() + 'px';
		eVerEpi.style.left = eModo.style.left = eGri.style.left = ePagAnt.style.left = (8 +  XPos()) + 'px';
		eLoad.style.left = (Math.floor(WScreen() / 2) + XPos() - 107 + ((Nav.esIE || Nav.esSa)? 50 : 40)) + 'px';
		eCerrar.style.left = eImgAnt.style.left = eImgSig.style.left = ePagSig.style.left = (WScreen() + XPos() - ((Nav.esIE || Nav.esSa)? 64 : 80)) + 'px';
		eCerrar.style.left = (WScreen() + XPos() - ((Nav.esIE || Nav.esSa)? 40 : 56)) + 'px';
		//
		this.verVotacion(true);
		//
		if(!!eDivAct) this.redimensionar('acomodar');
	}.closure(this);
	
	this.cargar = function(file){
		if(!bReady) return false;
		bReady = false;
		
		sAction = 'cargar';
		req.pedir(file, 'enviar=nada', 'GET');
	};
	
	this.ver = function(o, i, w, h, p, e){
		if(!!e) StopEvent(e);
		//
		if(iIdImg == i && sModo == '')  return false;
		//
		if(!!eDivAct) eDivAct.className = '';
		//
		//
		wImgAct = w;
		hImgAct = h;
		iIdImg = i;
		eEpi.firstChild.innerHTML = o.lastChild.innerHTML;
		eDivAct = o;
		eDivAct.className = 'galMiniDivAct';
		//
		this.buscarVotacion();
		//
		eBgAnim.style.width = ((wImgAct == 0)? 800 : wImgAct) + 'px';
		eBgAnim.style.height = ((hImgAct == 0)? 600 : hImgAct) + 'px';
		if(Nav.esIE6) eBgAnim.style.marginTop = Math.floor((HScreen() - ((hImgAct == 0)? 600 : hImgAct)) / 2) + 'px';
		eEpi.style.display = eImg.style.display = 'none';
		eBgAnim.style.display = 'inline';
		eLoad.style.display = 'block';
		//
		iEventRedim = 0;
		bImgLoad = false;
		//
		eImg.src = eDivAct.firstChild.src.replace('m.j', '.j').replace('m.g', '.g').replace('m.p', '.p');
		eImg.title = eDivAct.firstChild.title;
		//
		iImg = p;
		if(sModo == 'grilla') this.cambiarModo();
		if(sModo == ''){
			this.verImgSig();
			this.verImgAnt();
		}
		//
		this.redimensionar('nueva');
	}
	
	this.imagenCargada = function(){
		bImgLoad = true;
		this.mostrarImagen();
	}.closure(this);
	
	this.mostrarImagen = function(){
		//al ert(bImgLoad+' '+iEventRedim+' '+(!bImgLoad || (iEventRedim < 2)))
		if(!bImgLoad || (iEventRedim < 2)) return false;
		
		//
		eImg.style.height = hImgAct + 'px';
		eImg.style.width = wImgAct + 'px';
		//
		if(Nav.esIE6) eImg.style.marginTop = Math.floor((HScreen() - hImgAct) / 2) + 'px';
		
		//Registramos la carga de esta imagen
		oIdsImgs[iIdImg] = true;
		
		//
		eEpi.style.width = (wImgAct - ((Nav.esIE6)? 15 : 4)) + 'px';
		if(Nav.esIE){
			eEpi.style.marginTop = '-' + (Math.floor(hImgAct / 2) + ((Nav.esIE6)? -14: 4)) + 'px';
			eEpi.style.marginLeft = '-' + (wImgAct - 2) + 'px';
		}
		else{
			eEpi.style.top = (Math.floor((HScreen() - hImgAct) / 2) + 3) + 'px';
			if(Nav.esFf) eEpi.style.left = (Math.floor((WScreen() - wImgAct) / 2) - ((HScreen() == HBody())? 0 : 8)) + 'px';
			else eEpi.style.left = (Math.floor((WScreen() - wImgAct) / 2) - ((HScreen() == HBody())? 6 : 14)) + 'px';
		}
		
		//
		this.verVotacion(true);
		
		//
		eBgAnim.style.display = eLoad.style.display = 'none';
		eImg.style.display = 'inline';
		this.verEpigrafe(false);
	}
	
	this.redimensionar = function(tipo){
		//se no es nueva es que se disparo la redimension
		if(tipo !== 'nueva' && Nav.esIE){
			iEventRedim++;
			if(iEventRedim < 2) return false;
		}
		else iEventRedim = 2;
		
		if(tipo === 'acomodar') bImgLoad = true;
		
		var w = wImgAct;
		var h = hImgAct;
		var wV = parseInt(eBgAnim.style.width);
		var hV = parseInt(eBgAnim.style.height);
		
		//
		eBg.style.height = HBody() + 'px';
		ePrev.style.lineHeight = HScreen() + 'px';
		
		//si es mas ancho que el espacio disponible
		if(wImgAct > (WScreen() - 20)){
			w = WScreen() - 20;
			h = 0;
			//si el alto resultante de la redimension al ancho es mas alto que el disponible
			if((HScreen() - 20) < Math.floor(w * hImgAct / wImgAct)){
				h = HScreen() - 20;
				w = 0;
			}
		}
		
		//si es mas alto que el espacio disponible
		if(w != 0 && hImgAct > (HScreen() - 20)){
			h = HScreen() - 20;
			w = 0;
			//si el alto resultante de la redimension al ancho es mas alto que el disponible
			if((WScreen() - 20) < Math.floor(h * wImgAct / hImgAct)){
				w = WScreen() - 20;
				h = 0;
			}
		}
		
		eImg.style.height = '';
		eImg.style.width = '';
		
		wImgAct = (w == 0)? Math.floor(h * wImgAct / hImgAct) : w;
		hImgAct = (h == 0)? Math.floor(w * hImgAct / wImgAct) : h;
		
		//
		eBgAnim.style.height = hImgAct + 'px';
		eBgAnim.style.width = wImgAct + 'px';
		
		//
		this.mostrarImagen();
		if(sModo == '') this.repaginarMini();
		else this.repaginarGrilla();
	}.closure(this);
	//acciones
	this.cambiarModo = function(){
		if(sModo == ''){
			sModo = 'grilla';
			this.repaginarGrilla();
			RemEvent(document, 'mousemove', this.mostrarHerramientas);
			this.ocultarHerramientas();
			ePrev.style.display = eLoad.style.display = 'none';
			eGri.style.display = eCerrar.style.display = 'block';
		}
		else{
			sModo = '';
			this.repaginarMini();
			eGri.style.display = 'none';
			ePrev.style.display = 'block';
			AddEvent(document, 'mousemove', this.mostrarHerramientas);
			this.mostrarHerramientas(false);
		}
	}.closure(this);
	
	this.verEpigrafe = function(e){
		if(!!e){
			if(bVerEpi){
				bVerEpi = false;
				eVerEpi.className = '';
			}
			else{
				bVerEpi = true;
				eVerEpi.className = 'galOcuEpi';
			}
		}
		
		if(bVerEpi && eEpi.firstChild.innerHTML != '') eEpi.style.display = (Nav.esIE || Nav.esOp)? 'inline-block' : '-moz-inline-box';
		else eEpi.style.display = 'none';
		
		this.mostrarHerramientas(true);
	}.closure(this);
	
	this.verTeclado = function(e){
		if(e){
			if(e.keyCode == 39) this.imgSig();
			else if(e.keyCode == 37) this.imgAnt();
			StopEvent(e);
		}
	}.closure(this);
	//Modo minis
	this.repaginarMini = function(){
		var iTotImgXPagV = iTotImgXPag;
		var iNroImg = 0;
		this.calcularMiniPag();
		
		if(iTotImgXPagV != iTotImgXPag){
			if(iPag <= 0) iNroImg = iImg + 1;
			else iNroImg = (iTotImgXPagV * iPag) + (iImg + 1);
			
			iPag = Math.ceil(iNroImg / iTotImgXPag) - 1;
			if(iPag < 0) iPag = 0;
			iImg = ((iNroImg - 1) % iTotImgXPag);
			
			this.generarMiniHTML();
			this.verPagSig();
			this.verPagAnt();
			this.verImgSig();
			this.verImgAnt();
			
			FireEvent(eMini.childNodes[iImg], 'click');
		}
	}
	
	this.calcularMiniPag = function(){
		var wDis = WScreen() - 160;
		iTotImgXPag = Math.floor(wDis / 53);
		iTotPag = Math.ceil(iTotImg / iTotImgXPag);
	}
	
	this.generarMiniHTML = function(){
		var i = 0, v = '', o = null, d = (iPag * iTotImgXPag), h = ((iPag + 1) * iTotImgXPag);
		for(i = d; i < h; i++){
			if(!!( o = eDoc.firstChild.childNodes[i])){
				v += '<div onclick="oGaleria.ver(this,'+o.getAttribute('i')+','+o.getAttribute('w')+','+o.getAttribute('h')+
				','+(i - d)+',event);"><img src="'+URL_ROOT+eDoc.firstChild.getAttribute('d')+o.getAttribute('n')+'m.'+
				o.getAttribute('e')+'" /><span>'+((Nav.esIE)? o.firstChild.text : o.firstChild.textContent)+'</span></div>';
			}
			//no hay nada mas (en teoria)
			else break;
		}
		eMini.innerHTML = v;
	}
	//Modo grilla
	this.repaginarGrilla = function(){
		var iTotImgXPagV = iTotImgXPag;
		var iNroImg = 0;
		this.calcularGrillaPag();
		
		if(iTotImgXPagV != iTotImgXPag){
			if(iPag <= 0) iNroImg = iImg + 1;
			else iNroImg = (iTotImgXPagV * iPag) + (iImg + 1);
			
			iPag = Math.ceil(iNroImg / iTotImgXPag) - 1;
			if(iPag < 0) iPag = 0;
			iImg = ((iNroImg - 1) % iTotImgXPag);
			
			this.generarGrillaHTML();
		}
	}
	
	this.calcularGrillaPag = function(){
		iTotImgXPag = Math.floor((WScreen() - 80) / 53) * Math.floor((HScreen() - 40) / 53);
		iTotPag = Math.ceil(iTotImg / iTotImgXPag);
	}
	
	this.generarGrillaHTML = function(){
		var i = 0, v = '', o = null, d = (iPag * iTotImgXPag), h = ((iPag + 1) * iTotImgXPag);
		var iImgXLinea = Math.floor((WScreen() - 80) / 53);
		
		for(i = d; i < h; i++){
			if(!!( o = eDoc.firstChild.childNodes[i])){
				v += '<div onclick="oGaleria.ver(this,'+o.getAttribute('i')+','+o.getAttribute('w')+','+o.getAttribute('h')+
				','+(i - d)+',event);"><img src="'+URL_ROOT+eDoc.firstChild.getAttribute('d')+o.getAttribute('n')+'m.'+
				o.getAttribute('e')+'" /><span>'+((Nav.esIE)? o.firstChild.text : o.firstChild.textContent)+'</span></div>';
			}//no hay nada mas (en teoria)
			else break;
			//
			if(i == iImgXLinea) v += '<br />';
		}
		eGri.innerHTML = v;
	}
	//Pagina
	this.hayPagSig = function(){
		return ((iPag + 1) < iTotPag);
	}
	
	this.hayPagAnt = function(){
		return (iPag > 0);
	}
	
	this.pagSig = function(){
		if(!this.hayPagSig()) return false;
		
		iPag++;
		this.generarMiniHTML();
		iImg = -1;
		this.imgSig();
		this.verImgSig();
		this.verImgAnt();
		this.verPagSig();
		this.verPagAnt();
		this.mostrarHerramientas(true);
		if(indiceActual != 0){
			if(indiceActual < iTotImgXPag){
				eMini.childNodes[indiceActual].onclick();
				indiceActual = 0;
			}
			else{
				indiceActual = indiceActual - iTotImgXPag;
				this.pagSig();
			}
		}
		
	}.closure(this);
	
	this.pagAnt = function(){
		if(!this.hayPagAnt()) return false;
		
		iPag--;
		this.generarMiniHTML();
		iImg = iTotImgXPag;
		this.imgAnt();
		this.verImgSig();
		this.verImgAnt();
		this.verPagSig();
		this.verPagAnt();
		this.mostrarHerramientas(true);
	}.closure(this);
	
	this.verPagSig = function(){
		if(this.hayPagSig()) ePagSig.style.display = 'block';
		else ePagSig.style.display = 'none';
	};
	
	this.verPagAnt = function(){
		if(this.hayPagAnt()) ePagAnt.style.display = 'block';
		else ePagAnt.style.display = 'none';
	};
	//Imagen
	this.hayImgSig = function(){
		return (iImg < iTotImgXPag && !!eMini.childNodes[iImg + 1]);
	}
	
	this.hayImgAnt = function(){
		return (iImg > 0);
	}
	
	this.imgSig = function(){
		if(this.hayImgSig()){
			iImg++;
			FireEvent(eMini.childNodes[iImg], 'click');
			this.mostrarHerramientas(true);
		}
		else if(this.hayPagSig()) this.pagSig();
	}.closure(this);
	
	this.imgAnt = function(){
		if(this.hayImgAnt()){
			iImg--;
			FireEvent(eMini.childNodes[iImg], 'click');
			this.mostrarHerramientas(true);
		}
		else if(this.hayPagAnt()) this.pagAnt();
	}.closure(this);
	
	this.verImgSig = function(){
		if(this.hayImgSig() || this.hayPagSig()) eImgSig.style.display = 'block';
		else eImgSig.style.display = 'none';
	};
	
	this.verImgAnt = function(){
		if(this.hayImgAnt() || this.hayPagAnt()) eImgAnt.style.display = 'block';
		else eImgAnt.style.display = 'none';
	};
	//Herramientas
	this.ocultarHerramientas = function(){
		ePagSig.style.display = ePagAnt.style.display = eImgSig.style.display = eImgAnt.style.display = 
		eMini.style.display = eCerrar.style.display = eVerEpi.style.display = eModo.style.display = 'none';
		this.verVotacion(false, true);
		if(!!iTime){
			window.clearTimeout(iTime);
			iTime = 0;
		}
	}.closure(this);
	
	this.mostrarHerramientas = function(e){
		if(!!e && sModo != '') return false;
		
		if(!iTime){
			this.verImgSig();
			this.verImgAnt();
			this.verPagSig();
			this.verPagAnt();
			eMini.style.display = eCerrar.style.display = eModo.style.display = eVerEpi.style.display = 'block';
			
			if(bImgLoad && iEventRedim == 2) this.verVotacion(true, true);
		}
		else{
			window.clearTimeout(iTime);
			iTime = 0;
		}
		iTime = window.setTimeout(this.ocultarHerramientas, 2000);
	}.closure(this);
	//votacion
	this.buscarVotacion = function(){
		if(!bReady) return false;
		bReady = false;
		
		eVotCont.style.display = 'none';
		sAction = 'imgInfo';
		oInfoImg = null;
		req.pedir(URL_ROOT+'requests/infoImagen.php', 'id' + '|=|' + iIdImg + '|&|', 'POST');
	}
	
	this.verVotacion = function(si, mousemove){
		if(!bVotAct || !bImgLoad) return false;
		
		if(si == true && oInfoImg != null && sModo == ''){
			if(!mousemove){
				eVotCont.style.top = (Math.floor((HScreen() - hImgAct) / 2) + 3 + YPos()) + 'px';
				eVotCont.style.left = (Math.floor((WScreen() - wImgAct) / 2) + wImgAct - ((Nav.esIE)? 125:((Nav.esOp)? 140 : 133))) + 'px';
				//
				eEst.style.width = ((oInfoImg['v'] > 0)? (Math.round((oInfoImg['p'] / oInfoImg['v']) * 20)) : '0') + '%';
				eVot.innerHTML = oInfoImg['s'];
				eRatTxt.innerHTML = (oInfoImg['v'] > 0)? (oInfoImg['p'] / oInfoImg['v']).toString().replace('.',',').substr(0, 4) : 0;
			}
			//
			if(bVerEpi){
				eEpi.firstChild.style.paddingRight = '125px';
				if(Nav.esIE6) eEpi.style.width = (wImgAct - 120 - ((Nav.esIE6)? 15 : 4)) + 'px';
			}
			//
			eVotCont.style.display = 'block';
		}
		else{
			eVotCont.style.display = 'none';
			eEpi.firstChild.style.paddingRight = '';
			if(Nav.esIE6 && wImgAct > 0) eEpi.style.width = (wImgAct - ((Nav.esIE6)? 15 : 4)) + 'px';
		}
	}
	
	this.dejarVotar = function(){
		if(oInfoImg && oInfoImg['c'] == 0){
			eEst.parentNode.style.display = 'none';
			eEst1.parentNode.style.display = 'block';
		}
		this.verRating(true);
	}.closure(this);
	
	this.verEstrellas = function(){
		eEst1.parentNode.style.display = 'none';
		eEst.parentNode.style.display = 'block';
		eEst.style.width = eEst.style.width;
		this.verRating(false);
	}.closure(this);;
	
	this.pintarEstrellas = function(i){
		if(Nav.esIE6){
			if(i > 0) eEst1.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOn.png,sizingMethod=scale)';
			else eEst1.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOff.png,sizingMethod=scale)';
			if(i > 1) eEst2.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOn.png,sizingMethod=scale)';
			else eEst2.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOff.png,sizingMethod=scale)';
			if(i > 2) eEst3.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOn.png,sizingMethod=scale)';
			else eEst3.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOff.png,sizingMethod=scale)';
			if(i > 3) eEst4.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOn.png,sizingMethod=scale)';
			else eEst4.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOff.png,sizingMethod=scale)';
			if(i > 4) eEst5.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOn.png,sizingMethod=scale)';
			else eEst5.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/galeria/estrellaOff.png,sizingMethod=scale)';
		}
		else{
			if(i > 0) eEst1.style.backgroundImage = 'url(img/galeria/estrellaOn.png)';
			else eEst1.style.backgroundImage = 'url(img/galeria/estrellaOff.png)';
			if(i > 1) eEst2.style.backgroundImage = 'url(img/galeria/estrellaOn.png)';
			else eEst2.style.backgroundImage = 'url(img/galeria/estrellaOff.png)';
			if(i > 2) eEst3.style.backgroundImage = 'url(img/galeria/estrellaOn.png)';
			else eEst3.style.backgroundImage = 'url(img/galeria/estrellaOff.png)';
			if(i > 3) eEst4.style.backgroundImage = 'url(img/galeria/estrellaOn.png)';
			else eEst4.style.backgroundImage = 'url(img/galeria/estrellaOff.png)';
			if(i > 4) eEst5.style.backgroundImage = 'url(img/galeria/estrellaOn.png)';
			else eEst5.style.backgroundImage = 'url(img/galeria/estrellaOff.png)';
		}
	}
	
	this.votar = function(p){
		if(!bReady) return false;
		bReady = false;
		this.verRating(false);
		
		eVotCont.style.display = 'none';
		sAction = 'imgInfo';
		req.pedir('requests/votarImagen.php', 'id' + '|=|' + iIdImg + '|&|' + 'pts' + '|=|' + p + '|&|', 'POST');
	}
	
	this.verRating = function(si){
		if(si === true) eRatCont.style.display = 'block';
		else eRatCont.style.display = 'none';
	}
	
	this.activarVotacion = function(){
		bVotAct = true;
	}
	
	
	//EVENTs
	AddEvent(eCerrar, 'click', this.cerrar);
	AddEvent(eImgAnt, 'click', this.imgAnt);
	AddEvent(eImgSig, 'click', this.imgSig);
	AddEvent(ePagAnt, 'click', this.pagAnt);
	AddEvent(ePagSig, 'click', this.pagSig);
	AddEvent(eModo, 'click', this.cambiarModo);
	AddEvent(eVerEpi, 'click', this.verEpigrafe);
	//
	req.listener = function(){
		var d = req.respuestaXML, o = null;
		bReady = true;
		//
		if(!d) alert(req.respuestaHTML);
		//
		else if(sAction == 'imgInfo'){
			o = new Object;
			o['v'] = parseInt(d.getAttribute('v'));
			o['p'] = parseInt(d.getAttribute('p'));
			o['s'] = d.getAttribute('s');
			o['c'] = parseInt(d.getAttribute('c'));
			oInfoImg = o;
			if(bOpen) this.verVotacion(true);
			o = null;
		}
		//
		else{
			eDoc = d;
			eDivAct = null;
			iTotImg = eDoc.firstChild.childNodes.length;
			iPag = -1;
			this.calcularMiniPag();
			this.pagSig();
		}
		//
	}.closure(this);
	//
	AddEvent(eEst.parentNode, 'mouseover', this.dejarVotar);
	AddEvent(eEst1.parentNode, 'mouseover', this.dejarVotar);
	AddEvent(eEst1, 'mouseover', this.dejarVotar);
	AddEvent(eEst2, 'mouseover', this.dejarVotar);
	AddEvent(eEst3, 'mouseover', this.dejarVotar);
	AddEvent(eEst4, 'mouseover', this.dejarVotar);
	AddEvent(eEst5, 'mouseover', this.dejarVotar);
	AddEvent(eEst1.parentNode, 'mouseout', this.verEstrellas);
	AddEvent(eEst.parentNode, 'mouseout', this.verEstrellas);
	//
	AddEvent(eEst1, 'mouseover', function(){ this.pintarEstrellas(1); }.closure(this));
	AddEvent(eEst2, 'mouseover', function(){ this.pintarEstrellas(2); }.closure(this));
	AddEvent(eEst3, 'mouseover', function(){ this.pintarEstrellas(3); }.closure(this));
	AddEvent(eEst4, 'mouseover', function(){ this.pintarEstrellas(4); }.closure(this));
	AddEvent(eEst5, 'mouseover', function(){ this.pintarEstrellas(5); }.closure(this));
	//
	AddEvent(eEst1, 'click', function(){ this.votar(1); }.closure(this));
	AddEvent(eEst2, 'click', function(){ this.votar(2); }.closure(this));
	AddEvent(eEst3, 'click', function(){ this.votar(3); }.closure(this));
	AddEvent(eEst4, 'click', function(){ this.votar(4); }.closure(this));
	AddEvent(eEst5, 'click', function(){ this.votar(5); }.closure(this));
	
}