function createNamespace(e){var a=window,d=e.split("."),f=d.length;for(var c=0;c<f;c++){var b=d[c];if(!a[b])a[b]={};a=a[b]}}createNamespace("SoapboxService.Utils");SoapboxService.Utils.CreateEnum=function(){var a={};a.parse=function(h){var e=h.split("|"),f=0;for(var c=e.length-1;c>=0;c--){var g=e[c].trim(),d=false;for(var b in a)if(b==g){f|=a[b];d=true;break}if(d==false)throw new Error("Invalid Enumeration Value")}return f};a.toString=function(d){var b=new Sys.StringBuilder;for(var c in a)if((a[c]&d)!=0){if(b.isEmpty()==false)b.append(" | ");b.append(c)}return b.toString()};a.getName=function(){return name};a.isFlags=function(){return true};var c=arguments.length;for(var b=0;b<c;b+=2)a[arguments[b]]=arguments[b+1];return a};SoapboxService.Utils.GetUrlWithParams=function(a,c){a+=a.indexOf("?")==-1?"?":"";for(var b=0;b<c.length;b++){if(b>0)a+="&";a+=encodeURIComponent(c[b].Name)+"="+encodeURIComponent(c[b].Value.toString())}return a};SoapboxService.Utils.HashCodeFletcher=function(e){var c=e.length,a=65535,b=65535,f=0;while(c){var d=c>360?360:c;c-=d;do{a+=e.charCodeAt(f++);b+=a}while(--d);a=(a&65535)+(a>>16);b=(b&65535)+(b>>16)}a=(a&65535)+(a>>16);b=(b&65535)+(b>>16);return b<<16|a};function checkDefined(a){return typeof a!="undefined"&&null!=a}function checkString(a){return typeof a=="string"&&a.length>0}function checkStringNull(a){return checkString(a)&&a!="null"}function checkFloat(a,c,b){if(parseFloat(a)||0==a){if(checkDefined(c))if(a<c)return false;if(checkDefined(b))if(a>b)return false;return true}return false}function checkInt(a,c,b){if(null!=a&&(typeof a!="string"||""!=a)&&!isNaN(a)){if(checkDefined(c))if(a<c)return false;if(checkDefined(b))if(a>b)return false;return true}return false}function checkObject(a){return typeof a=="object"&&null!=a}function checkFunction(a){return typeof a=="function"}function checkGuid(a){var b=/^\{?[a-fA-F\d]{8}-?([a-fA-F\d]{4}-?){3}[a-fA-F\d]{12}\}?$/;return b.test(a)}function checkArray(b,d,c){var a=b instanceof Array;if(checkInt(d))a=a&&b.length>=d;if(checkInt(c))a=a&&b.length<=c;return a}function isTrue(a){switch(typeof a){case "boolean":return a;case "string":return a.toLowerCase()=="true";default:return false}}createNamespace("Msn.Json");Msn.Json.HttpRequestManager=function(){this.cfg={ENCODING:"responseEncoding",TIMEOUT:20000};var _this=this,_factories=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],_factory=null;this.NewRequest=function(){if(null!=_factory)return _factory();for(var a=0;a<_factories.length;a++)try{var b=_factories[a]();if(null!=b){_factory=_factories[a];return b}}catch(c){continue}_factory=function(){throw new error("XMLHttpRequest is not supported")};_factory()};this.MakeRequest=function(vidRequest){var request;try{request=this.NewRequest()}catch(a){vidRequest.ErrCallback(vidRequest.Context);return}var timer=setTimeout(function(){handleTimeout(request,vidRequest.ErrCallback,vidRequest.Context)},this.cfg.TIMEOUT);request.onreadystatechange=function(){if(request.readyState==4){if(timer)clearTimeout(timer);if(request.status==200){var json;eval("json ="+request.responseText);vidRequest.Callback(json,vidRequest.Context)}else vidRequest.ErrCallback(vidRequest.Context)}};vidRequest.AddParam(this.cfg.ENCODING,"json");var verb,url,params;if(vidRequest.HttpMethod=="post"){verb="POST";url=vidRequest.Url;params=encodePostParams(vidRequest.Params())}else{verb="GET";url=vidRequest.UrlWithParams();params=null}request.open(verb,url,true);if(verb=="POST")request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");request.send(params)};function handleTimeout(c,b,a){c.abort();b(a)}function encodePostParams(b){var c=[],d=/%20/g;for(var a=0;a<b.length;a++){var e=encodeURIComponent(b[a].Name).replace(d,"+")+"="+encodeURIComponent(b[a].Value).replace(d,"+");c.push(e)}return c.join("&")}};Msn.HttpRequestManager=new Msn.Json.HttpRequestManager;createNamespace("VideoService");VideoService.RequestFactory=function(g,h){var a=g,b=h;this.Create=function(a,b){switch(a){case VideoService.RequestType.Soapbox:return e();case VideoService.RequestType.VC:return f(b);case VideoService.RequestType.UserVideo:return d();case VideoService.RequestType.UserComments:return c();default:throw"Request type not supported"}};function e(){return new SoapboxService.Request(a)}function f(a){return new VCService.Request(b,a)}function d(){return new UserVideoService.Request(a,b)}function c(){return new UserCommentsService.Request(a,b)}};VideoService.RequestType=SoapboxService.Utils.CreateEnum("Soapbox",0,"VC",1,"UserVideo",2);createNamespace("VideoService");VideoService.RequestManagerFactory=new function(){this.Create=function(a){switch(a){case VideoService.HandlerType.XMLHTTP:return Msn.HttpRequestManager;default:return Msn.VideoRequestManager}}};VideoService.HandlerType=SoapboxService.Utils.CreateEnum("XMLHTTP",0,"AJAX",1);createNamespace("SoapboxService");SoapboxService.Config=function(b,a,c){this.AppServiceId=b;this.GetServiceUrl=function(){var b=typeof a=="string"&&a.length>0?a:"http://video.msn.com";return b+"/SoapboxService2.aspx"};this.HandlerType=c};createNamespace("SoapboxService");SoapboxService.ResultCode=SoapboxService.Utils.CreateEnum("Success",0,"UnknownError",1,"NotSignedIn",2,"OffendingInput",3,"LimitReached",4,"InvalidInput",5,"NicknameNotSet",6,"FeatureNotAvailable",7,"PermissionDenied",8,"BetaNotAuthorized",9,"VideoNotFound",10,"VideoNotEditable",11,"AccessDenied",12,"InvalidTitle",13,"InvalidDescription",14,"InvalidCategory",15,"InvalidTags",16,"InvalidPermission",17,"StorageFull",18,"UnknownFileType",19,"FileNotSpecified",20,"InvalidUserId",21,"InvalidVideoId",22,"InvalidTimeStamp",23,"InvalidHash",24,"InvalidAppServiceId",25,"UploadQuotaExceeded",26,"ABCHServiceDownRetry",27,"ABCHServiceDownFailed",28,"InvalidFriendsList",29,"ReverseIPLookupFailed",30);SoapboxService.NicknameCode=SoapboxService.Utils.CreateEnum("Success",0,"UnknownError",1,"TooManyChanges",2,"TooShort",3,"TooLong",4,"Offensive",5,"InvalidChar",6,"ServiceDown",7,"NotSignedIn",8,"AccessDenied",9,"CannotOverride",10,"AlreadyTaken",-1);SoapboxService.SearchType=SoapboxService.Utils.CreateEnum("Keyword",1,"User",2,"Tag",3,"Favorites",4,"AllVideos",5,"Channel",6,"Recommendations",7,"List",8,"Source",9,"Shared",10);SoapboxService.OffensiveType=SoapboxService.Utils.CreateEnum("Offensive",0,"ChildAbuse",1,"Nudity",2,"Harassment",3,"Copyrighted",4,"RacialDiscrimination",7);SoapboxService.SortOrder=SoapboxService.Utils.CreateEnum("Default",0,"Relevance",0,"Rating",1,"DateUploaded",2,"Playcount",3);SoapboxService.VideoStatus=SoapboxService.Utils.CreateEnum("New",0,"Processing",1,"Published",2,"Failed",3,"Approved",4,"Rejected",5,"Pending",6,"LockedForReview",7);createNamespace("SoapboxService");SoapboxService.Request=function(c){var b=c,a;this.cfg={METHOD:"mn",APPID:"appServiceId"};this.Execute=function(d,i,f,c,h,g){a=new Msn.Json.VideoRequest(b.GetServiceUrl(),f,c,g,h);a.AddParam(this.cfg.METHOD,d);a.AddParam(this.cfg.APPID,b.AppServiceId);a.AddParams(i);var e=VideoService.RequestManagerFactory.Create(b.HandlerType);e.MakeRequest(a)}};createNamespace("VideoService");VideoService.Proxy=function(c,b){var e=this,d=typeof b=="object"&&null!=b?b:VCService.Config.Default(),a=new VideoService.RequestFactory(c,d);this.GetAllUserVideos=function(c,f,d,b,e){var h=a.Create(VideoService.RequestType.Soapbox),g={"maxResults":c,"offset":f};h.Execute("getalluservideos",g,d,b,e)};this.GetUserVideoListPrivate=function(j,f,b,e,k,g,h,d,i){var c=a.Create(VideoService.RequestType.UserVideo),l={"userCid":j,"isPrivate":f,"rct":b,"maxResults":e,"videoType":g,"offset":k};if(b==VCService.UsageEventType.Bookmarked)c.SetAutoFill(true);c.Execute("getuservideolistprivate",l,h,d,i)};this.GetPublicUserVideos=function(f,c,g,d,b,e){var i=a.Create(VideoService.RequestType.UserVideo),h={"userCid":f,"maxResults":c,"offset":g};i.Execute("getpublicuservideos",h,d,b,e)};this.GetSharedUserVideos=function(c,f,d,b,e){var h=a.Create(VideoService.RequestType.Soapbox),g={"maxResults":c,"offset":f};h.Execute("getsharedvideos",g,d,b,e)};this.LoadVideo=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e};g.Execute("loadvideo",f,c,b,d)};this.LoadUserVideoData=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e};g.Execute("loaduservideodata",f,c,b,d)};this.GetCopyRightResult=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e};g.Execute("getcopyrightresult",f,c,b,d)};this.PostComment=function(g,e,c,h,d,b,f){var j=a.Create(VideoService.RequestType.Soapbox),i={"videoId":g,"comment":e,"maxResults":c,"offset":h};j.Execute("postcomment",i,d,b,f,"post")};this.GetComments=function(f,c,g,d,b,e){var i=a.Create(VideoService.RequestType.Soapbox),h={"videoId":f,"maxResults":c,"offset":g};i.Execute("getcomments",h,d,b,e)};this.DeleteComment=function(d,g,c,h,e,b,f){var j=a.Create(VideoService.RequestType.Soapbox),i={"commentId":d,"videoId":g,"maxResults":c,"offset":h};j.Execute("deletecomment",i,e,b,f,"post")};this.GetUserComments=function(f,c,g,d,b,e){var i=a.Create(VideoService.RequestType.UserComments),h={"userCid":f,"maxResults":c,"offset":g};i.Execute("getusercomments",h,d,b,e)};this.AddTag=function(e,h,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e,"tag":h};g.Execute("addtag",f,c,b,d,"post")};this.AddPrivateTag=function(e,h,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e,"tag":h};g.Execute("addprivatetag",f,c,b,d,"post")};this.RemoveTag=function(e,h,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e,"tag":h};g.Execute("removetag",f,c,b,d,"post")};this.RemovePrivateTag=function(e,h,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e,"tag":h};g.Execute("removeprivatetag",f,c,b,d,"post")};this.LoadUserTags=function(g,d,h,b,e,c,f){var j=a.Create(VideoService.RequestType.Soapbox),i={"userCid":g,"maxResults":d,"offset":h,"alphabetize":b};j.Execute("loadusertags",i,e,c,f)};this.SetVideoRating=function(e,g,c,b,d){var h=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e,"value":g};h.Execute("setvideorating",f,c,b,d,"post")};this.ClearVideoRating=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e};g.Execute("clearvideorating",f,c,b,d,"post")};this.GetCategories=function(c,b,d){var f=a.Create(VideoService.RequestType.Soapbox),e={};f.Execute("getcategories",e,c,b,d,"post")};this.AddFavorite=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e};g.Execute("addfavorite",f,c,b,d,"post")};this.RemoveFavorite=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e};g.Execute("removefavorite",f,c,b,d,"post")};this.GetCountryCode=function(c,d,b,e){var g=a.Create(VideoService.RequestType.Soapbox),f={"ipAddress":c};g.Execute("getcountrycode",f,d,b,e)};this.GetNickname=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"userCid":e};g.Execute("getnickname",f,c,b,d)};this.SetNickname=function(b,d,c,e){var g=a.Create(VideoService.RequestType.Soapbox),f={"desiredNickname":b};g.Execute("setnickname",f,d,c,e,"post")};this.SetCustomNickname=function(b,d,c,e){var g=a.Create(VideoService.RequestType.Soapbox),f={"desiredNickname":b};g.Execute("setcustomnickname",f,d,c,e,"post")};this.GetUserProperties=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"userCid":e};g.Execute("getuserproperties",f,c,b,d)};this.GetCurrentUserInfo=function(c,b,d){var f=a.Create(VideoService.RequestType.Soapbox),e={};f.Execute("getcurrentuserinfo",e,c,b,d)};this.FlagOffensive=function(g,d,e,c,b,f){var i=a.Create(VideoService.RequestType.Soapbox),h={"videoId":g,"flagType":d,"comment":e};i.Execute("flagoffensive",h,c,b,f,"post")};this.FlagOffensiveComment=function(c,f,d,b,e){var h=a.Create(VideoService.RequestType.Soapbox),g={"videoId":f,"commentId":c};h.Execute("flagoffensivecomment",g,d,b,e,"post")};this.ReportPlayback=function(e,f,c,b,d){var h=a.Create(VideoService.RequestType.Soapbox),g={"videoId":e,"isSkip":f};h.Execute("reportplayback",g,c,b,d,"post")};this.EditVideo=function(e,h,i,g,k,j,c,b,d){var l=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e,"title":h,"desc":i,"catId":g,"tags":k,"perm":j};l.Execute("editvideo",f,c,b,d,"post")};this.DeleteVideo=function(e,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),f={"videoId":e};g.Execute("deletevideo",f,c,b,d,"post")};this.DeleteSharedVideo=function(f,e,c,b,d){var h=a.Create(VideoService.RequestType.Soapbox),g={"videoId":f,"ownerId":e};h.Execute("deletesharedvideo",g,c,b,d,"post")};this.EmailVideo=function(c,e,g,h,d,b,f){var j=a.Create(VideoService.RequestType.Soapbox),i={"toEmailId":c,"fromName":e,"message":g,"videoId":h};j.Execute("emailvideo",i,d,b,f,"post")};this.RecordExpTrigger=function(f,c,b,d){var g=a.Create(VideoService.RequestType.Soapbox),e={"expId":f};g.Execute("recordexptrigger",e,c,b,d,"post")};this.RecordExpObservation=function(c,g,d,b,e){var h=a.Create(VideoService.RequestType.Soapbox),f={"observName":c,"data":g};h.Execute("recordexpobservation",f,d,b,e,"post")};this.GetUploadCredentials=function(g,h,j,i,f,c,b,d){var k=a.Create(VideoService.RequestType.Soapbox),e={"title":g,"desc":h,"tags":j,"perm":i,"catId":f};k.Execute("getuploadcredentials",e,c,b,d,"post")};this.AddPermissions=function(h,d,b,e,f,c,g){var j=a.Create(VideoService.RequestType.Soapbox),i={"videoId":h,"friendsList":d,"newFriendsList":b,"memberType":e};j.Execute("addpermissions",i,f,c,g,"post")};this.DeletePermissions=function(g,c,d,e,b,f){var i=a.Create(VideoService.RequestType.Soapbox),h={"videoId":g,"friendsList":c,"memberType":d};i.Execute("deletepermissions",h,e,b,f,"post")};this.GetActivities=function(h,d,c,f,e,b,g){var j=a.Create(VideoService.RequestType.Soapbox),i={"poolKey":h,"bucketKey":d,"startIndex":c,"endIndex":f};j.Execute("getactivities",i,e,b,g,"post")};this.ReportActivity=function(c,f,d,e,b,g){var i=a.Create(VideoService.RequestType.Soapbox),h={"viewKeys":f,"clickKeys":d,"bucketKey":c};i.Execute("reportactivity",h,e,b,g,"post")}};createNamespace("UserCommentsService");UserCommentsService.Request=function(f,g){var d=this,e=new VideoService.RequestFactory(f,g),c=function(){},b=function(){},a=null;this.Execute=function(d,i,f,a,g){c=f;b=a;var h=e.Create(VideoService.RequestType.Soapbox);h.Execute(d,i,this.OnSbRequestCb,this.OnSbRequestErrCb,g)};this.OnSbRequestCb=function(b,h){if(checkObject(b)&&checkDefined(b.Comments)){a=b;if(b.Comments.length>0){var g="";for(var f=0;f<b.Comments.length;f++){if(f>0)g+=",";g+=b.Comments[f].VideoId}var i=e.Create(VideoService.RequestType.VC,VCService.Domain.Soapbox);i.Execute("videobyuuids",{"uuids":g},d.OnVcRequestCb,d.OnVcRequestErrCb,h)}else c(d.BuildEmptyResult(),h)}};this.OnSbRequestErrCb=function(a){b(a)};this.OnVcRequestCb=function(b,d){if(checkObject(a)&&checkObject(b)){a.Videos=b.Videos;c(a,d)}};this.OnVcRequestErrCb=function(a){b(a)};this.BuildEmptyResult=function(){a.Videos=[];return a}};createNamespace("UserVideoService");UserVideoService.Request=function(g,h){var b=this,f=new VideoService.RequestFactory(g,h),d=function(){},c=function(){},a=null,e=false;this.Execute=function(b,i,e,a,g){d=e;c=a;var h=f.Create(VideoService.RequestType.Soapbox);h.Execute(b,i,this.OnSbRequestCb,this.OnSbRequestErrCb,g)};this.SetAutoFill=function(a){e=isTrue(a)};this.OnSbRequestCb=function(c,e){if(checkObject(c)&&checkDefined(c.VideoIds)){a=c;if(c.VideoIds.length>0){var g=c.VideoIds.join(","),h=f.Create(VideoService.RequestType.VC,VCService.Domain.Soapbox);h.Execute("videobyuuids",{"uuids":g},b.OnVcRequestCb,b.OnVcRequestErrCb,e)}else d(b.BuildEmptyResult(),e)}};this.OnSbRequestErrCb=function(a){c(a)};this.OnVcRequestCb=function(j,l){if(checkObject(a)&&checkObject(j)){var c={},i=a.VideoIds,g=j.Videos,k=i.length,f=g.length;c.SearchKey="uservideolist";c.Videos=g;c.Count=f;if(e&&f<k){var h=b.FindRejectedVideos(i,g);c.Videos=c.Videos.concat(b.CreateRejectedVideos(h));c.Count=f+h.length}c.Offset=a.Offset;c.TotalCount=a.TotalCount;c.SearchType="";d(c,l)}};this.CreateRejectedVideos=function(d){var c=[];for(var b=0;b<d.length;b++){var a={};a.Id=d[b];a.Status=SoapboxService.VideoStatus.Rejected;c.push(a)}return c};this.FindRejectedVideos=function(c,f){var e=c.length,g=f.length,b=[],a=0,d=0;while(d<g){if(c[a]==f[d].Id)d++;else b.push(c[a]);a++}if(a<e)b=b.concat(c.splice(a,e-a));return b};this.OnVcRequestErrCb=function(a){c(a)};this.BuildEmptyResult=function(){var b={};b.SearchKey="uservideolist";b.Videos=[];b.Count=0;b.Offset=a.Offset;b.TotalCount=0;b.SearchType="";return b}};createNamespace("VCService");VCService.Adapter=function(a){this.ConvertSearchResult=function(a,c){var d=null;if(checkObject(a)){var b=this.ConvertVideoList(a);if(checkDefined(b)){var g=c?a.$tag:a.$q,e=c?SoapboxService.SearchType.Tag:SoapboxService.SearchType.Keyword,f=checkInt(a.$total)?a.$total:b.length;d={"SearchKey":g,"Videos":b,"Count":b.length,"Offset":a.$ind-1,"TotalCount":f,"SearchType":e}}}return d};this.ConvertVideoList=function(a){var d=[];if(checkObject(a)&&checkArray(a.video)){var c=a.video;for(var b=0;b<c.length;b++){var e=this.ConvertVideo(c[b]);if(e)d.push(e)}}return d};this.ConvertVideo=function(d){var c={};try{c.CsId=d.csId.$;c.GeoAvailable=this.getVideoGeoAvailable(d);if(!c.GeoAvailable)return null;c.Title=b(d.title.$);c.Description=b(d.description.$);c.Id=d.uuid.$;c.Source=d.source.$;c.SourceFriendlyName=b(d.source.$friendlyName);c.Provider=d.providerId.$;c.MediaFiles=[this.getVideoFileUrl(d,1002),this.getVideoFileUrl(d,1003)];c.StreamLength=d.durationSecs.$;c.StartDate=d.startDate.$;c.ReleaseDate=d.startDate.$;c.RelatedLinks=this.getVideoRelatedLinks(d);c.PosterFrame=this.getFileUrl(d,2009);if(a.UseImageScaling){var e=a.GetRandomImageUrl(c.Id),g=d.$version;if(checkString(e)){var f="{0}/Image.aspx?uuid={1}&w={2}&h={3}";c.Thumbnail=f.format(e,c.Id,112,84);c.MiniThumbnail=f.format(e,c.Id,64,48);c.MediumThumbnail=f.format(e,c.Id,228,171);c.PosterFrame=f.format(e,c.Id,424,318)}}if(c.CsId==a.SoapboxCsId){if(!a.IsSoapboxEnabled)return null;c.Status=this.getVideoStatus(d);c.OwnerId=c.Source;c.OwnerNickname=c.SourceFriendlyName;if(!checkString(c.MediaFiles[VCService.MediaFormat.WMV])&&checkString(c.Id))c.MediaFiles[VCService.MediaFormat.WMV]=a.StreamingHostUrl+"/StreamingUrl.aspx?vid="+c.Id;if(!checkString(c.MediaFiles[VCService.MediaFormat.FLV])&&checkString(c.Id))c.MediaFiles[VCService.MediaFormat.FLV]=a.StreamingHostUrl+"/StreamingUrl.aspx?vid="+c.Id+"&t=.flv";if(!checkString(c.Thumbnail)){c.Thumbnail=this.getFileUrl(d,2007);if(!checkString(c.Thumbnail))c.Thumbnail=this.getFileUrl(d,2008)}c.Channels=this.getVideoCategory(d);c.Market=a.SoapboxMarket;c.PageGroup=this.getVideoPageGroup(d,a.SoapboxPageGroup);c.BSBPageGroup=a.SoapboxBsbPageGroup}else{if(!checkString(c.Thumbnail))c.Thumbnail=this.getFileUrl(d,2007);c.FlashMetadata=this.getFileUrl(d,1201);c.Status=SoapboxService.VideoStatus.Published;c.Market=a.VcMarket;c.PageGroup=this.getVideoPageGroup(d,a.MsnVideoPageGroup);c.BSBPageGroup=a.MsnVideoBsbPageGroup}c.Tags=this.getVideoTags(d,true);c.AllTags=this.getVideoTags(d,false);c.AverageRating=parseFloat(this.getUsage(d,VCService.UsageEventType.Rated,VCService.UsageCounterType.Average));c.PlayCount=this.getUsage(d,VCService.UsageEventType.Played,VCService.UsageCounterType.Total);c.NumComments=this.getUsage(d,VCService.UsageEventType.Reviewed,VCService.UsageCounterType.Total);c.NumFavorites=this.getUsage(d,VCService.UsageEventType.Bookmarked,VCService.UsageCounterType.Total);c.PlayCountExtended=this.getUsage(d,VCService.UsageEventType.Played,VCService.UsageCounterType.Extended);c.NumCommentsExtended=this.getUsage(d,VCService.UsageEventType.Reviewed,VCService.UsageCounterType.Extended);c.NumFavoritesExtended=this.getUsage(d,VCService.UsageEventType.Bookmarked,VCService.UsageCounterType.Extended)}catch(h){c=null}return c};function b(b){var a="";try{tempDiv=document.createElement("DIV");tempDiv.innerHTML=b+"&nbsp;";a=tempDiv.innerText;a=a.replace("\\r\\n","");a=a.replace(/\s*$/g,"")}catch(c){}return a}this.convertExtendedMetadata=function(a){return a};this.getVideoPageGroup=function(b,c){var a=c;if(checkObject(b)&&checkObject(b.pageGroup)&&checkString(b.pageGroup.$))switch(b.pageGroup.$){case "MSVBSB":case "MSVTV3":case "MSVBST":case "MSNFBS":a="MSVV43";break;case "MSNTV4":case "MSNSCB":case "MSCVE4":case "MSVAP4":case "MSVCE4":case "MSVCF4":case "MSVSCB":case "MSVUK4":a="MSVV44";break;case "MSVNPB":case "MSVTVM":case "MSVNP1":a="MSVV42";break;default:if(checkString(c))a=c;else a=b.pageGroup.$}return a};this.getVideoStatus=function(a){var c=null;if(checkObject(a)&&checkObject(a.tags))for(var b=0;b<a.tags.tag.length;b++){var d=a.tags.tag[b];if(d.$namespace=="UserVideoStatus"){c=parseInt(d.$);break}}return c};this.getVideoGeoAvailable=function(c){var b=true;if(c.csId.$==a.SoapboxCsId&&!a.IsSoapboxEnabled)b=false;return b};this.getVideoRelatedLinks=function(a){var d=[];if(checkObject(a)&&checkObject(a.extendedXml)&&checkObject(a.extendedXml.relatedLinks)&&checkObject(a.extendedXml.relatedLinks.link))if(checkDefined(a.extendedXml.relatedLinks.link.length))for(var c=0;c<a.extendedXml.relatedLinks.link.length;c++){var b={};b.url=a.extendedXml.relatedLinks.link[c].$url;b.text=a.extendedXml.relatedLinks.link[c].$;d[c]=b}else{b={};b.url=a.extendedXml.relatedLinks.link.$url;b.text=a.extendedXml.relatedLinks.link.$;d[0]=b}return d};this.getVideoTags=function(a,g){var f=[];if(checkObject(a)&&checkObject(a.tags)){var e=checkArray(a.tags.tag)?a.tags.tag:checkDefined(a.tags.tag)?[a.tags.tag]:[];for(var d=0;d<e.length;d++){var c=e[d];if(!g||c.$namespace=="User"){var b={};b.Name=c.$;b.Namespace=c.$namespace;f.push(b)}}}return f};this.getVideoCategory=function(a){var d=[];if(checkObject(a)&&checkObject(a.tags))for(var b=0;b<a.tags.tag.length;b++){var e=a.tags.tag[b];if(e.$namespace=="Category"){var c={};c.Id=e.$;d[0]=c;break}}return d};this.getVideoFileUrl=function(a,d){var c=null;if(checkObject(a)&&checkObject(a.videoFiles)&&checkObject(a.videoFiles.videoFile))for(var b=0;b<a.videoFiles.videoFile.length;b++)if(a.videoFiles.videoFile[b].$formatCode==d){c=a.videoFiles.videoFile[b].uri.$;break}return c};this.getFileUrl=function(a,d){var c=null;if(checkObject(a)&&checkObject(a.files)&&checkObject(a.files.file))for(var b=0;b<a.files.file.length;b++)if(a.files.file[b].$formatCode==d){c=a.files.file[b].uri.$;break}return c};this.getUsage=function(a,d,e){var c=null;if(checkObject(a)&&checkObject(a.usage)&&checkObject(a.usage.usageItem))for(var b=0;b<a.usage.usageItem.length;b++)if(a.usage.usageItem[b].$counterType==d){switch(e){case VCService.UsageCounterType.Total:c=a.usage.usageItem[b].$totalCount;break;case VCService.UsageCounterType.Average:c=a.usage.usageItem[b].$totalAverage;break;case VCService.UsageCounterType.Extended:c={hourlyCount:a.usage.usageItem[b].$hourlyCount,dailyCount:a.usage.usageItem[b].$dailyCount,weeklyCount:a.usage.usageItem[b].$weeklyCount,monthlyCount:a.usage.usageItem[b].$monthlyCount,allTimes:a.usage.usageItem[b].$totalCount};break}break}return c};this.convertRelatedTagsResult=function(b){var e,d=null;if(checkObject(b)&&checkObject(b.tag)){e=b.$mk==a.SoapboxMarket?VCService.Domain.Soapbox:VCService.Domain.VideoCatalog;d=[];for(var c=0;c<b.tag.length&&c<this.cfg.MAX_RELATED_TAGS;c++){var f={"Type":Msn.CloudEntryType.Tags,"Name":b.tag[c].$name,"Data":e};d.push(f)}}return d};this.convertTemplate=function(b){var a=null;if(checkObject(b)&&checkObject(b.template)){var c,g=b.template,f=["default","g0","g1","g2"];for(var e=0;e<f.length;e++){var d=f[e];if(checkDefined(g[d])){a={};a.type=d;c=g[d];break}}if(checkObject(a)&&checkObject(c)){a.label=b.$label;a.menuId=b.$id;switch(a.type){case "default":a.videosUrl=c.videosRef.$videosUrl;break;case "g0":case "g1":case "g2":a.header=this.convertTemplateHeader(c.header);a.section=this.convertTemplateSection(c.section);break}}}return a};this.convertTemplateHeader=function(a){var d=[];if(checkObject(a))for(var b=0;b<a.length;b++)try{var c={};c.imageUrl=a[b].$imageUrl;c.videoRef=a[b].$videoRef;c.caption=a[b].$caption;c.headline=a[b].$headline;c.copyright=a[b].$copyright;d.push(c)}catch(e){}return d};this.convertTemplateSection=function(a){var d=[];if(checkObject(a))for(var b=0;b<a.length;b++)try{var c={};c.title=a[b].$title;c.imageUrl=a[b].$imageUrl;c.videosUrl=a[b].videosRef.$videosUrl;d.push(c)}catch(e){}return d}};createNamespace("VCService");VCService.Config=function(){var b=[],a=[];this.VCServiceUrl="http://catalog.video.msn.com";this.SoapboxMarket="uv-en-us";this.VcMarket="us";this.RandomServerArray=[];this.RandomImageUrlArray=[];this.Lcid="";this.SoapboxCsId="";this.IsSoapboxEnabled=true;this.UseImageScaling=true;this.MaxRelatedTags=25;this.MsnVideoPageGroup="";this.SoapboxPageGroup="";this.MsnVideoBsbPageGroup="";this.SoapboxBsbPageGroup="";this.StreamingHostUrl="";this.GetFilter=function(){return this.GetFilterMask().toString(16)};this.GetFilterMask=function(){var b=0;for(var c=0;c<a.length;c++)b=b|a[c];return b};this.GetUsageCounters=function(){return b.join(",")};this.AddFilter=function(b){a.push(b)};this.AddUsageCounter=function(a){b.push(a)};this.GetServiceUrl=function(b){var a=this.VCServiceUrl;if(checkArray(this.RandomServerArray)&&this.RandomServerArray.length>0){var c=Math.abs(SoapboxService.Utils.HashCodeFletcher(b));a=this.RandomServerArray[c%this.RandomServerArray.length]}return a};this.GetRandomImageUrl=function(b){var a=this.VCServiceUrl;if(checkArray(this.RandomImageUrlArray)&&this.RandomImageUrlArray.length>0){var c=Math.abs(SoapboxService.Utils.HashCodeFletcher(b));a=this.RandomImageUrlArray[c%this.RandomImageUrlArray.length]}return a}};VCService.Config.Default=function(){var a=new VCService.Config;a.AddFilter(VCService.FilterType.HasThumbnail);a.AddFilter(VCService.FilterType.IsPublished);a.AddFilter(VCService.FilterType.HasFlash);a.AddUsageCounter(VCService.UsageEventType.Played);a.AddUsageCounter(VCService.UsageEventType.Rated);a.AddUsageCounter(VCService.UsageEventType.Reviewed);a.AddUsageCounter(VCService.UsageEventType.Bookmarked);a.SoapboxMarket="uv-en-us";a.VCMarket="us";a.ServiceUrl="http://catalog.video.msn.com";a.RandomServerArray=["http://edge1.catalog.video.msn.com","http://edge2.catalog.video.msn.com","http://edge3.catalog.video.msn.com","http://edge4.catalog.video.msn.com","http://edge5.catalog.video.msn.com"];return a};createNamespace("VCService");VCService.UsageEventType=SoapboxService.Utils.CreateEnum("Played",1,"Emailed",2,"Rated",3,"Blogged",4,"Reviewed",5,"Bookmarked",6,"PlaybackFailed",7,"TimeSpent",8,"Recommended",9);VCService.UsageCounterType=SoapboxService.Utils.CreateEnum("Total",0,"Average",1,"Extended",2);VCService.FilterType=SoapboxService.Utils.CreateEnum("HasWmv",1,"HasFlash",2,"HasThumbnail",8,"HasMediumImg",16,"IsPublished",128);VCService.Domain=SoapboxService.Utils.CreateEnum("Soapbox",0,"VideoCatalog",1);VCService.MediaFormat=SoapboxService.Utils.CreateEnum("WMV",0,"FLV",1);createNamespace("VCService");VCService.Request=function(k,e){var l=this,b=k,j=typeof e!="undefined"&&null!=e?e:VCService.Domain.Soapbox,d=new VCService.Adapter(b),a,h={"videobyuuid":"video","videobyuuids":"videolist","videobytag":"searchresult","search":"searchresult"},f,g=function(){},c=function(){};this.OverrideFilter=null;this.OverrideCounter=null;this.OverrideLcid=null;this.ConvertOutput=true;this.Execute=function(e,n,l,i,m){var r=checkString(this.OverrideFilter)?this.OverrideFilter:b.GetFilter(),q=checkString(this.OverrideCounter)?this.OverrideCounter:b.GetUsageCounters(),o=checkString(this.OverrideLcid)?this.OverrideLcid:b.Lcid;g=l;c=i;f=h[e];a=new Msn.Json.VideoRequest(e+".aspx?",this.OnVcRequestCb,this.OnVcRequestErrCb,"get",m);j==VCService.Domain.Soapbox?a.AddParam("mk",b.SoapboxMarket):a.AddParam("mk",b.VcMarket);a.AddParam("ff",r);a.AddParam("rct",q);a.AddParam("lcid",o);a.AddParams(n);var p=a.UrlWithParams(),d=b.GetServiceUrl(p),k=d.substr(d.length-1)=="/"?"":"/";a.Url=d+k+a.Url;Msn.VideoRequestManager.MakeRequest(a)};this.OnVcRequestCb=function(d,b){var a=d;if(l.ConvertOutput)a=i(d);if(null!=a)g(a,b);else c(b)};this.OnVcRequestErrCb=function(a){c(a)};function i(a){switch(f){case "video":return {"Video":d.ConvertVideo(a)};case "videolist":return {"Videos":d.ConvertVideoList(a)};case "searchresult":return d.ConvertSearchResult(a);default:}}};VCService.Sort=function(c,b,a){this.GetPrimary=function(){return checkInt(c)?c:""};this.GetSecondary=function(){return checkString(b)?b:""};this.GetSortDirection=function(){return checkInt(a)?a:""}};createNamespace("Msn.Json");Msn.Json.VideoRequestManager=function(){var _this=this,_requests=[],_maxRequestId=0,_scriptDiv=null;this.cfg={ENCODING:"responseEncoding",CALLBACK:"callbackName",CALLBACK_DATA:"cd",TIMEOUT:20000};var Request=function(d,e,f,c,a,b){this.Id=d;this.ReqId=e;this.Callback=c;this.CallbackData=b;this.ErrCallback=a;this.Cancelled=false};this.MakeRequest=function(a){var b=null;if(typeof a!="undefined"&&null!=a){if(_scriptDiv==null){_scriptDiv=document.createElement("div");document.body.appendChild(_scriptDiv)}var d=_maxRequestId++;b=SoapboxService.Utils.HashCodeFletcher(a.UrlWithParams());for(var e=0;e<_requests.length;e++)if(_requests[e].Id==b){b+="_"+d;break}a.AddParam(this.cfg.ENCODING,"json");a.AddParam(this.cfg.CALLBACK,"Msn.VideoRequestManager.DoCallback");a.AddParam(this.cfg.CALLBACK_DATA,b);var f=a.UrlWithParams(),g=new Request(d,b,f,a.Callback,a.ErrCallback,a.Context);_requests.push(g);var c=document.createElement("script");c.id="VideoRequest"+d;_scriptDiv.appendChild(c);window.setTimeout(function(){handleTimeout(b)},this.cfg.TIMEOUT);c.src=f}return b};function handleTimeout(b){for(var a=0;a<_requests.length;a++)if(_requests[a].ReqId==b&&!_requests[a].Cancelled){_requests[a].Cancelled=true;_requests[a].ErrCallback(_requests[a].CallbackData);cleanup(_requests[a].Id);break}}this.DoCallback=function(obj,reqId,error){for(var i=0;i<_requests.length;i++)if(_requests[i].ReqId==reqId){var req=_requests[i];_requests.splice(i,1);if(!req.Cancelled)if(checkError(error))req.ErrCallback(req.CallbackData);else{var result=eval(obj);req.Callback(result,req.CallbackData)}cleanup(req.Id);obj=null;break}};function checkError(a){if(typeof a=="string"&&a.length>0)return true;return false}function cleanup(b){var a=document.getElementById("VideoRequest"+b);setTimeout(function(){if(a&&a.parentNode)a.parentNode.removeChild(a)},100)}};Msn.Json.VideoRequest=function(f,c,d,e,b){var a=[];this.Url=f;this.HttpMethod=typeof e=="string"?e:"get";this.Callback=typeof c=="function"?c:function(){};this.ErrCallback=typeof d=="function"?d:function(){};this.Context=typeof b=="object"&&null!=b?b:{};this.AddParam=function(c,b){a.push(new Msn.Json.Param(c,b))};this.AddParams=function(c){var b;for(b in c)a.push(new Msn.Json.Param(b,c[b]))};this.Params=function(){return a};this.UrlWithParams=function(){return SoapboxService.Utils.GetUrlWithParams(this.Url,a)}};Msn.Json.Param=function(b,a){this.Name=b;this.Value=a};Msn.VideoRequestManager=new Msn.Json.VideoRequestManager