if (KIOS == undefined) {
	var KIOS = {};
}

KIOS.Slider = new Class({

	options: {
		width: 500,
		height: 300,
		transition: Fx.Transitions.Quad.easeInOut,
		duration: 2000
	},

	curIndex: 0,
	effects: new Array(),

	initialize: function(element, options) {
		this.setOptions(options);
		this.container = $(element);
		this.container.setStyles({
			width: this.options.width,
			height: this.options.height,
			overflow: 'hidden',
			position: 'relative',
			display: 'block'
		});

		this.items = this.container.getChildren();
		this.items.each(function(item, index) {
			item.addClass('slide-item');
			item.setStyles({
//				height: this.options.height,
				width: this.options.width,
				position: 'absolute',
				top: 0,
				opacity: 0
//				left: this.options.width
			});
			// ak je to nulta polozka, dame ju hned zobrazovat
			if (index == 0) {
				item.setStyle('opacity', 0);
			}
			this.effects.push(new Fx.Style(item, 'opacity', {transition: this.options.transition}));
		}, this);
	},

	slideNext: function() {

		var outIndex = this.curIndex;

		this.curIndex += 1;
		if (this.curIndex >= this.items.length) {
			this.curIndex = 0;
		}

		this.items[outIndex].setStyle('opacity', 0);
		this.effects[this.curIndex].start(0, 1);
//		this.effects[outIndex].start(-this.options.width);
//		this.effects[this.curIndex].start(this.options.width, 0);
	},

	slidePrev: function() {

		var outIndex = this.curIndex;

		this.curIndex -= 1;
		if (this.curIndex < 0) {
			this.curIndex = this.items.length - 1;
		}

		this.items[outIndex].setStyle('opacity', 0);
		this.effects[this.curIndex].start(0, 1);
//		this.effects[outIndex].start(this.options.width);
//		this.effects[this.curIndex].start(-this.options.width, 0);
	}
});

KIOS.Slider.implement(new Options);

KIOS.kios_layout = {

	'init': function() {
		try {
			var obj = $('anim-odrazky');
			if (obj) {
				obj = obj.getFirst(); // ul-ko v div-e
				KIOS.slider = new KIOS.Slider(obj, {width: 775, height: 50});
				KIOS.timer = KIOS.slider.slideNext.periodical(3000, KIOS.slider);
			}
		} catch (err) {
		}
	}
};


function blinkAll(cssclass, farba, farba2, cas) {

	var pole = $$('.' + cssclass);
	
	pole.each(function (item) {
		item.setStyle('color', farba);
	});
	if (pole.length > 0) {
		setTimeout('blinkAll("' +  cssclass + '","' + farba2 + '","' + farba + '",' + cas + ')', cas);
	}
}


window.addEvent('domready', KIOS.kios_layout.init);
window.addEvent('domready', function() { blinkAll('blink', 'green', 'red', 600) });

