/* 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);
}


// zamiana obrazków
function changeImg(source, status) {
 if (document.images) {
  document.images[source].src = tablicaWzorowTla[source + "_" + status].src;
 }
}

// preload obrazków
function preloadImages(img_name, img_source) {
 tablicaWzorowTla[img_name] = new Image();
 tablicaWzorowTla[img_name].src = img_source;
}

// 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 changeBorderColor(id, nr_koloru) {
 kolor = tablicaKolorowObrysu[nr_koloru];
 if(!document.layers) { id.style.borderColor = kolor; }
 else { id.borderColor = kolor; }
}

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(dane) { otworzOkno("wydrukuj.php?p=0," + dane, 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);
}

// obsluga funkcji js wywolywanych przez flash
function naglowek3_DoFSCommand(command, args) {
 args = unescape(args);
 switch (command) {
  case 'dodaj_do_ulubionych':
   dodajDoUlubionych();
   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 naglowek3_FSCommand(ByVal command, ByVal args)');
 document.writeln('call naglowek3_DoFSCommand(command, args)');
 document.writeln('end sub');
 document.write('<\/script>');
}



