/*
Funkce na otevření externího okna do středu obrazovky do kterého  se  načte
obrázek a okno se následně zvětsí na velikost  obrázku. Pokud je obrázek
větsí jak  rozlisení  obrazovky,  okno se roztáhne pouze na tuto velikost .

Pousití:
Nejdříve načteme funkci do stránky.  Mezi  tagy <head></head> vlosíme:
<script src="js/extpict.js" type="text/javascript"></script>

Následně můseme volat funkci s parametrem, kterým je obrázek, např.:
<a href="javascript:extpict('obrazek.gif');">Odkaz</a>


Verze 0.2; Vytvořil Pavel Černý pro NAUSUS (c) 2002
(extpict@beltaine.cz; nausus@nausus.cz)
*/

function extpict(picture)
{
	titlename = 'BLUE-STYLE - obrázek';
	defwidth  = 350; 
	defheight = 350; 
	bgcolor   = '#ffffff'; // barva pozadí
	text      = '#000000'; // barva textu
	alttext   = 'Kliknutím na obrázek zavřete okno'; // text, ktery nabidk
	winname   = ''; // jmeno oteviraneho okna

	// fyzické rozlisení obrazovky
	scw = window.screen.availWidth-29;
	sch = window.screen.availHeight;

	// pozice na středu otevřeného oknas
	wleft = scw/2-defwidth/2;
	wtop = sch/2-defheight/2;
	
	Preview = window.open('', winname, 'resizable=1, status=0, menubar=0, location=0, directories=0, scrollbars=1, width='+defwidth+', height='+defheight+', top='+wtop+', left='+wleft);
	Preview.document.write('<html><head><title>'+titlename+' ('+picture+')</title></head>');
	Preview.document.write('\n<script language="JavaScript">\n');
	Preview.document.write('function sizeImg(){\n');
	Preview.document.write('winwidth=document.all.foto.width+28;\n');
	Preview.document.write('winheigh=document.all.foto.height+31;\n');
	Preview.document.write('if (winwidth>'+scw+') winwidth='+scw+';\n');
	Preview.document.write('if (winheigh>'+sch+') winheigh='+sch+';\n');
	Preview.document.write('wtop='+(sch/2)+'-winheigh/2;\n'); 
	Preview.document.write('wleft='+(scw/2)+'-winwidth/2;\n');
	Preview.document.write('if (wtop<0) wtop=0;\n');
	Preview.document.write('if (wleft<0) wleft=0;\n');
	Preview.document.write('window.moveTo(wleft, wtop);\n'); // změna velikosti okna
	Preview.document.write('window.resizeTo(winwidth,winheigh);\n'); // změna velikosti okna
//	Preview.document.write('window.scrollbars=1;\n');
	Preview.document.write('}\n');
	Preview.document.write('</script>\n');
	Preview.document.write('<body onLoad="sizeImg()" bgcolor="'+bgcolor+'" text="'+text+'" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" bottommargin="0">');
	Preview.document.write('<a href="javascript:window.close();">');
	Preview.document.write('<img src="' + picture + '" border="0" id="foto" alt="' + alttext + '" hspace="0" vspace="0" />');
	Preview.document.write('</a>');
	Preview.document.write('</body></html>');
	Preview.document.close();
}

