  // Zmienna przechowujaca identyfikatory uruchomionych przerwan
  var timerStore = Array;
  // Zmienna przechowujaca obiekty, ktore maja byc wywolane w poszczegolnych przerwaniach
  var timerObjStore = Array();
  // Zmienna przechowujaca nazwy metod, ktore maja byc uruchomione dla poszczegolnych obiektow
  var timerMethodStore = Array();
  // Zmienna przechowujaca argumenty, z ktorymi maja byc wywolane metody
  var timerArgsStore = Array();
  // Zmienna przechowujaca identyfikator aktualnie wolnego przerwania
  var timerEventId = 0;

  var empty_image = new Image();
 // empty_image.src = "img/1/empty.gif";

  // pokazywanie / chowanie warstw

  function show(id) {
    if (isNS6) {
	document.getElementById(id).style.display='block';
    }
    else if (isNS4)
      document.layers[id].display = "block";
    else
      if (isIE) 
        document.all[id].style.display = "block";
  }

  function hide(id) {
    if (isNS6) {
      document.getElementById(id).style.display='none';
    }
    else if (isNS4)
      document.layers[id].display = "none";
    else 
      if (isIE) 
        document.all[id].style.display = "none";
  }

  // Ladowanie roznych rzeczy do warst

  function divPutText(div_name, text_to_put) {
    if (isNS6) {
	document.getElementById(div_name).innerHTML=text_to_put;
    }
    else if (isNS4) {
      document.layers[div_name].document.open();
      document.layers[div_name].document.write(text_to_put);
      document.layers[div_name].document.close()
    } else 
      if (isIE) {
        document.all[div_name].innerHTML = text_to_put;
	  }
  }

  // Tworzenie warstw

  function createLayer(id,left,top,width,height,content,bgColor,display,zIndex) {
    if (isNS4) {
      document.layers[id] = new Layer(width)
      var lyr = document.layers[id]
      lyr.left = left
      lyr.top = top
      if (height!=null) lyr.clip.height = height
      if (bgColor!=null) lyr.bgColor = bgColor
      if (zIndex!=null) lyr.zIndex = zIndex
      lyr.display = (display=='none')? 'none' : 'block'
      if (content) {
        lyr.document.open()
        lyr.document.write(content)
        lyr.document.close()
      }
    }
    else if ((isNS6)||(isIE)) {
      var str = '\n<DIV id='+id+' style="position:absolute; left:'+left+'; top:'+top+'; width:'+width
      if (height!=null) {
        str += '; height:'+height
        str += '; clip:rect(0,'+width+','+height+',0)'
      }
      if (bgColor!=null) str += '; background-color:'+bgColor		
      if (zIndex!=null) str += '; z-index:'+zIndex
      if (display) str += '; display:'+display
      str += ';">'+((content)?content:'')+'</DIV>'
      
      if(isNS6)
        document.getElementsByTagName("body")[0].innerHTML+=str;
      else
        document.body.insertAdjacentHTML("BeforeEnd",str);
	
    }
  }

  function isinherit(id) {
    if (isNS6) {
        if (document.getElementById(id).style.display == "block") {
          return 1;
        } else {
          return 0;
        }
    }
  
    else if (isNS4) {
      if (document.layers[id].display == "block") {
        return 1;
      } else {
        return 0;
      }
    } else {
      if (isIE) {
        if (document.all[id].style.display == "block") {
          return 1;
        } else {
          return 0;
        }
      }
    }

    return 0;
  }
  
  // Wyszukiwanie warstw

  function getLayer(layer_name) {
    if (isNS6) {
        return document.getElementById(layer_name);
    }
    else if (isNS4) {
      return document.layers[layer_name];
    } else 
      if (isIE) 
        return document.all[layer_name];

    return null;
  }
  
  function getLeft(id) {
    if (isNS6) {
      return parseInt(document.getElementById(id).style.left);
    }
    else if (isNS4) {
      return document.layers[id].left;
    } else 
      if (isIE) 
        return Number(document.all[id].style.left.substring(0, document.all[id].style.left.indexOf("p")));

    return 0;
  }

  function getTop(id) {
    if (isNS6) {
      return parseInt(document.getElementById(id).style.top);
    }
    else if (isNS4) {
      return document.layers[id].top;
    } else 
      if (isIE) 
        return Number(document.all[id].style.top.substring(0, document.all[id].style.top.indexOf("p")));

    return 0;
  }

  function getWidth(id) {
    if (isNS6) {
      return parseInt(document.getElementById(id).style.width);
    }
    else if (isNS4) {
      return 160 /*lay.width*/;
    } else 
      if (isIE) 
        return Number(document.all[id].style.width.substring(0, document.all[id].style.width.indexOf("p")));

    return 0;
  }

  function getHeight(id) {
    if (isNS6) {
      return parseInt(document.getElementById(id).style.height);
    }
    else if (isNS4) {
      return 110 /*lay.height*/;
    } else 
      if (isIE) 
        return Number(document.all[id].style.height.substring(0, document.all[id].style.height.indexOf("p")));

    return 0;
  }

  /* Obsluga kursora myszy */

  function getMouseX() {
    if (isNS6) {
      return event_x; //event.clientX;
    }
    else if (isNS4) {
      return 100;
    } else {
      return document.body.scrollLeft + event.clientX;
    }
  }

  function getMouseY() {
    if (isNS6) {
      return event_y; //event.clientY;
    }
    else 
    if (isNS4) {
      return 100;
    } else {
      return document.body.scrollTop + event.clientY;
    }
  }

  /* obsluga menu */

  // Tabica wyswietlonych warstw
  showed = new Array();
  // Tablica pokazujaca warswe, otworzona przez warstwe maciezysta
  // uzywana do szybkiego chowania warstw w sytuacji, gdy trzeba otworzyc nowa
  // - przejscie od jednej opcji menu do drugiej
  opened_by = new Array();
  // Tablica przechowuje informacje, ktora z warstw sa przyblokowene przed schowaniem
  // z powodu tego, ze otworzyly nowe submenu - zapisy kogo - kto blokuje
  blocked_by = new Array();
  // Taka sama jak wyzej, tylko odwrotne zapisy (kto - kogo blokuje)
  blocking = new Array();
  // Tablica przechowuje identyfikatory tych warst, ktore mozna juz schowac, 
  // jednak chowanie jest przyblokowane z powodu utworzenia submenu
  ready_to_hide = new Array();
  // Identyfikator ostatnio otwartej pozycji w menu
