/* 
 * REFONTE CIBLO 2008 - homepage custom script
 *
 * @author: T. Lecavelier
 * Mainly based on a script by C. Porteneuve.
 *
 * require prototype 1.6
 */

function initCarousel() {
  $('carouselPusher').toggle();
  var carousel = new UI.Carousel3D('carousel', { width: 350, height: 150, clickToRoll: true });
}

function initPortfolio() {
  var base = $('miniPortfolio');
  if (!base) return;
  var list = base.down('ul'), item = list.down('li'), itemWidth = item.getWidth() + parseInt(item.getStyle('padding-right'), 10);
  var width = list.select('li').length * itemWidth;
  list.setStyle('width: ' + width +'px; height: ' + item.getStyle('height') + '; left: 0px;');
  base.down('.navigationLinks').show();
  var carousel = new UI.Carousel(base, {
    previousButton: '.nav.previous', nextButton: '.nav.next', direction: 'horizontal'
  });
  base.select('.previous').invoke('observe', 'click', function(e) {
    e.stop();
    this.blur();
  });
  base.select('.next').invoke('observe', 'click', function(e) {
    e.stop();
    this.blur();
  });
}

document.observe('dom:loaded', function() {
    initCarousel();
    initPortfolio();
});
