function showImg(ev) {
	if (!ev) var ev = window.event;
	if (typeof(ev.target) != 'undefined') {
		ev.stopPropagation();
		ev.preventDefault();
	} else {
		ev.target = ev.srcElement;
		ev.cancelBubble = true;
	}
	big.alt = ev.target.title;
	big.title = ev.target.title;
	if (!document.getElementById('big')) {
		document.body.appendChild(big);
	}
	big.src = ev.target.parentNode.href;
	return false;
}

function init() {
	if (document.getElementById('seria') || document.getElementById('gallery')) {
		big = document.createElement('img');
		big.id = 'img';
		big.style.position = 'absolute'; big.style.top = '10px'; big.style.left = '10px';
		big.style.border = '1px solid #770000'; big.style.cursor = 'pointer';
		big.onload = function () { 
			this.style.left = Math.floor((document.documentElement.offsetWidth - this.width - 1) / 2) + 'px';
			this.style.top = Math.max(0, Math.floor(document.documentElement.scrollTop + (document.documentElement.offsetHeight - this.height - 1) / 2)) + 'px';
		};
		big.onclick = function () { this.style.left = '-10000px';};
	
		if (document.getElementById('gallery'))	{
			thumbs = document.getElementById('gallery').getElementsByTagName('a');
			for (i in thumbs) {
				thumbs[i].onclick = showImg;
			}
		} else {
			thumbs = document.getElementById('seria').getElementsByTagName('a');
			for (i in thumbs) {
				if (thumbs[i].className == 'lupa') {
					thumbs[i].onclick = showImg;
				}
			}
		}
	}
}
window.onload = init;