function HPopup(){
	function prepare_events(img){
		img.HPopup_click = img.onclick;
		img.onclick = imageClick;
	}

	function init(){
		var imgs = document.images;
		
		for (var i=0; i<imgs.length; i++){
			var img = imgs[i];
			if (img.getAttribute("popup_image") == null) continue;
			img.style.cursor = "hand";
			img.HPopup_src = img.getAttribute("popup_image");

			prepare_events(img);
		}
		if (window.HPopup_onload != null) window.HPopup_onload();
	}

	function imageClick(){
		window.status = "Slika ......";
		this.popup_image = document.createElement("IMG");
		this.popup_image.onload = show_popup;
		this.popup_image.src = this.HPopup_src;
		if (this.HPopup_click != null) this.HPopup_click();
	}


	function show_popup(){
		var win = window.open('','_blank','width='+this.width+' height='+this.height+' toolbars=no');
		win.document.open();
		win.document.write("<html>");
		win.document.write("<body margins=0 margintop=0 marginleft=0 topmargin=0 leftmargin=0>");
		win.document.write("<img src='"+this.src+"'>");
		win.document.write("</body>");
		win.document.write("</html>");
		win.document.close();
		window.status = "";
		win.document.title = document.title;
	}
	
	window.HPopup_onload = window.onload;
	window.onload = init;
	window.HPopup_called = true;
}

if(!window.HPopup_called) HPopup();

