//WARSTWA LOADER BY HOUSIK ...
//Uzycie : w kodzie strony pomiedzy <body></body> wpisac :
//
//create('nazwa_warstwy','dokument_do_wczytania',left,top,width,height');
//
//W dokument_do_wczytania w <body> wpisac :
//
//onLoad='if(!document.layer) parent.rewrite('nazwa_warstwy');
//
//dodatkowe funkcje warstwa_nazwa_warstwy.hide() np warstwa_news.hide();

isNN4=(document.layers)?true:false;
isIE5=(document.getElementById)?true:false;
isIE4=(document.all && !document.getElementById)?true:false;
isIE=(isIE4 || isIE5);
var kod;
var ramka;
var timer1=1000;
var timer2=2;
var ladowanie=0
var lejer;

function hide()
{
   this.layer.visibility = (isIE)? "hidden" : "hide";
}
function show()
{
   this.layer.visibility = (isIE)? "visible" : "show";
}
function move(x, y) {
  if (isNN4)
    this.layer.moveTo(x, y);
  else if (isIE) {
    this.layer.left = x;
    this.layer.top  = y;
  }
}

function write(tekst) {
  if(isNN4) {
      this.layer.document.open();
      this.layer.document.write(tekst);
      this.layer.document.close();
    }
    else if(isIE) {
      this.obj.innerHTML = tekst;
  }
}

function bgclr(color)
{
  if (isNN4)
    this.layer.bgColor = color;
  else if (isIE)
    this.layer.backgroundColor = color;
}

function warstwa(id,parent_id)
{
  this.layer=isIE5 ? document.getElementById(id).style : isIE4? document.all[id].style : (parent_id? eval("document." + parent_id + ".document." + id) : document.layers[id]);
  this.obj=isIE5 ? document.getElementById(id) : isIE4? document.all[id] : this.layer;
  this.show=show;
  this.hide=hide;
  this.move=move;
  this.write=write;
  this.bgclr=bgclr;
}

function create(id,src,left,top,width,height)
{
  ramka=id+"ramka";
  lejer="warstwa_"+id;
  if(isNN4)
  {
    document.write("<layer id='"+id+"' left='"+left+"' top='"+top+"' width='"+width+"'></layer>");
  }
  else if(isIE)
  {
    document.write("<iframe id='"+ramka+"' name='"+ramka+"' width='0' height='0' ></iframe>");
    document.write("<div id='"+id+"' style='position:absolute;left:"+left+";top:"+top+";width:"+width+"';height:"+height+"'></div>");
  }
  eval(lejer+"=new warstwa(id)");
  setTimeout("load('"+id+"','"+src+"')",timer1);
  timer2++;
  timer1=timer2*500;
}

function load(id,src)
{
  if(!ladowanie)
  {
    ladowanie=1;
    ramka=id+"ramka";
    lejer="warstwa_"+id;
    if(!isNN4) eval(lejer+".write('<img align=center src=images/loading.gif>')");

    if(isNN4)
      document.layers[id].src = src;
    else if(isIE4)
       eval(ramka+".location = '"+src+"'");
    else if(isIE5)
       document.getElementById(ramka).src = src;
   }
   else
   {
     kod="setTimeout(\"load('"+id+"','"+src+"')\",5000)";
     eval(kod);
   }
   window.status='Ładowanie dokumentu ...';
}
 
function rewrite(id)
{
  if(isIE4)
     eval("document.all['"+id+"'].innerHTML = "+ramka+".document.body.innerHTML");
  else if(isIE5)
     document.getElementById(id).innerHTML = window.frames[ramka].document.body.innerHTML;
  else if(isNN4)
  {
      document.width=760;
      document.height=document.layers[id].pageY + document.layers[id].document.height;
  }
  ladowanie=0;
  window.status='Ładowanie dokumentu zakończone ...';
}



