/**
 * product-info.js
 * 03.08.2010
 * 
 * @author: Daniel Busch
 *
 * Freiland Netzloesungen GmbH
 * www.freiland.cc
 *
 * @version: $Id: product-info.js 27 2010-08-12 14:31:54Z daniel.busch $
 */

(function($){
  $(function(){

   
    // CD Navigation
    $('#TrackLists ul#TrackListPager li a').each(function() {
      $(this).click(function() {
        if ($(this).hasClass('active')) {return false;}
        $('#TrackLists ul#TrackListPager li a').removeClass('active');
        $(this).addClass('active');
        $('div.TrackSet:visible').hide();
        $($(this).attr('href')).fadeIn(200);
        return false;
      });
    });
    $('#TrackLists ul#TrackListPager li a:first').click();
    
    // ProductSlider
    var navHeight = $('#AlsoPurchasedProducts div.navigation').outerHeight();
    var $productScrollable = $('#AlsoPurchasedProducts .Scrollable');
    $productScrollable.css('height', Number($('.Products', this).outerHeight()+navHeight)+'px')
    if ($('.Group',$productScrollable).size() > 1) {
      $productScrollable.scrollable({
        circular: true,
        items: '.Products',
        next: '.NextButton a',
        prev: '.PrevButton a',
        onSeek: function() {
          var page = Number(this.getIndex()+1)+'/'+this.getSize();
          $('#AlsoPurchasedProducts div.navigation span.page').html(page);
        }
      });
    }
  });
})(jQuery);
