var mxRotate = {
	_time	: 8000,
	_img	: [],
	_pos	: false,
	ini		: function(i) {
		var data = this._img[i];
		data.styles = { position: 'absolute', zIndex: 0, opacity: 0, display: 'block' };
		new Element( 'img', data ).inject( $('rotate') );
	},
	add		: function(obj) { this._img[ this._img.length ] = obj; },
	go		: function() {
	  var arr = $('rotate').getChildren();
	  if( this._img.length < 2 || !arr[0] ) return;
	  var time = this._time;
	  var half = time / 2;
	  if( this._pos === false ) {
 			this._pos = 0;
	    var dim = [ arr[0].offsetWidth, arr[0].offsetHeight ];
	    arr[0].setStyles( { width : dim[0], height : dim[1], position : 'absolute', zIndex : 1, opacity : 1, display : 'block' } );
	    $('rotate').setStyles( { width : dim[0], height : dim[1], overflow : 'hidden' } );
 			this.ini( 1 );
	  } else {
	  	var i = this._pos;
	  	var n = this._img[i+1] ? i+1 : 0;
			new Fx.Morph( arr[i], { duration: half - 1000, transition: Fx.Transitions.easeOut } ).start( { opacity : 0, zIndex : 0 } );
			new Fx.Morph( arr[n], { duration: half, transition: Fx.Transitions.easeIn } ).start( { opacity : 1, zIndex : 1 } );
		  this._pos = n;
		  this.ini( this._img[n+1] ? n+1 : 0 );
		}		
	  window.setTimeout( function() { mxRotate.go(); }, ( this._pos === false ) ? half : time );	  		
	}
}
window.addEvent( 'domready', function() { mxRotate.go(); } );
