function addfav(url, txt)
{
  var msg_netscape = "Wiadomość Netscape";
  var msg_opera    = "Ta funkcja nie działa z tą wersją Opery. Dodaj nas do ulubionych ręcznie.";
  var msg_other    = "Twoja przeglądarka nie wspiera automatycznego dodawania do ulubionych. Dodaj nas do ulubionych ręcznie.";
  var agt          = navigator.userAgent.toLowerCase();
  var title        = txt + " - Witamy!";

  if (agt.indexOf("opera") != -1) 
  {
    if (window.opera && window.print)
    {
      return true;
    } else 
    {
      alert(msg_other);
    }
  }    
  else if (agt.indexOf("firefox") != -1) window.sidebar.addPanel(title,url,"");
  else if ((agt.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >=4)) window.external.AddFavorite(url,title); 
  else if (agt.indexOf("netscape") != -1) window.sidebar.addPanel(title,url,"")         
  else if (window.sidebar && window.sidebar.addPanel) window.sidebar.addPanel(title,url,""); 
  else alert(msg_other);

 return;  
}

/* ---------------------- Splash ----------------------- */
function showspl()
{
 document.cookie='wiek=ok';
 n = document.getElementsByTagName('html');
 n[0].style.height = '100%';
 n[0].style.overflow = 'hidden';
 document.body.style.height = '100%';
 document.body.style.overflow = 'hidden';
 if($('splash')) $('splash').style.display = 'block';
}

function hidespl()
{
 n = document.getElementsByTagName('html');
 n[0].style.height = '';
 n[0].style.overflow = '';
 document.body.style.height = '';
 document.body.style.overflow = '';
 if($('splash')) $('splash').style.display = '';
}

function getcookie(nazwa)
{
 nazwa+="="; 
 startCookie=document.cookie.indexOf(nazwa);
 if (startCookie==-1) {return ""}
 startCookie+=nazwa.length;
 if (document.cookie.indexOf(";",startCookie)==-1) {
  koniecCookie=document.cookie.length; }
   else { koniecCookie=document.cookie.indexOf(";",startCookie); }
 textCookie=document.cookie.substring(startCookie,koniecCookie);
 textCookie=unescape(textCookie);
 return textCookie;
}
var Teraz = new Date();
Teraz.setTime(Termin = (24*60*60*1000) + Teraz.getTime());
Termin = (Teraz.toGMTString());

/* ---------------------- Email replace ----------------------- */
var emailReplaceArray = [
    ['na serwie', '@'],
    ['kropka', '.'],
    ['||', '@'],
    ['^^', '.'] ];

  ( function(elm, evnt, func) {
    if (elm.addEventListener) {
      elm.addEventListener(evnt, func, false);
    }
    else if (elm.attachEvent) {
      elm.attachEvent('on' + evnt, function() {
        func.call(elm, event);
      } );
    }
  } ) (window, 'load', function(e) {

    var replTab = emailReplaceArray;
    for (var i = 0; i < replTab.length; i++) {
      var s = escape(replTab[i][0].replace(/\s/g, ''));
      replTab[i][0] = s.replace(/%u/g, '\\u').replace(/%/g, '\\x');
    }
    var getEmail = function(s) {
      s = s.replace(/\s/g, '');
      for (var i = 0; i < replTab.length; i++) {
        s = s.replace(new RegExp(replTab[i][0], 'ig'), replTab[i][1]);
      }
      return s;
    };
    var as = document.getElementsByTagName('a');
    var html = document.getElementsByTagName('html')[0];
    var text = html.textContent != undefined ? 'textContent' : 'innerText';
    for (var i = 0; i < as.length; i++) {
      if (! as[i].className.match(/(^|\s)email_address($|\s)/)) continue;
      var email = getEmail(as[i][text]);
      as[i].setAttribute('href', 'mailto:' + email);
      as[i][text] = as[i].getAttribute('rel');
	  as[i].style.visibility = 'visible';
    }
    emailReplaceArray = undefined;
} );
