// JavaScript Document
extJS = {};
extJS = {
	
	flash_id: 'slideshow',
	_receivers: [],
	
	get_flash: function( $id ){
		return document.getElementById( $id );
	},
	sendAS: function( $method, $data ){
		/**
		 * Method is used by flash to help delegate what should be
		 * done with this function.
		 */
		if( !$method )
			$method = 'default';
			
		var obj 	= 	new Object();
		obj.method 	= 	$method;
		obj.data	=	$data;
		
		this.get_flash(this.flash_id).receiveJS( obj );
	},
	receiveAS: function( $object ){
		/**
		 * This is the receiver for FromFlash calls.
		 * We must add receivers first with a method
		 * name and callback function. Upon call from
		 * Flash, we'll execute whatever function it
		 * requests.
		 *
		 * extJS.addReceiver( 'MSN_Connected' , 
				  [function] );
		 *
		 * If Flash sends "MSN_Connected," the above
		 * function will be executed (with data passed).
		 */
		var method 	= 	$object.method;
		var data	=	$object.data;
		
		this._receivers[method](data);				
	},
	addReceiver: function ( $method, $data ){
		/**
		 * Add a function to our list assigned by method
		 * name
		 */
		this._receivers[$method] = $data;
	},
	removeReceiver: function( $method ){
		this._receivers[$method] = function(){};
	}
};

//extJS.addReceiver( 'MSN_Connected' , 
//				  function(){extJS.sendAS( 'hithere', 'crackers' );} );

//extJS.addReceiver( 'bah' , function(data){alert( 'imidiot ' + data );	} );