function popup_html(url, win_options) {
	var _POPUP_FEATURES = 'dependent=1,resizable=1,scrollbars=1,location=0,statusbar=0,menubar=0,width=660,height=500';
	if (!win_options) win_options = _POPUP_FEATURES;
	var win = window.open(url.getAttribute('href'), '_blank', win_options);
	win.focus();
	return win;
}




function popup_img_init()
{
	if (!document.body.getElementsByTagName) {return false;}

	var as = document.body.getElementsByTagName('a');
	for(i=0;i<as.length;i++)
		if (as[i].className == 'popup_img')
			as[i].onclick = popup_img;

	return true;
}

function popup_img()
{
	var imgs = this.getElementsByTagName('img');
	var title = imgs[0].getAttribute('title');
	var alt = imgs[0].getAttribute('alt');

	/* finds dimensions in given string, format: (<width>x<height>), output: width=<width>,height=<height> */
	if (title)
	{
		var reg = title.match(new RegExp('\(([0-9]+)x([0-9]+)\)'));
		img_size = "width="+(parseInt(reg[2]))+",height="+(parseInt(reg[3])+5);
	}
	else { var img_size = "width=640,height=485"; }
	
	/* window options */
	var win_options = "dependent=1,resizable=1,scrollbars=0,location=0,menubar=0,statusbar=0,"+img_size;

	/* creates new window */
  if (win = window.open(this.href,'_blank',win_options))
  {
		win.document.open();
		win.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
		win.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">');
		win.document.write('<head><title>'+alt+'</title>');
		win.document.write('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />');
		win.document.write('<style type="text/css">body {margin:0;	padding:0; background:#666;}</style>');
		win.document.write('</head><body onclick="window.close()">');
		win.document.write('<img title="'+title+'" src="'+this.href+'" alt="'+alt+'"></body></html>');
		win.document.close();
		return false;
  }
	
  /* follows link on failure */
	return true; 
}

window.onload = popup_img_init;
