function Galeria(zdjecia)
{
	this.kolumny = 7;          //liczba kolumn
	this.naStronie = 1000;		//ile na stronie

	this.id = 'galeria';
	this.zdjecia = zdjecia;
	this.ochrona = true;
	this.css = 'cssijs/galeria.css';

	this.wyswietl = function(strona)                // zdjecia[i][0]-małe ;   zdjecia[i][1]-duże ;
	{
		if (typeof strona == 'undefined') strona = 1;
		var html = '';

// wyswietla wszystkie małe na stronie
		for (var i = start_ = (strona - 1) * this.naStronie, stop_ = Math.min(start_ + this.naStronie, this.zdjecia.length); i < stop_; i++)
		{
			var numer = this.zdjecia[i][1];
	  		var ind = numer.lastIndexOf("/");
	  		numer = numer.substr(ind+1,7);

			if (i > start_ && !(i % this.kolumny)) html += '</tr><tr>';
			html +=
				'<td>' +
					'<a href="' + (this.ochrona ? 'javascript:void(0)' : this.zdjecia[i][1]) + '" onclick="return !' + this.id + '.pokaz(' + i + ')" onkeypress="return !' + this.id + '.pokaz(' + i + ')"><img src="gfx/uszczelki/' + this.zdjecia[i][0] + '"style="margin-left:-18px; min-height:79px"  alt="uszczelki silikonowe"' + (this.ochrona ? ' onmousedown="return false" oncontextmenu="return false" onselectstart="return false" onselect="return false" oncopy="return false" ondragstart="return false" ondrag="return false" galleryimg="no"' : '') + ' /></a>' +
					(typeof this.zdjecia[i][2] != 'undefined' ? '<div>' + this.zdjecia[i][2] + '</div>' : '') +
				'<br />' + numer + '</td>';
		}
		if (html) html = '<table class="katalog_uszcz" style="margin-left:-16px; margin-right:-16px;"><tr>' + html + '</tr></table>';
		document.getElementById(this.id).innerHTML = '<div>' + html + '</div>';
	}

	this._pokaz = function(i)
	{
		var numer = this.zdjecia[i][1];
	   var ind = numer.lastIndexOf("/");
	  		numer = numer.substr(ind+1,7);

		var html =
			'<html>' +
				'<head>' +
					'<title>&nbsp; Uszczelka silikonowa '+(typeof this.zdjecia[i][2] != 'undefined' ? this.zdjecia[i][2].replace(/<[^>]+>/g, '') + (numer ? ' (' + numer + ')' : '') : numer) + '</title>' +
					(typeof this.css != 'undefined' && this.css ? '<link rel="Stylesheet" type="text/css" href="' + this.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)); }' +
					(this.ochrona ? '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 style="margin: 0; padding: 0" onload="dopasuj(); dopasuj()"' + (this.ochrona ? ' 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\'"' : '') + '>' +
					'<div id="body">' +
						'<div id="zdjecie">' +
							(typeof this.zdjecia[i][2] != 'undefined' || numer ? '<h1> Uszczelka silikonowa &nbsp; ' + (typeof this.zdjecia[i][2] != 'undefined' ? this.zdjecia[i][2] : numer) + '</h1>' : '') +
							'<div style="text-align: center"><img id="img" src="gfx/uszczelki/' + this.zdjecia[i][1] + '" alt=""' + (this.ochrona ? ' onmousedown="return false" oncontextmenu="return false" onselectstart="return false" onselect="return false" oncopy="return false" ondragstart="return false" ondrag="return false" galleryimg="no"' : '') + ' /></div>' +
							(typeof this.zdjecia[i][2] != 'undefined' ? '<div>' + this.zdjecia[i][2] + '</div>' : '') +
						'</div>' +
						'<center><input style="font-family: Tahoma; font-size: 11px" type="button" value="  Zamknij  okno  " onClick="window.close();"></center>' +
					'</div>' +
				'</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=400,height=400');
		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;

