/* class */ function PTEMapHome( ) {
	PTEMap.apply( this, [] );
}

extend( PTEMapHome.prototype, PTEMap.prototype );
extend( PTEMapHome.prototype, {
	  heroes				: new Array( null )
	, mast					: null
	, last					: 0
	, setMast				: function( obj ) {
		this.mast = obj;
		return this;
	  }
	, getHeroName			: function( n ) {
		return 'hero_' + n + '.jpg';
	  }
	, getHeroPath			: function( n ) {
		return auri( this.imgd + this.getHeroName( n ) );
	  }
	, getHero				: function( ) {
		return getObj( 'hero' );
	  }
	, preload				: function( ) {
		PTEMap.prototype.preload.call( this );
		
	  	for( var i = 0; i <= kPTENumRegions; i++ ) {
	  		this.heroes[ i ] = new Image( );
	  		this.heroes[ i ].src = this.getHeroPath( i );
	  	}
	  }
	, toggleOn				: function( n ) {
		this.mast.pause( );
		PTEMap.prototype.toggleOn.call( this, n );
		this.getHero( ).src = this.heroes[ n ].src;
		
		this.last = n;
	  }
	, toggleOff				: function( ) {
		this.mast.resume( this.last );
	  }
} );

var pte = new PTEMapHome( );
pte.preload( );

window.addEvent( 'domready', pte.attach );



var DartHero = new Class( {
	
	  pte:			null
	, interval:		5000
	
	, Extends: Hero
	
	, initialize:	function( hardpoint ) {
		this.parent( hardpoint );
		this.pte = new PTEMap( );
	  }
	
	, addHero:		function( uri ) {
		var img = new Image( );
		img.src = uri;
		this.heroes.push( img );
	  }
	
	, resume:		function( which ) {
		this.cursor = which;
		this.parent( );
	  }
	
	, didBeginSwap:	function( ) {
		this.pte.toggleOn( this.getNextCursor( ) );
	  }
	
} );

function bootstrap_banner( ) {
	if( !isset( 'MooTools' ) ) {
		return;
	}
	
	var Hero = new DartHero( 'hero' );
	
	pte.heroes.each(
		  function( hero, i ) {
		  	if( hero ) {
			  	this.addHero( hero.src );
			}
		  }
		, Hero
	);
	
	pte.setMast( Hero );
	Hero.start( );
}

window.addEvent( 'domready', bootstrap_banner );