IBSYS.using("media");IBSYS.media.relatedVid={init:function(c,b){var a=b.jsonEndPoint+"?contentId=urn:ibsys:content:"+b.video_coid+"&linkLevelsToResolve=1";YAHOO.util.Connect.asyncRequest("GET",a,{success:this.onContentService,scope:this});b.width=b.width||"240";if(!isNaN(b.height)){b.height=String(parseInt(b.height,10))}else{b.height="225"}IBSYS.media.vidPlayModule.init(c,b)},onContentService:function(a){this.currentVideo=YAHOO.lang.JSON.parse(a.responseText);this.currentVideo.coidValue=this.currentVideo.contentId.substring("urn:ibsys:content:".length);this.currentVideo.loadMediaOnly=true;this.sortStreams(this.currentVideo)},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(e,d){var a=this;var c=IBSYS.application.Application.getProperty("userBitsPerSec");if(c){if(e.stream){e.coidValue=e.contentId.substring("urn:ibsys:content:".length);for(var b=0;b<e.metadata.length;b++){switch(e.metadata[b].type){case"urn:ibsys:taxonomy:topic":e.topic=e.metadata[b].tag.replace(/\//g,"");break;case"urn:ibsys:taxonomy:pool":e.pool=e.metadata[b].tag;break;case"urn:ibsys:taxonomy:videoCategory":e.category=e.metadata[b].tag;break}}}e.category=e.category||e.topic;e.stream.sort(function(g,f){if((g.mimetype=="video/x-flv")^(f.mimetype=="video/x-flv")){return(g.mimetype=="video/x-flv"?-1:1)}else{a.prepStream(g);a.prepStream(f);g.rateDiff=g.rateDiff||(c-g.bitsPerSecond);f.rateDiff=f.rateDiff||(c-f.bitsPerSecond);if((g.rateDiff<0)^(f.rateDiff<0)){return f.rateDiff-g.rateDiff}else{return Math.abs(g.rateDiff)-Math.abs(f.rateDiff)}}});IBSYS.media.genericFlash2.announceEventProxy("newMediaContent",e)}else{d=d||1;d++;if(d<15){setTimeout(function(){a.sortStreams(e,d)},500)}else{IBSYS.application.Application.setProperty("userBitsPerSec",56000);a.sortStreams(e,d)}}}};