var d=document;
var gid=(d.getElementById)?true:false;
var preloadFlag=false;

function obslugaNapisu(nazwaFormularza,nazwaPola,napis) {
  var pole=d[nazwaFormularza][nazwaPola];
  if (pole.value==napis)
    pole.value=''; else
  if (pole.value=='')
    pole.value=napis;
}

function ustaw(nazwa,sufiksStanu,formatPliku) {
  if (d.images && preloadFlag) {
    var tlo='url("img/'+nazwa+sufiksStanu+'.'+formatPliku+'")';
    if (gid) {
      d.getElementById(nazwa).style.backgroundImage=tlo;
    }
  }
}

function preloader() {
  if (d.images) {
    var k;
    var sciezki=preloader.arguments;
    var obrazki=new Array();
    for (var k=0;k<=sciezki.length-1;k++) {
      obrazki[k]=new Image();
      obrazki[k].src=sciezki[k];
      }
    preloadFlag=true;
  }
}

function sformatujLokalizacje() {
  var identyfikator="sciezka";
  var wzorzec=new RegExp();
  if (gid) {var str=d.getElementById(identyfikator).innerHTML;}

//  wzorzec.compile(">Strona g.ówna<","g"); //skrypt źle pobiera "ł"
//  var obrazek='<img src="../img/home.gif" width="11" height="9" alt="Strona g&#322;ówna" title="Strona g&#322;ówna" />';
//  str=str.replace(wzorzec,">"+obrazek+"<");
  
  wzorzec.compile(String.fromCharCode(32)+"*"+String.fromCharCode(8250)+String.fromCharCode(32)+"*","g");
  obrazek=' <img src="img/next.gif" class="next" width="9" height="5" alt="" /> ';
  str=str.replace(wzorzec," "+obrazek+" ");

  if (gid) {d.getElementById(identyfikator).innerHTML=str;}
}

function odLewej(el) {
  var x=el.offsetLeft;
  if (el.offsetParent!=null)
    x+=odLewej(el.offsetParent);
  return x;
}

function odGory(el) {
  var x=el.offsetTop;
  if (el.offsetParent!=null)
    x+=odGory(el.offsetParent);
  return x;
}

function pokazMenu(nazwa,przyJakimElemencie) {
  if (gid && d.images && preloadFlag) {
  var przy=d.getElementById(przyJakimElemencie);
  var obiekt=d.getElementById(nazwa).style;
  obiekt.left=odLewej(przy)+204+"px"
  obiekt.top=odGory(przy)+"px";
  obiekt.display="block";


  }
}

function ukryjMenu(nazwa) {
  if (gid && d.images)
    d.getElementById(nazwa).style.display="none";
}

function usunLamanieLinijek() {
try{
  if (gid) {
    for (var k=0;k<=usunLamanieLinijek.arguments.length-1;k++) {
      str=d.getElementById(usunLamanieLinijek.arguments[k]).innerHTML;
      var wzorzec=new RegExp("<br />","gi");
      str=str.replace(wzorzec,"");
      wzorzec.compile("<br/>","gi");
      str=str.replace(wzorzec,"");
      wzorzec.compile("<br>","gi");
      str=str.replace(wzorzec,"");
      d.getElementById(usunLamanieLinijek.arguments[k]).innerHTML=str;;
    }
  }
}
catch(ex){}
}




/*** poniżej zapożyczona część skryptu (zaadaptowana do relatywnie pozycjonowanych elementów) ***/

/*
Author: Krzysztof Szafranek
http://szafranek.net
This script may be used and changed freely as long as this message is included.
*/

