IBSYS.using("media");IBSYS.media.loadImg=function(src){var img=new Image();img.src=src;};IBSYS.media.vidPlayModule={clearMsgAndTimers:function(){clearTimeout(this.promptTimer);clearTimeout(this.liveTimer);if(this.wmp){this.wmp.style.height=this.height+"px";}if(this.messageBox){this.messageBox.style.visibility="hidden";}},init:function(el,config){if(!swfobject.hasFlashPlayerVersion("6.0.65")){var legacyForFlash=this.getArchiveURL(config.video_coid);el.innerHTML='<div align="center" valign="middle"><p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#444444; line-height:1.5;">'+"To watch videos, you need a newer version of <strong>Flash.</strong><br /><br />"+"After you install Flash, you may need to restart your browser.<br />"+"Copy this URL first, so that you can find your way back:<br />"+'<form><input id=thisPage name="this_page_url" type="text" size="30" maxlength="256" readonly="true" align="middle" value='+document.location.href+" /></form>"+'</p><br /><div id="FlashInstallPromptDiv"><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">'+'<img src="/sh/flex3MediaPlayer/images/getflash.jpg" alt="Get Flash" border="0" /></a></div><br />'+'<p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#444444; line-height:1.5;">'+"If you cannot install the latest version of Flash,<br />you may be able to view videos on our "+"<strong><a href="+legacyForFlash+">legacy player page</a>.</strong></p><br /></div>";}else{if(!swfobject.hasFlashPlayerVersion("9.0.28")){document.title=document.title.slice(0,47)+" - Flash Player Installation";var legacyForFlash=this.getArchiveURL(config.video_coid);var eiSwf="/sh/flex3MediaPlayer/expressinstall_custom.swf?legacy="+legacyForFlash;var fv={MMredirectURL:window.location.href,MMplayerType:(typeof ActiveXObject=="function"?"ActiveX":"PlugIn"),MMdoctitle:document.title};var atts={id:el.id};swfobject.embedSWF(eiSwf,el.id,config.width||"320",config.height||"225","6.0.65",eiSwf,fv,{},atts);}else{IBSYS.application.Application.addEventListener(this.onIBEvent,this);this.playerType=config.playerType||"playbackModule";this.loadMediaOnly=(!config.play_first_editorial_video)||true;this.width=config.width;this.height=config.height;this.renderPlayer(el,config);IBSYS.ad.AdManager.registerPosition({element:this,type:"asxProxy"});YAHOO.util.Event.addListener(window,"unload",this.destroy,this,true);IBSYS.media.flashPlayer=IBSYS.media.flashPlayer||{};IBSYS.media.flashPlayer.setBandwidth=this.setBandwidth;}}},getArchiveURL:function(coid){var c=(coid?coid+"/":"");return window.location.protocol+"//"+window.location.host+"/video_legacy/"+c+"index.html"+window.location.search;},renderPlayer:function(el,config){this.rel=document.getElementById(el.id+"_rel");this.wmParent=document.getElementById(el.id+"_wmParent");var ua=navigator.userAgent.toLowerCase();var objectIndex=(ua.indexOf("webkit")!=-1||ua.indexOf("msie")!=-1)?0:1;this.flashPlaybackSwf=YAHOO.util.Dom.getElementsByClassName("videoplayerSWF","object",el)[objectIndex];this.flParent=document.getElementById(el.id+"_flParent");var that=this;if(this.checkForPlugins()){if(this.userOS!="mac"){var wmp=document.createElement("object");wmp.id=el.id+"_wmp";this.styleWMP(wmp);if(window.ActiveXObject){wmp.setAttribute("classid","CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6");}else{wmp.type="video/x-ms-wmv";}var p=document.createElement("param");p.setAttribute("name","SendPlayStateChangeEvents");p.setAttribute("value","True");wmp.appendChild(p);var q=document.createElement("param");q.setAttribute("name","autoStart");q.setAttribute("value","True");wmp.appendChild(q);this.addPluginFrame(wmp);this.wmParent.appendChild(wmp);this.wmp=wmp;this.wmp.style.position="absolute";this.wmp.style.left="-9999px";}}else{this.wmpOpen=function(){that.addPluginFrame(that.wmParent);};}},userOS:"",checkForPlugins:function(){if(navigator.appVersion.indexOf("Mac")>=0){this.userOS="mac";return this.searchPluginList("Flip4Mac WMV Plugin.plugin");}else{if(navigator.appVersion.indexOf("Win")>=0){this.userOS="win";if(YAHOO.env.ua.gecko&&navigator.plugins.length>0){return this.searchPluginList("np-mswmp.dll");}}}return true;},searchPluginList:function(filename){if(navigator.plugins&&navigator.plugins.length>0){for(var i=0;i<navigator.plugins.length;i++){if(navigator.plugins[i].filename==filename){return true;}}}return false;},onIBEvent:function(e){switch(e.getName()){case"movieLoaded":if(e.eventData.name=="flashPlayback"){this.setBandwidth();if(this.adData){this.tellPlaybackSwf(this.adData);}}break;case"newMediaContent":this.currentVideo=e.eventData;this.setBandwidth();if(!e.eventData.showAds){if(e.eventData.stream[0].mimetype=="video/x-ms-wmv"&&!e.eventData.loadMediaOnly){this.wmpStop();this.trackVideo(this.currentVideo,"both");this.tryWMP(e.eventData.contentId);}else{this.tellPlaybackSwf();}}else{if(this.adData){this.tellPlaybackSwf(this.adData);}}break;case"videoAdSkipped":this.trackVideo(this.currentVideo,"both");this.tryWMP(e.eventData.contentId);break;case"playingVideoAd":this.trackVideo(this.currentVideo,"webTrends");break;case"startWMVVideo":this.trackVideo(this.currentVideo,"nielsen");this.tryWMP(e.eventData.contentId);break;case"startFlashVideo":this.trackVideo(this.currentVideo,"nielsen");break;}},setBandwidth:function(kbps){var swfBandwidth=this.flashPlaybackSwf.getBandwidth();this.bitsPerSec=(kbps)?(kbps*1000):((swfBandwidth==0)?56000:swfBandwidth);IBSYS.application.Application.setProperty("userBitsPerSec",this.bitsPerSec);IBSYS.log(this.bitsPerSec);},setAdUrl:function(url,coid){this.adData={url:url,coid:coid};},showMessage:function(msg,onClick){if(!this.messageBox){var el=document.createElement("div");el.style.width=(this.width)-10+"px";el.style.height="35px";el.style.position="absolute";el.style.backgroundColor="black";YAHOO.util.Dom.setStyle(el,"opacity",0.5);el.style.color="white";el.style.textAlign="center";el.style.padding="5px";el.style.fontSize="10px";el.style.fontWeight="bold";el.style.fontFamily="Arial,sans-serif";el.style.cursor="pointer";this.rel.appendChild(el);this.messageBox=el;}this.messageBox.innerHTML=msg;this.messageBox.style.visibility="visible";var newHeight=this.height-45;this.messageBox.style.top=newHeight+"px";this.wmp.style.height=newHeight+"px";YAHOO.util.Event.purgeElement(this.messageBox,"click");YAHOO.util.Event.addListener(this.messageBox,"click",onClick);},tellPlaybackSwf:function(adData){var t=typeof this.flashPlaybackSwf;if((t=="function"||t=="object")&&this.flashPlaybackSwf.contentSelected&&this.currentVideo&&((!this.currentVideo.showAds&&!adData)||(this.currentVideo.contentId==adData.coid&&!this.currentVideo.loaded))){this.flParent.style.left="0px";this.clearMsgAndTimers();if(this.slMediaEl&&this.slMediaEl.CurrentState=="Playing"){this.slMediaEl.Stop();this.slMediaEl.source="";}if(this.wmp){this.wmp.style.left="-9999px";}this.wmpStop();var c=this.currentVideo.content;var img;var self=this;if(c&&c.length>0){for(var i=0;i<c.length;i++){if(c[i].role=="urn:ibsys:role:mainImage"){c[i].resolvedContent.image.rendition.sort(function(a,b){var aDiff=a.width-self.flashPlaybackSwf.width;var bDiff=b.width-self.flashPlaybackSwf.width;if(aDiff<0^bDiff<0){return bDiff-aDiff;}else{if(a.width==b.width&&(a.role=="urn:ibsys:role:rendition:reduced"^b.role=="urn:ibsys:role:rendition:reduced")){return(a.role=="urn:ibsys:role:rendition:reduced"?-1:1);}else{return Math.abs(aDiff)-Math.abs(bDiff);}}});img=c[i].resolvedContent.image.rendition[0].href;break;}}}var stream=this.currentVideo.stream[0];stream=(stream.mimetype=="video/x-flv"?stream.href+stream.streamId:null);try{this.flashPlaybackSwf.contentSelected(this.currentVideo.headline,img,this.currentVideo.contentId,this.currentVideo.showAds?adData.url:null,(typeof this.currentVideo.loadMediaOnly=="boolean"?this.currentVideo.loadMediaOnly:this.loadMediaOnly),stream);}catch(ex){IBSYS.log(ex.message);}if(this.currentVideo.loadMediaOnly){this.currentVideo.loaded=true;}this.loadMediaOnly=false;}else{if(adData){this.adData=adData;}}},tryWMP:function(coid){if(this.currentVideo.contentId==coid&&this.currentVideo.stream[0].mimetype=="video/x-ms-wmv"){var t=typeof this.flashPlaybackSwf;if(t=="function"||t=="object"){this.flashPlaybackSwf.stopFlashPlayback();}this.flParent.style.left="-9999px";var href=this.currentVideo.stream[0].href;if(this.wmp){this.wmp.style.left="0px";this.wmp.style.position="absolute";this.wmp.style.zIndex="9999";}this.wmpOpen(href);if(this.currentVideo.isLive){this.startLiveTimer();}}},onLiveTimeout:function(){var that=this;this.showMessage("This live stream will close in 20 seconds. Click here to continue watching.",function(){that.clearMsgAndTimers();that.startLiveTimer();});this.promptTimer=setTimeout(function(){that.onPromptTimeout();},20000);},onPromptTimeout:function(){this.wmpStop();var that=this;this.showMessage("The live stream has closed due to inactivity. Click to resume.",function(){that.wmpStart();that.clearMsgAndTimers();that.startLiveTimer();});},startLiveTimer:function(){var that=this;this.liveTimer=setTimeout(function(){that.onLiveTimeout();},600000);},trackVideo:function(meta,target){var poolName;var topic;var format=(meta.stream[0].mimetype=="video/x-flv")?"flv":"wmv";for(var i=0;i<meta.metadata.length;i++){switch(meta.metadata[i].type){case"urn:ibsys:taxonomy:pool":poolName=meta.metadata[i].tag;break;case"urn:ibsys:taxonomy:topic":topic=meta.metadata[i].tag.replace(/\//g,"");break;}}if(target=="webTrends"||target=="both"){this.trackInWebTrends(poolName,topic,meta,format);}if(target=="nielsen"||target=="both"){this.trackInNeilson("start","false",meta,format,poolName,topic);}},trackInWebTrends:function(poolName,topic,meta,format){var wtcgn=(meta.metadata[0].tag).replace(/\//g,"").charAt(0).toUpperCase()+(meta.metadata[0].tag).replace(/\//g,"").slice(1).toLowerCase();var cg_s=YAHOO.util.Dom.getElementsBy(function(el){return el.name==="WT.cg_s"?true:false;},"meta");cg_s.length>0?cg_s=cg_s[0].content:cg_s="Video";var ntwk=DCSext.ib_netwk,partner=DCSext.ib_partner,station=DCSext.ib_station;DCSext={};dcsMultiTrack("DCS.dcsuri","/video/"+meta.coidValue+"/index.html","WT.ti",meta.headline,"DCSext.mtype","video","DCSext.ib_coid",meta.coidValue,"DCSext.ib_pool",poolName,"DCSext.ib_media_category",topic,"DCSext.ib_creation_time",meta.dateCreated,"DCSext.ib_media_location","index","WT.cg_n",wtcgn,"DCSext.ib_ntwk",ntwk,"DCSext.ib_partner",partner,"DCSext.ib_station",station,"WT.cg_s",cg_s,"DCSext.ib_media_file_format",format,"DCSext.ib_media_format",(meta.isLive?"live_stream":"video_on_demand"),"DCSext.vtype","clickplay","DCSext.ib_media_action",this.origin,"WT.ed",IBSYS.tracking.clientData.screenColorDepth,"WT.fi",IBSYS.tracking.clientData.isFlashInstalled,"WT.fv",IBSYS.tracking.clientData.flashVersion);},trackInNeilson:function(event,ad,meta,format,poolName,topic){var ScRandom=Math.ceil(Math.random()*1000000000);var escHeadline=escape(meta.headline);var ScImgSrc;ScImgSrc="http://secure-us.imrworldwide.com/cgi-bin/m";ScImgSrc+="?ci=us-600552";ScImgSrc+="&cg="+topic;ScImgSrc+=event==="start"?"&tl=dav0-"+escHeadline:"&tl=dav2-"+escHeadline;ScImgSrc+=ad==="true"?"&c3=st,a"+escape("StreamType"):"";ScImgSrc+="&c6=vc,c01"+escape("");ScImgSrc+="&cc=1";ScImgSrc+="&rnd="+ScRandom;var davImg=new Image();davImg.src=ScImgSrc;},wmpStop:function(){var w=this.wmp;if(w&&w.controls){w.controls.stop();}else{this.wmParent.innerHTML="";}},wmpStart:function(){var w=this.wmp;if(w&&w.controls){w.controls.play();}else{this.wmpOpen(this.currentVideo.stream[0].href);}},wmpOpen:function(url){var w=this.wmp;if(w&&typeof w.URL=="string"){w.URL=url;}else{var el=document.createElement("embed");el.setAttribute("showControls","true");el.setAttribute("scale","ASPECT");el.type="application/x-mplayer2";el.src=url;this.styleWMP(el);this.addPluginFrame(el);this.wmParent.appendChild(el);this.wmp=el;}},styleWMP:function(el){el.width=this.width;el.height=this.height;el.style.cssText="padding:0px; margin:0px; overflow:hidden; width:"+this.width+"px; height:"+this.height+"px; border:none; background-color: #F1F1F1;";},addPluginFrame:function(el,src){var i=document.createElement("iframe");i.src="/sh/flex3MediaPlayer/wmpInstallFlexible.html";this.styleWMP(i);if(el){try{el.appendChild(i);}catch(ex){}}return i;},stopVideo:function(){if(this.flashPlaybackSwf){this.flashPlaybackSwf.stopFlashPlayback();}if(this.wmp&&this.wmp.controls){this.wmpStop();}},destroy:function(){this.flashPlaybackSwf=null;this.wmp=null;}};
