//ő
var icCarousel = new Class({
	setOptions: function(options) {
		this.options = Object.extend({
			speed: 1000,
			delay: 5000,
			direction: 'horizontal',
			onComplete: Class.empty,
			onStart: Class.empty
		}, options || {});
	},
	initialize: function(el, options){
		this.setOptions(options);
		this.el = $(el);
		this.items = this.el.getElements('li');
		var w = 0;
		var h = 0;
		this.current = 0;
		
		h = this.el.getSize().size.y;
		this.items.each(function(li, index){
			w += li.getSize().size.x;
		});
		this.scrollFx = new Fx.Scroll('carouselScroller', {
			wait: false,
			duration: 1100,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Quad.easeInOut
		});
		icCarouselTimer = this.next.bind(this).delay(this.options.delay+this.options.speed);

	},
	previous: function() {
	    $clear(icCarouselTimer);
	    icCarouselTimer = null;
		this.current--;
		if(this.current < 0)this.current = this.items.length;
		this.scrollFx.scrollTo(675*this.current,0);
		icCarouselTimer = this.next.bind(this).delay(this.options.delay+this.options.speed);
	},
	next: function() {
	    $clear(icCarouselTimer);
	    icCarouselTimer = null;
		this.current++;
		if(this.current >= this.items.length)this.current = 0;
		this.scrollFx.scrollTo(675*this.current,0);
		icCarouselTimer = this.next.bind(this).delay(this.options.delay+this.options.speed);
/*
		this.current++;
		if (this.current >= this.items.length) this.current = 0;
		var pos = this.items[this.current];
		this.fx.start({
			top: -pos.offsetTop,
			left: -pos.offsetLeft
		});
		icCarouselTimer = this.next.bind(this).delay(this.options.delay+this.options.speed);
*/
	}
});

var icCarouselTimer = null;

window.addEvent('domready', function() {
   var carousel = new icCarousel('icCarouselContainer', {
      speed : 500, delay : 4500, direction : 'horizontal'});
    $('carouselButtonPrevious').addEvent('click', function() {
		carousel.previous();
	});
    $('carouselButtonNext').addEvent('click', function() {
		carousel.next();
	});
});
	