var linksZoom = new Object();
	linksZoom.name = "linksZoom";
function zoomImg(imageSrc) {
    //Mostramos la capa contenedora en negro
    var layer = document.getElementById("contenedorZoom");
    layer.onclick= function(){ocultarZoom()}
    layer.style.left = 0 + getDeltaX() + "px";
    layer.style.top = 0 + getDeltaY() + "px";
	mostrarCapa(layer.id);
	setOpacity(layer, 0);
	fadeIn(layer,0,75);

	//Mostramos la capa que contiene la imagen.
	layer = document.getElementById("zoom");
	layer.onclick= function(){ocultarZoom()}
	mostrarCapa(layer.id);
	setOpacity(layer, 0);
	fadeIn(layer,75);

	//Imagen de precarga
    var image = new Image();
	image.scr = "imagenes/fans/loading.gif";
	layer.innerHTML = "<center><img id='imgZoom' src='imagenes/fans/loading.gif'/></center>";
	image = document.getElementById("imgZoom");
	image.onload = function(){center("zoom", this.width, this.height)}
	setOpacity(image, 100);

	//Creamos la imagen ampliada con sus efectos.
	image = new Image();
	image.scr = imageSrc;
	ocultarCapa(layer.id);
	layer.innerHTML = "<center><img id='imgZoom' src='"+imageSrc+"'/></center>";
	image = document.getElementById("imgZoom");
	setOpacity(image, 0);
	mostrarCapa(layer.id);
	image.onload = function(){
		center("zoom", this.width, this.height);
		setOpacity(this, 0);
		this.style.visibility = 'visible';
		fadeIn(this,0);
	}
	image.onclick= function(){ocultarZoom()}
}

function ocultarZoom() {
	fadeOut(document.getElementById("contenedorZoom"),100);
	fadeOut(document.getElementById("zoom"),100);
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)? 99.999: opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:" + opacity + ")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function fadeIn(obj,opacity,maxOpacity) {
	if(!maxOpacity)maxOpacity = 100;
	if (opacity <= maxOpacity) {
		setOpacity(obj, opacity);
		opacity += 10;
		window.setTimeout("fadeIn(document.getElementById('"+obj.id+"'),"+opacity+","+maxOpacity+")", 50);
	}
}

function fadeOut(obj,opacity) {
	if (opacity >= 0) {
		setOpacity(obj, opacity);
		opacity -= 10;
		window.setTimeout("fadeOut(document.getElementById('"+obj.id+"'),"+opacity+")", 50);
	} else {
		ocultarCapa(obj.id);
	}
}

function center (elementName, width, height) {
	var element = document.getElementById(elementName);
	element.style.position = "absolute";
	var offset_left = (getDeltaX() + Math.floor((getWindowWidth() - width) / 2));
	var offset_top = (getDeltaY() + ((getWindowHeight() > height) ? Math.floor((getWindowHeight() - height) / 2) : 0));
	element.style.left = ((width <= getDocumentWidth()) ? ((offset_left != null && offset_left > 0) ? offset_left : '0') + 'px' : 0);
	element.style.top = ((height <= getDocumentHeight()) ? ((offset_top != null && offset_top > 0) ? offset_top : '0') + 'px' : 0);
}

function getDeltaX() {
	return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
}

function getDeltaY() {
	return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
}

function getWindowWidth(){
	return (self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0);
}

function getWindowHeight(){
	return (self.innerHeight ||  document.documentElement.clientHeight || document.body.clientHeight || 0);
}

function getDocumentWidth(){
	return Math.min(document.body.scrollWidth,getWindowWidth());
}

function getDocumentHeight(){
	return Math.max(document.body.scrollHeight,getWindowHeight());
}

function initZoom() {
	var enlaces = document.getElementsByTagName("a");
	for(var i = 0; i < enlaces.length; i++) {
		var enlace = enlaces[i];
		if(enlace.href && enlace.href.length > 3) {
			var ext = enlace.href.substring((enlace.href.length -3), enlace.href.length).toLowerCase();
			if(ext == "gif" || ext == "jpg" || ext == "pnj") {
				eval(linksZoom.name + "."+enlace.id + "=\""+enlace.href+"\";");
				enlace.href="#";
				enlace.onclick = function() {
					eval("zoomImg("+linksZoom.name+"."+this.id+")");
					return;
				}
			}
		}
	}
}