﻿/* 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":"203-4.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			'new Sys.UI.Silverlight.MediaChapter("ALKOI",0,"203-4_0.000.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("4",63.24,"203-4_63.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("5",90.12,"203-4_90.120.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("7",109.16,"203-4_109.160.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("8",235.72,"203-4_235.720.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("9",294.92,"203-4_294.920.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("10",374.72,"203-4_374.720.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("11",538.88,"203-4_538.880.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("12",552.56,"203-4_552.560.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("13",636.92,"203-4_636.920.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("14",703.04,"203-4_703.040.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("15",794.24,"203-4_794.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("16",839.84,"203-4_839.840.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("17",853.52,"203-4_853.520.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("18",903.68,"203-4_903.680.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("19",1013.12,"203-4_1013.120.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("20",1074.68,"203-4_1074.680.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("21",1111.16,"203-4_1111.160.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("22",1138.52,"203-4_1138.520.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("23",1165.88,"203-4_1165.880.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demo1",1206.92,"203-4_1206.920.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("pois",1406.68,"203-4_1406.680.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("24",1427.96,"203-4_1427.960.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("25",1472.76,"203-4_1472.760.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("26",1496.28,"203-4_1496.280.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demo2",1543.32,"203-4_1543.320.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("pois",1833.44,"203-4_1833.440.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("27",1842.56,"203-4_1842.560.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("28",1957.92,"203-4_1957.920.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demo3",1998.24,"203-4_1998.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("29",2214.84,"203-4_2214.840.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("30",2271.84,"203-4_2271.840.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("31",2301.48,"203-4_2301.480.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demo4",2399.52,"203-4_2399.520.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("31",2569.72,"203-4_2569.720.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("32",2597.32,"203-4_2597.320.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demo5",2668.08,"203-4_2668.080.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("pois",3400.8,"203-4_3400.800.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("loppui",3406.4,"203-4_3406.400.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("loppui",3442.84,"203-4_3442.840.jpg")'+
			']}'+
		'];' ); 
    }
    catch(e){}

    this._galleryItems=[];
    try {
        eval( 'this._galleryItems=['+
		'new ExpressionPlayer.GalleryItem("203-4.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);
}

