if(typeof jeroenwijering=="undefined"){var jeroenwijering=new Object();jeroenwijering.utils=new Object()}jeroenwijering.Player=function(a,b,c){this.configuration={backgroundcolor:"ffffff",file:"video.wmv",height:"260",image:"",backcolor:"FFFFFF",frontcolor:"000000",lightcolor:"000000",screencolor:"000000",width:"320",logo:"",overstretch:"false",showicons:"true",shownavigation:"true",showstop:"false",showdigits:"true",usefullscreen:"true",usemute:"false",autostart:"false",bufferlength:"3",duration:"0",repeat:"false",sender:"",volume:"90",link:"",linkfromdisplay:"false",linktarget:"_0"};for(itm in this.configuration){if(c[itm]!=undefined){if(itm.indexOf("color")>0){this.configuration[itm]=c[itm].substr(-6)}else{this.configuration[itm]=c[itm]}}}Silverlight.createObjectEx({source:b,parentElement:a,properties:{width:this.configuration.width,height:this.configuration.height,version:"1.0",inplaceInstallPrompt:true,isWindowless:"false",background:"#"+this.configuration.backgroundcolor},events:{onLoad:this.onLoadHandler},context:this})};jeroenwijering.Player.prototype={onLoadHandler:function(a,b,c){b.configuration.sender=c;var d=new jeroenwijering.Controller(b.configuration);var e=new jeroenwijering.View(b.configuration,d);var f=new jeroenwijering.Model(b.configuration,d,e);d.startMVC(e,f)}};jeroenwijering.Controller=function(a){this.configuration=a};jeroenwijering.Controller.prototype={startMVC:function(a,b){this.view=a;this.model=b;if(this.configuration.usemute=="true"){this.view.onVolume(0);this.view.onMute(true);this.model.goVolume(0)}else{this.view.onVolume(this.configuration.volume);this.model.goVolume(this.configuration.volume)}if(this.configuration.autostart=="true"){this.model.goStart()}else{this.model.goPause()}},setState:function(a,b){this.state=b},setLink:function(){if(this.configuration.linktarget.indexOf("javascript:")==0){return Function(this.configuration.linktarget).apply()}else{if(this.configuration.linktarget=="_1"){window.open(this.configuration.link)}else{if(this.configuration.linktarget!=""){window.location=this.configuration.link}}}},setMute:function(){if(this.configuration.usemute=="true"){this.configuration.usemute="false";this.model.goVolume(this.configuration.volume);this.view.onMute(false)}else{this.configuration.usemute="true";this.model.goVolume(0);this.view.onMute(true)}},setPlay:function(){if(this.state=="Buffering"||this.state=="Playing"){this.model.goPause()}else{this.model.goStart()}},setScrub:function(a){if(a<2){a=0}else{if(a>this.configuration.duration-4){a=this.configuration.duration-4}}if(this.state=="Buffering"||this.state=="Playing"){this.model.goStart(a)}else{this.model.goPause(a)}},setStop:function(){this.model.goStop()},setVolume:function(a){if(a<0){a=0}else{if(a>100){a=100}}this.configuration.volume=Math.round(a);this.model.goVolume(a);this.view.onVolume(a);if(this.configuration.usemute=="true"){this.configuration.usemute="false";this.view.onMute(false)}},setFullscreen:function(){var a=!this.configuration.sender.getHost().content.FullScreen;this.configuration.sender.getHost().content.FullScreen=a;jeroenwijering.utils.delegate(this.view,this.view.onFullscreen)}};jeroenwijering.View=function(a,b){this.configuration=a;this.controller=b;this.fstimeout;this.fslistener;this.display=this.configuration.sender.findName("PlayerDisplay");this.controlbar=this.configuration.sender.findName("PlayerControls");this.configuration.sender.getHost().content.onResize=jeroenwijering.utils.delegate(this,this.resizePlayer);this.configuration.sender.getHost().content.onFullScreenChange=jeroenwijering.utils.delegate(this,this.onFullscreen);this.assignColorsClicks();this.resizePlayer()};jeroenwijering.View.prototype={onBuffer:function(a){var b=this.configuration.sender;if(a==0){b.findName("BufferText").Text=null}else{a<10?a="0"+a:a=""+a;b.findName("BufferText").Text=a}},onFullscreen:function(a){var b=this.configuration.sender;var c=b.getHost().content.FullScreen;if(c){this.fstimeout=setTimeout(jeroenwijering.utils.delegate(this,this.hideFSControls),2000);this.fslistener=this.display.addEventListener("MouseMove",jeroenwijering.utils.delegate(this,this.showFSControls));b.findName("FullscreenSymbol").Visibility="Collapsed";b.findName("FullscreenOffSymbol").Visibility="Visible"}else{clearTimeout(this.fstimeout);this.display.removeEventListener("MouseMove",this.fslistener);this.controlbar.Visibility="Visible";this.display.Cursor="Hand";b.findName("FullscreenSymbol").Visibility="Visible";b.findName("FullscreenOffSymbol").Visibility="Collapsed"}this.resizePlayer()},showFSControls:function(a,b){var c=a.findName("PlayerControls");var d=b.GetPosition(c).Y;clearTimeout(this.fstimeout);this.controlbar.Visibility="Visible";this.display.Cursor="Hand";if(d<0){this.fstimeout=setTimeout(jeroenwijering.utils.delegate(this,this.hideFSControls),2000)}},hideFSControls:function(){this.controlbar.Visibility="Collapsed";this.display.Cursor="None"},onLoad:function(a){var b=this.configuration.sender;var c=b.findName("TimeSlider").Width;b.findName("DownloadProgress").Width=Math.round(c*a/100)},onMute:function(a){var b=this.configuration.sender;this.configuration.usemute=""+a;if(a){b.findName("VolumeHighlight").Visibility="Collapsed";b.findName("MuteSymbol").Visibility="Visible";b.findName("MuteOffSymbol").Visibility="Collapsed";if(this.state=="Playing"){b.findName("MuteIcon").Visibility="Visible"}}else{b.findName("VolumeHighlight").Visibility="Visible";b.findName("MuteSymbol").Visibility="Collapsed";b.findName("MuteOffSymbol").Visibility="Visible";b.findName("MuteIcon").Visibility="Collapsed"}},onState:function(a,b){var c=this.configuration.sender;this.state=b;if(b=="Buffering"||b=="Playing"||b=="Opening"){c.findName("PlayIcon").Visibility="Collapsed";c.findName("PlaySymbol").Visibility="Collapsed";c.findName("PlayOffSymbol").Visibility="Visible";if(b=="Playing"||this.configuration.showicons=="false"){c.findName("BufferIcon").Visibility="Collapsed";c.findName("BufferText").Visibility="Collapsed";if(this.configuration.usemute=="true"){c.findName("MuteIcon").Visibility="Visible"}}else{if(this.configuration.showicons=="true"){c.findName("BufferIcon").Visibility="Visible";c.findName("BufferText").Visibility="Visible"}else{c.findName("BufferIcon").Visibility="Collapsed";c.findName("BufferText").Visibility="Collapsed"}}}else{c.findName("MuteIcon").Visibility="Collapsed";c.findName("BufferIcon").Visibility="Collapsed";c.findName("BufferText").Visibility="Collapsed";c.findName("PlaySymbol").Visibility="Visible";c.findName("PlayOffSymbol").Visibility="Collapsed";if(this.configuration.showicons=="true"){c.findName("PlayIcon").Visibility="Visible"}else{c.findName("PlayIcon").Visibility="Collapsed"}}},onTime:function(a,b){var c=this.configuration.sender;var c=this.configuration.sender;var d=c.findName("TimeSlider").Width;var e=Math.round(d*a/b);if(isNaN(e)){e=0}this.configuration.duration=b;c.findName("ElapsedText").Text=jeroenwijering.utils.timestring(a);c.findName("RemainingText").Text=jeroenwijering.utils.timestring(b-a);c.findName("TimeSymbol")["Canvas.Left"]=e+4;c.findName("TimeHighlight").Width=e-2},onVolume:function(a){var b=this.configuration.sender;b.findName("VolumeHighlight").Width=Math.round(a/5)},assignColorsClicks:function(){this.display.Cursor="Hand";this.display.Background="#FF"+this.configuration.screencolor;if(this.configuration.linkfromdisplay=="false"){this.display.addEventListener("MouseLeftButtonUp",jeroenwijering.utils.delegate(this.controller,this.controller.setPlay))}else{this.display.addEventListener("MouseLeftButtonUp",jeroenwijering.utils.delegate(this.controller,this.controller.setLink))}if(this.configuration.logo!=""){this.display.findName("OverlayCanvas").Visibility="Visible";this.display.findName("OverlayLogo").ImageSource=this.configuration.logo}this.controlbar.findName("ControlbarBack").Fill="#FF"+this.configuration.backcolor;this.assignButton("Play",this.controller.setPlay);this.assignButton("Stop",this.controller.setStop);this.configuration.sender.findName("ElapsedText").Foreground="#FF"+this.configuration.frontcolor;this.assignSlider("Time",this.changeTime);this.configuration.sender.findName("DownloadProgress").Fill="#FF"+this.configuration.frontcolor;this.configuration.sender.findName("RemainingText").Foreground="#FF"+this.configuration.frontcolor;this.assignButton("Link",this.controller.setLink);this.assignButton("Fullscreen",this.controller.setFullscreen);this.assignButton("Mute",this.controller.setMute);this.assignSlider("Volume",this.changeVolume)},assignButton:function(a,b){var c=this.configuration.sender.findName(a+"Button");c.Cursor="Hand";c.addEventListener("MouseLeftButtonUp",jeroenwijering.utils.delegate(this.controller,b));c.addEventListener("MouseEnter",jeroenwijering.utils.delegate(this,this.rollOver));c.addEventListener("MouseLeave",jeroenwijering.utils.delegate(this,this.rollOut));this.configuration.sender.findName(a+"Symbol").Fill="#FF"+this.configuration.frontcolor;try{this.configuration.sender.findName(a+"OffSymbol").Fill="#FF"+this.configuration.frontcolor}catch(D){}},assignSlider:function(a,b){var c=this.configuration.sender.findName(a+"Button");c.Cursor="Hand";c.addEventListener("MouseLeftButtonUp",jeroenwijering.utils.delegate(this,b));c.addEventListener("MouseEnter",jeroenwijering.utils.delegate(this,this.rollOver));c.addEventListener("MouseLeave",jeroenwijering.utils.delegate(this,this.rollOut));this.configuration.sender.findName(a+"Slider").Fill="#FF"+this.configuration.frontcolor;this.configuration.sender.findName(a+"Highlight").Fill="#FF"+this.configuration.frontcolor;this.configuration.sender.findName(a+"Symbol").Fill="#FF"+this.configuration.frontcolor},rollOver:function(a){var b=a.Name.substr(0,a.Name.length-6);this.configuration.sender.findName(b+"Symbol").Fill="#FF"+this.configuration.lightcolor;try{this.configuration.sender.findName(b+"OffSymbol").Fill="#FF"+this.configuration.lightcolor}catch(A){}},rollOut:function(a){var b=a.Name.substr(0,a.Name.length-6);this.configuration.sender.findName(b+"Symbol").Fill="#FF"+this.configuration.frontcolor;try{this.configuration.sender.findName(b+"OffSymbol").Fill="#FF"+this.configuration.frontcolor}catch(A){}},changeTime:function(a,b){var c=a.findName("TimeSlider");var d=b.GetPosition(c).X;var e=Math.floor(d/c.Width*this.configuration.duration);this.controller.setScrub(e)},changeVolume:function(a,b){var c=a.findName("VolumeButton");var d=b.GetPosition(c).X;this.controller.setVolume(d*5)},resizePlayer:function(){var a=this.configuration.sender.getHost().content.actualWidth;var b=this.configuration.sender.getHost().content.actualHeight;var c=this.configuration.sender.getHost().content.FullScreen;if(this.configuration.shownavigation=="true"){if(c==true){this.resizeDisplay(a,b);this.controlbar["Canvas.Left"]=Math.round(a/2-250);this.resizeControlbar(500,b-this.controlbar.Height-16);this.controlbar.findName("ControlbarBack")["Opacity"]=0.5}else{this.resizeDisplay(a,b-20);this.controlbar["Canvas.Left"]=0;this.resizeControlbar(a,b-this.controlbar.Height);this.controlbar.findName("ControlbarBack")["Opacity"]=1}}else{this.resizeDisplay(a,b)}},resizeDisplay:function(a,b){this.stretchElement("PlayerDisplay",a,b);this.stretchElement("VideoWindow",a,b);this.stretchElement("PlaceholderImage",a,b);this.centerElement("PlayIcon",a,b);this.centerElement("MuteIcon",a,b);this.centerElement("BufferIcon",a,b);this.centerElement("BufferText",a,b);this.display.findName("OverlayCanvas")["Canvas.Left"]=a-110;this.display.Visibility="Visible"},resizeControlbar:function(a,b,c){this.controlbar["Canvas.Top"]=b;this.stretchElement("PlayerControls",a);this.stretchElement("ControlbarBack",a);this.placeElement("PlayButton",0);var d=17;this.placeElement("VolumeButton",a-24);this.placeElement("MuteButton",a-37);var e=37;if(this.configuration.showstop=="true"){this.placeElement("StopButton",d);d+=17}else{this.controlbar.findName("StopButton").Visibility="Collapsed"}if(this.configuration.usefullscreen=="true"){e+=18;this.placeElement("FullscreenButton",a-e)}else{this.controlbar.findName("FullscreenButton").Visibility="Collapsed"}if(this.configuration.link!=""){e+=18;this.placeElement("LinkButton",a-e)}else{this.controlbar.findName("LinkButton").Visibility="Collapsed"}if(this.configuration.showdigits=="true"&&a-e-d>160){e+=35;this.controlbar.findName("RemainingButton").Visibility="Visible";this.controlbar.findName("ElapsedButton").Visibility="Visible";this.placeElement("RemainingButton",a-e);this.placeElement("ElapsedButton",d);d+=35}else{this.controlbar.findName("RemainingButton").Visibility="Collapsed";this.controlbar.findName("ElapsedButton").Visibility="Collapsed"}this.placeElement("TimeButton",d);this.stretchElement("TimeButton",a-d-e);this.stretchElement("TimeShadow",a-d-e);this.stretchElement("TimeStroke",a-d-e);this.stretchElement("TimeFill",a-d-e);this.stretchElement("TimeSlider",a-d-e-10);this.stretchElement("DownloadProgress",a-d-e-10);var f=this.configuration.sender.findName("TimeSymbol");this.stretchElement("TimeHighlight",f["Canvas.Left"]-5);this.controlbar.Visibility="Visible"},centerElement:function(a,b,c){var d=this.configuration.sender.findName(a);d["Canvas.Left"]=Math.round(b/2-d.Width/2);d["Canvas.Top"]=Math.round(c/2-d.Height/2)},stretchElement:function(a,b,c){var d=this.configuration.sender.findName(a);d.Width=b;if(c!=undefined){d.Height=c}},placeElement:function(a,b,c){var d=this.configuration.sender.findName(a);d["Canvas.Left"]=b;if(c){d["Canvas.Top"]=c}}};jeroenwijering.Model=function(a,b,c){this.configuration=a;this.controller=b;this.view=c;this.video=this.configuration.sender.findName("VideoWindow");this.preview=this.configuration.sender.findName("PlaceholderImage");var d={"true":"UniformToFill","false":"Uniform",fit:"Fill",none:"None"};this.state=this.video.CurrentState;this.timeint;this.video.Stretch=d[this.configuration.overstretch];this.preview.Stretch=d[this.configuration.overstretch];this.video.BufferingTime=jeroenwijering.utils.spanstring(this.configuration.bufferlength);this.video.AutoPlay=true;this.video.AddEventListener("CurrentStateChanged",jeroenwijering.utils.delegate(this,this.stateChanged));this.video.AddEventListener("MediaEnded",jeroenwijering.utils.delegate(this,this.mediaEnded));this.video.AddEventListener("BufferingProgressChanged",jeroenwijering.utils.delegate(this,this.bufferChanged));this.video.AddEventListener("DownloadProgressChanged",jeroenwijering.utils.delegate(this,this.downloadChanged));if(this.configuration.image!=""){this.preview.Source=this.configuration.image}};jeroenwijering.Model.prototype={goPause:function(a){this.video.pause();if(!isNaN(a)){this.video.Position=jeroenwijering.utils.spanstring(a)}this.timeChanged()},goStart:function(a){this.video.Visibility="Visible";this.preview.Visibility="Collapsed";if(this.state=="Closed"){this.video.Source=this.configuration.file}else{this.video.play()}if(!isNaN(a)){this.video.Position=jeroenwijering.utils.spanstring(a)}},goStop:function(){this.video.Visibility="Collapsed";this.preview.Visibility="Visible";this.goPause(0);this.video.Source="null"},goVolume:function(a){this.video.Volume=a/100},stateChanged:function(){var a=this.video.CurrentState;if(a!=this.state){this.controller.setState(this.state,a);this.view.onState(this.state,a);this.state=a;this.configuration.duration=Math.round(this.video.NaturalDuration.Seconds*10)/10;if(a!="Playing"&&a!="Buffering"&&a!="Opening"){clearInterval(this.timeint)}else{this.timeint=setInterval(jeroenwijering.utils.delegate(this,this.timeChanged),100)}}},mediaEnded:function(){if(this.configuration.repeat=="true"){this.goStart(0)}else{this.video.Visibility="Collapsed";this.preview.Visibility="Visible";this.goPause(0)}},bufferChanged:function(){var a=Math.round(this.video.BufferingProgress*100);this.view.onBuffer(a)},downloadChanged:function(){var a=Math.round(this.video.DownloadProgress*100);this.view.onLoad(a)},timeChanged:function(){var a=Math.round(this.video.Position.Seconds*10)/10;this.view.onTime(a,this.configuration.duration)}};jeroenwijering.utils.delegate=function(a,b){return function(){return b.apply(a,arguments)}};jeroenwijering.utils.timestring=function(a){var b=Math.floor(a/3600);var c=Math.floor(a%3600/60);var d=Math.round(a%60);var e="";d>9?e+=d:e+="0"+d;c>9?e=c+":"+e:e="0"+c+":"+e;b>0?e=b+":"+e:null;return e};jeroenwijering.utils.spanstring=function(a){var b=Math.floor(a/3600);var c=Math.floor(a%3600/60);var d=Math.round(a%60*10)/10;var e=b+":"+c+":"+d;return e};

