jQuery(document).ready(function(){
  $('#accordion').accordion({
		autoHeight: false,
		navigation: true,
		active: false,
    collapsible: true,
    animated: 'easeOutQuint'
	});
	
  $('#images-big img.default-image').fadeIn();
	
	$('#accordion h3').click(function(){
	  var idx = $('#accordion h3').index(this);
    
    $('#images-big img').hide();
    
    if($('#accordion h3').eq(idx).hasClass('ui-state-active')){
      $('#images-big img:not(.default-image)').eq(idx).fadeIn();
    }
    else{
      $('#images-big img.default-image').fadeIn();
    }
  });
  
  $('#add-comment').click(function(){
    $('#accordion').accordion('activate', parseInt($('#accordion h3').length)-1);
  });
  
  /*
   * Carousel init
   */
  /**/



});
jQuery(document).ready(function() {
    var prevButton = $('#lounge-gallery-prev');
    var nextButton = $('#lounge-gallery-next');
    var biggerviewButtons = $('#lounge-gallery-biggerview a');
    
    jQuery('#lounge-gallery').jcarousel({
      scroll: 1,
      animation: 1500,
      easing: 'easeOutQuint',
      buttonNextHTML: '',
      buttonPrevHTML: '',
      initCallback: carousel_initCallback,
      itemVisibleInCallback: {
        onBeforeAnimation: carousel_onBeforeAnimation
      }
    });
  
  function carousel_initCallback(carousel){   
    prevButton.addClass('first');
    biggerviewButtons.eq(0).css('visibility', 'visible');

    prevButton.bind('click', function() {
        carousel.prev();
        return false;
    });
    
    nextButton.bind('click', function() {
        carousel.next();
        return false;
    });
  }
  function carousel_onBeforeAnimation(carousel,object,index,state){
    $('#lounge-gallery-index').text(index);
    biggerviewButtons.eq(index-1).css('visibility', 'visible');
    
    if(index == 1){
      prevButton.addClass('first');
      nextButton.removeClass('last');
    }
    else if(index == $('#lounge-gallery li').length){
      prevButton.removeClass('first');
      nextButton.addClass('last');
    }
    else{
      prevButton.removeClass('first');
      nextButton.removeClass('last');
    }
  }

});


