n=navigator.appName;
ns=(n=="Netscape");
ie=(n=="Microsoft Internet Explorer");
op=(n=="Opera");

function popup ( ord, evt, content )
{
	evt = (evt) ? evt : event;
	mouse_x=evt.clientX;
	mouse_y=evt.clientY;
	//alert (evt.clientY);
	order=ord;
	podskazka.innerHTML=content;
	podskazka.style.visibility="visible";
	//podskazka.style.left=mouse_x;
	//podskazka.style.top=mouse_y-100+document.body.scrollTop;

	//mouv(evt);
	//podskazka.style.top = evt.clientY  + document.body.scrollTop - 100;
	podskazka.style.top = mouse_y - 300 +document.body.scrollTop;
	podskazka.style.left = mouse_x +20;
	//podskazka.style.left = evt.clientX + document.body.scrollLeft  + 15;
}

function popup2 ( ord, evt, content )
{
	evt = (evt) ? evt : event;
	mouse_x=evt.clientX;
	mouse_y=evt.clientY;
	//alert (evt.clientY);
	order=ord;
	podskazka.innerHTML=content;
	podskazka.style.visibility="visible";
	//podskazka.style.left=mouse_x;
	//podskazka.style.top=mouse_y-100+document.body.scrollTop;

	//mouv(evt);
	//podskazka.style.top = evt.clientY  + document.body.scrollTop - 100;
	podskazka.style.top = mouse_y - 300 +document.body.scrollTop;
	podskazka.style.left = mouse_x -650;
	//podskazka.style.left = evt.clientX + document.body.scrollLeft  + 15;
}

function mouv(evt){
	podskazka = document.getElementById ( "podskazka" );
	podskazka.style.top = evt.clientY  + document.body.scrollTop - 300;
//	podskazka.style.left = evt.clientX + document.body.scrollLeft  + 15;
}

function kill()
{
	podskazka.style.visibility="hidden";
}
function openWindow(path, title) {
	w = 600;
	h = 600;
	
	if(w>screen.width) 
	{
		h = parseInt((screen.width/w)*h);
		w = screen.width;
		if(h>screen.height)
		{
			w = parseInt((screen.height/h)*w);
			h = screen.height;
		}
	}
	if(h>screen.height)
	{
		w = parseInt((screen.height/h)*w);
		h = screen.height;
		if(w>screen.width)
		{
				h = parseInt((screen.width/w)*h);
				w = screen.width;			
		}
	}
	var screenX = parseInt((screen.width-w)/2);
	var screenY = parseInt((screen.height-h)/2);

	var html3 = '<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><TITLE>'+title+'</TITLE><sc'+'ript type="text/javascript" src="/templates/js/jquery-1.5.1.js"></sc'+'ript></HEAD>';
		html3 += '<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
		html3 += '<img src="'+path+'" alt="'+title+'" id="img2">';
		html3 += '<sc'+'ript>$(document).ready(function(){ window.resizeTo((document.getElementById("img2").clientWidth+8), (document.getElementById("img2").clientHeight+80)); })</sc'+'ript>';
		html3 +=	'</BODY></HTML>';
		myWin = open(path,'displayWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',screenX='+screenX+',screenY='+screenY);
		myWin.document.open();
		myWin.document.write(html3);
		myWin.document.close();  
	return false;
}
function openWindow2(path, title, w, h) {
	if(w>screen.width) 
	{
		h = parseInt((screen.width/w)*h);
		w = screen.width;
		if(h>screen.height)
		{
			w = parseInt((screen.height/h)*w);
			h = screen.height;
		}
	}
	if(h>screen.height)
	{
		w = parseInt((screen.height/h)*w);
		h = screen.height;
		if(w>screen.width)
		{
				h = parseInt((screen.width/w)*h);
				w = screen.width;			
		}
	}
	var screenX = parseInt((screen.width-w)/2);
	var screenY = parseInt((screen.height-h)/2);

	var html3 = '<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><TITLE>'+title+'</TITLE><sc'+'ript type="text/javascript" src="/templates/js/jquery-1.5.1.js"></sc'+'ript></HEAD>';
		html3 += '<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
		html3 += '<img src="'+path+'" alt="'+title+'" id="img2">';
		html3 +=	'</BODY></HTML>';
		myWin = open(path,'displayWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',screenX='+screenX+',screenY='+screenY);
		myWin.document.open();
		myWin.document.write(html3);
		myWin.document.close();  
	return false;
}
jQuery(document).ready(function(){
	jQuery('a.popup').click(function(){
		var img_href = jQuery(this).attr('href');
		var img_title = jQuery(this).attr('title');
		openWindow(img_href, img_title);
		return false;
	});
	jQuery('a.popup2').click(function(){
		var img_href = jQuery(this).attr('href');
		var img_title = jQuery(this).attr('title');
		var img_width = jQuery(this).attr('width');
		var img_height = jQuery(this).attr('height');
		openWindow2(img_href, img_title, img_width, img_height);
		return false;
	});
})
