Element.implement({
	'bibber':function(array, otherEl)
	{
		this.items = array;
		this.otherEl = otherEl;
		
		if( !this.intCurrentItem)
		{
			this.intCurrentItem = 0;
		};
		
		this.orgPosition = this.getStyle('position');
		this.setStyle('position','absolute');
		
		this.orgX = this.getStyle('left').toInt();
		this.orgY = this.getStyle('top').toInt();
			
		if( !$type( this.orgX ) ){ this.orgX = 0; }
		if( !$type( this.orgY ) ){ this.orgY = 0; }

		this.start = function(){			
			this.bX = this.items[this.intCurrentItem][0];
			this.bY = this.items[this.intCurrentItem][1]
			this.setStyle('position','absolute');
			
			
			this.stopId = setInterval( this.stop.bind(this), this.items[this.intCurrentItem][2] );
			this.onEnterFrameId = setInterval( this.onEnterFrame.bind(this), 50 );
		}.bind(this);
		
		this.stop = function(){
			clearInterval( this.stopId );
			clearInterval( this.onEnterFrameId );
			
			this.setStyle('left', this.orgX );
			this.setStyle('top', this.orgY );
			this.setStyles({'position':this.orgPosition});
			
			if( this.intCurrentItem >= ( this.items.length )-1 )
			{
				this.intCurrentItem = false;
			}
			else
			{
				this.intCurrentItem++;
				this.start();
			}
		}.bind(this);
		
		this.onEnterFrame = function(){	
			var x = this.orgX + (Math.random() * (this.bX * 2) - this.bX);
			var y = this.orgY + (Math.random() * (this.bY * 2) - this.bY);
		
			this.setStyle('left', x );
			this.setStyle('top', y );
			
			//this.otherEl.setStyle('left', x );
			//this.otherEl.setStyle('top', y );
		}.bind(this);
		
		this.start();
	}
});


