/**
 * @author Victor Zamfir <victor.zamfir@skipvine.ro>
 */

var vzTabs = new Class({
  Implements: [Options],
  initialize: function(options)
  {
    this.setOptions(options);
    this.current = this.options.current ? this.options.current : this.options.handlers[0];
    this.createLinks();
    this.makeActive(this.current);
  },
  createLinks: function()
  {
    this.options.handlers.each(function(handler, position) {
      handler.store('description', this.options.descriptions[position]);
      handler.addEvent('click', function(ev) {
        ev.stop();
        this.swapWith(ev.target);
      }.bindWithEvent(this));
    }, this);
  },
  swapWith: function(handler)
  {
    this.makeInactive(this.current);
    this.makeActive(this.current = handler);
  },
  makeActive: function(handler)
  {
    handler.addClass('active');
    handler.retrieve('description').addClass('displayed');
  },
  makeInactive: function(handler)
  {
    handler.removeClass('active');
    handler.retrieve('description').removeClass('displayed');
  }
})

window.addEvent('domready', function(){
  
  if ($('content_rotator'))
  {
    new noobSlide({
      autoPlay: true,
      box: $('content_rotator').getElement('.block-content-wrapper'),
      items: $$('#content_rotator .block-content-wrapper .block-content'),
      size: 620,
      handles: $$('#content_rotator_controls span'),
      onWalk: function(currentItem,currentHandle){
        this.handles.removeClass('active');
        currentHandle.addClass('active');
      },
      interval: 10000
    });
  }
  
  if ($$('body.services').length)
  {
    new vzTabs({
      handlers: $$('#services_navigation li a'),
      descriptions: $$('#services_description .service-description')
    });
  }
	
	if ($$('body.portfolio').length)
	{
		new Lightbox();
	}
  
})