$(function () {
  $(".slidetabs").tabs('.images > div', {
    effect: 'fade',
    rotate: true,
    onClick: function(event, tabIndex) {
      var tabs = this.getPanes();
      $(tabs.last()).parent().next().children('.images-counter-container').children('.images-counter').text(tabIndex + 1);
  }}).slideshow({
    autoplay: (window.homepage) ? true : false,
    interval: 3000
  });
  var hidden = true;
  $('.extra').bind('click', function() {
    var extras = $(this).parent().siblings('.images').children('div').children('.image-extra, .embed-extra');
    if (hidden === true) {
      extras.show();
      hidden = false;
    } else {
      extras.hide();
      hidden = true;
    }
  });
  $('.backward, .forward').bind('click', function() {
  });
  $('.extra').toggle(function() {
    $(this).css('background-position', '0 -120px');
  }, function() {
    $(this).css('background-position', '0 -80px');
  });
  $('.images-container').bind('mouseover', function(){
    var container = this;
    $(container).children('.image-controls, .image-extra-controls').show();
  });
  $('.images-container').bind('mouseout', function() {
    var container = this;
    $(container).children('.image-controls, .image-extra-controls').hide();
  });
});

