
$(function(){

   // preload overlays
   if ($('div.produkty-box').length > 0) {
      var pop = $('<img />').attr('src', '/images/produkty-pop.jpg');
      $('#pop div.decor').append(pop);
      
      var sis = $('<img />').attr('src', '/images/produkty-sis.jpg');
      $('#sis div.decor').append(sis);      
      
      var promo = $('<img />').attr('src', '/images/produkty-promo.jpg');
      $('#promo div.decor').append(promo); 
      
      $('div.produkty-box a').append($('<img />').attr('src', '/images/produkty-bar-hover.png'));
   }

   $('div.produkty-box a').hover(
      function(){      
         $(this).find('.decor img').stop(true, true).fadeIn();
         $(this).children('img').stop(true, true).fadeIn();
         $(this).children('span').animate({ fontSize:'110%' }, 200);
      },
      function(){
         $(this).find('.decor img').stop(true, true).fadeOut();
         $(this).children('img').stop(true, true).fadeOut();
         $(this).children('span').animate({ fontSize:'90%' }, 200);
      }
   );


   // dispose flash messages after a while
   setTimeout(function(){
      $('div.flash').fadeOut();
   }, 4000);


   $('a[rel]').lightBox({
      imageLoading: '/images/lightbox/loading.gif',
	imageBtnClose: '/images/lightbox/close.gif',
	imageBtnPrev: '/images/lightbox/prev.gif',
	imageBtnNext: '/images/lightbox/next.gif',
      imageBlank: '/images/lightbox/blank.gif'
   });
     
});


function urlencode (str) {
   str = escape(str);
   return str.replace(/[*+\/@]|%20/g,
      function (s) {
         switch (s) {
            case "*": s = "%2A"; break;
            case "+": s = "%2B"; break;
            case "/": s = "%2F"; break;
            case "@": s = "%40"; break;
            case "%20": s = "+"; break;
         }
         return s;
      }
   );
}

