var ie=document.all;
var ns6=document.getElementById && !document.all;
/*
oElm - obiekt pudelka
strTagName - nazwa znacznika
strClassName - nazwa klasy

przyklad
elems =  getElementsByClassName($$("boxK"),"td","zak_pocz_off");
elems - tablica elementów
*/

function pokaz(id) {
  $$(id).style.display = 'block';
}
function ukryj(id) {
  $$(id).style.display = 'none';
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function $$(id) { 
  if (ie||ns6) {
  	ob=document.all? document.all[id] : document.getElementById? document.getElementById(id) : "";
  }
  return ob; 
}

function potwierdz(tresc, funkcja) {
  var odp = confirm(tresc);
  if(funkcja == '')
    return odp;
  else {
    if(odp) return eval(funkcja);
    else return false;
  }
}

/* -- TOOLTIP --*/
var ttClass = 'tooltip1';

function addwarning(){
	tipobj = $$("theToolTip");
	tipobj.className = ttClass;
	
  var thealinks = getElementsByClassName(document.body, '*', 'tt');
  if (!thealinks) { return; }
  for(var x=0;x!=thealinks.length;x++){
    if (thealinks[x].getAttribute('title'))
      if (thealinks[x].getAttribute('title').length > 0) {
        thealinks[x].setAttribute("tooltiptext",thealinks[x].title);
        thealinks[x].removeAttribute("title");
        thealinks[x].onmouseover=function gomouseover(){ddrivetip(this.getAttribute("tooltiptext"))};
        thealinks[x].onmouseout=function gomouseout(){hideddrivetip();};
      } 
    if (thealinks[x].getAttribute('alt') && !thealinks[x].getAttribute('title'))
      if (thealinks[x].getAttribute('alt').length > 0) {
        thealinks[x].setAttribute("tooltiptext",thealinks[x].getAttribute('alt'));
        thealinks[x].onmouseover=function gomouseover(){ddrivetip(this.getAttribute("tooltiptext"))};
        thealinks[x].onmouseout=function gomouseout(){hideddrivetip();};
      }
  }
}

var enabletip=false;
var offsetfromcursorX=9; //Customize x offset of tooltip
var offsetfromcursorY=9; //Customize y offset of tooltip

var offsetdivfrompointerX=13; //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=13; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="theToolTip"></div>'); //write out tooltip span

function ietruebody(){
  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function ddrivetip(thetext, thewidth, thecolor){
  if (ns6||ie){
    if (typeof thewidth!=="undefined") {tipobj.style.width=thewidth+"px";}
    if (typeof thecolor!=="undefined" && thecolor!=="") {tipobj.style.backgroundColor=thecolor;}
    tipobj.innerHTML=thetext;
    tipobj.clientWidth > 300? tipobj.style.width = "300px": true;
    enabletip=true;
    return false;
  }
}

function positiontip(e){
  if (enabletip){
  var nondefaultpos=false;
  var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
  var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
  //Find out how close the mouse is to the corner of the window
  var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
  var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;
  
  var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
  var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;
  
  var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;
  
  //if the horizontal distance isn't enough to accomodate the width of the context menu
  if (rightedge<tipobj.offsetWidth){
    //move the horizontal position of the menu to the left by it's width
    tipobj.style.left=curX-tipobj.offsetWidth+"px";
    nondefaultpos=true;
  }
  else if (curX<leftedge) {tipobj.style.left="5px";}
  else{
    //position the horizontal position of the menu where the mouse is positioned
    tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
  }

  //same concept with the vertical position
  if (bottomedge<tipobj.offsetHeight){
    tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
    nondefaultpos=true;
  }
  else{
    tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
  }
  tipobj.style.visibility="visible";
}
}

function hideddrivetip(){
  if (ns6||ie){
    enabletip=false;
    tipobj.style.visibility="hidden";
    tipobj.style.left="-1000px";
    tipobj.style.backgroundColor='';
    tipobj.style.width='';
  }
}

function initTooltip() {
  (typeof(positiontip) == 'function') ? document.onmousemove=positiontip : true;
  (typeof(addwarning) == 'function') ? addwarning() : true;
}

document.onmousemove=positiontip;

/* -- POKA¯/UKRYJ --*/
function zamknij(id) { $$(id).style.display = "none"; }
function pokaz(id) { $$(id).style.display = "block"; }


/* -- MAXLENGTH --*/
function maxDlugosc (el, elMax) { return maxLength(el, elMax); }
function maxLength(el, elMax) {
  var elLength = el.value.length;
  var charsLeft = elMax-elLength;
  if (charsLeft < 0) charsLeft = 0;
  var counterTxt = '<span>'+charsLeft+'</span>/'+elMax;  
  if (elLength > elMax) el.value = el.value.substring(0,elMax);
  
  if (el.nextSibling && el.nextSibling.wlasciwosc =='licznik') {// sprawdzam czy istnieje licznik
    var counter = el.nextSibling;
    counter.innerHTML = counterTxt;
  } else {// dodaje licznik za textarea
    var counter = document.createElement('div');
    counter.className = 'kol_sza m';
    counter.wlasciwosc = 'licznik';
    counter.innerHTML = counterTxt;
    el.parentNode.insertBefore(counter,el.nextSibling);
  }
}

function form2array(form) {
  var elementy = form.getElementsByTagName('input');
  
  var arrNames = new Array();
  var arrValues = new Array();
  
  for(var i = 0; i < elementy.length; i++) {
    var elem = elementy[i];
    switch(elem.type) {
      case 'hidden':
      case 'text':
        if(elem.name != null && elem.value != null){
          arrNames[arrNames.length] = elem.name;
          arrValues[arrValues.length] = elem.value;
        }
        break;
      case 'radio':
        if(elem.checked) {
          arrNames[arrNames.length] = elem.name;
          arrValues[arrValues.length] = elem.value;
        }
        break;
      case 'checkbox':
        if(elem.checked) {
          arrNames[arrNames.length] = elem.name;
          arrValues[arrValues.length] = elem.value;
        }        
        break;
    }
  }
  
  var elementy2 = form.getElementsByTagName('textarea');
  for(var k = 0; k < elementy2.length; k++) {
    var elem = elementy2[k];
    if(elem.name != null && elem.value != null){
        arrNames[arrNames.length] = elem.name;
        arrValues[arrValues.length] = elem.value;
    }
  }
  
  var elementy3 = form.getElementsByTagName('select');
  for(var l = 0; l < elementy3.length; l++) {
    var elem = elementy3[l];
    if(elem.name != null && elem.options[elem.selectedIndex].value != null){
        arrNames[arrNames.length] = elem.name;
        arrValues[arrValues.length] = elem[elem.selectedIndex].value;
    }
  }
    
  var arr = new Array();
  
  for(var j=0; j<arrNames.length; j++){
    arr[arrNames[j]] = arrValues[j];
  }
  
  return arr;  
}

/* GENERUJE LANCUCH GET Z FORMULARZA*/
function form2get(form) {
  var elementy = form.getElementsByTagName('input');
  
  var arrNames = new Array();
  var arrValues = new Array();
  
  for(var i = 0; i < elementy.length; i++) {
    var elem = elementy[i];
    switch(elem.type) {
      case 'hidden':
      case 'text':
        if(elem.name != null && elem.value != null){
          arrNames[arrNames.length] = elem.name;
          arrValues[arrValues.length] = elem.value;
        }
        break;
      case 'radio':
        if(elem.checked) {
          arrNames[arrNames.length] = elem.name;
          arrValues[arrValues.length] = elem.value;
        }
        break;
      case 'checkbox':
        if(elem.checked) {
          arrNames[arrNames.length] = elem.name;
          arrValues[arrValues.length] = elem.value;
        }        
        break;
    }
  }
  
  var elementy2 = form.getElementsByTagName('textarea');
  for(var k = 0; k < elementy2.length; k++) {
    var elem = elementy2[k];
    if(elem.name != null && elem.value != null){
        arrNames[arrNames.length] = elem.name;
        arrValues[arrValues.length] = elem.value;
    }
  }
  
  var elementy3 = form.getElementsByTagName('select');
  for(var l = 0; l < elementy3.length; l++) {
    var elem = elementy3[l];
    if(elem.name != null && elem.options[elem.selectedIndex].value != null){
        arrNames[arrNames.length] = elem.name;
        arrValues[arrValues.length] = elem[elem.selectedIndex].value;
    }
  }
    
  var get = "";
  
  for(var j=0; j<arrNames.length; j++){
    get = get+arrNames[j]+'='+arrValues[j]+'&';
  }
  
  return get;
}

/* KONWERSJA GET NA TABLICE*/
function get2array(get) {
  var arr1=get.split("&");
  var arr2 = new Array();
  
  for(var k = 0; k < arr1.length; k++) {
    var elem = arr1[k];
    elem2 = elem.split("=");
    arr2[elem2[0]] = elem2[1];
  }
  
  return arr2;
}

/* KONWERSJA TABLICY NA GET*/
function array2get(array) {
  var arr = new String();
  
  for(var x in array) {
    arr = arr + x + '='+array[x]+'&';
  }
  
  return arr;
}

/* NEW WINDOW */
function newWindow(tUrl,name,a,h){
  /* url - adres , name - nazwa nowego okna , w - szerokosc , h - wysokosc */
    okienko = window.open(tUrl,name,'resizable,height='+h+',width='+a+',left=40,top=40,scrollbars=yes');
}
/* NEW WINDOW */

var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

__startStack=function() { };  // A stack of functions to run onload/domready

registerOnLoad = function(func) {
   var orgOnLoad = __startStack;
   __startStack = function () {
      orgOnLoad();
      func();
      return;
   }
}

var __ranOnload=false; // Flag to determine if we've ran the starting stack already.

if (document.addEventListener) {
  // Mozilla actually has a DOM READY event.
   document.addEventListener("DOMContentLoaded", function(){if (!__ranOnload) {__ranOnload=true; __startStack();}}, false);
}  else if (document.all && !window.opera) {
  // This is the IE style which exploits a property of the (standards defined) defer attribute
  document.write("<scr" + "ipt id='DOMReady' defer=true " + "src=//:><\/scr" + "ipt>");
  document.getElementById("DOMReady").onreadystatechange=function(){
    if (this.readyState=="complete"&&(!__ranOnload)){
      __ranOnload=true;
      __startStack();
    }
  }
}

var orgOnLoad=window.onload;
window.onload=function() {
   if (typeof(orgOnLoad)=='function') {
      orgOnLoad();
   }
   if (!__ranOnload) {
     __ranOnload=true;
     __startStack();
   }
}

/* LIGHTBOX START
	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com
	
	Table of Contents
	-----------------
	Configuration
	
	Functions
	- getPageScroll()
	- getPageSize()
	- pause()
	- getKey()
	- listenKey()
	- showLightbox()
	- hideLightbox()
	- initLightbox()
	- addLoadEvent()
	
	Function Calls
	- addLoadEvent(initLightbox)
*/

//
// Configuration
//

// If you would like to use a custom loading image or close button reference them in the next two lines.
var loadingImage = 'http://z.nf.pl/i2/lightbox/loading.gif';		
var closeButton = 'http://z.nf.pl/i2/lightbox/close.gif';		

//
// getPageScroll()
// Returns array with x,y page scroll values.
//
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
//
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;
}


//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//

function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){ hideLightbox(); }
}


