
var tAmp;
var tAdd;
var cargaCODE="";
var oldsize;
var listo = false;
var scrollTop = 0;
function ampliar(imagen){
	var VenIMG;
	var superVen;
	var VenFoto;
	var acomodador;
	var adicional;
	var tmpimg = new Image();
	var Height;
	var Width;
	var titulo;

	var carga;
	var boton;
	if(imagen.complete == false)return;
	listo = false;
	boton = document.getElementById("imgbotonx");
	VenIMG = document.getElementById("VenIMG");
	superVen = document.getElementById("superVen");
	VenFoto = document.getElementById("VenFoto");
	acomodador = document.getElementById("acomodador");
	adicional = document.getElementById("adicional");
	carga = document.getElementById("carga");
	titulo = document.getElementById("titulo_imagen");
	//
	if(document.documentElement.scrollTop != 0){
		scrollTop = document.documentElement.scrollTop;
	}else{
		scrollTop = document.body.scrollTop;
	}
	tmpimg.src = imagen.src;
	while(tmpimg.width == null){
		true;
	}
	if (!window.innerHeight) {
		window.innerHeight = document.documentElement.clientHeight;
	}


	titulo.innerHTML = imagen.title;
	adicional.innerHTML = imagen.alt;
	adicional.style.visibility = "hidden";
	boton.style.visibility = "hidden";
	Width = tmpimg.width + 10;
	Height = tmpimg.height + 50;
	VenIMG.style.width = tmpimg.width + "px";
	VenIMG.style.height = tmpimg.height + "px";
	superVen.style.display = "inline";

	carga.style.top = ((VenIMG.style.height.NumPx() - carga.style.height.NumPx()) / 2) + "px";
	VenFoto.style.width = "150px";
	VenFoto.style.height = "0px";
	acomodador.style.top = (((window.innerHeight - VenFoto.style.height.NumPx()) / 2) + scrollTop) + "px";
	cargaCODE = VenIMG.innerHTML;
	VenIMG.innerHTML = "";
	acomodador.style.display = "inline";
	//alert("Listo");
	tAmp = setInterval("crece(" + Height + "," + Width + ",'" + tmpimg.src + "')",10);

}
var cuenta = false;
var espera = 0;
function crece(height,width,imagepath){
	var VenFoto;
	var VenIMG;
	var adicional;
	var superVen;
	var acomodador;
	var razon=0;
	acomodador = document.getElementById("acomodador");
	superVen = document.getElementById("superVen");
	VenFoto = document.getElementById("VenFoto");
	VenIMG = document.getElementById("VenIMG");
	adicional = document.getElementById("adicional");
	razon = width / 20;
	//if(VenFoto.style.height.NumPx() >= height){
		if(VenFoto.style.width.NumPx() < width){
				VenFoto.style.width = (VenFoto.style.width.NumPx() + 25) + "px";
		}
	//}
	if(VenFoto.style.width.NumPx() >= width){
		if(espera>=10){
			if(VenFoto.style.height.NumPx() < height){
				VenFoto.style.height = (VenFoto.style.height.NumPx() + 25) + "px";
			}
			//espera= 0;
		}else{
			espera++;
		}
	}
	if(acomodador.style.top.NumPx() > (scrollTop + 20)){
			acomodador.style.top = (((window.innerHeight - VenFoto.style.height.NumPx()) / 2) + scrollTop) + "px";
	}
	if(VenFoto.style.height.NumPx() >= height && VenFoto.style.width.NumPx() >= width){
		VenIMG.innerHTML = cargaCODE;
		setTimeout("terminaampliar('" + imagepath + "')",2000);
		clearInterval(tAmp);
	}
}

function terminaampliar(imagepath){
	var VenIMG;
	var VenFoto;
	var adicional;
	VenIMG = document.getElementById("VenIMG");
	adicional = document.getElementById("adicional");
	VenFoto = document.getElementById("VenFoto");

	VenIMG.innerHTML = "";
	VenIMG.style.background = "#FFFFFF url('" + imagepath + "')";
	//VenIMG.innerHTML = "<div style='opacity:0.3;font-size:15pt;font-weigth:bold;color:white'>Tibiavenezuela.com</div>";
	oldsize = VenFoto.style.height.NumPx();
	tAdd = setInterval("creceadicional()",10);

}

function creceadicional(){
	var VenFoto;
	var adicional;
	var newsize;
	var boton;
	boton = document.getElementById("imgbotonx");
	adicional = document.getElementById("adicional");
	VenFoto = document.getElementById("VenFoto");
	newsize = oldsize + adicional.style.height.NumPx();
	if(VenFoto.style.height.NumPx() < newsize){
		VenFoto.style.height = (VenFoto.style.height.NumPx() + 5) + "px";
	}else{
		adicional.style.opacity = 0;
		adicional.style.filter = "alpha(opacity=0)";
		adicional.style.visibility = "visible";
		aparece(adicional.id,20);
		boton.style.visibility = "visible";
		listo = true;

		clearInterval(tAdd);
	}
}
/**
 *
 * @access public
 * @return void
 **/
function cierraIMG(){
	var superVen;
	var VenIMG;
	var VenFoto;
	var acomodador;
	var adicional;
	var superVen;
	var boton;
	VenIMG = document.getElementById("VenIMG");
	superVen = document.getElementById("superVen");
	VenFoto = document.getElementById("VenFoto");
	acomodador = document.getElementById("acomodador");
	adicional = document.getElementById("adicional");
	superVen = document.getElementById("superVen");
	boton = document.getElementById("imgbotonx");
	if (listo == true) {
	espera= 0;
		if(!VenFoto.tag){
			superVen.style.display = "none";
			acomodador.style.display = "none";
			VenIMG.style.background = "#FFF";
			VenIMG.innerHTML = cargaCODE;
		}else{
			if(boton.tag){
				superVen.style.display = "none";
				acomodador.style.display = "none";
				VenIMG.style.background = "#FFF";
				VenIMG.innerHTML = cargaCODE;
			}
		}

	}
}