var BF_MoviePlayer = new Class({

	options : {},

	initialize : function(element, options)
  {
    if ( this.container = $(element) ) {
			this.setOptions(options);

			this._initializeLinkList();

			window.addEvent('domready', this._AJAXgetMovie.bind(this));
		}; // endif
	},

	_initializeLinkList : function()
	{
		if ( this.list = $(this.options.list) ) {
			this.list.getElements('a.spot_link').each(function(el_a) {
				el_a.addEvent('click', function(e) {
					e.stop();
					BF_MP._AJAXgetMovie(this.get('name').replace("spot_link_","").toInt());
				}); // addEvent
			}.bind(this)); // each
		}; // endif
	},

	_AJAXgetMovie : function( spot_id )
	{
		if ( this.options.script_url != "" ) {
			this.data = {
				doc_lang: this.options.language,
				spot_id: $defined(spot_id) && 0 < spot_id ? spot_id : this.options.current,
				type: this.options.type
			};

			new Request.HTML({
				url: this.options.script_url,
				method: 'post',
				onRequest: function() { this.container.addClass('loading'); }.bind(this),
				onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript) {
					this.container.setHTML(responseHTML).removeClass('loading');
					if ( ( info = $$('div.info')[0] ) && ( new_info = this.container.getElements('div.info')[0] ) )
						new_info.replaces(info).removeClass('hidden');
				}.bind(this)
			}).post(this.data);
		}; // endif
	}

});
BF_MoviePlayer.implement(new Options());
