
 
//http://viphttp.yacast.net/msn/_special/silverlight/iceage3_sl.wmv

function get_mediainfo(mediainfoIndex) {
    switch (mediainfoIndex) {        

        case 0:
            return  { "mediaUrl": "http://viphttp.yacast.net/msn/_special/silverlight/iceage3_sl.wmv",
                      "placeholderImage": "",
                      "chapters": [               
                                  ] };                                                                
                          
        default:
             throw Error.invalidOperation("No such mediainfo");
     }
}

function StartWithParent(parentId, appId) {
    new StartPlayer_0(parentId);
}

function StartPlayer_0(parentId) {
    this._hostname = EePlayer.Player._getUniqueName("xamlHost");
    Silverlight.createObjectEx( {   source: 'player.html', 
                                        parentElement: $get(parentId ||"divplayer_0"), 
                                        id:this._hostname, 
                                        properties:{ width:'1000', height:'635', version:'1.0', background:'transparent', isWindowless:'true' }, 
                                        events:{ onLoad:Function.createDelegate(this, this._handleLoad) } } );
    this._currentMediainfo = 0;      
}
StartPlayer_0.prototype= {
    _handleLoad: function(plugIn) {
        this._player = $create(   ExtendedPlayer.Player, 
                                  { // properties
                                    autoPlay    : true, 
                                    volume      : 1.0,
                                    muted       : false
                                  }, 
                                  { // event handlers
                                    mediaEnded: Function.createDelegate(this, this._onMediaEnded),
                                    mediaFailed: Function.createDelegate(this, this._onMediaFailed)
                                  },
                                  null, $get(this._hostname)  ); 
		
	// Bouton plein Ecran
		plugIn.Content.findName('FullScreen').addEventListener("MouseEnter", Function.createDelegate(this,this._FullscreenRollOver));
		plugIn.Content.findName('FullScreen').addEventListener("MouseLeave", Function.createDelegate(this,this._FullscreenRollOut));
		plugIn.Content.findName('FullScreen').addEventListener("MouseLeftButtonUp", Function.createDelegate(this,this._FullscreenOn));
	// Bouton Votez pour Scrat
		plugIn.Content.findName('btn').addEventListener("MouseEnter", Function.createDelegate(this,this._btn_RollOver));
		//plugIn.Content.findName('btn').addEventListener("MouseLeave", Function.createDelegate(this,this._btn_RollOut));
		plugIn.Content.findName('btn').addEventListener("MouseLeftButtonUp", Function.createDelegate(this,this._btn_Click));
	
		plugIn.Content.findName('intro').addEventListener("Completed", Function.createDelegate(this,this._playNextVideo));
		
		//this._playNextVideo();     
    },    
    _onMediaEnded: function(sender, eventArgs) {
        window.setTimeout( Function.createDelegate(this, this._playNextVideo), 1000);
    },
    _onMediaFailed: function(sender, eventArgs) {
        alert(String.format( Ee.UI.Xaml.Media.Res.mediaFailed, this._player.get_mediaUrl() ) );
    },
    _playNextVideo: function() {
        var cVideos = 1;
        if (this._currentMediainfo<cVideos)
            this._player.set_mediainfo( get_mediainfo( this._currentMediainfo++ ) );    
    },        
	// Fonction btn_histoire
	_FullscreenRollOver: function(sender, mouseEventArgs) { sender.findname("FullScreen_MouseEnter").Begin(); },
	_FullscreenRollOut: function(sender, mouseEventArgs) { sender.findname("FullScreen_MouseLeave").Begin(); },
	_FullscreenOn: function(sender, mouseEventArgs) { var plugin = sender.getHost(); plugin.content.fullScreen = !plugin .content.fullScreen; },
	// Fonction btn_histoire
	_btn_RollOver: function(sender, mouseEventArgs) { sender.findname("bouton").Begin(); },
	_btn_RollOut: function(sender, mouseEventArgs) { sender.findname("histoire_off").Begin(); },
	_btn_Click: function(sender, mouseEventArgs) { window.open("http://battles.fr.msn.com/personnagesdecinema/StarsBattles.aspx?cateId=440"); }
}