function scroller() {
  var aP=d.getElementById("aktualnosci");
  var zawartosc=aP.innerHTML;
  aP.innerHTML="";
  aP.style.overflow="hidden";
  aP.innerHTML='<div id="aktualnosciTrescKontener">'+
                 '<div id="aktualnosciTresc">'+
                 zawartosc+
                 '</div>'+
               '</div>'+
               '<div id="aktualnosciPasek">'+
                 '<div id="up"></div>'+
                 '<div id="msNaSuwak">'+
                   '<div id="suwak"></div>'+
                 '</div>'+
                 '<div id="down"></div>'+
               '</div>';
  var clip_size=246;
  var speed=15;
  var bar=d.getElementById('suwak');
  var sc=d.getElementById('aktualnosciTresc');
  var buttonUp=d.getElementById('up');
  var buttonDown=d.getElementById('down');
  var clip_top=0;
  var bar_offset=0;
  var scrolled_top=0;
  var limit_top=odGory(buttonUp)+buttonUp.offsetHeight;
  var limit_bottom=odGory(buttonDown)-bar.offsetHeight;
  buttonUp.onmouseup=buttonDown.onmouseup=scrollStop;
  buttonUp.onmousedown=buttonDown.onmousedown=scrollButton;
  buttonUp.onmouseover=buttonUp.style.cursor="hand";
  buttonUp.onmouseout=buttonUp.style.cursor="pointer";
  buttonDown.onmouseover=buttonDown.style.cursor="hand";
  buttonDown.onmouseout=buttonDown.style.cursor="pointer";
//  d.onmousemove=scrollBar;
  d.onmouseup=cast;
  bar.onmousedown=take;
  bar.onselectstart=buttonUp.onselectstart=buttonDown.onselectstart=stop;
  

  function stop() {
    return false;
  }

  function scrollStop() {
    clearTimeout(sc.timer);
  }

  function scrollButton(e) {
    // determine speed and direction
    if (e=eventIE(e))
      current_speed=e.target.id==buttonDown.id?-speed:speed;
    if (clip_top-current_speed<0) {
      limitUp();
      return;
    }
    if (clip_top+clip_size-current_speed>sc.offsetHeight) {
      limitDown();
      return;
    }
    clip_top-=current_speed;
    bar.style.top=(Math.ceil(clip_top/(sc.offsetHeight-clip_size)*(limit_bottom-limit_top)))+'px';
    move();
    args=arguments; // can't refer to 'arguments' directly in setTimeout()
    sc.timer=setTimeout('args.callee()', 1);
  }

  function scrollBar(e) {
    if (!bar_offset) return;
    e=eventIE(e);
    if (e.pageY-bar_offset<limit_top) {
      limitUp();
      return;
    }
    if (e.pageY>limit_bottom+bar_offset) {
      clip_top=sc.offsetHeight-clip_size;
      limitDown();
      return;
    }
    bar.style.top=(e.pageY-bar_offset-limit_top)+'px';
    move();
  }

  function move() {
    position=(odGory(bar)-limit_top)/(limit_bottom-limit_top);
    sc.style.top=(scrolled_top-(Math.floor(sc.offsetHeight-clip_size)*position))+'px';
    clip_top=Math.floor((sc.offsetHeight-clip_size)*position);
    sc.style.clip='rect('+clip_top+'px,'+sc.offsetWidth+'px,'+(clip_top+clip_size)+'px,0px)';
  }

  function limitUp() {
    clip_top=0;
    bar.style.top='0px';
    sc.style.top=scrolled_top+'px';
    sc.style.clip='rect(0px '+sc.offsetWidth+'px '+clip_size+'px 0px)';
  }

  function limitDown() {
    bar.style.top=limit_bottom-limit_top+'px';
    sc.style.top=scrolled_top+clip_size-sc.offsetHeight+'px';
    sc.style.clip='rect('+(sc.offsetHeight-clip_size)+'px,'+sc.offsetWidth+'px,'+sc.offsetHeight+'px,0px)';
  }


  function take(e) {
    e=eventIE(e);
    bar_offset=e.pageY-odGory(bar);
  }

  function cast() {
    bar_offset=0;
  }

  function eventIE(e) {
    // map IE event handling to Gecko mode
    if (window.event && !window.opera) {
      e=window.event;
      e.pageY=window.event.y;
      e.target=window.event.srcElement;
    }
    return e;
  }
}

function okno1(co,w,h){
eval("window.open('" + co + "','_new','width=" + w + ",height=" + h + 
",left=50,top=50,scrollbars=1')")
}

function okno(co,w,h){
eval("window.open('" + co + "','_new','width=" + w + ",height=" + h + 
",left=50,top=50,scrollbars=0')")
}
