  /*
    Class: Uplayer
    Mootools class for initializing and controlling a uplayer
    
    MooTools options:
    * height
    * width
    * version - Version of flash player plugin to require. Defaults "9.0.114"
    * smoothing - Defaults false
    * loopPlaylist - Defaults false
    * autoplay - Defaults true
    * swf - Use an alternative swf
    * playlist - Array of playlist element objects
    * modules - Array of module object
    
    Playlist element object:
    * mediaFile - Path to FLV file
    * scaleMode - "anamorphic" | "box" | "crop"
    * firstframeImage - Path to JPG or other imageformat supported by flash. The image will be shown before the item plays
    
    Module object:
    * className - Classname of the module. IE: "DefaultControls"
    * parameters - This parameter object will be passed to the modules contructor
    
    Example:
    > uplayer = new Uplayer(document.getElement("#uplayer_container"), {'height':'300', 'width':'180', playlist:[{'mediaFile':'video.flv'}], modules:[{'className':'JavaScript'}]});
    
    
  */
  var Uplayer = new Class(
  {
    Implements: [Events, Options],
    options:
    {
      height:"200",
      width:"600",
      version:"9.0.114",
      smoothing:false,
      loopPlaylist:false,
      autoplay:true,
      swf:'/mitdr/assets/swf/uplayer2.1.swf'
    },
    initialize: function(container, options)
	{
      this.container = container;
      this.setOptions(options);
      this.swiff = new Swiff(this.options.swf, 
      {
				width:  this.options.width, 
				height: this.options.height, 
				container: container,
				version: this.options.version,
				params:
                {
                  //bgcolor: "#FFFFFF",
                  allowScriptAccess: 'sameDomain',
                  allowFullScreen: true
                },
				vars:
				{
					data: JSON.encode(this.options),
					login: false // Make this dynamic somehow when SSO is working.
				},
				callBacks:
				{
					onLoad: function()
					{
					    /*
					    Event: load
					    Fired when the player is loaded and ready
					    */
						this.fireEvent('load');
					}.bind(this),
					
					onData: function()
					{
					    this.fireEvent('data');
					}.bind(this),
					
                    onSkip: function(pos)
					{
					    /*
					    Event: skip
					    Fired when the player skips to another item in playlist
					    */
						this.fireEvent('skip', pos);
					}.bind(this),
					
                    onStateChange: function(state)
					{
						/*
					    Event: stateChange
					        Fired when the players state changes from stopped to playing to paused.
					    
					    Parameters:
					        state - the new state
					    */
						this.fireEvent('stateChange', state);
					}.bind(this),
					
					onComplete: function(state)
					{
						this.fireEvent('complete', state);
					}.bind(this),
					
					onModuleEvent: function(state)
					{
						this.fireEvent('moduleEvent', state);
					}.bind(this)
				}
			});
    },
    /*
        Function: play
    */
    play : function()
    {
      Swiff.remote(this.swiff.object, 'uplayer_play');
    },
    /*
        Function: pause
    */
    pause : function()
    {
      Swiff.remote(this.swiff.object, 'pause');
    },
    /*
        Function: skipTo
        
        Parameters:
            pos -   Position in playlist to play
    */
    skipTo : function(pos)
    {
        //alert(this.swiff.object.skipTo);
        //this.swiff.object.skipTo(pos);
        Swiff.remote(this.swiff.object, 'skipTo', pos);
    }
});

function isJavascriptReadyForFlash()
{
	return true;
}

