var nakShowed = false;
  var divOver, divPod;
  var frameWidth = 460;
  var frameHeight = 390;
  function Xclose() {
 	Element = document.getElementById('ekran');
 	Element.parentNode.removeChild(Element);
 	Element = document.getElementById('nakladka');
 	Element.parentNode.removeChild(Element);
 	Element = document.getElementById('podkladka');
 	Element.parentNode.removeChild(Element);	
  }
  function bodyResize() {
    if (nakShowed) {
      var ps = getPageSize();
      divOver.style.width = ps[0]+"px";
      divOver.style.height = ps[1]+"px";
      divPod.style.left = Math.round((ps[0]-frameWidth)/2)+"px";
      var yPos = ps[4]+Math.round((ps[3]-frameHeight)/2);
      yPos = (yPos<150) ? 150 : yPos; 
      divPod.style.top = yPos+"px";
    }
  }
  function initialize(kod) {
  	var xBody = document.getElementsByTagName("body").item(0);
  	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','nakladka');
	xBody.appendChild(objOverlay);
	divOver = document.getElementById('nakladka');
	divOver.style.background = "black";
	divOver.style.opacity = "0.5";
	divOver.style.filter = "alpha(opacity=50)";
	divOver.style.position = "absolute";
	divOver.style.left = "0px";
	divOver.style.top = "0px";
	divOver.style.zIndex = "100";
		
	var objPod = document.createElement("div");
	objPod.setAttribute('id','podkladka');
	xBody.appendChild(objPod);
	divPod = document.getElementById('podkladka');
	divPod.style.background = "white";
	divPod.style.position = "absolute";
	divPod.style.textAlign = "center";
	divPod.style.width = frameWidth+"px";
	divPod.style.height = frameHeight+"px";
	divPod.style.zIndex = "101"
	
	var objEkr = document.createElement("iframe");
	objEkr.setAttribute('id','ekran');
	objEkr.setAttribute('frameborder','0');
	objEkr.setAttribute('scrolling','no');
	objPod.appendChild(objEkr);
	divEkr = document.getElementById('ekran');
	divEkr.src = "film.php?film="+kod;
	divEkr.style.position = "absolute";
	divEkr.style.top = "30px";
	divEkr.style.left = "10px";
	divEkr.style.width = (frameWidth-20)+"px";
	divEkr.style.height = (frameHeight-40)+"px";
	
	var objZam = document.createElement("a");
	objZam.setAttribute('id','zamknij');
	objZam.setAttribute('href','javascript:Xclose()');
	objPod.appendChild(objZam);
	butZam = document.getElementById('zamknij');
	butZam.style.color = "#666666";
        butZam.style.fontWeight = "bold";
        butZam.style.textDecoration = "none";
        butZam.style.verticalAlign = "bottom";
        butZam.style.top = "200px";
	butZam.innerHTML = 'zamknij';
	
	nakShowed = true;
	bodyResize();

  }
  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){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}	
	var windowWidth, windowHeight, scrOfY;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
		scrOfY = window.pageYOffset;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
		scrOfY = document.documentElement.scrollTop;
	} else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
		scrOfY = document.body.scrollTop;		
	}	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,scrOfY) 
	return arrayPageSize;
}
