﻿/* 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":"3 Way.wmv",'+
		'"placeholderSource":"3 Way_Thumb.jpg",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Aileen.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Angels Farm.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Cigar.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Crazy Horse.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Dental.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Dental Chair.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"DrAngel.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Drummers.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Greeting Band.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Greeting Bus.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Horse.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Jhett RH.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Lagoon.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Lahar.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Leaving Romblon.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Mt. Fuji.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Old Hospital.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Patangas Prov.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Pinatabu driver.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Pool.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Quaint Cafe.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Raina H.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Raina Teaching.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Romblon Hospital.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"School Kids.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Shool Ed DrO.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"Smart kid.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']},'+
		'{"mediaSource":"The Gang.wmv",'+
		'"placeholderSource":"",'+
		'"chapters":'+
			'['+
			']}'+
		'];' ); 
    }
    catch(e){}

    this._galleryItems=[];
    try {
        eval( 'this._galleryItems=['+
		'new ExpressionPlayer.GalleryItem("3 Way.wmv","3 Way_Thumb.jpg"),'+
		'new ExpressionPlayer.GalleryItem("Aileen.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Angels Farm.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Cigar.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Crazy Horse.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Dental.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Dental Chair.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("DrAngel.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Drummers.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Greeting Band.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Greeting Bus.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Horse.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Jhett RH.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Lagoon.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Lahar.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Leaving Romblon.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Mt. Fuji.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Old Hospital.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Patangas Prov.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Pinatabu driver.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Pool.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Quaint Cafe.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Raina H.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Raina Teaching.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Romblon Hospital.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("School Kids.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Shool Ed DrO.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("Smart kid.wmv",""),'+
		'new ExpressionPlayer.GalleryItem("The Gang.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);
}

