IBSYS.using("post.storyPlayer");IBSYS.post.storyPlayer={getContentObject:function(b){var a="/ec/content-service/json/getContent?contentId=urn:ibsys:content:"+b.video_coid+"&linkLevelsToResolve=1";YAHOO.util.Connect.asyncRequest("GET",a,{success:this.onContentService,scope:this})},setup:function(e,d){var b=e;b.style.width=d.component_width+"px";b.style.height=d.component_height+"px";b.style.backgroundColor=d.bg_clr;b.style.backgroundImage="url("+d.background_image_path+")";b.style.position="relative";this.playbackDiv=document.createElement("div");this.playbackDiv.setAttribute("id",e.id+"_pb");this.playbackDiv.style.width=d.vp_width;this.playbackDiv.style.height=d.vp_height;this.playbackDiv.style.position="absolute";this.playbackDiv.style.top="8px";this.playbackDiv.style.left="1px";b.appendChild(this.playbackDiv);this.contentSelectWrapper=document.createElement("div");this.contentSelectWrapper.setAttribute("id",e.id+"_csw");this.contentSelectWrapper.style.width=d.cs_width+"px";this.contentSelectWrapper.style.height=d.cs_height+"px";this.contentSelectWrapper.style.position="absolute";this.contentSelectWrapper.style.top=(parseInt(d.vp_height)+10)+"px";this.contentSelectWrapper.style.left="6px";b.appendChild(this.contentSelectWrapper);var a=document.createElement("div");a.setAttribute("id",e.id+"_cs");a.style.width=d.cs_width+"px";a.style.height=d.cs_height+"px";this.contentSelectWrapper.appendChild(a);var f={swfUrl:d.vp_swf_url,width:d.vp_width,height:d.vp_height,usage:d.playback_usage,skin_swf_url:d.skin_swf_url,xamlUrl:d.xamlUrl,bg_clr:d.bg_clr,hlgt_clr:d.hlgt_clr,hdl_txt_clr:d.hdl_txt_clr,minutes_between_ads:d.minutes_between_ads,play_first_editorial_video:d.play_first_editorial_video};var c={swfUrl:d.cs_swf_url,width:d.cs_width,height:d.cs_height,related_coid:d.video_coid,skin_swf_url:d.skin_swf_url,contentEndPoint:d.contentEndPoint,idx_label:d.idx_label,bg_clr:d.bg_clr,hlgt_clr:d.hlgt_clr,vid_link:d.vid_link,thin:"true",show_related:"true"};IBSYS.media.vidPlayModule.init(this.playbackDiv,f);IBSYS.media.selectContentModule.init(a,c)},destroy:function(){while(this.el.childNodes.length>0){this.el.removeChild(this.el.childNodes[0])}},init:function(b,a){this.el=b;this.config=a;if(IBSYS.application.Application.getProperty("loadTab")==="video"){this.setup(b,a)}IBSYS.application.Application.addEventListener(this.onIBEvent,this)},prepareVideo:function(){var a=IBSYS.media.selectContentModule;a.setSuppressDefault(true);if(IBSYS.media.vidPlayModule.currentVideo){IBSYS.media.vidPlayModule.currentVideo.loaded=false}this.sortStreams(this.meta)},onContentService:function(a){var b=YAHOO.lang.JSON.parse(a.responseText);b.loadMediaOnly=true;b.coidValue=b.contentId.substring(b.contentId.lastIndexOf(":")+1);this.meta=b;this.prepareVideo()},onIBEvent:function(a){if(a.getName()==="tabboxTabChanged"){if(a.getSource().tab_name==="Video"){this.setup(this.el,this.config)}else{if(this.currentTab==="Video"||"undefined"){IBSYS.media.vidPlayModule.stopVideo();IBSYS.media.vidPlayModule.destroy();this.destroy()}}this.currentTab=a.getSource().tab_name}if(a.getName()==="movieLoaded"&&a.eventData.name!=="contentSelection"){this.getContentObject(this.config)}},prepStream:function(a){if(!a.bitsPerSecond||isNaN(a.bitsPerSecond)){if(!this.reRateFromPath){this.reRateFromPath=/\.(\d+)k\./}a.bitsPerSecond=this.reRateFromPath.exec(a.href);if(!a.bitsPerSecond){a.bitsPerSecond=this.reRateFromPath.exec(a.streamId)}if(a.bitsPerSecond){a.bitsPerSecond=Number(a.bitsPerSecond[1])*1000}else{a.bitsPerSecond=0}}},sortStreams:function(d,c){var a=this;var b=IBSYS.application.Application.getProperty("userBitsPerSec");if(b){d.stream.sort(function(f,e){if((f.mimetype=="video/x-flv")^(e.mimetype=="video/x-flv")){return(f.mimetype=="video/x-flv"?-1:1)}else{a.prepStream(f);a.prepStream(e);f.rateDiff=f.rateDiff||(b-f.bitsPerSecond);e.rateDiff=e.rateDiff||(b-e.bitsPerSecond);if((f.rateDiff<0)^(e.rateDiff<0)){return e.rateDiff-f.rateDiff}else{return Math.abs(f.rateDiff)-Math.abs(e.rateDiff)}}});IBSYS.media.genericFlash2.announceEventProxy("newMediaContent",d)}else{c=c||1;c++;if(c<15){setTimeout(function(){a.sortStreams(d,c)},500)}else{IBSYS.application.Application.setProperty("userBitsPerSec",56000);a.sortStreams(d,c)}}}};