var ddSlider = new Class({
	
	initialize: function(sliderId) {

		
		this.slider = $(sliderId);
		this.sliderId = sliderId;

		/* fetch elements */
		this.elements = $$('#' + this.sliderId + ' div.sliderElement');
		this.texts = new Array();
		/* first element is active element */
		this.activeElement = this.elements[0];
		this.activeIndex = 0;
		
		/* first hide all except first element */
		for (c=0; c<this.elements.length; c++) {
			if (c) {
				this.elements[c].fade('hide');
			}
			this.texts.push(this.elements[c].getChildren('div.sliderText'));

		}
		
		this.slideInterval = this.slide.periodical(4000, this);
		
	},
	
	slide: function() {
		var fadeOut = new Fx.Tween(this.activeElement, 
			{
				duration: 2000,
				property: 'opacity'
			}).start(0);
		
		this.activeIndex = ((this.activeIndex+1)==this.elements.length)?0:(this.activeIndex+1);
		this.activeElement = this.elements[this.activeIndex];
		var fadeIn = new Fx.Tween(this.activeElement, 
			{
				duration: 2000,
				property: 'opacity'
			}).start(1);
		
	}
	
	
});

window.addEvent('domready', initSlider);
function initSlider() {
	homeSlider = new ddSlider('slider');
	
}
