/* polskie znaczki aby editplus zapisywal jako utf-8 -> ąśź */
var ds, dw, dwc, dws, menuZaladowane=0;

var isNS4 = (document.layers ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isDOM = (document.getElementById ? true : false);
var isNS6 = ((document.getElementById&&!document.all) ? true : false);

window.onresize = restorePage
function restorePage() { location.reload(); }

// uchwyt do obiektu
function layerGet(id) {
 if (isNS6 || isDOM) return document.getElementById(id);
 else if (isNS4) return document.layers[id];
 else return document.all[id];
}

// dla ie dodaj style
function layerObj(id) {
 return (isNS4 ? layerGet(id) : layerGet(id).style);
}

// po zaladowaniu zrob to
function zaladowane() {
 wymiaryOkna();
 var wd;

 if (isNS6 || isNS4) { wd = document.documentElement.scrollHeight; }
 else { wd = document.body.scrollHeight; }

 if (wd != null && wd > (dw + 200)) {
  obj = layerObj("stopka_gora_pojemnik_gora");
  obj.display = "block";
 }
}

// zamiana obrazków
function changeImg(picture, source, status) {
 if (document.images) {
  document.images[picture].src = tablicaWzorowTla[source + "_" + status].src;
 }
}

// preload obrazków
function preloadImages(img_name_on, img_source_on, img_name_off, img_source_off) {
 tablicaWzorowTla[img_name_on] = new Image();
 tablicaWzorowTla[img_name_on].src = img_source_on;
 tablicaWzorowTla[img_name_off] = new Image();
 tablicaWzorowTla[img_name_off].src = img_source_off;
}

// zapis do pola
function layerPut(id, opis) {
 if (isNS4) { // zapis do starego netscape
  obj = document.layers[id];
  obj.document.open();
  obj.document.write(opis);
  obj.document.close();
 }
 else {
  obj = layerGet(id);
  obj.innerHTML = opis;
 }
}

function wymiaryOkna() {
 if (document.width) { ds = document.width; dw = document.height;}
 else { ds = document.body.clientWidth; dw = document.body.clientHeight; }
 // calkowita szerokosc dokumentu
 if (window.innerWidth && window.scrollMaxX) { dws = window.innerWidth + window.scrollMaxX; }
 else if (document.body.scrollWidth && document.body.offsetWidth) {
  if (document.body.scrollWidth <= document.body.offsetWidth) { dws = document.body.scrollWidth }
  else { dws = document.body.scrollWidth; }
 }
 else { dws = document.body.offsetWidth + document.body.offsetLeft; }
 //calkowita wysoksoc dokumentu
 if (window.innerHeight && window.scrollMaxY) { dwc = window.innerHeight + window.scrollMaxY; }
 else if (document.body.scrollHeight && document.body.offsetHeight) {
  if (document.body.scrollHeight <= document.body.offsetHeight) { dwc = document.body.scrollHeight }
  else { dwc = document.body.scrollHeight; }
 }
 else { dwc = document.body.offsetHeight + document.body.offsetTop; }
}

function changeBgColor(id, nr_koloru) {
 if (g_wydrukuj == 0) {
  kolor = tablicaKolorowTla[nr_koloru];
  if(!document.layers) { id.style.backgroundColor = kolor; }
  else { id.backgroundColor = kolor; }
 }
}

function changeTxtColor(id, nr_koloru) {
 kolor = tablicaKolorowCzcionki[nr_koloru];
 var obj = layerObj(id);
 obj.color = kolor;
}

function wydrukuj() { otworzOkno("wydrukuj.php?p=0," + druk_strona, 1, 800, 430); }

function otworzOkno(link, statusy, szerokosc, wysokosc) {
 if (statusy == undefined) { statusy = 0; }
 if (szerokosc == undefined || wysokosc == undefined) { gora=0; lewa=0; }
 else {
  gora = Math.round((screen.availHeight - wysokosc) / 2);
  lewa = Math.round((screen.availWidth - szerokosc) / 2);
 }
 if (szerokosc == undefined) { szerokosc = screen.availWidth; }
 if (wysokosc == undefined) { wysokosc = screen.availHeight; }
 var okienko = window.open(link, "okno", "toolbar="+statusy+",location="+statusy+",directories="+statusy+",status="+statusy+",menubar="+statusy+",scrollbars=1,resizable="+statusy+",dependent=1,width=" + szerokosc + ",height=" + wysokosc + ",top=" + gora + ",left=" + lewa);
}

// odkodowanie adresu poczty
function decodeTxt(sTxt, addM) {
 var sTxt1 = unescape(sTxt.substr(0,sTxt.length-1));
 var tTxt = '';
 var lTxt = sTxt1.length;
 var eTxt = sTxt.substr(sTxt.length-1,1);
 for (var i=0; i<lTxt; i++) {
  tTxt += String.fromCharCode(sTxt1.charCodeAt(i)-eTxt);
 }
 var doZwrotu = unescape(tTxt);
 doZwrotu = doZwrotu.replace(/!/g, "@");
 doZwrotu = doZwrotu.replace(/:/g, ".");
 if (addM == 1) { doZwrotu = "mailto:"+doZwrotu; }
 return (doZwrotu);
}

function stworzCookie(nazwa, wartosc, dni) {
 if (dni) { var date = new Date(); date.setTime(date.getTime()+(dni*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); }
 else { expires = ""; }
 document.cookie = nazwa+"="+wartosc+expires+"; path=/";
}

// obsluga funkcji js wywolywanych przez flash
function prawa_DoFSCommand(command, args) {
 args = unescape(args);
 switch (command) {
  case 'dodaj_do_ulubionych':
   dodajDoUlubionych();
   break;
  case 'cofnij_strone':
   history.back();
   break;
  case 'wydrukuj_strone':
   wydrukuj();
   break;
 }
}
if (navigator.appName && navigator.appName.indexOf("Microsoft")!=-1 && navigator.userAgent.indexOf("Windows")!=-1) {
 document.writeln('<script language=VBScript>');
 document.writeln('on error resume next');
 document.writeln('sub prawa_FSCommand(ByVal command, ByVal args)');
 document.writeln('call prawa_DoFSCommand(command, args)');
 document.writeln('end sub');
 document.write('<\/script>');
}

function menupOn(id) {
 var obj = layerObj("menup" + id + "_pasek1");
 obj.backgroundColor = tablicaKolorowTla[3];
 var obj = layerObj("menup" + id + "_pasek2");
 obj.backgroundColor = tablicaKolorowTla[5];
 var obj = layerObj("menup" + id + "_pasek3");
 obj.backgroundColor = tablicaKolorowTla[5];
 obj.color = tablicaKolorowCzcionki[3];
 changeImg("menup" + id + "_strzalka", "menup_strzalka", "on");
}

function menupOff(id) {
 var obj = layerObj("menup" + id + "_pasek1");
 obj.backgroundColor = tablicaKolorowTla[2];
 var obj = layerObj("menup" + id + "_pasek2");
 obj.backgroundColor = tablicaKolorowTla[4];
 var obj = layerObj("menup" + id + "_pasek3");
 obj.backgroundColor = tablicaKolorowTla[4];
 obj.color = tablicaKolorowCzcionki[2];
 changeImg("menup" + id + "_strzalka", "menup_strzalka", "off");
}
