<!--

function lightbox(n, x)
{
	this.n = n;
	this.images = new Array();
	this.rel = x || 'lightbox';
	this.prefix= 'sdfhjl893'+this.rel+'_';
	this.imgLoadSrc = 'lightbox/loading.gif';
	this.imgLeftSrc = 'lightbox/arrow_l.gif';
	this.imgRightSrc = 'lightbox/arrow_r.gif';
	this.actImage = 0;
	this.inInit = false;

	//tablela
	this.table = null;
	
	//div gdzie będzie tlo
	this.bg = null;
	
	//img z loaderem
	this.loader = null;
	
	//img z plikiem
	//this.img = null;
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.show = function(n)
	{
		this.tryShow(this.images[n-1]);
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.onArrowClick = function(n)
	{
		var _prev, _next;
		
		this.closeLightbox(1);

		if(n == 1)
		{
			_next = (this.actImage + 1 == this.images.length)? 0 : this.actImage + 1;
			this.tryShow(this.images[_next]);
		}
		else if(n == -1)
		{
			_prev = (this.actImage - 1 == -1)? this.images.length-1 :  this.actImage - 1;
			this.tryShow(this.images[_prev]);
		}
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.tryShow = function(hrefObj)
	{
		var ps = this.pageSize();

		this.bg.style.width = ps.pageWidth;
		this.bg.style.height = ps.pageHeight;
		this.bg.style.display = 'block';

		this.loader.style.display = 'block';

		this.loader.style.left = ps.windowWidth/2 - GetWidth(this.loader)/2;
		this.loader.style.top = ps.windowHeight/2 + this.scroll();

		$(this.prefix+"title").innerHTML = (hrefObj.title && hrefObj.title.length > 0)? hrefObj.title : "&nbsp;";

		this.img.src = hrefObj.href;
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.onLoadImg = function(hrefObj)
	{
		this.loader.style.display = 'none';
		this.showImg(hrefObj.src);
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.showImg = function(src)
	{
		if (navigator.appVersion.indexOf("MSIE")!=-1)
			this.pause(300);
		
		this.actSrc = this.img.src;
		
		var ps = this.pageSize();
		var tSize = GetSize(this.table);
		
		this.table.style.left = ps.pageWidth/2 - tSize.width/2;
		this.table.style.top = ps.windowHeight/2 - tSize.height/2 + this.scroll();

		//mint.fx.Style(this.img, "opacity", 0, 100, 20, 200);
	
		for(var i=0; i<this.images.length; i++)
		{
			if(this.images[i].href == src)
			{
				this.actImage = i;
				break;
			}
		}		
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	this.closeLightbox = function(x)
	{
		this.table.style.top = '-10000px';
		this.table.style.left = '-10000px';
		
		if(!x)
			this.bg.style.display = 'none';
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.init = function(n)
	{
		var that = this;

		if(this.inInit)
			return;
		else
			this.inInit = true;

		if(!document.getElementsByTagName)
			return;
			
		var links = document.getElementsByTagName("a");
	
		for(var i=0; i<links.length; i++)
		{
			var lnk = links[i];
			var href = lnk.getAttribute("href");
			
			if(href && lnk.getAttribute("rel") == this.rel)
			{
				this.images.push(lnk);

				lnk.onclick = function(){
					that.tryShow(this);
					return false;
				}
			}
		}

		//var objBody = document.getElementsByTagName("body").item(0);
	
		this.bg = document.createElement('div');
		this.bg.style.display = 'none';
		this.bg.style.position = 'absolute';
		this.bg.style.top = '0px';
		this.bg.style.left = '0px';
		this.bg.style.zIndex = '99';
 		this.bg.style.width = '100%';
		this.bg.style.height = '100%';
		//this.bg.style.background = '#999999';
		//this.bg.class = 'lightbox_titie';
		
		this.loader = document.createElement('img');
		this.loader.src = this.imgLoadSrc;
		this.loader.style.display = 'none';
		this.loader.style.position = 'absolute';
		this.loader.style.top = '0px';
		this.loader.style.left = '0px';
		this.loader.style.zIndex = '101';

		this.table = document.createElement('table');

		var tr, td;
		tr = this.table.insertRow(0);
		td = tr.insertCell(0);
		td.setAttribute('colspan', '3');
		td.colSpan = 3;
		td.innerHTML = '<a href="#" onclick="return false;"><img src="" id="'+this.prefix+'image" border="0"></a>';

		tr = this.table.insertRow(1);

		td = tr.insertCell(0);
		td.innerHTML = '<a href="#" onclick="'+this.n+'.onArrowClick(-1); return false;"><img src="'+this.imgLeftSrc+'" border="0"></a>';
		td.className = "lightbox_title";
		td = tr.insertCell(1);
		td.className = "lightbox_title";
		td.setAttribute('id', this.prefix+'title');
		td = tr.insertCell(2);
		td.className = "lightbox_title";
		td.setAttribute('align', 'right');
		td.innerHTML = '<a href="#" onclick="'+this.n+'.onArrowClick(1); return false;"><img src="'+this.imgRightSrc+'" border="0"></a>';

		this.table.style.position = 'absolute';
		this.table.style.top = '-10000px';
		this.table.style.left = '-10000px';
		this.table.style.zIndex = '100';
		this.table.setAttribute('id', this.prefix+'table');
		this.table.setAttribute('border', 0);
		this.table.setAttribute('cellpadding', "0");
		this.table.setAttribute('cellspacing', "0");
		
		document.body.appendChild(this.bg);
		document.body.appendChild(this.loader);
		document.body.appendChild(this.table);
		this.bg.className = "lightbox_bg";
		
		this.img = $(this.prefix+'image');
		
		var that = this;
		
		AddEvent(this.img, 'load', function(){that.onLoadImg(this)});
		AddEvent(this.img, 'click', function(){that.closeLightbox();});
		
		if(n)
			setTimeout(function(){that.show(1);}, 100);
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	// Core code from - quirksmode.org

	this.scroll = function()
	{
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		return yScroll;
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	// Core code from - quirksmode.org
	
	this.pageSize = function()
	{
		var xScroll, yScroll;
		var windowWidth, windowHeight;
	
		if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
	
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	
		return {pageWidth:pageWidth, pageHeight:pageHeight, windowWidth:windowWidth, windowHeight:windowHeight};
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	//Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602	

	this.pause = function(numberMillis)
	{
		var now = new Date();
		var exitTime = now.getTime() + numberMillis;
		while (true)
		{
			now = new Date();
			if (now.getTime() > exitTime)
				return;
		}
	}
}

//-->