var Hero = new Class( {
	
	  hardpoint:	null
	, heroes:		new Array( )
	, cursor:		0
	, hold:			false
	, timer:		null
	, interval:		10000
	
	, isPaused:		function( ) { return this.hold; }
	
	, initialize:	function( hardpoint ) {
	 	this.hardpoint = $( hardpoint );
	 	if( !this.hardpoint ) {
	 		log( 'No hero found for hardpoint: `'+hardpoint+"'" );
	 	}
	  }
	
	, start:		function( ) {
		this.rotate( );
	  }
	
	, swap:			function( toCursor ) {
		if( this.shouldSwap( toCursor ) ) {
			this.didBeginSwap( );
				var nextHero = this.getHero( toCursor );
				nextHero.replaces( this.hardpoint );
				this.hardpoint = nextHero;
				this.cursor = toCursor;
			this.didEndSwap( );
		}
	  }
	
	, next:			function( ) {
		this.swap( this.getNextCursor( ) )
	  }
	
	, jump:			function( toCursor ) {
		this.swap( toCursor );
	  }
	
	, rotate:		function( ) {
		clearTimeout( this.timer );
		this.timer = setTimeout( this.next.bind( this ), this.interval );
	  }
	
	, pause:		function( ) {
		this.hold = true;
		clearTimeout( this.timer );
	  }
	
	, resume:		function( ) {
		this.hold = false;
		this.rotate( );
	  }
	
	, callOrder:	0
	, load:			function( uri ) {
		this.heroes[ this.callOrder ] = null;
		var img = new Image( );
		img.callOrder = this.callOrder;
		img.onload = bind(
			  this
			, this.heroDidLoad
			, img
		);
		img.src = auri( uri );
		this.callOrder++;
	  }
	
	, heroDidLoad:	function( img ) {
		this.heroes[ img.callOrder ] = $( img );
	  }
	
	, addHero:		function( uri ) {
		this.load( uri );
	  }
	
	, hasHero:		function( which ) {
		return ( this.heroes[ which ] !== null );
	  }
	
	, getHero:		function( which ) {
		return this.heroes[ which ];
	  }
	
	, getCurrentHero: function( ) {
		return this.getHero( this.cursor );
	  }
	
	, getNextHero: function( ) {
		return this.getHero( this.getNextCursor( ) );
	  }
	
	, getNextCursor: function( ) {
		if( this.cursor == this.heroes.length - 1 ) {
			cursor = 0;
		}
		else {
			cursor = this.cursor + 1;
		}
		
		return cursor;
	  }
	
	, shouldSwap:	function( toCursor ) {
		if( !this.isPaused( )
		&& this.hasHero( toCursor )
		&& this.cursor !== toCursor ) {
			return true;
		}
		
		return false;
	  }
	
	, didBeginSwap:	function( ) { }
	
	, didEndSwap:	function( ) {
		this.rotate( );
	  }
	
} );
