var Cookie = {
  set: function(name, value, daysToExpire) {
    var path= ';  path=/';
    var expire = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire + path);
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  }
};


function toggleMenu(cat) {

  if (menuclickable==false) return false;

  if ($(cat).style.display == "none") 
	 {
    menuclickable=false;
    $('m'+cat).className = 'kat_rozwinieta';
    Effect.BlindDown($(cat),{duration:0.5});
    catMenuCookie[catMenuCookie.size()]=cat.substr(1);
    Cookie.set('catMenu',catMenuCookie);
    setTimeout("menuclickable=true",500);
   } else {
    menuclickable=false;
    $('m'+cat).className = 'kat_zwinieta';
    Effect.BlindUp($(cat),{duration:0.5});
    catMenuCookie=catMenuCookie.without(cat.substr(1));
    Cookie.set('catMenu',catMenuCookie);
    setTimeout("menuclickable=true",500);
   }
}

function wyswietlStrefe(strefa_id,div_id,kid,mid)
 {
  var url = location.href;
  var baseURL = url.substring(0, url.indexOf('/', 14));
  
  if (!kid) var kid=0;
  if (!mid) var mid=0;

  new Ajax.Updater(div_id,baseURL+'/Bannery-strefa.html?id='+strefa_id+'&kid='+kid+'&mid='+mid,
   {
    method: 'get',
    asynchronous: true
   } );
 }

function zagielPoliczRate(numerSklepu,koszyk) 
 { 
  window.open('https://www.eraty.pl/symulator/oblicz.php?numerSklepu='+numerSklepu+'&wariantSklepu=1&typProduktu=0&wartoscTowarow='+koszyk, 'Policz_rate', 'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no'); 
 }
 
function zagielValidate() 
 { 
  if ($('ratyDiv').visible()==false)
   {
    return true;
   }
  else if ($('ratyZgoda').checked==false)
   { 
    alert ("Zanim złożysz zamówienie, zapoznaj się z procedurą udzielenia kredytu ratalnego eRaty Żagiel."); 
    return false; 
   } 
  else 
   { 
    return true; 
   } 
 } 
