MVC.Controller.create("VideoPlayer",{theme:"Portal",config:{},currentTime:function(){return this.getView("VideoPlayer").startPlayer._player.get_position()}.isProperty(),loaded:false,opened:false,firstScreen:false,playing:false,buffering:false,paused:false,embedEmailClick:false,marcomOriginatingSiteClick:false,originatingSiteClick:false,diggLinkClick:false,deliciousLinkClick:false,blogToSpacesLinkClick:false,facebookLinkClick:false,twitterLinkClick:false,dimClick:false,_savedVolume:0,_muted:false,_muteSymbol:null,_postRollPlaying:false,muted:function(C){if(C==undefined){return this._muted}else{this._muted=!this._muted;if(this.muteSymbol==null){var A=this.getView("VideoPlayer").startPlayer;this._muteSymbol=A.findName(C.Tag)}C.Visibility="Collapsed";this._muteSymbol.Visibility="Visible";var B=0;if(this._muted==true){this.set("_savedVolume",A._player.get_volume())}else{B=this.get("_savedVolume")}A._player.set_volume(B);this._muteSymbol=C}}.isProperty(),_details:"",details:function(C){if(C==undefined){return this._details}else{var A=this.getView("Embed");var D=this._details;if(D==""){A.showMain()}else{if(A["hide"+D]){A["hide"+D]()}}this._details=C;if(C!=""){if(A["show"+C]){A["show"+C]()}}else{A.hideScreens();if(this.get("endScreen")==true){var B=this.getView("VideoPlayer").startPlayer.findName("Controls");B.Visibility="Collapsed";B.Opacity=0}}}}.isProperty(),dimmed:false,fullScreen:false,marcomShowed:false,endScreen:false,fiftyPercent:false,carouselMoving:false,carouselIndex:0,relatedVideosLoaded:false,currentState:null,currentStateObserver:function(F,E){var B="playing",A="paused",C="buffering";this.currentState=F;if(F==false){return }switch(E){case B:this.set(A,false);this.set(C,false);clearTimeout(this._timePingId);var D=this.getView("VideoPlayer").startPlayer._player.get_position();D=parseInt(D);D=20-((D+20)%20);this._timePingId=setTimeout(function(){this._ping(8);this._numTimePings++;clearTimeout(this._timePingId);this._timePingId=undefined;this._timePingId=setTimeout(arguments.callee.scope(this),20000)}.scope(this),D*1000);break;case A:clearTimeout(this._timePingId);this.set(B,false);this.set(C,false);break;case C:clearTimeout(this._timePingId);this.set(B,false);break;case"endScreen":clearTimeout(this._timePingId);this._timePingId=undefined;if(this._numTimePings==0){this._ping(8)}this.set(B,false);this.set(C,false);this.set(A,false);break}}.observes("loaded","opened","firstScreen","playing","buffering","paused","details","dimmed","fullScreen","marcomShowed","muted","endScreen"),redirectToSite:function(B,C,A){switch(this.get("theme")){case"Portal":if(C=="timeoutYes"){setTimeout(function(){location.href=B},200)}else{location.href=B}break;case"Embed":case"Detached":window.open(B);break}},_pingCache:[],_ping:function(A){var E=new Image(1,1);var B=new Image(1,1);var D=this.get("models");var C=D.Video.getId();E.src="http://edge3.catalog.video.msn.com/frauddetect.aspx?u="+C+"&t="+A;B.src="http://catalog.video.msn.com/usage.aspx?u="+C+"&t="+A;this._pingCache.push(E);this._pingCache.push(B)},emailPing:function(){this._ping(2)},_played:false,played:function(A){if(A==undefined){return this._played}else{this._played=A;this._ping(1)}}.isProperty(),_timePingId:undefined,_numTimePings:0,actions:{Init:function(A){var E=A.views;var C=this.getView("VideoPlayer");var H=E.VideoPlayer;var B=A.models;var D=B.videoData;var G=this.get("models");this.set("theme",H.playerConfig.theme);C.Init(H);var F=this.getView("AdDisplay");F.Init(C,A.models.adData);delete E.VideoPlayer;delete E.Embed;G.Video=new MVC.Models.VideoInfo(D.json);G.VideoData=D},PlayerLoading:function(){var B=this.getView("VideoPlayer");var C=B.startPlayer;var D=C._downloader;if(C._theme=="Embed"){var A=C.findName("watermark");A.SetSource(D,"watermark.png");A.Visibility="Visible";A.Cursor="Hand"}C.findName("BufferingArea_Buffering").Begin();this.set("firstScreen",!B.startPlayer._autoPlay)},CreatePlayer:function(){var A=this.getView("VideoPlayer");var B=A.startPlayer;var C=this.get("models").VideoData;A.InitPlayer({hideMarcom:C.hideMarcom,marcomImg:C.marcomImg,marcomUrl:C.marcomUrl},{relatedVideosBlur:"thumb-blur.png",mainPlayButtonGlow:"mainPlayButtonGlow.png",playPauseButtonGlow:"playPauseButtonGlow.png",muteOn:"muteOn.png",muteOnGlow:"muteOnGlow.png",muteOff:"muteOff.png",muteOffGlow:"muteOffGlow.png",dimmerGlow:"dimmerGlow.png",fullScreenButtonOnGlow:"fullScreenButtonGlow.png",fullScreenButtonOffGlow:"normalScreenButtonGlow.png",detachGlow:"detachGlow.png",timeThumbGlow:"timeThumbGlow.png",volumeThumbGlow:"volumeThumbGlow.png"});switch(this.get("theme")){case"Embed":this.getView("Embed").Init(A,{marcomUrl:C.marcomUrl});break}this.getView("FullScreen").Init(A);this.getView("EndScreen").Init(A);this.set("loaded",true);if(this.get("opened")==false){this.set("opened",true)}if(!this.get("firstScreen")){A.Start();this.set("played",true)}},MediaOpened:function(){var G=this;var I=this.originScope;var B=I._downloader;var D=I.findName("VideoWindow");var E=I._xamlHost.content;var H=this.getView("VideoPlayer");E.findName("BufferingArea").Opacity="0";H.renderMarkers();if(this.get("firstScreen")==true){H.InitFirstScreen()}else{var F=I.findName("BufferingArea");F["Canvas.ZIndex"]=2}if(this.get("opened")==false){this.set("opened",true)}var C=this.getView("AdDisplay");var A=this.get("models");C.videoCheck(A.Video)},GetExtras:function(){var A=this.get("models").Videos;if(this.get("relatedVideosLoaded")==false){if(typeof A!="string"){this.getView("EndScreen").renderCarousel(A.getVideos());this.set("relatedVideosLoaded",true)}else{this.continueToAction("GetRelatedVideos",[A])}}},PlayFirstScreen:function(){var A=this.getView("VideoPlayer");this.set("firstScreen",false);A.Start();this.set("played",true);var B=this.getView("VideoPlayer").startPlayer;var C=B.findName("BufferingArea");C["Canvas.ZIndex"]=2},MarkerReached:function(C,A){switch(A.marker.type){case"FiftyPercent":this.set("fiftyPercent",true);break;case"Marcom":var B=this.getView("VideoPlayer").startPlayer;var E=B.findName("VideoScreensTransform");if((!this.get("marcomShowed"))&&(E.ScaleX!=0.5)){this.getView("VideoPlayer").showMarcom();this.set("marcomShowed",true)}break;case"bumper":var D=this.getView("AdDisplay");D.bumperObjectCreation(A.marker.type);break;case"midRoll":var D=this.getView("AdDisplay");D.adObjectCreation(A.marker.type);break;case"postRoll":this.set("_postRollPlaying",true);break}},ShowControls:function(C){if(this.get("details")!=""||this.get("endScreen")||this.get("paused")==true){return }var B=this.getView("VideoPlayer");var A=B.startPlayer.findName("Controls");if((A.Visibility=="Collapsed")||(A.opacity<0.1)){B.showControls()}},HideControls:function(A){if(this.get("endScreen")||this.get("details")!=""||this.get("paused")==true){return }this.getView("VideoPlayer").hideControls()},MediaEnded:function(){var A=this.getView("VideoPlayer");var B=A.startPlayer._player;if(this.get("_postRollPlaying")==true){var C=this.getView("AdDisplay");C.adObjectCreation("postRoll")}this.getView("EndScreen").showEndScreen();this.set("endScreen",true);if(this.get("details")!=""){A.startPlayer.findName("Video").IsHitTestVisible=true}else{A.hideControls()}},MediaFailed:function(B){this.controller._ping(7);var A=this.getView("VideoPlayer").startPlayer;A.findName("BufferingArea_Buffering").stop();A.findName("BufferingArea").Visibility="Collapsed"},MainButtonClick:function(){if(this.get("endScreen")){var A=this.getView("VideoPlayer");this.getView("EndScreen").hideEndScreen();A.startPlayer._player.set_position(0)}var A=this.originScope;var C=A._downloader;var B=A.findName("tooltip");B.visibility="Collapsed"},CurrentStateChanged:function(){var C=this.originScope;var F=C._downloader;var D=C._xamlHost.content;var B=D.findName("VideoWindow");var A=this.getView("VideoPlayer");switch(B.CurrentState){case"Buffering":this.set("buffering",true);break;case"Playing":if(this.get("firstScreen")&&C._player.get_position()==0){A.startPlayer._player.pause();return }C.findName("BufferingArea").Visibility="Collapsed";var E=D.findName("tooltip");var G=D.findName("tooltipText");if((E["Canvas.Top"]<200)&&(E["Canvas.Top"]>100)&&(G.Text=MSVideo.Resx.PlayerMessage)){A.hideTooltip()}C.findName("EndScreenMask").Opacity=0;if(this.get("endScreen")==true){this.set("endScreen",false)}this.set("playing",true);break;case"Paused":this.set("paused",true);break}},FullScreenChange:function(B){var A=B.getHost().content.fullScreen;this.set("fullScreen",A);if(A==true){this.getView("FullScreen").showFullScreen(B)}else{this.getView("FullScreen").hideFullScreen(B)}},TimelineSeek:function(){var B=this.getView("VideoPlayer").startPlayer;var E=B._player.get_position();var D=B.getMediaElement().NaturalDuration.Seconds;if(this.get("fiftyPercent")==false){var C=parseInt(D/2);if(E>=C){this.set("fiftyPercent",true)}}if(this.get("relatedVideosLoaded")==false){var A=this.get("models").Videos;this.continueToAction("GetRelatedVideos",[A])}},GetRelatedVideos:function(){if(this.get("relatedVideosLoaded")==true){return }this.set("relatedVideosLoaded",true);var A=this.get("models").Videos;if(typeof A!="string"){this.getView("EndScreen").renderCarousel(A.getVideos());return }Sys.$.getJson({method:"GET",url:A,callback:{success:function(B){var C=this.get("models");C.Videos=new MVC.Models.VideoInfoCollection(B);this.getView("EndScreen").renderCarousel(C.Videos.getVideos())}.scope(this),error:function(){this.get("models").Videos=[]}.scope(this)}})},RelatedVideoMouseEnter:function(F){var H=this.getView("EndScreen");var K=H.startPlayer;var E=this.data;var B=K.findName("relatedVideosBlur");B["Canvas.Left"]=23+(F["Canvas.Left"]+F.GetParent()["Canvas.Left"]);B.Opacity=0;B.Visibility="Visible";K.findName("Thumbnail_MouseOut").stop();var G=K.findName("Thumbnail_MouseEnter");var A=F;var D=document.createElement("textarea");D.innerHTML=E.getTitle();var I=D.value.replace(/&/g,"&amp;");D.innerHTML=E.getDescription();var J=D.value.replace(/&/g,"&amp;");D=null;var C=G.AddEventListener("Completed",function(M){H.showRelatedOverlay({ratingUrl:"/video/Content/img/stars/r_gray_"+E.getRating()+".png",title:E._truncate(I,47),description:E._truncate(J,134),total:E.getTotal(),startDate:E.getStartDate()});var N=K.findName("relatedOverlayArrow");var L=N.findName("relatedOverlayArrowScale");N["Canvas.Left"]=(A["Canvas.Left"]-Math.abs(K.findName("relatedVideos")["Canvas.Left"]))+(A.Width/2)+8;L.ScaleX=1;M.RemoveEventListener("Completed",C)});G.begin()},RelatedVideoMouseLeave:function(){var A=this.getView("EndScreen");var B=A.startPlayer;A.hideRelatedOverlay();B.findName("Thumbnail_MouseEnter").stop();B.findName("relatedVideosBlur").Visibility="Collapsed"},ToggleMute:function(A){this.set("muted",A)},VolumeIsChanged:function(){var A=this.getView("EndScreen");var B=A.startPlayer;if(B._player.get_volume()>0){this.set("_savedVolume",B._player.get_volume());if(this.get("muted")==true){B.findName("MuteOffSymbol").Visibility="Visible";B.findName("MuteOnSymbol").Visibility="Collapsed";this.set("muted",B.findName("MuteOnSymbol"))}}},ToggleDimmer:function(A){if(A==true){this.set("dimClick",true)}this.set("dimmed",A)},DetachPlayer:function(){var A=this.getView("VideoPlayer");var C=A.startPlayer._player;try{var D=window.open(this.get("models").VideoData.detachedUrl+"?startTime="+C.get_position(),"detached_player","width=450,height=346,resizable=no");if(D!=undefined&&D!=null){C.pause();if(this.get("dimmed")==true){A.toggleDimmer()}}}catch(B){}},MoveCarouselLeft:function(B){if(this.get("carouselMoving")){return }var D=this.get("carouselIndex");var G=this.getView("VideoPlayer").startPlayer;var I=G.findName("relatedVideos").Children.Count;if(D+3>=I){return }this.set("carouselMoving",true);var H=G.getHost();var A=G.findName("relatedVideos");var C=D+Math.min(I-D,3);var E=126*Math.min(I-D,3);var F=G.findName("Carousel_Move_Left");F.Children.GetItem(0).By=-E;A.IsHitTestVisible=false;Sys.$.animateXaml([{storyboard:F,after:function(){A.IsHitTestVisible=true;this.set("carouselMoving",false);this.set("carouselIndex",C)}.scope(this)}])},MoveCarouselRight:function(E){if(this.get("carouselMoving")){return }var C=this.get("carouselIndex");if(C==0){return }this.set("carouselMoving",true);var D=this.getView("VideoPlayer").startPlayer;var F=D.getHost();var B=D.findName("relatedVideos");var C=this.get("carouselIndex");var A=Math.max(C-3,0);if(A==0){var G=126*C}else{var G=126*Math.min(A,3)}var H=D.findName("Carousel_Move_Right");H.Children.GetItem(0).By=G;B.IsHitTestVisible=false;Sys.$.animateXaml([{storyboard:H,after:function(){B.IsHitTestVisible=true;this.set("carouselMoving",false);this.set("carouselIndex",A)}.scope(this)}])},EmbeddedMenuClick:function(C){var A=this.getView("Embed");var B=C.Name;if(this.get("details")==B){this.continueToAction("HideEmbedScreens");return }if(this.get("endScreen")&&this.get("details")==""){return }if(this.get("details")==""){A.resizeVideo()}if(this.get("details")){this.continueToAction("HideMenuTextHLStraight",[this.get("details")])}this.set("details",B)},HideEmbedScreens:function(){this.continueToAction("HideMenuTextHLStraight",[this.get("details")]);this.set("details","")},ShareClick:function(C){var A=this.originScope.id;var B=this.get("models").Video;switch(A){case"share_links_blogToSpaces":MSVideo.Share.BlogToSpaces(B.getTitle(),B.getDescription(150),B.getVideoUrl());break;case"share_links_digg":MSVideo.Share.Digg(B.getTitle(),B.getDescription(150),B.getVideoUrl());break;case"share_links_delicious":MSVideo.Share.Delicious(B.getTitle(),B.getVideoUrl());break;case"share_links_facebook":MSVideo.Share.Facebook(B.getVideoUrl(),B.getTitle());break;case"share_links_twitter":MSVideo.Share.Twitter(B.getVideoUrl());break}C.preventDefault()},EmailAddressValidation:function(B,D){if(B==""||B=="Your friend's email"){D.innerHTML=MSVideo.Resx.EmailAddressError1;D.style.display="block";return 1}if(B[(B.length)-1]==","){B=B.substring(0,B.length-1)}var E=B.split(",");for(var A=0;A<E.length;A++){var F="^[\\w-_.]*[\\w-_.]@[\\w][\\S]*[.][\\S]*[\\w]$";var C=new RegExp(F);if(!C.test(E[A].trim())){D.innerHTML=MSVideo.Resx.EmailAddressError2;D.style.display="block";return 1}}return 0},EmailMessageValidation:function(A,B){if(A.length>1024){B.style.display="block";return 1}return 0},EmailSubmit:function(N){this.set("embedEmailClick",true);N.preventDefault();var C=this.data;var K=this.controller;var D=this.originScope;var G={};var O="";var P="";document.getElementById("friend_email_error_1").style.display="none";document.getElementById("email_msg_error_1").style.display="none";var J=0;for(var H=0,E,B=D.elements,L=B.length;H<L;H++){E=B[H];switch(E.name){case"email_friendemail":var I=document.getElementById("friend_email_error_1");J+=this.continueToAction("EmailAddressValidation",[E.value,I]);O=E.value;break;case"email_message":var M=document.getElementById("email_msg_error_1");J+=this.continueToAction("EmailMessageValidation",[E.value,M]);P=E.value;break}if(E.value==MSVideo.Resx.EmailMessage){E.value="";P=""}G[E.name]=E.value}if(J>0){return false}var F=this.get("models").Video;P=P.replace(/\n/g,"%0A");P=P.replace(/&/g,"%26");P=P.replace(/\"/g,"%22");var A=window.open("mailto:"+O+"?subject=Check out this video on Microsoft Showcase &body=Check out this video - %0A%0A"+F.getTitle()+"%0A"+F.getVideoUrl()+"%0A%0A"+P,"emailWindow");if(A!=null||A!=undefined){A.close()}return false},ShowMenuTextHighlight:function(B){var A=this.getView("VideoPlayer").startPlayer;A.findName(B.Name+"Text").Foreground="Yellow";A.findName(B.Name+"Text").TextDecorations="Underline"},HideMenuTextHighlight:function(A){if(this.get("details")==A.Name){return }this.continueToAction("HideMenuTextHLStraight",[A.Name])},HideMenuTextHLStraight:function(A){var B=this.getView("VideoPlayer").startPlayer;B.findName(A+"Text").Foreground="White";B.findName(A+"Text").TextDecorations="None"},originatingSiteClicked:function(){this.set("originatingSiteClick",true)},marcomOriginatingSiteClicked:function(){this.set("marcomOriginatingSiteClick",true)},diggLinkClicked:function(){this.set("diggLinkClick",true)},deliciousLinkClicked:function(){this.set("deliciousLinkClick",true)},blogToSpacesLinkClicked:function(){this.set("blogToSpacesLinkClick",true)},facebookLinkClicked:function(){this.set("facebookLinkClick",true)},twitterLinkClicked:function(){this.set("twitterLinkClick",true)}}});
MVC.View.create("VideoPlayer",{controllerName:"VideoPlayer",init:function(A){this.startPlayer=new StartPlayer(A.playerConfig);this.events=new MSVideo.CustomEvents(this);this.events.add("FirstScreenPlay");this.startPlayer.addEventListener("PlayerLoading",this.routeEvent("PlayerLoading"));this.startPlayer.addEventListener("PlayerCreated",this.routeEvent("CreatePlayer"));this.events.addHandler("FirstScreenPlay",this.routeEvent("PlayFirstScreen"));this.startPlayer.addEventListener("MediaOpened",this.routeEvent("MediaOpened"));this.startPlayer.addEventListener("MediaEnded",this.routeEvent("MediaEnded"));this.startPlayer.addEventListener("MainPlayButtonClick",this.routeEvent("MainButtonClick"));this.startPlayer.addEventListener("FullScreenChanged",this.routeEvent("FullScreenChange"));this.startPlayer.addEventListener("CurrentStateChanged",this.routeEvent("CurrentStateChanged"));this.startPlayer.addEventListener("MediaFailed",this.routeEvent("MediaFailed"));this.startPlayer.addEventListener("TimelineSeek",this.routeEvent("TimelineSeek"));this._showCtrlTimer=undefined;this._hideCtrlTimer=undefined;if(this.startPlayer._theme!="Detached"){Sys.$("digg_link").on("mousedown",this.routeEvent("diggLinkClicked"));Sys.$("delicious_link").on("mousedown",this.routeEvent("deliciousLinkClicked"));Sys.$("blogToSpaces_link").on("mousedown",this.routeEvent("blogToSpacesLinkClicked"));Sys.$("facebook_link").on("mousedown",this.routeEvent("facebookLinkClicked"));Sys.$("twitter_link").on("mousedown",this.routeEvent("twitterLinkClicked"))}},helpers:{InitPlayer:function(Y,K){var F=this.startPlayer;var P=F._downloader;for(var a in K){F.findName(a).SetSource(P,K[a])}var D=F.findName("VideoWindow");D.AddEventListener("DownloadProgressChanged",this.UpdateDownloadProgress.scope(this));this._hideMarcom=Y.hideMarcom;this.startPlayer.findName("marcomImage").Source=Y.marcomImg;var W=F.findName("marcomImage");W.AddEventListener("MouseLeftButtonDown",this.routeEvent("marcomOriginatingSiteClicked"));W.AddEventListener("MouseLeftButtonDown",function(b){this.getController().redirectToSite(Y.marcomUrl,"timeoutYes")}.scope(this));var T=this.startPlayer.findName("marcomCloseSign");T.AddEventListener("MouseLeftButtonDown",function(b){b.findName("marcom").Visibility="Collapsed"});var Q=F.findName("marcomLink");Q.AddEventListener("MouseEnter",function(b){b.findName("marcomLinkText").TextDecorations="Underline"});Q.AddEventListener("MouseLeave",function(b){b.findName("marcomLinkText").TextDecorations="None"});Q.AddEventListener("MouseLeftButtonDown",this.routeEvent("marcomOriginatingSiteClicked"));Q.AddEventListener("MouseLeftButtonDown",function(b){this.getController().redirectToSite(Y.marcomUrl,"timeoutYes")}.scope(this));var M=F.findName("dimmer");var S=[];if(F._theme=="Portal"){M.AddEventListener("MouseLeftButtonDown",this.toggleDimmer.scope(this));S.push(M)}else{M.Visibility="Collapsed"}S.push(F.findName("FullScreenButton"));var Z=F.findName("detach");if(F._theme!="Detached"){S.push(Z);Z.AddEventListener("MouseLeftButtonDown",this.routeEvent("DetachPlayer"))}else{Z.Visibility="Collapsed"}for(var R=S.length-1,E=385;R>=0;R--,E-=6){S[R]["Canvas.Left"]=E;if(R>0){E-=S[R-1].Width}}this.renderTooltips(MSVideo.ControlAddOnResources.Tooltip.Player);if(F._theme=="Portal"){this.renderTooltips(MSVideo.ControlAddOnResources.Tooltip.Portal)}else{if(F._theme=="Detached"){this.renderTooltips(MSVideo.ControlAddOnResources.Tooltip.Detach)}}var X=this;var A=F.findName("MuteOnSymbol");A.AddEventListener("MouseLeftButtonDown",this.routeEvent("ToggleMute"));var V=F.findName("MuteOffSymbol");V.AddEventListener("MouseLeftButtonDown",this.routeEvent("ToggleMute"));A.Tag="MuteOffSymbol";V.Tag="MuteOnSymbol";var C=F.findName("PlayPauseButton");C.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("playPauseButtonGlowReveal").Begin()});C.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("playPauseButtonGlowHide").Begin()});var U=F.findName("mainPlayButtonIcon");U.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("mainPlayButtonGlowReveal").Begin()});U.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("mainPlayButtonGlowHide").Begin()});var J=F.findName("MuteOnSymbol");J.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("muteOnGlowReveal").Begin()});J.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("muteOnGlowHide").Begin()});var H=F.findName("MuteOffSymbol");H.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("muteOffGlowReveal").Begin()});H.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("muteOffGlowHide").Begin()});var M=F.findName("dimmer");M.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("dimmerGlowReveal").Begin()});M.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("dimmerGlowHide").Begin()});var I=F.findName("FullScreenButtonOn");I.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("fullScreenButtonOnGlowReveal").Begin()});I.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("fullScreenButtonOnGlowHide").Begin()});var O=F.findName("FullScreenButtonOff");O.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("fullScreenButtonOffGlowReveal").Begin()});O.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("fullScreenButtonOffGlowHide").Begin()});var L=F.findName("detach");L.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("detachGlowReveal").Begin()});L.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("detachGlowHide").Begin()});var N=F.findName("TimeThumb");N.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("timeThumbGlowReveal").Begin()});N.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("timeThumbGlowHide").Begin()});var G=F.findName("VolumeThumb");G.AddEventListener("MouseEnter",function(b){X.startPlayer.findName("volumeThumbGlowReveal").Begin()});G.AddEventListener("MouseLeave",function(b){X.startPlayer.findName("volumeThumbGlowHide").Begin()});this.startPlayer._player.add_volumeChanged(this.routeEvent("VolumeIsChanged"));var B=this.startPlayer.findName("relatedLearnMoreText");B.AddEventListener("MouseEnter",function(b){b.TextDecorations="Underline"});B.AddEventListener("MouseLeave",function(b){b.TextDecorations="None"});B.AddEventListener("MouseLeftButtonDown",function(b){this.getController().redirectToSite(Y.marcomUrl,"timeoutNo")}.scope(this))},InitFirstScreen:function(){var G=this.startPlayer;var D=G.findName("PlaceholderImage_Image");D.Source=G._placeHolderImage;D.GetParent().Visibility="Visible";var C=G.findName("mainPlayButton");var B=G.findName("PlayPauseButton");var E=G.findName("Video");C.Visibility="Visible";var F=Sys.xaml(G.findName("Controls"));F.show();F.set("Opacity",1);var I=function(K){C.RemoveEventListener("MouseLeftButtonDown",H);B.RemoveEventListener("MouseLeftButtonDown",A);E.IsHitTestVisible=true;G.findName("mainPlayButton").Visibility="Collapsed";var J=Sys.xaml(G.findName("PlaceholderImage_Container"));Sys.$.animateXaml([{storyboard:G.findName("PlaceholderImage_Container_Hide"),after:function(L){J.hide()}}]);this.events.fire("FirstScreenPlay")}.scope(this);var H=C.AddEventListener("MouseLeftButtonDown",I);var A=B.AddEventListener("MouseLeftButtonDown",I);E.IsHitTestVisible=false},Start:function(){var A=this.startPlayer.findName("rootVideoCanvas");A.AddEventListener("MouseEnter",this.routeEvent("ShowControls"));A.AddEventListener("MouseLeave",this.routeEvent("HideControls"));setTimeout(this.routeEvent("GetExtras").scope(this),15000)},UpdateDownloadProgress:function(C){var B=this.startPlayer;var A=B.findName("DownloadProgressSlider");var E=B.findName("VideoWindow");var D=B.findName("ControlsTimeline");A.Width=E.DownloadProgress*D.Width},showTooltip:function(A){var B=this;this.showTimer=setTimeout(function(){if(A.Visibility!="Collapsed"){var M=B.startPlayer;var O=M.findName("tooltip");var H=M.findName("tooltipText");var N=M.findName("tooltipBg");var G=M.findName("tooltipDropshadow");var J=MSVideo.ControlAddOnResources.TooltipSettings[A.name];H.Text=J.Text;N.Width=J.Width;G.Width=J.Width;var K=M.findName("VideoScreensTransform").ScaleX;var I=M.findName("VideoScreensTransform").ScaleY;var E=Sys.xaml(M.findName(A.name)).offset();var D=0;var C=0;if((K!=1)&&(A.name=="mainPlayButtonIcon")){var L=J.RelativeLeft*K;var F=J.RelativeTop*I;D=E.x*K;C=E.y*I;O["Canvas.Left"]=D+L;O["Canvas.Top"]=C+F;if(K==0.5){O["Canvas.Top"]+=18}}else{O["Canvas.Left"]=E.x+J.RelativeLeft;O["Canvas.Top"]=E.y+J.RelativeTop}O.Visibility="Visible"}},350)},hideTooltip:function(B){var A=this.startPlayer;var C=A.findName("tooltip");C.Visibility="Collapsed";clearTimeout(this.showTimer)},toggleDimmer:function(){var B=Sys.$("content_header");var A=Sys.$("pageDimmer");if(!A){return }var C=function(){A.fadeOut({duration:0.25,maximumOpacity:0.8,minimumOpacity:0},function(){A.hide();B.removeClass("dimmed")});this.routeEvent("ToggleDimmer").call(A,false)}.scope(this);var E;var D=function(){clearTimeout(E);E=setTimeout(function(){A.style("width",(window.innerWidth||document.body.scrollWidth)+"px");A.style("height",(window.clientHeight||document.body.scrollHeight)+"px")},250)};if(A.style("display")!="block"){AjaxControlToolkit.CommonToolkitScripts.setElementOpacity(A[0],0);B.addClass("dimmed");A.show();A.style("width",(window.innerWidth||document.body.scrollWidth)+"px");A.style("height",(window.clientHeight||document.body.scrollHeight)+"px");A.fadeIn({duration:0.25,maximumOpacity:0,minimumOpacity:0.65},function(){A.on("click",function(){C();A.removeHandler("click",C);Sys.$(window).removeHandler("resize",D)})});Sys.$(window).on("resize",D);this.routeEvent("ToggleDimmer").call(A,true)}else{C()}},showControls:function(){var B=this.startPlayer;var A=Sys.xaml(B.findName("EndScreen"));if(this._hideCtrlTimer!=undefined){clearTimeout(this._hideCtrlTimer);this._hideCtrlTimer=undefined}this._showCtrlTimer=setTimeout(function(){Sys.$.animateXaml([{storyboard:B.findName("PlayerControls_MouseEnter"),before:function(){Sys.xaml(B.findName("Controls")).show()}}])}.scope(this),350)},hideControls:function(){var A=this.startPlayer;if(this._showCtrlTimer!=undefined){clearTimeout(this._showCtrlTimer);this._showCtrlTimer=undefined}this._hideCtrlTimer=setTimeout(function(){Sys.$.animateXaml([{storyboard:A.findName("PlayerControls_MouseLeave"),after:function(){Sys.xaml(A.findName("Controls")).hide()}}])}.scope(this),350)},showMarcom:function(){var A=this.startPlayer;var B=Sys.xaml(A.findName("marcom"));Sys.$.animateXaml([{storyboard:A.findName("marcomreveal"),before:function(){if(A.findName("Controls").Visibility=="Visible"){var C=A.findName("marcom");C["Canvas.Top"]="245"}B.show()},after:function(){B.hide()}}])},renderMarkers:function(){var C=this.startPlayer.getHost();var B=this.startPlayer.getMediaElement();if(this._hideMarcom==undefined||this._hideMarcom==false){var A=C.createFromXaml('<TimelineMarker Time="0:00" Type="Marcom" Text="Show Marcom" />');A.time.seconds=15;B.markers.add(A)}A=C.createFromXaml('<TimelineMarker Time="0:00" Type="FiftyPercent" Text="Omniture Ping" />');A.time.seconds=parseInt(B.NaturalDuration.Seconds/2);B.markers.add(A);B.AddEventListener("MarkerReached",this.routeEvent("MarkerReached"))},renderTooltips:function(D){var C=this.startPlayer;var E;for(var B=0,A=D.length;B<A;B++){E=C.findName(D[B].xname);E.AddEventListener("MouseEnter",this.showTooltip.scope(this));E.AddEventListener("MouseLeave",this.hideTooltip.scope(this))}}}});
MVC.View.create("EndScreen",{controllerName:"VideoPlayer",init:function(A){this.player=A;this.startPlayer=A.startPlayer},helpers:{showEndScreen:function(){var B=this.startPlayer;var A=B.findName("Video");A.IsHitTestVisible=false;Sys.$.animateXaml([{storyboard:B.findName("EndScreen_Show"),before:function(){var C=Sys.xaml(B.findName("EndScreen"));C.show();B.findName("mainPlayButton").Visibility="Visible";B.findName("watermark").Visibility="Collapsed"}}])},hideEndScreen:function(){var B=this.startPlayer;var A=B.findName("Video");A.IsHitTestVisible=true;B.findName("watermark").Visibility="Visible";B.findName("Controls").Visibility="Visible";B.findName("Controls").Opacity=1;Sys.$.animateXaml([{storyboard:B.findName("EndScreen_Hide"),after:function(){Sys.xaml(B.findName("EndScreen")).hide()}}])},renderCarousel:function(F){var L=this.startPlayer;var C=L.findName("relatedVideos");var N=L.getHost();var K=['<Canvas Width="118" Height="89" Canvas.Left="{Canvas.Left}" Cursor="Hand" Tag="{index}">','<Rectangle Width="118" Height="89" Fill="#FF000000" Stroke="#8e9ba8" RadiusX="5" RadiusY="5" StrokeThickness="1"></Rectangle>','<Image Width="118" Height="89" Source="{src}" Canvas.Left="1" Canvas.Top="1" Stretch="UniformToFill">',"<Image.Clip>",'<RectangleGeometry Rect="0,0,116,87" RadiusX="5" RadiusY="5"/>',"</Image.Clip>","</Image>","</Canvas>"].join("");var B;var D;var J=0;var E=0;if(F.length==1){E=126}if(F.length==2){E=63}for(var H=0,I=Math.min(F.length,15);H<I;H++,E+=(118+8)){D=F[H];C.Children.Add(this._renderCarouselItem(K,E,D,H))}C.Width=E+118;var M=Sys.xaml(C);var A=L.findName("carouselArrowLeft");var G=L.findName("carouselArrowRight");if(F.length<=3){A.Visibility="Collapsed";G.Visibility="Collapsed";if(F.length==0){L.findName("relatedText").Visibility="Collapsed"}}else{C["Canvas.Left"]=J;A.AddEventListener("MouseLeftButtonDown",this.routeEvent("MoveCarouselRight"));G.AddEventListener("MouseLeftButtonDown",this.routeEvent("MoveCarouselLeft"))}},showRelatedOverlay:function(D){var B=['<Canvas Width="400" Height="72">','<Canvas Width="110" Height="72">','<TextBlock Canvas.Left="8" Canvas.Top="5" ','FontFamily="Tahoma" FontSize="11" Text="Rating:" TextWrapping="Wrap"/>','<Image Source="{ratingUrl}" ','Width="64" Height="12" Canvas.Top="5" Canvas.Left="45" />','<TextBlock Canvas.Left="8" Canvas.Top="18" ','FontFamily="Tahoma" FontSize="11" Text="{startDate}" TextWrapping="Wrap"/>	','<TextBlock Canvas.Left="8" Canvas.Top="32" ','FontFamily="Tahoma" FontSize="11" Text="Views:" TextWrapping="Wrap"/>','<TextBlock Canvas.Left="44" Canvas.Top="32" ','FontFamily="Tahoma" FontSize="11" Text="{total}" TextWrapping="Wrap"/>',"</Canvas>",'<Canvas Width="276" Height="72" Canvas.Left="119">','<TextBlock Foreground="Black" ','TextWrapping="NoWrap" ','Width="273" Canvas.Left="1" Canvas.Top="3">','<Run Foreground="Black" FontFamily="Tahoma" FontSize="11" FontWeight="Bold">{title}</Run>',"</TextBlock>",'<TextBlock Foreground="#000000" ','TextWrapping="Wrap" Canvas.Top="18" ','Width="275" FontSize="11" >','<Run FontFamily="Tahoma">{description}</Run>',"</TextBlock>","</Canvas>","</Canvas>"].join("");var E=this.renderData(B,D);var A=this.startPlayer.getHost().createFromXaml(E,true);var C=this.startPlayer.findName("relatedOverlayContent");C.Children.Clear();C.Children.Add(A);A.GetParent().GetParent().Visibility="Visible"},hideRelatedOverlay:function(){this.startPlayer.findName("relatedOverlay").Visibility="Collapsed";this.startPlayer.findName("relatedOverlay").Visibility="Collapsed"},_renderCarouselItem:function(C,F,E,B){var D=this.startPlayer.getHost();var A=D.createFromXaml(this.renderData(C,{"Canvas.Left":F,src:E.getThumbailSrc().replace(/&/g,"&amp;"),index:B}),true);A.AddEventListener("MouseEnter",this.routeEvent("RelatedVideoMouseEnter",E));A.AddEventListener("MouseLeave",this.routeEvent("RelatedVideoMouseLeave",E));A.AddEventListener("MouseLeftButtonDown",function(){this.getController().redirectToSite(E.getVideoUrl(),"timeoutNo")}.scope(this));return A}}});
MVC.View.create("FullScreen",{controllerName:"VideoPlayer",init:function(A){this.startPlayer=A.startPlayer;this.mouseMoveTimeout=undefined},helpers:{showFullScreen:function(C){var G=undefined;this.mouseMoveToken=this.startPlayer.findName("rootVideoCanvas").AddEventListener("MouseMove",function(V){clearTimeout(G);G=setTimeout(function(){this.routeEvent("ShowControls").call(this,V)}.scope(this),100);this._hideControls()}.scope(this));var P=this.startPlayer;var L=C.findName("FullScreenArea");var M=C.findName("Controls");M.Visibility="Visible";M.Opacity=1;var A=C.findName("controlBgTransform");var E=C.findName("VideoScreensTransform");var K=C.findName("VideoScreens");var U=C.findName("controlAddOn");var J=C.findName("loadingImageScale");var B=C.findName("PlaceholderImageTransform");var F=C.findName("marcomScale");L.Visibility="Visible";M.Visibility="Visible";if(P._theme!="Portal"){U.Visibility="Collapsed"}if(P._theme=="Embed"){var R=P.findName("rootVideoCanvasTransform");R.ScaleX=1;R.ScaleY=1}var I=C.findName("FullScreenVideoWindow");var D=C.getHost();var T=D.content.actualWidth/430;var S=D.content.actualHeight/326;A.ScaleX=734/409;M.Width=734;M["Canvas.Left"]=((D.content.actualWidth-M.Width)/2)-10;var H=C.findName("ControlsPart2");H["Canvas.Left"]=M.Width-409;C.findName("ControlsTimeline").Width=470;C.findName("DownloadProgressSlider").Width=470;C.findName("TimeSlider").Width=462;var N=C.findName("TimeThumb");N["Canvas.Left"]=(N["Canvas.Left"]/137)*462;C.findName("TimeSlider_Highlight").Width=N["Canvas.Left"];C.findName("TimeSliderBg").Width=N["Canvas.Left"];M["Canvas.Top"]=D.content.actualHeight-(36+(18*A.ScaleY));if(M["Canvas.Top"]<(D.content.actualHeight-54)){M["Canvas.Top"]=D.content.actualHeight-54}I.Width=D.content.actualWidth;I.Height=D.content.actualHeight;E.ScaleX=T;E.ScaleY=S;J.ScaleX=T;J.ScaleY=S;J.CenterX=0;J.CenterY=0;B.ScaleX=T;B.ScaleY=S;F.ScaleX=T;F.ScaleY=S;var Q=C.findName("FullScreenButtonOn");Q.Visibility="Collapsed";var O=C.findName("FullScreenButtonOff");O.Visibility="Visible";C.findName("dimmer").Visibility="Collapsed";C.findName("tooltip").Visibility="Collapsed"},hideFullScreen:function(F){this.startPlayer.findName("rootVideoCanvas").RemoveEventListener("MouseMove",this.mouseMoveToken);var P=this.startPlayer;if(P._theme=="Embed"){var I=P.findName("rootVideoCanvasTransform");I.ScaleX=0.93;I.ScaleY=0.93}var O=F.findName("FullScreenArea");var Q=F.findName("Controls");if(F.findName("EndScreen").Visibility!="Visible"){Q.Visibility="Visible";Q.Opacity=1}var N=F.findName("controlBgTransform");var H=F.findName("VideoScreensTransform");var C=F.findName("VideoScreens");var L=F.findName("controlAddOn");var A=F.findName("loadingImageScale");var K=F.findName("PlaceholderImageTransform");var G=F.findName("marcomScale");O.Visibility="Collapsed";if(P._theme=="Embed"){L.Visibility="Visible"}N.ScaleX=1;N.ScaleY=1;Q["Canvas.Top"]=280;Q["Canvas.Left"]=10;Q.Visibility="Visible";var B=F.findName("ControlsPart2");B["Canvas.Left"]=0;F.findName("ControlsTimeline").Width=145;F.findName("DownloadProgressSlider").Width=145;F.findName("TimeSlider").Width=137;var E=F.findName("TimeThumb");E["Canvas.Left"]=(E["Canvas.Left"]/462)*137;F.findName("TimeSlider_Highlight").Width=E["Canvas.Left"];F.findName("TimeSliderBg").Width=E["Canvas.Left"];var D=F.findName("VideoWindow");if(D.Width=="211"){C["Canvas.Top"]=36;H.ScaleX=0.5;H.ScaleY=0.5;A.ScaleX=211/430;A.ScaleY=160/326;A.CenterX=0;A.CenterY=(36+160)/2}else{H.ScaleX=1;H.ScaleY=1;A.ScaleX=1;A.ScaleY=1;A.CenterX=0;A.CenterY=0}K.ScaleX=1;K.ScaleY=1;G.ScaleX=1;G.ScaleY=1;var J=F.findName("FullScreenButtonOn");J.Visibility="Visible";var M=F.findName("FullScreenButtonOff");M.Visibility="Collapsed";if(P._theme=="Portal"){F.findName("dimmer").Visibility="Visible"}},_hideControls:function(){if(this.mouseMoveTimeout!=undefined){clearTimeout(this.mouseMoveTimeout)}this.mouseMoveTimeout=setTimeout(function(){this.routeEvent("HideControls").call(this,this.startPlayer.findName("rootVideoCanvas"))}.scope(this),3200)}}});
MVC.View.create("AdDisplay",{controllerName:"VideoPlayer",init:function(B,A){this.adData=A;this.player=B;this.startPlayer=B.startPlayer;this.currentAdObject;this.adType="mid";this.adObject;this.bumperObject;this.adDataQueue={length:0,items:{}};this.videoId;this.videoTime;this.index;this.events=new MSVideo.CustomEvents(this);this.events.add("AdDataLoaded");this.adIsPlaying=false;this.getController().observe("fullScreen",function(C){if(this.adIsPlaying&&C==false){this._hideFullScreen()}}.scope(this));this.events.addHandler("AdDataLoaded",this.routeEvent("AdsLoaded"))},helpers:{videoCheck:function(C){if(!this.adData){return }var A=this.videoId=C.getId();var L=C.getTotal();var M=C.videoData.tags.tag;var G={};var J=this.startPlayer.getMediaElement();var K=this.adData;var B;this.adUrl="/video/GetAdData.aspx?uuid="+A+"&pg={pg}";var D=this.videoTime=Math.round(J.NaturalDuration.Seconds);var H=Math.floor(Math.random()*100+1);for(var E=0,I=K.AdProfiles,F=I.length;E<F;E++){B=I[E];if(L<=B.maxVideoPlays&&L>=B.minVideoPlays){if(D<=B.maxVideoLength&&D>=B.minVideoLength){if(!this.hasIgnoreTags(M,B.ignoreTags)){if(B.frequency!=undefined&&H<=B.frequency){if(B.id=="bumper"){this.initBumper(B.pageGroup,B.id)}else{setTimeout((function(O,N){return function(){O.videoRequestObject(N.pageGroup,N.id)}})(this,B),D*1000>8000?5000:100)}}}}}}},hasIgnoreTags:function(E,B){for(var F=0,A=B.length;F<A;F++){for(var D=0,C=E.length;D<C;D++){if(B[F].nameSpace==E[D].$namespace&&B[F].tag==E[D].$){return true}}}return false},initBumper:function(B,A){if(Sys.$.cookies.getCookie("_bmp")!="false"){this.videoRequestObject(B,A);Sys.$.cookies.setCookie("_bmp","true")}},videoRequestObject:function(B,A){this.adDataQueue.items[A]=A;this.adDataQueue.length++;Sys.$.getJson({method:"GET",url:this.adUrl.replace("{pg}",B),params:{},callback:{success:function(C){this.adObject=this.adObject||{};C.adType=A;this.adObject[A]=C;this.adCall(C,A);delete this.adDataQueue.items[A];this.adDataQueue.length--;if(this.adDataQueue.length==0){}}.scope(this),error:function(){}}})},adCall:function(E,B){var D=this.startPlayer.getHost();var C=this.startPlayer.getMediaElement();if(!E.success||(E.index>-1&&E.index<9)){return }var A=D.createFromXaml('<TimelineMarker Time="0:00" Type="'+B+'" Text="Ad Markers" />');switch(B){case"bumper":A.time.seconds=0;C.markers.add(A);break;case"midRoll":A.time.seconds=(this.videoTime/2);C.markers.add(A);break;case"postRoll":A.time.seconds=this.videoTime-1;C.markers.add(A);break}},adObjectCreation:function(A){var B=this.startPlayer.getMediaElement();if(A!="postRoll"){B.Pause()}this.makeVideoObject(A)},bumperObjectCreation:function(A){var B=this.startPlayer.getMediaElement();B.Pause();this.makeVideoObject(A);Sys.$.cookies.setCookie("_bmp","false")},makeVideoObject:function(D){var H=this.currentAdObject=this.adObject[D];var C=this.startPlayer;var N=C.getMediaElement();var A=C.findName("AdvertVideo");var F=C.findName("AdvertWindow");var I=C.findName("AdvertInfo");var G=C.findName("FullScreenVideoBrush");var P=this.videoId;var B;A.Visibility="Visible";F.AutoPlay="true";var M=C.findName("Controls");M.Visibility="Collapsed";M.Opacity=0;I.Visibility="Visible";I.Opacity=1;Sys.$.animateXaml([{storyboard:C.findName("advertShowLayer"),after:function(){C.findName("AdvertInfo_Hide").Begin()}.scope(this)}]);F.Source=H.videoUrl;B=H.href;if(this.getController().get("fullScreen")==true){var O=C.findName("AdvertInfoTransform");var L=C.getHost();var E=this.startPlayer.findName("VideoScreens");E.Visibility="Collapsed";var K=L.actualWidth/430;var J=L.actualHeight/326;G.SourceName="AdvertWindow";A.Tag=A["Canvas.ZIndex"].toString();A["Canvas.ZIndex"]=1;O.ScaleX=K;O.ScaleY=J}this._createAdEventMarkers(F);A.AddEventListener("MouseLeftButtonDown",function(Q){this.ping("click");window.open(B,"_new")}.scope(this));F.AddEventListener("MediaEnded",function(){Sys.$.animateXaml([{storyboard:N.findName("advertHideLayer"),after:function(){I.Visibility="Collapsed";I.Opacity=0;A.Visibility="Collapsed";N.Play();F.Source="";Sys.$.cookies.setCookie(D,"watched");if(this.currentAdObject.adType=="postRoll"){var Q=this.startPlayer.findName("VideoScreens");Q.Visibility="Visible";this.getController().set("_postRollPlaying",false)}this.currentAdObject=null;this.adIsPlaying=false;G.SourceName="VideoWindow";A["Canvas.ZIndex"]=7}.scope(this)}])}.scope(this))},ping:function(A){this._imgs=this._imgs||[];var B=new Image();B.src=this.getAdEventUrl(A);this._imgs.push(B)},getAdEventUrl:function(B){var E=this.currentAdObject;var D=E.events;for(var C=0,A=D.length;C<A;C++){if(D[C].type==B){return D[C].url}}return null},_createAdEventMarkers:function(A){A.AddEventListener("MediaOpened",function(){this.adIsPlaying=true;var B=this.startPlayer.getHost();var F=B.createFromXaml('<TimelineMarker Time="0:00" Type="onload" Text="Ad Markers" />');var E=B.createFromXaml('<TimelineMarker Time="0:00" Type="durationtrack" Text="Ad Markers" />');var D=B.createFromXaml('<TimelineMarker Time="0:00" Type="endtrack" Text="Ad Markers" />');A.Volume=this.startPlayer._player.get_volume();F.time.seconds=0;E.time.seconds=7.5;D.time.seconds=Math.floor(A.NaturalDuration.Seconds);var C=A.findName("AdvertText");C.Text=MSVideo.ControlAddOnResources.AdMessages[this.currentAdObject.adType];C["Canvas.Left"]=(A.Width/2)-(C.ActualWidth/2);A.AddEventListener("MarkerReached",function(H,G){this.ping(G.marker.type)}.scope(this));A.markers.add(F);A.markers.add(E);A.markers.add(D)}.scope(this))},_hideFullScreen:function(){var A=this.startPlayer.findName("AdvertInfoTransform");A.ScaleX=1;A.ScaleX=1;this.player.hideControls()}}});
MVC.Models.VideoInfoCollection=MVC.Class({construct:function(E){this._videos=[];this._videosHash={};var F;for(var D=0,A=E.length,C=this._videos,B=this._videosHash;D<A;D++){F=new MVC.Models.VideoInfo(E[D]);C[D]=F;B[F.getId()]=F}},getVideos:function(){return this._videos},findVideo:function(A){return this._videosHash[A]}});MVC.Models.VideoInfo=MVC.Class({construct:function(A){this.videoData=A},_rand:Math.ceil(5*Math.random()),getId:function(){return this.videoData.uuid.$},getTitle:function(A){var B=this.videoData.title.$;A=A||B.length;return this._truncate(B,A)},getDescription:function(A){var B=this.videoData.description.$;A=A||B.length;return this._truncate(B,A)},getTotal:function(){var D="0";var C=this.videoData.usage.usageItem;for(var B=0,A=C.length;B<A;B++){if(C[B].$counterType=="1"){D=C[B].$totalCount;break}}return D},getVideoUrl:function(){var A=this.getId();return MVC.config.fullUrl+"/video/"+MVC.config.language+"/"+MVC.config.locale+"/details/"+A},getThumbailSrc:function(A,B){A=A||84;B=B||112;return"http://img"+this._rand.toString()+".catalog.video.msn.com/image.aspx?uuid="+this.getId()+"&w="+B+"&h="+A},getRating:function(){var D="0";var C=this.videoData.usage.usageItem;for(var B=0,A=C.length;B<A;B++){if(C[B].$counterType=="3"){D=Math.floor(C[B].$totalAverage);if(C[B].$totalCount==1&&D==2){D=0}break}}return D},getStartDate:function(){var A=this.videoData.startDate.$.replace(/[T].*$/g,"").replace(/-/g,"/");A=new Date(A);return A.format("MMMM dd, yyyy")},getProviderId:function(){return this.videoData.providerId.$},getCsid:function(){return this.videoData.csId.$},getSource:function(){var A=this.videoData.source!=undefined?this.videoData.source.$:"";return A},getPageGroup:function(){return this.videoData.pageGroup.$},_truncate:function(C,A){var B=C+"";if(C.length>A){B=C.substr(0,A-3);B+="..."}return B}});
MSVideo.Share={BlogToSpaces:function(D,C,B){var A="http://spaces.live.com/BlogIt.aspx?Title="+encodeURIComponent(D)+"&description="+encodeURIComponent(C)+"&SourceURL="+encodeURIComponent(B);window.open(A,"livespaces","toolbar=0,status=0,height=650,width=1024,scrollbars=yes,resizable=yes,location=1")},Digg:function(D,C,B){var A="http://digg.com/remote-submit?phase=2&url="+B+"&title="+encodeURIComponent(D)+"&bodytext="+encodeURIComponent(C)+"&media=video&topic=Microsoft";window.open(A,"digg","toolbar=0,status=0,height=450,width=650,scrollbars=yes,resizable=yes,location=1")},Delicious:function(C,B){var A="http://del.icio.us/post?noui&v=4&jump=close&url="+B+"&t="+encodeURIComponent(C)+"&partner=microsoft";window.open(A,"delicious","toolbar=0,status=0,height=450,width=650,scrollbars=yes,resizable=yes,location=1")},Facebook:function(B,C){var A="http://www.facebook.com/sharer.php?u="+encodeURIComponent(B)+"&t="+encodeURIComponent(C);window.open(A,"facebook","toolbar=0,status=0,height=450,width=650,scrollbars=yes,resizable=yes,location=1")},Twitter:function(B){var A="http://twitter.com/home?status=Add+This:"+encodeURIComponent(B);window.open(A,"twitter","toolbar=0,status=0,height=450,width=650,scrollbars=yes,resizable=yes,location=1")}};
MSVideo.ControlAddOnResources={AdMessages:{bumper:"Your video will begin in 15 seconds or less.",midRoll:"Your video will resume in 30 seconds.",postRoll:"You may make another video selection in 30 seconds or less."},Tooltip:{Player:[{xname:"PlaySymbol"},{xname:"PauseSymbol"},{xname:"mainPlayButtonIcon"},{xname:"MuteOnSymbol"},{xname:"MuteOffSymbol"}],Portal:[{xname:"detach"},{xname:"dimmer"},{xname:"FullScreenButtonOn"},{xname:"FullScreenButtonOff"}],Detach:[{xname:"FullScreenButtonOn"},{xname:"FullScreenButtonOff"}],Embed:[{xname:"detach"},{xname:"FullScreenButtonOn"},{xname:"FullScreenButtonOff"}]},TooltipSettings:{PlaySymbol:{Text:"Click to play",Width:"75",RelativeLeft:-5,RelativeTop:-23},PauseSymbol:{Text:"Click to pause",Width:"85",RelativeLeft:-5,RelativeTop:-23},detach:{Text:"Detach player",Width:"80",RelativeLeft:-60,RelativeTop:-23},dimmer:{Text:"Dim lights",Width:"60",RelativeLeft:-5,RelativeTop:-23},FullScreenButtonOn:{Text:"Full screen",RelativeLeft:-30,RelativeTop:-23,Width:"65"},FullScreenButtonOff:{Text:"Normal screen",RelativeLeft:-5,RelativeTop:-23,Width:"80"},MuteOnSymbol:{Text:"Sound",Width:"45",RelativeLeft:-5,RelativeTop:-23},MuteOffSymbol:{Text:"Mute",Width:"40",RelativeLeft:-5,RelativeTop:-23},mainPlayButtonIcon:{Text:"Click to play",Width:"75",RelativeLeft:100,RelativeTop:85}},Main:{Icons:[{Text:"EMBED",xname:"Embed",Source:"getCode.png"},{Text:"EMAIL",xname:"Email",Source:"email.png"},{Text:"SHARE",xname:"Share",Source:"socialMedia.png"},{Text:"INFORMATION",xname:"Info",Source:"info.png"}]},RelatedVideos:{Heading:{Text1:{content:"�hnliche Videos"}}},SocialMedia:{Root:{CanvasXaml:'<Canvas Canvas.Left="10" Canvas.Top="0" Canvas.ZIndex="1" Visibility="Collapsed" Name="socialMediaCanvas"/>'},Items:[{xname:"DiggIt",ImageSource:"digg.png",CanvasXaml:'<Canvas Canvas.Left="0" Canvas.Top="5" Canvas.ZIndex="2" Visibility="Visible" Name="diggCanvas"/>',CanvasTop:30,LinkName:"Digg This"},{xname:"Delicious",ImageSource:"delicious.png",CanvasXaml:'<Canvas Canvas.Left="0" Canvas.Top="5" Canvas.ZIndex="2" Visibility="Visible" Name="deliciousCanvas"/>',CanvasTop:50,LinkName:"Del.icio.us"},{xname:"Facebook",ImageSource:"facebook.png",CanvasXaml:'<Canvas Canvas.Left="0" Canvas.Top="5" Canvas.ZIndex="2" Visibility="Visible" Name="facebookCanvas"/>',CanvasTop:70,LinkName:"Facebook"},{xname:"Twitter",ImageSource:"twitter.png",CanvasXaml:'<Canvas Canvas.Left="0" Canvas.Top="5" Canvas.ZIndex="2" Visibility="Visible" Name="twitterCanvas"/>',CanvasTop:90,LinkName:"Twitter"}]},Info:{Root:{CanvasXaml:'<Canvas Canvas.Left="0" Canvas.Top="0" Canvas.ZIndex="1" Visibility="Collapsed" Background="Black" Name="infoCanvas"/>'}}};
StartPlayer=MVC.Class({construct:function(A){this._isCreated=false;this._hostname=A.id;this._playlist=A.playlist;this._zipUrl=A.zipUrl;this._rootElement;this._plugin;this._isEmbed=A.isEmbed!=undefined?A.isEmbed:false;this._placeHolderImage=A.placeHolderImage;this._scripts=A.scripts;this._theme=A.theme;this._autoPlay=A.autoplay;A.source=StartPlayer.createInlineXaml(A.source);this.events=new MSVideo.CustomEvents(this);this.events.add("PlayerLoading");this.events.add("PlayerCreated");this.events.add("MainPlayButtonClick");this.events.add("FullScreenChanged");this.events.add("TimelineSeek");var B="<a onmousedown='MVC.Controllers.Analytics.silverlightInstall()' href='javascript:Silverlight.getSilverlight(\"{1}\");'><img src='/video/Content/img/installSL.gif' alt='"+MSVideo.Resx.SilverlightMessage+"' title=''/></a>";Silverlight.createObjectEx({source:A.source,parentElement:$get(A.parentId),id:this._hostname,properties:{width:A.width||"100%",height:A.height||"100%",version:"1.0",background:"transparent",isWindowless:"true",inplaceInstallPrompt:true,alt:B},events:{onLoad:Function.createDelegate(this,this._getPlayerAssets),onError:function(){}}});var C=this;this._currentMediainfo=0},addEventListener:function(A,B){if(this.events.hasEvent(A)){this.events.addHandler(A,B)}else{if(this._isCreated){this._player.addEventListener(this.getMediaElement(),A,Function.createDelegate(this,B))}else{var C=this;this.events.addHandler("PlayerCreated",function(){C._player.addEventListener(C.getMediaElement(),A,Function.createDelegate(C,B))})}}},getHost:function(){return this._xamlHost.content},getMediaElement:function(){return this._player.get_mediaElement()},findName:function(A,B){B=B||this._rootElement;return B.findName(A)},_getPlayerAssets:function(C,D,A){this._plugin=A.getHost();this._rootElement=A;this._rootElement.findName("BufferingArea_Buffering").begin();var B=this._plugin.createObject("downloader");B.addEventListener("completed",Function.createDelegate(this,this._handleLoad));B.open("GET",this._zipUrl);B.send();this._downloader=B},_handleLoad:function(G,B){var J=this._plugin.content;var H=J.createFromXamlDownloader(G,"player.xaml");var C=this._rootElement.children.getItem(0);C.Children.Add(H);this.events.fire("PlayerLoading");var E=this._scripts;var N;var M=document.getElementsByTagName("head")[0]||document.documentElement;for(var F=0,I=E.length;F<I;F++){N=Sys.$.execScript(G.GetResponseText(E[F]));M.appendChild(N);M.removeChild(N)}this._xamlHost=$get(this._hostname);var L=Sys.$.cookies.enabled()&&(Sys.$.cookies.getCookie("_vvl")!=null)?Math.min(Math.max(Csp.Cookies.getCookie("_vvl"),0),1):0.5;L=isNaN(L)?0.5:L;var K=this;this._player=$create(ExtendedPlayer.Player,{autoPlay:this._autoPlay,autoCue:true,scaleMode:1,muted:false,enableCaptions:false,volume:L},{volumeChanged:function(O){Sys.$.cookies.setCookie("_vvl",O.get_volume())}},null,this._xamlHost);this._player.set_mediaSource(this._playlist[0].mediaSource);var D=location.href;this._plugin.content.onfullScreenChange=function(O){this.events.fire("FullScreenChanged",[O])}.scope(this);this._isCreated=true;this.findName("mainPlayButton").AddEventListener("MouseLeftButtonDown",Function.createDelegate(this,function(O){Sys.xaml(O).hide();this.events.fire("MainPlayButtonClick");this._player.play()}));this.events.fire("PlayerCreated");this.findName("TimeSlider").AddEventListener("MouseLeftButtonDown",function(O){this.events.fire("TimelineSeek",[this])}.scope(this));var A=this.findName("TimeThumb");A.AddEventListener("MouseLeftButtonDown",function(S){var R=this.findName("rootVideoCanvas");var P=function(T){this.events.fire("TimelineSeek",[this]);T.RemoveEventListener("MouseLeftButtonUp",Q);T.RemoveEventListener("MouseLeftButtonUp",O)}.scope(this);var Q=R.AddEventListener("MouseLeftButtonUp",P);var O=R.AddEventListener("MouseLeave",P)}.scope(this));this._downloader=null}});StartPlayer.createInlineXaml=function(C){var B=['<?xml version="1.0"?>','<Canvas xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"	xmlns="http://schemas.microsoft.com/client/2007" Width="430" Height="326">','<Canvas x:Name="theRootCanvas" Width="430" Height="326">',"<Canvas.RenderTransform>",'<ScaleTransform x:Name="rootVideoCanvasTransform" ScaleX="1" ScaleY="1" CenterX="215" CenterY="163" />',"</Canvas.RenderTransform>","<Canvas.Resources>",'<Storyboard x:Name="BufferingArea_Buffering">','<DoubleAnimation BeginTime="00:00:00" Storyboard.TargetName="BufferingArea" Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:00.25" />','<DoubleAnimation RepeatBehavior="Forever" BeginTime="00:00:00" Storyboard.TargetName="timeclock" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" From="0" To="-360" Duration="00:00:00.5" />',"</Storyboard>","</Canvas.Resources>",'<Canvas x:Name="BufferingArea" Width="430" Height="326" Canvas.ZIndex="0" IsHitTestVisible="false">',"<Canvas.RenderTransform>",'<ScaleTransform x:Name="loadingImageScale" ScaleX="1" ScaleY="1" CenterX="0" CenterY="0" />',"</Canvas.RenderTransform>",'<Canvas x:Name="timeclock" Canvas.Left="200" Canvas.Top="142" Width="30.5" Height="30.25" RenderTransformOrigin="0.5,0.5">',"<Canvas.RenderTransform>","<TransformGroup>",'<RotateTransform Angle="0"/>',"</TransformGroup>","</Canvas.RenderTransform>",'<Ellipse Fill="#FF7D7D7D" Width="7.75" Height="7.75" x:Name="e1" Canvas.Left="3.25" Canvas.Top="19.25"/>','<Ellipse Fill="#FF959595" Width="7.75" Height="7.75" x:Name="e2" Canvas.Left="11" Canvas.Top="22.5"/>','<Ellipse Fill="#FFACACAC" Width="7.75" Height="7.75" x:Name="e3" Canvas.Left="19.25" Canvas.Top="19.25"/>','<Ellipse Fill="#FFC1C1C1" Width="7.75" Height="7.75" x:Name="e4" Canvas.Left="22.75" Canvas.Top="11.25"/>','<Ellipse Fill="#FFD7D7D7" Width="7.75" Height="7.75" x:Name="e5" Canvas.Left="19" Canvas.Top="3"/>','<Ellipse Fill="#FFEBEBEB" Width="7.75" Height="7.75" x:Name="e6" Canvas.Left="11.25"/>','<Ellipse Fill="#FFF5F5F5" Width="7.75" Height="7.75" x:Name="e7" Canvas.Left="3.25" Canvas.Top="3.5"/>','<Ellipse Fill="#FFFFFFFF" Width="7.75" Height="7.75" x:Name="e8" Canvas.Top="11.25"/>',"</Canvas>","</Canvas>","</Canvas>",'<Image x:Name="chromeBorder" Source="/video/Content/img/chrome_border.png" Canvas.ZIndex="-1" Width="430" Height="326" Canvas.Left="0" Canvas.Top="0" Visibility="Collapsed" />',"</Canvas>"].join("");var A=Sys.$.execScript(B,{type:"text/xaml",id:C});document.body.appendChild(A);if(!document.getElementById(C)){return"/video/xaml/empty.xaml"}else{return"#"+C}};