﻿/* 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-2.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			'new Sys.UI.Silverlight.MediaChapter("alkoiko",0,"203-2_0.000.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("Alkoiko nyt",84.36,"203-2_84.360.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("2",147.32,"203-2_147.320.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("3",169.72,"203-2_169.720.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("4",213.4,"203-2_213.400.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("5",277.24,"203-2_277.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demoko",355.64,"203-2_355.640.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("poisko",586.36,"203-2_586.360.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("6",634.24,"203-2_634.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("7",668.44,"203-2_668.440.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("demoonko",736.84,"203-2_736.840.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("poisko",862.24,"203-2_862.240.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("8",905.56,"203-2_905.560.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("9",940.16,"203-2_940.160.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("10",1030.12,"203-2_1030.120.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("11",1071.64,"203-2_1071.640.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("12",1154.68,"203-2_1154.680.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("Wakaru",1206.28,"203-2_1206.280.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("2",1282.96,"203-2_1282.960.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("4",1393.44,"203-2_1393.440.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("5",1689.28,"203-2_1689.280.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("6",1861.28,"203-2_1861.280.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("7",1902.56,"203-2_1902.560.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("8",2009.2,"203-2_2009.200.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("9",2126.16,"203-2_2126.160.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("10",2167.44,"203-2_2167.440.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("11",2225.92,"203-2_2225.920.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("12",2267.2,"203-2_2267.200.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("13",2386.32,"203-2_2386.320.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("14",2484.32,"203-2_2484.320.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("15",2539.36,"203-2_2539.360.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("16",2597.84,"203-2_2597.840.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("17",2663.2,"203-2_2663.200.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("19",2714.8,"203-2_2714.800.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("20",2732,"203-2_2732.000.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("destia",2752.76,"203-2_2752.760.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("2",2773.52,"203-2_2773.520.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("3",2801.2,"203-2_2801.200.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("4",2856.56,"203-2_2856.560.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("5",3029.52,"203-2_3029.520.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("6",3112.08,"203-2_3112.080.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("7",3257.4,"203-2_3257.400.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("8",3354.28,"203-2_3354.280.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("9",3395.8,"203-2_3395.800.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("10",3492.68,"203-2_3492.680.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("qa",3585.68,"203-2_3585.680.jpg"),'+
			'new Sys.UI.Silverlight.MediaChapter("loppui",3680.16,"203-2_3680.160.jpg")'+
			']}'+
		'];' ); 
    }
    catch(e){}

    this._galleryItems=[];
    try {
        eval( 'this._galleryItems=['+
		'new ExpressionPlayer.GalleryItem("203-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);
}