//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	
//
// showLightbox()
// Preloads images. Pleaces new image in lightbox then centers and displays.
//
function showLightbox(objLink) {
	if($$("oknoPanelOdtwrzacz"))
	   $$("oknoPanelOdtwrzacz").style.display = 'none';
	// prep objects
	var objOverlay = $$('overlay');
	var objLightbox = $$('lightbox');
	var objCaption = $$('lightboxCaption');
	var objImage = $$('lightboxImage');
	var objLoadingImage = $$('loadingImage');
	var objLightboxDetails = $$('lightboxDetails');

	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// center loadingImage if it exists
	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}

	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';

	// preload image
	imgPreload = new Image();

	imgPreload.onload=function(){
		objImage.src = objLink.href;

		// center lightbox and make sure that the top and left values are not negative
		// and the image placed outside the viewport
		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);
		
		objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";


		objLightboxDetails.style.width = imgPreload.width + 'px';
		
		if(objLink.getAttribute('title')){
			objCaption.style.display = 'block';
			//objCaption.style.width = imgPreload.width + 'px';
			objCaption.innerHTML = objLink.getAttribute('title');
		} else {
			objCaption.style.display = 'none';
		}
		
		// A small pause between the image loading and displaying is required with IE,
		// this prevents the previous image displaying for a short burst causing flicker.
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			pause(250);
		} 

		if (objLoadingImage) {	objLoadingImage.style.display = 'none'; }

		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }

		objLightbox.style.display = 'block';

		// After image is loaded, update the overlay height as the new image might have
		// increased the overall page height.
		arrayPageSize = getPageSize();
		objOverlay.style.height = (arrayPageSize[1] + 'px');
		
		// Check for 'x' keypress
		listenKey();

		return false;
	}
	imgPreload.src = objLink.href;
}

