function getPageScroll(){

	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;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else 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;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function setWidth(element,w) {
	   	element = $(element);
    		element.style.width = w +"px";
			}
function setHeight(element,h) {
   		element = $(element);
    		element.style.height = h +"px";
			}
function setInnerHTML(element,content) {
			element = $(element);
			element.innerHTML = content;
			}
function setTop(element,t) {
	   	element = $(element);
	    	element.style.top = t +"px";
			}
function setLeft(element,t) {
	   	element = $(element);
	    	element.style.left = t +"px";
			}

	
function start(szer) {	

		//hideSelectBoxes();

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		setHeight('tlo_block', arrayPageSize[1]);
		//new Effect.Appear('tlo_block', { duration: 0.2, from: 0.0, to: 0.8 });

	  	// calculate top offset for the lightbox and display 
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);
		
		var ile = (arrayPageSize[0]-szer)/2-12
		
		setLeft('galeria', ile);
		setTop('galeria', lightboxTop);
		
	}
	
function Galeria(Nazwa,tresc,szer,tytul) {
objFirma = document.getElementById(Nazwa);
objFirma.style.display="block";
objBlock = document.getElementById('tlo_block');
objBlock.style.display="block";

start(szer);


text='<table cellspacing=2 cellpadding=3 cellpadding=2 style="background-color: #ffffff;">';
text+='<tr><td style="font-size: 12px; background-color: #ffffff; font-size: 11px; text-align:left;"><img src="'+tresc+'" alt=""></td></tr>';

text+='<tr><td>';
text+='<img src="public/images/zamknij.gif" alt="" onclick="javascript:Galeria_close();"; style="cursor: pointer;" align="right">';
text+='<b>'+tytul+'</b>';
text+='</td></tr>';
text+='</table>';
document.getElementById(Nazwa).innerHTML=text;
}

function Galeria_close() {
 objFirma = document.getElementById('galeria');
 objFirma.style.display="none";
 objBlock = document.getElementById('tlo_block');
 objBlock.style.display="none";
}
function $( ide ){
	return document.getElementById( ide );
}