//  current_menu = null;

  function getMenuPositionX (a_name) {
    var x=100;
    if (isNS4) {
      for (var i=0; i<document.anchors.length; i++) {
        if (document.anchors[i].name==a_name) { 
          x=document.anchors[i].x;
          break; 
        }
      }
      x+=167;
    } else if (isIE) {
      var el=document.all[a_name];
      var ol=el.offsetLeft;
      while ((el=el.offsetParent) != null) { 
        ol += el.offsetLeft; 
      }
      x=ol+167;
    }
    else if (isNS6) {
      var el=document.getElementById(a_name);
      var ol=el.offsetLeft;
      while ((el=el.offsetParent) != null) { 
        ol += el.offsetLeft; 
      }
      x=ol+167;
    }
//alert(ol);
//alert(x);
    return x;
  } /*getMenuPositionX*/

  function getMenuPositionY (a_name) {
    var y=50;
    if (isNS4) {
      for (var i=0; i<document.anchors.length; i++) {
        if (document.anchors[i].name==a_name) { 
          y=document.anchors[i].y;
          break; 
        }
      }
//      y-=5;
    } else if (isIE) {
      var el=document.all[a_name];
      var ot=el.offsetTop;
      while((el=el.offsetParent) != null) { 
        ot += el.offsetTop; 
      }
      y=ot;
    }
    else if (isNS6) {
      var el=document.getElementById(a_name);
      var ot=el.offsetTop;
      while((el=el.offsetParent) != null) { 
        ot += el.offsetTop; 
      }
      y=ot;
    }
    return y;
  } /*getMenuPositionY*/
 

  function tS (pageid, parent_id) {
    return trySubmenu (pageid, parent_id, 1);
  } /*tS*/
  function uS (pageid) {
    return untrySubmenu (pageid, 1);
  } /*uS*/
  function cH (page_id) {
    return cancelHide (page_id);
  } /*cH*/
  function pH (page_id) {
    return prepareHide (page_id);
  } /*pH*/

  function hM(parent_id) {
    if (opened_by[parent_id]) {
      hideMenuNow(opened_by[parent_id]);
    }
  }
 
  function trySubmenu(pageid, parent_id, issub) {
    if (issub && (! showed[pageid])) {
      showed[pageid] = 1;
      cH(pageid);
      ready_to_hide[pageid] = 0;
      if (blocked_by[parent_id]) {
        blocking[blocked_by[parent_id]] = 0;
      }
      blocked_by[parent_id] = pageid;
      if (opened_by[parent_id]) {
        hideMenuNow(opened_by[parent_id]);
      }
      opened_by[parent_id] = pageid;
      blocking[pageid] = parent_id;
      moveDiv(getMenuPositionX('a'+pageid), getMenuPositionY('a'+pageid), 'submenu_' + pageid);
      show('submenu_' + pageid);
    }
    return true;
  }