//
// hideLightbox()
//
function hideLightbox() {

  if($$("oknoPanelOdtwrzacz"))
	   $$("oknoPanelOdtwrzacz").style.display = 'block';
	// get objects
	objOverlay = $$('overlay');
	objLightbox = $$('lightbox');

	// hide lightbox and overlay
	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';

	// make select boxes visible
	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}

	// disable keypress listener
	document.onkeypress = '';
}

//
// initLightbox()
// Function runs on window load, going through link tags looking for rel="lightbox".
// These links receive onclick events that enable the lightbox display for their targets.
// The function also inserts html markup at the top of the page which will be used as a
// container for the overlay pattern and the inline image.
//
function initLightbox() {

	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("a");

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox")){
			anchor.onclick = function () {showLightbox(this); return false;}
		}
	}

	// the rest of this code inserts html at the top of the page that looks like this:
	//
	// <div id="overlay">
	//		<a href="#" onclick="hideLightbox(); return false;"><img id="loadingImage" /></a>
	//	</div>
	// <div id="lightbox">
	//		<a href="#" onclick="hideLightbox(); return false;" title="Click anywhere to close image">
	//			<img id="closeButton" />		
	//			<img id="lightboxImage" />
	//		</a>
	//		<div id="lightboxDetails">
	//			<div id="lightboxCaption"></div>
	//			<div id="keyboardMsg"></div>
	//		</div>
	// </div>
	
	var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {hideLightbox(); return false;}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// preload and create loader image
	var imgPreloader = new Image();
	
	// if loader image found, create link to hide lightbox and create loadingimage
	imgPreloader.onload=function(){

		var objLoadingImageLink = document.createElement("a");
		objLoadingImageLink.setAttribute('href','#');
		objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
		objOverlay.appendChild(objLoadingImageLink);
		
		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objLoadingImageLink.appendChild(objLoadingImage);

		imgPreloader.onload=function(){};	//	clear onLoad, as IE will flip out w/animated gifs

		return false;
	}

	imgPreloader.src = loadingImage;

	// create lightbox div, same note about styles as above
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';	
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);
	
	// create link
	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','Kliknij aby zamkn±æ');
	objLink.onclick = function () {hideLightbox(); return false;}
	objLightbox.appendChild(objLink);

	// preload and create close button image
	var imgPreloadCloseButton = new Image();

	// if close button image found, 
	imgPreloadCloseButton.onload=function(){

		var objCloseButton = document.createElement("img");
		objCloseButton.src = closeButton;
		objCloseButton.setAttribute('id','closeButton');
		objCloseButton.style.position = 'absolute';
		objCloseButton.style.zIndex = '200';
		objLink.appendChild(objCloseButton);

		return false;
	}

	imgPreloadCloseButton.src = closeButton;

	// create image
	var objImage = document.createElement("img");
	objImage.setAttribute('id','lightboxImage');
	objLink.appendChild(objImage);
	
	// create details div, a container for the caption and keyboard message
	var objLightboxDetails = document.createElement("div");
	objLightboxDetails.setAttribute('id','lightboxDetails');
	objLightbox.appendChild(objLightboxDetails);

	// create caption
	var objCaption = document.createElement("div");
	objCaption.setAttribute('id','lightboxCaption');
	objCaption.style.display = 'none';
	objLightboxDetails.appendChild(objCaption);

	// create keyboard message
	var objKeyboardMsg = document.createElement("div");
	objKeyboardMsg.setAttribute('id','keyboardMsg');
	objKeyboardMsg.innerHTML = 'kliknij <a href="#" onclick="hideLightbox(); return false;"><kbd>x</kbd></a> aby zamkn±æ';
	objLightboxDetails.appendChild(objKeyboardMsg);
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
//
function addLoadEvent(func) {	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
  		oldonload();
  		func();
		}
	}
}
addLoadEvent(initLightbox);	// run initLightbox onLoad
/* LIGHTBOX END */

