function Galeria(id, zdjecia, tytul, kolumny)

{

this.kolumny = kolumny;
this.naStronie = 100;

this.id = id;
this.zdjecia = zdjecia;
this.tytul = tytul;

for (var i = 0; i < this.zdjecia.length; i++)
{new Image().src = this.zdjecia[i][0];}



this.wyswietl = function(strona)
{
	var strona = 1;

	var html = '';
	for (var i = start_ = (strona - 1) * this.naStronie, stop_ = Math.min(start_ + this.naStronie, this.zdjecia.length); i < stop_; i++)
	{
		if (i > start_ && !(i % this.kolumny)) html += '</tr><tr>';
		html +=
			'<td>' +
				'<a href="javascript:void(0)" onclick="return !' + this.id + '.pokaz(' + i + ')" onkeypress="return !' + this.id + '.pokaz(' + i + ')"><img src="' + this.zdjecia[i][0] + '" alt="" onmousedown="return false" oncontextmenu="return false" onselectstart="return false" onselect="return false" oncopy="return false" ondragstart="return false" ondrag="return false" galleryimg="no" border=0 /></a>' +
			'</td>';
	}
	if (html) html = '<table><tr>' + html + '</tr></table>';
	if (this.zdjecia.length > this.naStronie)
	{
		html += '<div class="stronicowanie">';
		if (strona > 1) html += '<a href="javascript:void(0)" onclick="' + this.id + '.wyswietl(' + (strona - 1) + '); return false" onkeypress="' + this.id + '.wyswietl(' + (strona - 1) + '); return false">&laquo;</a>';
		for (var i = 1, stop_ = Math.ceil(this.zdjecia.length / this.naStronie); i <= stop_; i++)
		{
			html += ' ' + (i == strona ? i : '<a href="javascript:void(0)" onclick="' + this.id + '.wyswietl(' + i + '); return false" onkeypress="' + this.id + '.wyswietl(' + i + '); return false">' + i + '</a>');
		}
		if (strona < stop_) html += ' <a href="javascript:void(0)" onclick="' + this.id + '.wyswietl(' + (strona + 1) + '); return false" onkeypress="' + this.id + '.wyswietl(' + (strona + 1) + '); return false">&raquo;</a>';
		html += '</div>';
	}
	document.getElementById(this.id).innerHTML = '<div class="galeria">' + html + '</div>';
}


	
this._pokaz = function(i)
{

var numer = (i + 1) + ' / ' + this.zdjecia.length;

if (i>0)
var wstecz='<a href="javascript:void(0)" onclick="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(' + (i - 1) + ')); document.close(); document.close()\', 1); return false" onkeypress="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(' + (i - 1) + ')); document.close(); document.close()\', 1); return false"><font class=tekst><u><b><< wstecz</b></u></font></a>';
else
var wstecz='<a href="javascript:void(0)" onclick="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(' + (this.zdjecia.length - 1) + ')); document.close(); document.close()\', 1); return false" onkeypress="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(' + (this.zdjecia.length - 1) + ')); document.close(); document.close()\', 1); return false"><font class=tekst><u><b><< wstecz</b></u></font></a>';

if (i<this.zdjecia.length - 1)
var dalej='<a href="javascript:void(0)" onclick="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(' + (i + 1) + ')); document.close()\', 1); return false" onkeypress="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(' + (i + 1) + ')); document.close()\', 1); return false"><font class=tekst><u><b>dalej >></b></u></font></a>';
else
var dalej='<a href="javascript:void(0)" onclick="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(0)); document.close()\', 1); return false" onkeypress="setTimeout(\'document.write(window.opener.' + this.id + '._pokaz(0)); document.close()\', 1); return false"><font class=tekst><u><b>dalej >></b></u></font></a>';

var przelacz =
'<font class=tekst><br></font><table border=1 bgcolor=#699cba bordercolor=darkBlue CELLSPACING=0><tr>' +
'<td width=100 height=50 align=center valign=middle>'+wstecz+'</td>' +
'<td width= 70 height=50 align=center valign=middle><font class=tekst><b>'+ numer+'</b></font></td>' +
'<td width=100 height=50 align=center valign=middle>'+dalej+'</td>' +
'</tr></table>';


var html =
	'<html>' +
		'<head>' +
			'<title>' +numer+'</title>' +
			'<link rel="Stylesheet" type="text/css" href="style.css" />'+
			'<'+'script type="text/javascript">'+
			'function dopasuj(){window.resizeTo(Math.min(screen.availWidth,Math.max(document.getElementById(\'img\').width + 50, document.getElementById(\'body\').offsetWidth)),Math.min(screen.availHeight,document.getElementById(\'body\').offsetHeight+80));}' +
			'window.onblur = function() { if (document.getElementById(\'body\')) document.getElementById(\'body\').style.visibility = \'hidden\'; try { clipboardData.clearData(); } catch (e) {} }; window.onfocus = function () { if (document.getElementById(\'body\')) document.getElementById(\'body\').style.visibility = \'visible\'; };' +
			'</script>' +
		'</head>' +

		'<body bgcolor=#c6d7e2 style="margin: 0; padding: 0" onload="dopasuj(); dopasuj()" oncontextmenu="return false" onbeforeprint="document.getElementsByTagName(\'body\')[0].style.visibility = \'hidden\'; window.alert(\'Wydruk jest niedostêpny!\')" onafterprint="document.getElementsByTagName(\'body\')[0].style.visibility = \'visible\'">' +
		'<center><font class=tytulpokaz><br>'+this.tytul+'<br><br></font><table width=800 height=600 border=1 bordercolor=darkBlue CELLSPACING=0 CELLPADDING=0 bgcolor=lightsteelblue><tr><td align=center valign=middle >' +
		'<img id="img" src="' + this.zdjecia[i][1] + '" alt="" onmousedown="return false" oncontextmenu="return false" onselectstart="return false" onselect="return false" oncopy="return false" ondragstart="return false" ondrag="return false" galleryimg="no"/>' +
		'</td></tr></table>' +
		przelacz +
		'</center>' +
		'</body>' +
	'</html>';
return html;
}


	
this.pokaz = function(i)
{
try { Galeria.okno.close() } catch (e) {}
Galeria.okno = window.open('', this.id, 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=900,height=750');
if (!Galeria.okno) return false;

Galeria.okno.document.close();
Galeria.okno.document.write(this._pokaz(i));
Galeria.okno.document.close();
Galeria.okno.focus();
return true;
}

document.write('<div id="' + this.id + '"></div>');

this.wyswietl();

}

Galeria.okno = null;