/*
  function trySubmenu(pageid, parent_id, issub) {
    if (issub && (! showed[pageid])) {
      showed[pageid] = 1;
      cancelHide(pageid);
      ready_to_hide[pageid] = 0;
      if (blocked_by[parent_id]) {
        blocking[blocked_by[parent_id]] = 0;
      }
      blocked_by[parent_id] = pageid;
      if (opened_by[parent_id]) {
        hideMenuNow(opened_by[parent_id]);
      }
      opened_by[parent_id] = pageid;
      blocking[pageid] = parent_id;
      moveDiv(getMouseX() + 30, getMouseY() - 10, 'submenu_' + pageid);
      show('submenu_' + pageid);
    }
    return true;
  }
*/
  function untrySubmenu(pageid, issub) {
    if (issub) {
      prepareHide(pageid);
    }
    return true;
  }

  var timerID = new Array();

  function prepareHide(page_id) {

    // Przygotowuje menu do ukrycia - ustawia timer na 1 sekunde
    timerID[page_id] = setTimeout("hideMenu(" + page_id + ")", 2000);
  }

  function cancelHide(page_id) {
    // Anuluje chowanie warstwy, ktora zostala ustawiona w kolejce do ukrycia
    if (timerID[page_id]){
      clearTimeout(timerID[page_id]);
      timerID[page_id] = 0;
      ready_to_hide[page_id] = 0;
    }
  }

  function hideMenu(page_id) {
    // Przygotowuje do ukrycia warstwy
    if (! blocked_by[page_id]) {
      showed[page_id] = 0;
      cancelHide(page_id);
      hide('submenu_' + page_id);
      if (blocking[page_id]) {
        // jezeli aktualnie chowana warstwa blokowala ukrycie innej warstwy
        blocked_id = blocking[page_id];
        // to odblokowujemy te inna - parentMenu
//        opened_by[page_id] = 0;
        blocking[page_id] = 0;
        if (blocked_by[blocked_id] == page_id) {
          blocked_by[blocked_id] = 0;
          if (ready_to_hide[blocked_id]) {
            // jezeli blokowana warstwa byla gotowa do schowania, to ja chowamy
            hideMenu(blocked_id);
          }
        }
      }
    } else {
      ready_to_hide[page_id] = 1;
    }
  }

  function hideMenuNow(page_id) {
    // Chowa warstwe natychmiast, ukrywajac jednoczesnie wszystkie warstwy 
    // otworzone powyzej 
    cancelHide(page_id);
    hide('submenu_' + page_id);
    blocked_id = blocking[page_id];
    blocking[page_id] = 0;
    blocked_by[blocked_id] = 0;
    showed[page_id] = 0;
    if (opened_by[page_id]) {
      opened_id = opened_by[page_id];
      opened_by[page_id] = 0;
      hideMenuNow(opened_id);
    }
  }

  // Obsluga rysunkow

  function changeImage(image_name, image_url) {
    // Ustawia ares ilustracji dla zadanego obrazka o nazwie image_name

    if (isNS4) {
      // W przypadku Netscape'a kazda warstwa ma wlasna liste obrazkow
      // Dlatego tez najpierw musimy nalezc, w jakiej warstwie siedzi obrazek, ktory
      // chcemy podmienic
      i = 0;
      img_found = 0;
      while ((i < document.layers.length) && (! img_found)) {
        // petla po wszystkich warstwach
        j = 0;
        while ((j < document.layers[i].document.images.length) && (! img_found)) {
          // Petla po wszystkich rysunkach w warstwie
          if (document.layers[i].document.images[j].name != image_name) {
            j++;
          } else {
            img_found = 1;
          }
        }
        if (! img_found) {
          i++;
        }
      }
      if (img_found) {
        if (! image_url) {
          document.layers[i].document.images[j].src = empty_image.src;
        } else {
          document.layers[i].document.images[j].src = image_url;
        }
      } else {
        alert("image '" + image_name + "' not found");
      }
    } else
      if (isIE||isNS6) {
        if (! image_url) {
          document.images[image_name].src = empty_image.src;
        } else {
          document.images[image_name].src = image_url;
        }
      }
  }

  function getImageURL(image_name) {
    // Zwraca ares (url) pliku dla zadanego obrazka o nazwie image_name

    if (isNS4) {
      // W przypadku Netscape'a kazda warstwa ma wlasna liste obrazkow
      // Dlatego tez najpierw musimy nalezc, w jakiej warstwie siedzi obrazek, ktory
      // chcemy podmienic
      i = 0;
      img_found = 0;
      while ((i < document.layers.length) && (! img_found)) {
        // petla po wszystkich warstwach
        j = 0;
        while ((j < document.layers[i].document.images.length) && (! img_found)) {
          // Petla po wszystkich rysunkach w warstwie
          if (document.layers[i].document.images[j].name != image_name) {
            j++;
          } else {
            img_found = 1;
          }
        }
        if (! img_found) {
          i++;
        }
      }
      if (img_found) {
        return document.layers[i].document.images[j].src;
      } else {
        alert("image '" + image_name + "' not found");
        return "";
      }
    } else
      if (isIE||isNS6) 
        return document.images[image_name].src;

    return "";
  }
  
  
  var isIE=document.all?true:false; 
  var isNS4=document.layers?true:false; 
  var isNS6=(document.getElementById&&!document.all)?true:false;

  var event_x = 0;
  var event_y = 0;

  function fakeMouseMove(e) {
    x = (isNS4||isNS6) ? e.pageX : document.body.scrollLeft + event.clientX; 
    y = (isNS4||isNS6) ? e.pageY : document.body.scrollTop + event.clientY; 
    event_x = x;
    event_y = y;
    if (! is_initiated) {
      showLatawiec();
    }
  }

  function initDPointer() {
    if(isNS4) {
      document.captureEvents(Event.MOUSEMOVE); 
      document.onmousemove=fakeMouseMove; 
      } else {
      if(isNS6) {
        document.addEventListener("mousemove", fakeMouseMove, true);
      } else {
        if(isNS4||isIE) {
        document.onmousemove=fakeMouseMove; 
        }
      }
    }
  }

  function moveDiv(x,y,div_name) {
    if(isNS4){ 
      eval("document." + div_name  + ".top=" + y);
      eval("document." + div_name + ".left=" + x);
    } else
      if(isNS6) {
        document.getElementById(div_name).style.top = y + "px";
        document.getElementById(div_name).style.left = x + "px";
      } else
        if(isIE) {
          eval(div_name + ".style.top=" + y);
          eval(div_name + ".style.left=" + x);
        }
  }