/* RANKING */
function pictPreload(num,pSrc) {
	this[num] = new Image;
	this.src = pSrc;
}
s1 = new pictPreload(1,"http://z.nf.pl/i2/ranking/star_on.gif");
s2 = new pictPreload(2,"http://z.nf.pl/i2/ranking/star_off.gif");
s3 = new pictPreload(3,"http://z.nf.pl/i2/ranking/star_half.gif");

function pozycja(e) {
	$$("ind").style.marginTop = e.clientY-30;
	$$("ind").style.marginLeft = e.clientX+30;
}

function podmien(nazwa,id,num) {
	for(i=1; i<=5; i++) {
		if(i <= Math.floor(num)) {
			$$(nazwa+id+"_"+i).setAttribute("src","http://z.nf.pl/i2/ranking/"+nazwa+"_on.gif");
		} else {
			j = i-1;
			if(j < num) {
				$$(nazwa+id+"_"+i).setAttribute("src","http://z.nf.pl/i2/ranking/"+nazwa+"_half.gif");
			} else {
				$$(nazwa+id+"_"+i).setAttribute("src","http://z.nf.pl/i2/ranking/"+nazwa+"_off.gif");
			}
		}
	}
}

function openPopupToPrint()
{
	var location = window.location.pathname+'?doDruku=on';
	var popUp = window.open(
		location,
		'Druk',
		'menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=no,status=no,width=800,height=600'
	).focus();
	return false;
}

function getMenuElementTree(id)
{
	var div_id = $$('submenu_'+id);
	if(div_id.style.display == 'none' || div_id.style.display == '')
	{
		div_id.style.display = 'block';
	}else{
		div_id.style.display = 'none';
	}
}

