/* opinie klientow */
Vertis.didyouknow = (function () {
  var did = $('#sidebar-didyouknow');

  return {
    next: function() {
      var firstNotHidden = did.children(":not(span[class='hidden'])").eq(1);
      lastCount = did.children("span:last").prevAll().length;

      firstNotHidden.addClass("hidden");

      if(firstNotHidden.prevAll().length < lastCount) {
        firstNotHidden.next().hide().removeClass("hidden").fadeIn(700);
      } else {
        did.children("span:first").hide().removeClass("hidden").fadeIn(700);
      }
    },
    previous: function() {
      var firstNotHidden = did.children(":not(span[class='hidden'])").eq(1);
      firstNotHidden.addClass("hidden");
      if(firstNotHidden.prevAll().length > 1) {
        firstNotHidden.prev().hide().removeClass("hidden").fadeIn(700);
      } else {
        did.children("span:last").hide().removeClass("hidden").fadeIn(700);
      }
    }
  }
})();


$(document).ready(function(){

  $("#didyouknow_next").click(function(){
    iv = window.clearInterval(iv); 
    iv = setInterval(Vertis.didyouknow.next, 20000);
  });

  $("#didyouknow_previous").click(function(){
    iv = window.clearInterval(iv); 
    iv = setInterval(Vertis.didyouknow.next, 20000);
  });

  iv = setInterval(Vertis.didyouknow.next, 20000);

 $('.morePromos').live('click', function() {
   $(this).html('Mniej...');
   $(this).removeClass('morePromos');
   $(this).addClass('lessPromos');
   $(this).siblings('.no_display').removeClass('no_display');
 });
 
 $('.lessPromos').live('click', function() {
   $(this).html('Więcej...');
   $(this).removeClass('lessPromos');
   $(this).addClass('morePromos');
   $(this).siblings(':gt(4)').addClass('no_display');
 });


});
