


function popupMedia(url,width,height,security,pelny,opis) {


	
	if (screen.width<width || screen.height<height) {
		if(opis) {
			winheight=screen.height-200;
			winwidth=screen.width;
			
			proporcja=height/winheight;
			height=winheight;
			width=width/proporcja;
			
			winheight=winheight+30;
			winwidth=width;
		}else {
			winheight=screen.height-200;
			winwidth=screen.width;
			
			proporcja=height/winheight;
			height=winheight;
			width=width/proporcja;
			
			winwidth=width;
		}
	} else {
		if(opis) {
			winheight = parseFloat(height)+30;
			winwidth =  parseFloat(width);
			width= parseFloat(width);
			height= parseFloat(height);
		}else {	
			winheight = parseFloat(height);
			winwidth =  parseFloat(width);
			width= parseFloat(width);
			height= parseFloat(height);
		}
	}			
	scrl=0;	
	
	if(pelny==1){
			winheight=screen.height-90;
			winwidth=screen.width;
			pekr=1;
		}else pekr=0;
	
	for (var i=0; i<10; i++){
	url = url.replace(" ","%20");
	url = url.replace("±","%b9");
	url = url.replace("¶","%9c");
	url = url.replace("¿","%bf");
	url = url.replace("¼","%9f");
	url = url.replace("æ","%e6");
	url = url.replace("ó","%f3");
	url = url.replace("³","%b3");
	url = url.replace("ê","%ea");
	url = url.replace("ñ","%f1");
	
	url = url.replace(" ","%20");
	url = url.replace("¡","%b9");
	url = url.replace("¦","%9c");
	url = url.replace("¯","%bf");
	url = url.replace("¬","%9f");
	url = url.replace("Æ","%e6");
	url = url.replace("Ó","%f3");
	url = url.replace("£","%b3");
	url = url.replace("Ê","%ea");
	url = url.replace("Ñ","%f1");
}


	newWin=window.open('', 'popupwin','fullscreen='+pekr+',resizable=1,HEIGHT='+winheight+',WIDTH='+winwidth+', scrollbars='+scrl, true);
	newWin.document.write('<html>\n');
	newWin.document.write('<head>\n');
	newWin.document.write('<title>Foto</title>');
	newWin.document.write('<script language="javascript" type="text/javascript">\n<!--\n');
	newWin.document.write('var arrTemp=self.location.href.split("?");\n');
	newWin.document.write('var picUrl = (arrTemp.length>1)?arrTemp[1]:"";\n');
	newWin.document.write('var NS = (navigator.appName=="Netscape")?true:false;\n');
	newWin.document.write('function fitMedia() {\n');
	newWin.document.write('	iWidth = (NS)?window.innerWidth:document.body.clientWidth;\n');
	newWin.document.write('	iHeight = (NS)?window.innerHeight:document.body.clientHeight;\n');
	newWin.document.write('	iWidth = '+winwidth+' - iWidth;\n');
	newWin.document.write('	iHeight = '+winheight+' - iHeight;\n');
	newWin.document.write('	window.resizeBy(iWidth, iHeight);\n');
	newWin.document.write('	var posLeft = (window.screen.width - '+winwidth+')/2;\n');
	newWin.document.write('	window.moveTo(posLeft,80);\n');
	newWin.document.write('};\n');
	newWin.document.write('-->\n</script>\n');

	newWin.document.write('<style>html,body{height:100%;padding:0px; margin:0px;}</style>\n');
	newWin.document.write('</head>\n');
	
	newWin.document.write('<body valign=top');
	if(security==1) newWin.document.write(' onselectstart="window.event.returnValue=false;" oncopy="window.event.returnValue=false;" onblur="window.clipboardData.clearData();" oncontextmenu="window.event.returnValue=false;" ondrag="window.event.returnValue=false;" ');
	newWin.document.write(' style="background-color:black; margin:0px; padding:0px;">\n');
	
	newWin.document.write('<table width=100% height=100% valign=top border=0 cellpadding=0 cellspacing=0 style="font-size: 16px; text-align:center;"><tr>');
	newWin.document.write('<td valign="middle" align="center" onclick="window.close()" style="cursor: hand ;" background="galeria/gfx/tlowpodgladzie.jpg" >');
	newWin.document.write('<a href="javascript:window.close()"><img border="0" src="'+url+'" width="'+width+'" height="'+height+'" alt="" /></a>');	
	newWin.document.write('</td></tr><tr><td>\n');

	if(opis) {
	newWin.document.write('<table valign=middle border=0 cellpadding=0 cellspacing=0 style="font-size: 16px;color:white; height:30; width:100%; text-align:center;"><tr><td valign=middle>\n');
	newWin.document.write(opis+'</td>\n</tr>\n</table>');
	}
	newWin.document.write('</td>\n</tr>\n</table>\n</body>\n<script language="javascript" type="text/javascript">\n<!--\n');
	newWin.document.write('fitMedia();\n');
	newWin.document.write('-->\n</script>\n');	
	newWin.document.write('</html>');
	newWin.document.close()
	newWin.focus();
}


