// podmiana i preload grafik
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// galeria
function galeria(src, w, h) {
	noweOkienko = null;
	if (window.screen) {
		aw = screen.availWidth;
		ah = screen.availHeight;
	} else {
		aw = 640;
		ah = 450;
	}
	if (noweOkienko==null || noweOkienko.closed) {
		ustawienia=
		"left=" + (aw-w)/2 + ","
		+"top=" + (ah-h)/2 + ","
		+"screenX=" + (aw-w)/2 + ","
		+"screenY=" + (ah-h)/2 + ","
		+"width=" + w + ","
		+"height=" + h + ","
		+"innerWidth=" + w + ","
		+"innerHeight=" + h + ","
		+"toolbar=no,"
		+"location=no,"
		+"directories=no,"
		+"status=yes,"
		+"menubar=no,"
		+"scrollbars=no,"
		+"resizable=no"
		noweOkienko = window.open("", 'obrazek', ustawienia);
	}
	noweOkienko.document.open();
	noweOkienko.document.clear();
	noweOkienko.document.write(
	"<html><head><title>ZDJÊCIA</title>\n"
	+"</head><BODY bgcolor=#FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 link=#000000 vlink=#000000 alink=#000000>\n"
	+"<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0' align='center'><tr><td align='center'>"
	+"<a href='javascript:window.close()'><img src="+ src +"  border=1></a>"
	+"</td></tr></table>\n"
	+"</body></html>"
	);
	noweOkienko.document.close();
	noweOkienko.focus();
}

// drukuj
function drukuj(src,base) {
	drukujWH(src,543,400,base);
}

function drukujWH(src,w,h,base) {
	noweOkienko = null;
	if (window.screen) {
		aw = screen.availWidth;
		ah = screen.availHeight;
	} else {
		aw = 640;
		ah = 450;
	}
	if (noweOkienko==null || noweOkienko.closed) {
		ustawienia=
		"left=" + (aw-w)/2 + ","
		+"top=" + (ah-h)/2 + ","
		+"screenX=" + (aw-w)/2 + ","
		+"screenY=" + (ah-h)/2 + ","
		+"width=" + w + ","
		+"height=" + h + ","
		+"innerWidth=" + w + ","
		+"innerHeight=" + h + ","
		+"toolbar=no,"
		+"location=no,"
		+"directories=no,"
		+"status=yes,"
		+"menubar=no,"
		+"scrollbars=yes,"
		+"resizable=no"
		if (!base) {
			var url = base_href+""+src; 
		} else {
			var url = src; 
		}
		
		noweOkienko = window.open(url, 'plik', ustawienia);
	}

	if (noweOkienko!=null) {
		noweOkienko.focus();
	}
}

/*
* 	Class CPopup - Bardzo prosta klasa do obslugi okienka Popup
*
*	Autor Jacek N. 2006
*/


/*
* 	function CPopup
*
*	domyslny konstruktor
*/
function CPopup()
{
	// inicjacja zmiennych
	this.init();
}

CPopup.Screen = function()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		return [window.innerWidth, window.innerHeight];
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return [document.documentElement.clientWidth, document.documentElement.clientHeight];
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return [document.body.clientWidth, document.body.clientHeight];
	}
}

/*
* 	function prepareBackground
*
*	przygotowanie tla
*/
CPopup.prototype.setHandle = function(handle)
{
	this.handle = document.getElementById(handle);
	
	if(!this.handle)
		this.handle = document.body;
}

/*
* 	function prepareBackground
*
*	przygotowanie tla
*/
CPopup.prototype.prepareBackground = function()
{
	var screen = CPopup.Screen();
	var overlayHeight = document.body.offsetHeight;
	
	if(overlayHeight < screen[1])
	{
		overlayHeight = screen[1];
	}
	
	this.background = document.createElement('div');
	
	this.background.style.display = '';
	this.background.style.position = 'absolute';
	this.background.style.left = '0px';
	this.background.style.top = '0px';
	this.background.style.height = overlayHeight + 'px';
	this.background.className = 'PopupOverlay';
	
	this.handle.appendChild(this.background);
}

/*
* 	function prepareCanvas
*
*	przygotowanie plotna
*/
CPopup.prototype.prepareCanvas = function()
{
	this.canvasHandle = document.createElement('div');
	this.canvasHandle.style.display = '';
	this.canvasHandle.style.position = 'absolute';
	this.canvasHandle.style.left = '0px';
	this.canvasHandle.style.top = '0px';
	this.canvasHandle.style.width = '100%';
	this.canvasHandle.style.textAlign = 'center';
	
	// stworzenie diva w ktorym bedzie zawartosc popup'a
	this.canvas = document.createElement('div');
	this.canvas.style.display = '';
	this.canvas.style.position = 'relative';
	this.canvas.style.left = this.x + 'px';
	this.canvas.style.top = this.y + 'px';
	this.canvas.style.width = this.width;
	this.canvas.style.height = this.height;
	this.canvas.style.margin = 'auto';
	this.canvas.style.zIndex = 2000;
	this.canvas.style.textAlign = 'justify';
	
	this.canvas.className = 'Popup';
	this.canvas.innerHTML = this.content;
	
	this.canvasHandle.appendChild(this.canvas);
	this.handle.appendChild(this.canvasHandle);
}

/*
* 	function init
*
*	inicjacja zmiennych
*/
CPopup.prototype.init = function()
{
	this.x = 0;
	this.y = 0;
	this.width = '200px';
	this.height = '150px';
}

/*
* 	function setPosition
*
*	ustawienie pozycji popup'a
*/
CPopup.prototype.setPosition = function(x, y)
{
	this.x = x;
	this.y = y;
}

/*
* 	function setSize
*
*	ustalenie rozmiaru popup'a
*/
CPopup.prototype.setSize = function(width, height)
{
	this.width = width;
	this.height = height;
}

/*
* 	function setContent
*
*	ustawienie zawartosci popup'a
*/
CPopup.prototype.setContent = function(content)
{
	this.content = content;
}

/*
* 	function hide
*
*	ukrycie popup'a
*/
CPopup.prototype.hide = function()
{
	this.canvas.style.display = 'none';
	this.background.style.display = 'none';
}

/*
* 	function redirect
*
*	przekierowanie
*/
CPopup.prototype.redirect = function(link)
{
	location.href = link;
}

/*
* 	function show
*
*	pokazanie popup'a
*/
CPopup.prototype.show = function()
{
	// przygotowanie tla
	this.prepareBackground();
	
	// przygotowanie plotna na ktorym bedzie sie wyswietlac zawartosc
	this.prepareCanvas();
}