$(document).ready(function(){

  $('#banners li').hide();
  $('#bannerNavigation li a').click(function() {

    $('#bannerNavigation li a img').attr('src', '/img/dot.png');
    $(this).children('img').attr('src', '/img/dot-a.png');
    
    selIndex = $(this).parent().index();
    liElement = $('#banners li').get(selIndex);
    
    // pierwsze uruchomienie
    if ($('#banners li.active').length == 0) {
      $(liElement).show().addClass('active');
    } else {
      $('#banners li.active').fadeOut('slow', function() {
        $(liElement).fadeIn('slow', function() {
          $(this).addClass('active');
        })
      }).removeClass('active');
    }

    return false;
    
  });
  
  var randIndex = Math.floor(Math.random() * $('#banners li').length);
  //$('#banners li').eq(randIndex).addClass('active');  
  $('#bannerNavigation a').eq(randIndex).trigger('click');
  
  

  $('#tabs li a.tab').click(function() {
    
    var parent = $(this).parent('li');
    var tabIndex = $(parent).index();

    if (!$(parent).hasClass('active')) {
    
      $('#tabs li').removeClass('active');
      $(parent).addClass('active');

/*
      $('.tabContent.active').fadeOut('fast', function() {
        $(this).removeClass('active');
        $('.tabContent').eq(tabIndex).fadeIn('fast').addClass('active');
      });
*/      
      // Bez animacji, ale nie przewija strony
      $('.tabContent.active').hide().removeClass('active');
      $('.tabContent').eq(tabIndex).show().addClass('active');
      

    }
    
    //$.scrollTo($("#tabs"), { duration: 0});

    return false;
    
  });
  
  
  
  
  // galeria
  $('.thumbs a').click(function() {
    $('#preview').attr('src', $(this).attr('href'));
    
    $('.thumbs a').removeClass('active');
    $(this).addClass('active');
    
    return false;
  });
  
});
