var rotator = new Class({
	
	options: {
		rotatorDuration : 2500,
		stopped : false,
		onRotatorStart: Class.empty,
		onRotatorStop: Class.empty
	}, 
	
	initialize : function($cont, $titles, $contents, $textes, $obj) {
		this.setOptions($obj);
		this.accr = new Accordion($titles, $contents, this.options);
		this.txt = new Accordion($titles, $textes, this.options);
		this.rotate.periodical(this.options.rotatorDuration, this);
		//$cont.addEvent("mouseover", this.stop.bind(this) );
		//$titles.addEvent("click", this.stop.bind(this) );
		
		
		//$cont.addEvent("mouseout", this.start.bind(this) );
		
		
		$titles.addEvent("mouseover", this.stop.bind(this) );
		$titles.addEvent("mouseout", this.start.bind(this) );
		$contents.addEvent("mouseover", this.stop.bind(this) );
		$contents.addEvent("mouseout", this.start.bind(this) );
		$textes.addEvent("mouseover", this.stop.bind(this) );
		$textes.addEvent("mouseout", this.start.bind(this) );
	},
	
	stop : function() {
		this.fireEvent("onRStop",this.accr.previous);
		this.fireEvent("onRStop",this.txt.previous);
		this.options.stopped = true;
	},
	
	start : function() {
		this.fireEvent("onRStart",this.accr.previous);
		this.fireEvent("onRStart",this.txt.previous);
		this.options.stopped = false;
	},
	
	rotate: function() {
		if (!this.options.stopped) {
			var toShow = this.accr.previous+1;
			var toShow_ = this.txt.previous+1;
			if (toShow>this.accr.elements.length-1) {
				toShow=0;
			}
			if (toShow_>this.txt.elements.length-1) {
				toShow_=0;
			}
			this.accr.display(toShow);
			this.txt.display(toShow_);
		}
	}
	
	
});
rotator.implement(new Options);
rotator.implement(new Events);
