function nakladkaLoaderGraphic() {
   pokaz_on('nakladkaLoader');
   pokaz_off('wnetrzeNakladki');
}
function nakladkaInit() {
   pokazEkran();
   pokaz_on('extraLayer1');pokaz_on('extraLayer2');
   nakladkaLoaderGraphic();
}
function pokazEkran() {
   x = wysOkna();
   z = getVPos();
   w = getElementTop('dolStrony');
   w2 = getElementTop('dolEkranu');
   if (w2>w)
      w=w2;
   div = document.getElementById("extraLayer1");
   if (x>w)
      div.style.height = (x+40)+"px";
   else 
      div.style.height = (w+40)+"px";
   ustawTop('extraLayer2',z);
   
   }
var nakladkaImages = null;
var nakladkaImagesLoaded = true;
function nakladkaWaitForImages(krok) {
   var x = nakladkaImages;
   var loaded = true;
   for(var i=0;i<x.length;i++) {
      if (!x[i].complete)
         loaded = false;
   }
   if (!loaded && krok<20) {
      krok++;
      setTimeout('nakladkaWaitForImages('+krok+')', 250); 
   }
   else {
      //window.alert('img loaded');
      nakladkaImagesLoaded = true;
      nakladkaComplete();
   }
}
function nakladkaCeil(x) {
   if (x<0)
      return Math.floor(x);
   else
      return Math.ceil(x);
}
function nakladkaResize(w,h) {
   var iloscKrokow = Number(5);
   var div = getByID('nakladka');
   var height = Number(nakladkaStripPX(div.style.height));
   var width = Number(nakladkaStripPX(div.style.width));
   //window.alert(height+' '+width+' '+h+' ' +w);
   if (height==h && width==w) {
      //window.alert('koniec:'+height+' '+width+' '+h+' ' +w);
      nakladkaResized = true;
      nakladkaComplete();
      return;
   }
   var rozh = ((h-height)/iloscKrokow);
   var rozw = ((w-width)/iloscKrokow);
   rozh = nakladkaCeil(rozh);
   rozw = nakladkaCeil(rozw);
   height = height+rozh;
   width = width+rozw;
   //window.alert(height+' '+width+' '+rozh+' ' +rozw);
   div.style.height = height+'px';
   div.style.width = width+'px';
   //window.alert(div.style.height+' '+div.style.width);
   setTimeout('nakladkaResize('+w+','+h+')', 50);
}
function nakladkaStripPX(str) {
	return str.substr(0,str.length-2);
}
var nakladkaResized = true;
function nakladkaShow(doc) {
   var div = getByID('wnetrzeNakladki');
   div.innerHTML = doc;
   //zmieniamy rozmiar nakladki
   var cont = getByID('dynamicContainer');
   nakladkaImagesLoaded = false;
   nakladkaResized = false;
   if (cont!=null) {
      //odczytujemy rozmiar wnetrza
      //window.alert(cont.style.width+' ' +cont.style.height);
      nakladkaResize(nakladkaStripPX(cont.style.width),nakladkaStripPX(cont.style.height));
   }
   else {
      nakladkaResized = true;
   }
   var x = div.getElementsByTagName('img');
   if (x.length>0) { 
      nakladkaImages = x;
      nakladkaWaitForImages(0);
   }
   else {
      nakladkaImagesLoaded = true;
      nakladkaComplete();
   }
}
function nakladkaComplete() {
   if (!nakladkaResized || !nakladkaImagesLoaded)
      return;
   pokaz_off('nakladkaLoader');
   pokaz_on('wnetrzeNakladki');
   //var div = getByID('wnetrzeNakladki');
   //var div = getByID('nakladka');
   //window.alert(div.innerHTML);
   pokazEkran();
}
var x = wysOkna();
var y = szerOkna();

if (navigator.userAgent.indexOf("Firefox")!=-1) {
   var hNakl = x+'px';
   document.write('<div id="extraLayer1" style="position:absolute;top:0px;left:0px;z-index:2;display:none;width:'+ y +'px;height:'+ x +'px;background-color: rgb(0,0,0); -moz-opacity:.60;opacity:.60;">');
   }
else { 
   var hNakl = '100%';
   document.write('<div id="extraLayer1" style="position:absolute;top:0px;left:0px;z-index:2;display:none;width:'+ y +'px;height:'+ x +'px;background-color: rgb(0,0,0); filter: alpha(opacity=60);">');
   }
document.write('</div>');
document.write('<div id="extraLayer2" style="position:absolute;top:0px;left:0px;z-index:3;display:none;width:'+ y +'px;height:'+ hNakl +';">');
document.write('<center><table width=100% height='+hNakl+'><tr><td width=100% height=100% valign=center><center>');
document.write('<div id="nakladka" style="width:220px;height:220px;margin-right: auto;margin-left: auto;background:white;border:2px solid #e9e4c8">');
document.write('<div id="nakladkaLoader" style="display:none;width:100px;height:100px;background:white;margin:auto auto auto auto;"><center><br /><br /><br /><img src="imgMain/loader.gif"></center></div>');
document.write('<div id="wnetrzeNakladki" style="display:none;margin-right:auto;margin-left:auto;"></div>');
document.write('</div>');
document.write('<br><div style="width:80px;color:white;"><a href="Javascript:pokaz_off(\'extraLayer1\');pokaz_off(\'extraLayer2\');" style="color:white">zamknij</a></div>');
document.write('<BR><BR><div style="clear:both" id="dolEkranu"></div>');
document.write('</center></td></tr></table><center>');
document.write('</div>');

