wczytane=false;
function opis (opis, komorka)
{
document.getElementById(komorka).innerHTML = opis;
}

function pobierz(url, element_docelowy, napis, data)
{
if(data==null) data="";
zap = false;
        if (window.XMLHttpRequest) {
            zap = new XMLHttpRequest();

            if (zap.overrideMimeType) {
             }
        } else if (window.ActiveXObject) {
            try {
                zap = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    zap = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
wcz = napis;
el_docelowy = element_docelowy;
zap.onreadystatechange = zczytaj;
zap.open('POST', url, true);
zap.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
zap.setRequestHeader("Content-length", data.length);
zap.setRequestHeader("Connection", "close");
zap.send(data);
}

function zczytaj()
{
if (zap.readyState == 4)
   {
   if (zap.status==200)
      {
      wczytane=true;
      if(el_docelowy!=false) opis(zap.responseText, el_docelowy);
      }
   }
   else
   {
   if(wcz==true) opis("<div style='text-align:center; padding:7px; font-size:14px; background:#C9FFD7; border:solid 1px green;'>Trwa wczytywanie...</div>", el_docelowy);
   }
}


function getScrollY() {
var scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
scrOfY = window.pageYOffset;
} else if( document.body && document.body.scrollTop ) {
scrOfY = document.body.scrollTop;
} else if( document.documentElement && document.documentElement.scrollTop ) {
scrOfY = document.documentElement.scrollTop;
}
return scrOfY;
}

function getScrollX() {
var scrOfX = 0;
if( typeof( window.pageXOffset ) == 'number' ) {
scrOfX = window.pageXOffset;
} else if( document.body && document.body.scrollLeft ) {
scrOfX = document.body.scrollLeft;
} else if( document.documentElement && document.documentElement.scrollLeft ) {
scrOfX = document.documentElement.scrollLeft;
}
return scrOfX;
}

function findPosX(obj)
{
  var curleft = 0;
  if(obj.offsetParent)
      while(1) 
      {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  if(obj.offsetParent)
      while(1)
      {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}


function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getDocWidth() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}

function szuflujA(polea)
{
pole = document.getElementById(polea);
if(pole.style.display=="none" || pole.style.display=="") document.getElementById(polea).style.display='block';
else document.getElementById(polea).style.display='none';
}

function szuflujB(polea)
{
pole = document.getElementById(polea);
if(pole.style.display=="block" || pole.style.display=="") document.getElementById(polea).style.display='none';
else document.getElementById(polea).style.display='block';
}

function szukajS(string)
{
  if(string.length==0) 
  {
  document.getElementById('szukajWskazania').style.display='none';
  return;
  }
document.getElementById('szukajWskazania').style.display='block';
pobierz('/ajax_szukaj.php', 'szukajWskazania', true, 'searchString='+string);
}

function uzupelnijSzukaj(string)
{
document.getElementById('szukajForm').value=string;
document.forms['szukajForm'].submit();
}

function pokazZakladke(idz, string)
{
pobierz('/ajax_szukaj.php', 'wynikiWyszukwiania', true, 'search='+string+'&tryb='+idz);
}

function scrollToolbox()
{
var wskaznik = 140;
var get = getScrollY();
if(get>wskaznik) wskaznik = 10;
else wskaznik = wskaznik-get;
document.getElementById('toolbox').style.top= (get+wskaznik)+"px";
}

var przewijaj = false;
var resetP = true;

function autoprzewijanie(czas, play, reset)
{
przewijaj = play;
if(reset==1) resetP = true;
if(reset==2) resetP = false;
if(!przewijaj) return;
if(resetP) location.href="#tresc";
przewin(czas);
}

function przewin(czas)
{
var dh = getDocHeight();
var starty = 395;
var endy = dh-winheight()-460;
var droga = endy - starty;
var v=1;
interval = (czas/droga)*1000;
//alert("int: "+interval+" droga: " + droga+" czas: " + czas);


var scroll = getScrollY();
if(scroll>=endy) return;
setScrollY(scroll+v);
//przewijaj = false;
if(przewijaj) setTimeout("przewin("+czas+")", interval);
}

function setScrollY(yy) {
if( document.body && document.body.scrollTop ) {
document.body.scrollTop = yy;
} else if( document.documentElement && document.documentElement.scrollTop ) {
document.documentElement.scrollTop = yy;
}
}

function winheight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && (document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && (document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
return myHeight;
}

var oZoom = 14;
function zoom(zmiana)
{
document.getElementById("trescPiosenki").style.fontSize = oZoom+zmiana+"px";
}

function przeliczCzas()
{
return ((parseInt(document.getElementById("czasInputMin").value)*60)+(parseInt(document.getElementById("czasInputSec").value)));
}

function openForPrint(pio,pdf)
{
if(pdf==0) window.open ('/print.php?pio='+pio, 'okno_wydruku', 'location=no,status=no,scrollbars=1,width=800,height=600');	
else location.href='/print.php?pio='+pio+'&pdf='+pdf
}
