﻿/* Do not remove this commented code. This is compiled by Expression Encoder at template compile time.


 
*/


function rgbToHex(rgb)
{
	var strHex="0123456789ABCDEF";
	var ichBracket=rgb.indexOf("(");
	if (ichBracket!=-1) {
		var rgstr = rgb.substr(ichBracket+1, rgb.length-ichBracket-2).split(',');
		rgb = "#"+ strHex[parseInt(rgstr[0])>>4]+strHex[parseInt(rgstr[0])%16]+
			   strHex[parseInt(rgstr[1])>>4]+strHex[parseInt(rgstr[1])%16]+
			   strHex[parseInt(rgstr[2])>>4]+strHex[parseInt(rgstr[2])%16];
	}
	return rgb;
}


function StartPlayer_0(parentId) {
    try {
    	eval('document.body.style.backgroundColor="#000000"');
    } catch(e){}

    this._hostname = ExpressionPlayer.Player._getUniqueName("xamlHost");
    Silverlight.createObjectEx( {   source: 'player.xaml', 
                                    parentElement: $get(parentId ||"divPlayer_0"), 
                                    id:this._hostname, 
                                    properties:{ width:'100%', height:'100%', version:'1.0', background:rgbToHex(document.body.style.backgroundColor), isWindowless:'false', inplaceInstallPrompt:true }, 
                                    events:{ onLoad:Function.createDelegate(this, this._handleLoad) } } );
    this._currentMediainfo = -1;     
}
StartPlayer_0.prototype= {
    _handleLoad: function() {
        this._player = $create(   ExtendedPlayer.Player, 
                                  { // properties
                                    autoPlay       : this.autoPlayParam(), 
                                    autoLoad       : this.autoLoadParam(),
				    scaleMode 	   : this.scaleModeParam(),
                                    muted          : this.mutedParam(),
				    enableCaptions : this.enableCaptionsParam(),
                                    volume         : 1.0
                                  }, 
                                  { // event handlers
                                    mediaEnded: Function.createDelegate(this, this._onMediaEnded),
                                    mediaFailed: Function.createDelegate(this, this._onMediaFailed),
                                    playPreviousVideo: Function.createDelegate(this, this._onPlayPreviousVideo),
                                    playNextVideo: Function.createDelegate(this, this._onPlayNextVideo)
                                  },
                                  null, $get(this._hostname)  );   

    this._playlist=[];
    try {
        eval( 'this._playlist=['+
		'{"mediaSource":"216-2.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			'new Sys.UI.Silverlight.MediaChapter("alkoi",0,"216-2_0.000.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("2",2.52,"216-2_2.520.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("3",47.32,"216-2_47.320.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("4",49.84,"216-2_49.840.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("5",91.12,"216-2_91.120.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("6",173.68,"216-2_173.680.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("7",235.6,"216-2_235.600.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("8",328.48,"216-2_328.480.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("9",445.44,"216-2_445.440.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("10",500.48,"216-2_500.480.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demo1",634.64,"216-2_634.640.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("pois",1349.2,"216-2_1349.200.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("11",1501.96,"216-2_1501.960.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("12",1577.2,"216-2_1577.200.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("13",1634.2,"216-2_1634.200.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("14",1768.72,"216-2_1768.720.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("15",1825.72,"216-2_1825.720.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("16",2039,"216-2_2039.000.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("17",2111.24,"216-2_2111.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("18",2197.24,"216-2_2197.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("19",2279.8,"216-2_2279.800.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("20",2417.4,"216-2_2417.400.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demo2",2513.72,"216-2_2513.720.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("pois",3504.44,"216-2_3504.440.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("21",3590.44,"216-2_3590.440.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("23",3617.96,"216-2_3617.960.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("24",3645.48,"216-2_3645.480.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("25",3693.64,"216-2_3693.640.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("loppui",3746.12,"216-2_3746.120.jpg")'+
			']}'+
		'];' ); 
    }
    catch(e){}

    this._galleryItems=[];
    try {
        eval( 'this._galleryItems=['+
		'new ExpressionPlayer.GalleryItem("216-2.wmv","")'+
		'];' ); 
    }
    catch(e){}

    this._player.set_galleryInfo( this._galleryItems, Function.createDelegate(this, this._onClickGalleryItem) );  
    this._onPlayNextVideo(null,null);                                        
    },
    
    _onClickGalleryItem : function (galleryItemIndex) {
        this._player.set_mediainfo( this._playlist[ galleryItemIndex ] ); 
        this._currentMediainfo = galleryItemIndex+1;
    },

    _onMediaEnded: function(sender, eventArgs) {
        window.setTimeout( Function.createDelegate(this, this._onPlayNextVideo), 1000);
    },
    
    _onMediaFailed: function(sender, eventArgs) {
        alert(String.format( Sys.UI.Silverlight.MediaPlayer.Res.mediaFailed, this._player.get_mediaSource() ) );
    },
      

    _onPlayPreviousVideo: function(sender, eventArgs) {
        if (this._playlist!=null) {
            if (this._currentMediainfo>0) {
                this._player.set_mediainfo( this._playlist[ --this._currentMediainfo ] );    
            }
        }        
    },
    
    _onPlayNextVideo: function(sender, eventArgs) {
        if (this._playlist!=null) {
            if (this._currentMediainfo<this._playlist.length-1) {                
                this._player.set_mediainfo( this._playlist[ ++this._currentMediainfo ] );                    
            }
        }
    },
    
    autoLoadParam: function() {
	    var autoLoad=true;
	    try {
		    eval("autoLoad=('True'!=='False')");
	    } catch(e){}
	    return autoLoad;
    },  
    
    autoPlayParam: function() {
	    var autoPlay=true;
	    try
	    {
		    eval("autoPlay=('True'!=='False')");
	    } catch(e){}
	    return autoPlay;
    },  
    
    scaleModeParam: function() {
	    var scaleMode = 1/*Normal*/;
	    try {
		    eval("scaleMode=1;");
	    } catch(e){}
	    return scaleMode;
    },

    enableCaptionsParam: function() {
	    var enableCaptions=true;
	    try {
		    eval("enableCaptions=('True'!=='False');");
	    } catch(e){}
	    return enableCaptions;
    },

    mutedParam: function() {
	    var muted=false;
	    try {
		    eval("muted=('False'!=='False');");
	    } catch(e){}
	    return muted;
    }
}

function StartWithParent(parentId, appId) {
    new StartPlayer_0(parentId);
}

