initEmPopUpWidth  = 200;
initEmPopUpHeight = 100;

emPopUp = {
	sizeImgWin : function(img) {
		if (!img.loaded) {
			// v Mozille se vyvola onload 2x
			img.loaded = true;
			img.onload = null;
			var new_w  = img.width + 20;
			var new_h  = img.height + 20;
			if ((screen.width > new_w) || (screen.height > new_h)) {
				var left       = (screen.width  - new_w) / 2;
				var top        = (screen.height - new_h) / 2;
			} else {
				var left       = 0;
				var top        = 0;
			}
			window.moveTo(left, top);
			new_w -= initEmPopUpWidth;
			new_h -= initEmPopUpHeight;
			window.resizeBy(new_w,new_h);
			window.document.title = window.loadTl;
			img.style.top  = '0px';
			img.style.left = '0px';
		}
	},

	popUp : function(e) {
		e = evt.fix(e);
		var anchor     = e.target;
		while (anchor.tagName != 'A') {
			anchor = anchor.parentNode;
		}
		var width      = initEmPopUpWidth;
		var height     = initEmPopUpHeight;
		var left       = (screen.width  - width)  / 2;
		var top        = (screen.height - height) / 2;
		var scrollbars = 'no';
		imgWin         = window.open(anchor.href + '?popUp=true','', 'scrollbars='+scrollbars+', width='+width+', height='+height+', top='+top+', status=no, left='+left);
		imgWin.loadTl  = anchor.title;
		e.preventDefault();
		return false;
	},

	init : function() {
		var anchors = document.getElementsByTagName('A');
		for (i=0; i<anchors.length; i++) {
			if (cls.has(anchors[i], 'emPopUp')) {
				evt.add(anchors[i], 'click', emPopUp.popUp);
			}
		}
	}
}

evt.add(window, 'load', emPopUp.init);