﻿anim = {
	qtos : null,
	topo : null,
	prox : null,
	itvl : null,
	hdlr : null,
	xchg : function(e){
		if ('undefined' != typeof e) {
			clearInterval(this.hdlr);
			this.init();
		}
		if (e != this.topo) {
			var prxm = e || this.prox();
			Ext.get('c-'+this.topo).stopFx().sequenceFx().setVisible(Ext.Element.DISPLAY).hide({duration: 1}).removeClass('vis');
			Ext.get('s-'+this.topo).stopFx().animate(
				{
					backgroundColor:{from: '#aa0000', to: '#c66a22'}
				}, 1, null, 'easeIn', 'color'
			);
			this.topo = prxm;
			Ext.get('s-'+this.topo).stopFx().animate(
				{
					backgroundColor:{from: '#c66a22', to: '#aa0000'}
				}, 1, null, 'easeIn', 'color'
			);
			Ext.get('c-'+this.topo).stopFx().sequenceFx().setVisible(Ext.Element.DISPLAY).show({duration: 1}).radioClass('vis');
		}
	},
	trans: new Ext.util.DelayedTask(this.xchg, this),
	init: function(i) {
		this.qtos = this.qtos || Ext.query('#cartazes div').length;
		this.topo = this.topo || parseInt(Ext.query('#bt-cartazes span.sel')[0].id.match(/-(\d+)/)[1]);
		this.prox = this.prox || function() {return ((this.topo + 1) % (this.qtos + 1)) || 1};
		this.itvl = i || this.itvl || 10000;
		this.hdlr = setInterval('anim.trans.delay(200,anim.xchg,anim,[anim.prox()])', this.itvl);
	}
}


