var stopScripts = true;

var Acc = new Class({
	options:{
		period:5000
	},
	initialize: function(main_id , handler_class , box_class){
		var $this = this;
		this.togglers = $$(handler_class);
		this.counter = 0;
		this.ac = new Accordion($(main_id), handler_class, box_class, {
			opacity:false,
			onActive: function(toggler, element){
				toggler.className = 'accTogglerH'
			},
			onBackground: function(toggler, element){
				toggler.className = 'accToggler';
				$this.counter = this.previous+1;
			}
		});
		this.accTimer = (function(){
			$this.fireDelay();
		}).periodical(this.options.period);
		$(main_id).addEvents({
			'mouseenter': function(){
				$clear($this.accTimer);
			},
			'mouseleave': function(e){
				ev = new Event(e);
				ev.stopPropagation();
				$this.accTimer = (function(){
					$this.fireDelay();
				}).periodical($this.options.period);
			}
		});
		//this.makeEv();
	},
	makeEv: function(){
		var $this = this;
		this.togglers.each(function(item){
			item.addEvent('mouseenter',function(ev){
				$clear($this.accTimer);
				ev.stop();
				item.fireEvent('click');
			});
		})
	},
	fireDelay: function(){
		if(stopScripts)
			return;
		if(this.counter<this.togglers.length){
			this.togglers[this.counter].fireEvent('click');
			//this.counter++;
			return;
		}
		if(this.counter>=this.togglers.length){
			this.counter=0;
			this.togglers[this.counter].fireEvent('click');
			//this.counter++;
		}
	}
});
Acc.implement(new Options);
