(function(){var A="SDK_"+"4.2.1-r7123-201109130634".replace(/[^\w]/g,"_"),q=typeof window!="undefined"?window:typeof GLOBAL!="undefined"?GLOBAL:this;q.tv=q.tv||{};q.tv.freewheel=q.tv.freewheel||{};q.tv.freewheel[A]=function(t){var a={};a.version="js-4.2.1-r7123-201109130634";if(typeof window!="undefined"){window._fw_admanager=window._fw_admanager||{};window._fw_admanager.version=a.version}a.LOG_LEVEL_QUIET=0;a.LOG_LEVEL_INFO=1;a.LOG_LEVEL_DEBUG=2;a.setLogLevel=function(b){if(typeof console!="undefined"&&
b>a.LOG_LEVEL_QUIET){a.log=function(){console.log(">FW "+(new Date).toTimeString().substr(3,6)+Array.prototype.slice.call(arguments).join(" "))};a.warn=function(){console.warn(">FW "+(new Date).toTimeString().substr(3,6)+Array.prototype.slice.call(arguments).join(" "))};a.debug=b>a.LOG_LEVEL_INFO?function(){console.log(">FW "+(new Date).toTimeString().substr(3,6)+Array.prototype.slice.call(arguments).join(" "))}:function(){}}else a.warn=a.log=a.debug=function(){}};a.setLogLevel(a.LOG_LEVEL_INFO);
a.log("FreeWheel Integration Runtime",a.version);a.RENDERER_STATE_INIT=1;a.RENDERER_STATE_STARTING=2;a.RENDERER_STATE_STARTED=3;a.RENDERER_STATE_COMPLETING=4;a.RENDERER_STATE_COMPLETED=5;a.RENDERER_STATE_FAILED=6;a.EVENT_SLOT_IMPRESSION="slotImpression";a.EVENT_AD_IMPRESSION="defaultImpression";a.EVENT_AD_QUARTILE="quartile";a.EVENT_AD_FIRST_QUARTILE="firstQuartile";a.EVENT_AD_MIDPOINT="midPoint";a.EVENT_AD_THIRD_QUARTILE="thirdQuartile";a.EVENT_AD_COMPLETE="complete";a.EVENT_AD_CLICK="defaultClick";
a.EVENT_AD_MUTE="_mute";a.EVENT_AD_UNMUTE="_un-mute";a.EVENT_AD_COLLAPSE="_collapse";a.EVENT_AD_EXPAND="_expand";a.EVENT_AD_PAUSE="_pause";a.EVENT_AD_RESUME="_resume";a.EVENT_AD_REWIND="_rewind";a.EVENT_AD_ACCEPT_INVITATION="_accept-invitation";a.EVENT_AD_CLOSE="_close";a.EVENT_AD_MINIMIZE="_minimize";a.EVENT_ERROR="_e_unknown";a.EVENT_RESELLER_NO_AD="resellerNoAd";a.INFO_KEY_CUSTOM_ID="customId";a.INFO_KEY_MODULE_TYPE="moduleType";a.MODULE_TYPE_EXTENSION="extension";a.MODULE_TYPE_RENDERER="renderer";
a.MODULE_TYPE_TRANSLATOR="translator";a.INFO_KEY_ERROR_CODE="errorCode";a.INFO_KEY_ERROR_INFO="errorInfo";a.INFO_KEY_ERROR_MODULE="errorModule";a.ERROR_IO="_e_io";a.ERROR_TIMEOUT="_e_timeout";a.ERROR_NULL_ASSET="_e_null-asset";a.ERROR_ADINSTANCE_UNAVAILABLE="_e_adinst-unavail";a.ERROR_UNKNOWN="_e_unknown";a.ERROR_MISSING_PARAMETER="_e_missing-param";a.ERROR_NO_AD_AVAILABLE="_e_no-ad";a.ERROR_PARSE="_e_parse";a.ERROR_INVALID_VALUE="_e_invalid-value";a.ERROR_NO_RENDERER="_e_no-renderer";a.ERROR_DEVICE_LIMIT=
"_e_device-limit";a.INFO_KEY_SHOW_BROWSER="showBrowser";a.INFO_KEY_CUSTOM_EVENT_NAME="customEventName";a.EVENT_TYPE_CLICK_TRACKING="CLICKTRACKING";a.EVENT_TYPE_IMPRESSION="IMPRESSION";a.EVENT_TYPE_CLICK="CLICK";a.EVENT_TYPE_STANDARD="STANDARD";a.EVENT_TYPE_GENERIC="GENERIC";a.EVENT_TYPE_ERROR="ERROR";a.EVENT_VIDEO_VIEW="videoView";a.SHORT_EVENT_TYPE_IMPRESSION="i";a.SHORT_EVENT_TYPE_CLICK="c";a.SHORT_EVENT_TYPE_STANDARD="s";a.SHORT_EVENT_TYPE_ERROR="e";a.INFO_KEY_PARAMETERS="parameters";a.URL_PARAMETER_KEY_ET=
"et";a.URL_PARAMETER_KEY_CN="cn";a.URL_PARAMETER_KEY_INIT="init";a.URL_PARAMETER_KEY_LAST="last";a.URL_PARAMETER_KEY_CT="ct";a.URL_PARAMETER_KEY_METR="metr";a.URL_PARAMETER_KEY_CR="cr";a.URL_PARAMETER_KEY_KEY_VALUE="kv";a.URL_PARAMETER_KEY_ERROR_INFO="additional";a.URL_PARAMETER_KEY_ERROR_MODULE="renderer";a.URL_PARAMETER_KEY_CREATIVE_RENDITION_ID="reid";a.CAPABILITY_SLOT_TEMPLATE="sltp";a.CAPABILITY_MULTIPLE_CREATIVE_RENDITIONS="emcr";a.CAPABILITY_RECORD_VIDEO_VIEW="exvt";a.CAPABILITY_CHECK_COMPANION=
"cmpn";a.CAPABILITY_CHECK_TARGETING="targ";a.CAPABILITY_FALLBACK_UNKNOWN_ASSET="unka";a.CAPABILITY_FALLBACK_UNKNOWN_SITE_SECTION="unks";a.CAPABILITY_SLOT_CALLBACK="slcb";a.CAPABILITY_NULL_CREATIVE="nucr";a.SLOT_TYPE_TEMPORAL="temporal";a.SLOT_TYPE_VIDEOPLAYER_NONTEMPORAL="videoPlayerNonTemporal";a.SLOT_TYPE_SITESECTION_NONTEMPORAL="siteSectionNonTemporal";a.TIME_POSITION_CLASS_PREROLL="PREROLL";a.TIME_POSITION_CLASS_MIDROLL="MIDROLL";a.TIME_POSITION_CLASS_POSTROLL="POSTROLL";a.TIME_POSITION_CLASS_OVERLAY=
"OVERLAY";a.TIME_POSITION_CLASS_DISPLAY="DISPLAY";a.EVENT_REQUEST_COMPLETE="onRequestComplete";a.EVENT_SLOT_STARTED="onSlotStarted";a.EVENT_SLOT_ENDED="onSlotEnded";a.EVENT_CONTENT_VIDEO_PAUSE_REQUEST="contentVideoPauseRequest";a.EVENT_CONTENT_VIDEO_RESUME_REQUEST="contentVideoResumeRequest";a.EVENT_CONTENT_VIDEO_ATTACH="contentVideoAttach";a.EVENT_CONTENT_VIDEO_DETACH="contentVideoDetach";a.CAPABILITY_STATUS_OFF=0;a.CAPABILITY_STATUS_ON=1;a.PARAMETER_LEVEL_PROFILE=0;a.PARAMETER_LEVEL_GLOBAL=1;a.PARAMETER_LEVEL_OVERRIDE=
5;a.PARAMETER_EXTENSION_AD_CONTROL_CLICK_ELEMENT="extension.ad.control.clickElement";a.PARAMETER_PLAY_MIDROLL_BY_CURRENT_VIDEO_ELEMENT="PARAMETER_PLAY_MIDROLL_BY_CURRENT_VIDEO_ELEMENT";a.PARAMETER_RENDERER_VIDEO_START_DETECT_TIMEOUT="renderer.video.startDetectTimeout";a.PARAMETER_RENDERER_VIDEO_PROGRESS_DETECT_TIMEOUT="renderer.video.progressDetectTimeout";a.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED="extension.contentVideo.enabled";a.PARAMETER_EXTENSION_CONTENT_VIDEO_AUTO_SEEK_BACK="extension.contentVideo.autoSeekBack";
a.PARAMETER_RENDERER_VIDEO_ANDROID_DELAY="renderer.video.android.delay";a.PARAMETER_VIDEO_POOL_SIZE="sdk.videoPoolSize";a.ID_TYPE_FW=1;a.ID_TYPE_CUSTOM=2;a.ID_TYPE_GROUP=3;a.VIDEO_STATE_PLAYING=1;a.VIDEO_STATE_PAUSED=2;a.VIDEO_STATE_STOPPED=3;a.VIDEO_STATE_COMPLETED=4;a.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED=1;a.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED=2;a.VIDEO_ASSET_AUTO_PLAY_TYPE_NON_AUTO_PLAY=3;a.ADUNIT_PREROLL="preroll";a.ADUNIT_MIDROLL="midroll";a.ADUNIT_POSTROLL="postroll";a.ADUNIT_OVERLAY="overlay";
a.Util={detectPlatform:function(){var b=navigator.userAgent.toLowerCase();this.PLATFORM_IS_IPAD=b.search("ipad")>-1;this.PLATFORM_IS_IPHONE_IPOD=b.search("iphone")>-1||b.search("ipod")>-1;this.PLATFORM_IOS_VERSION=function(){var c=b.search(/os \d_\d/);if(c>-1){var d=b.substr(c+3,1);c=b.substr(c+5,1);return 1*d+0.1*c}else return 0}();this.PLATFORM_ANDROID_VERSION=function(){var c=b.search(/android \d\.\d/);if(c>-1){var d=b.substr(c+8,1);c=b.substr(c+10,1);return 1*d+0.1*c}else return 0}();this.PLATFORM_IS_SAFARI=
this.PLATFORM_IOS_VERSION>0&&b.search("applewebkit")>-1||this.PLATFORM_ANDROID_VERSION==0&&b.search("chrome")<0&&b.search("safari")>-1;this.PLATFORM_ID=(this.PLATFORM_IS_MOBILE=this.PLATFORM_IOS_VERSION>0||this.PLATFORM_ANDROID_VERSION>0)?this.PLATFORM_ANDROID_VERSION>0?"Android"+this.PLATFORM_ANDROID_VERSION:this.PLATFORM_IS_IPAD?"iPad"+this.PLATFORM_IOS_VERSION:this.PLATFORM_IS_IPHONE_IPOD?"iPhone"+this.PLATFORM_IOS_VERSION:"UnknownMobile":"Desktop";a.log("Device:",this.PLATFORM_ID,"PLATFORM_IS_SAFARI:",
this.PLATFORM_IS_SAFARI)},trim:function(b){if(typeof b!="string")return b.toString();return b.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},isBlank:function(b){return!b||a.Util.trim(b)===""},mixin:function(b,c){var d={};for(var e in c)if(typeof d[e]=="undefined"||d[e]!=c[e])b[e]=c[e];return b},copy:function(b){return a.Util.mixin({},b)},bind:function(b,c){var d=Array.prototype.slice.call(arguments);d.shift();c=d.shift();return function(){return c.apply(b,d.concat(Array.prototype.slice.call(arguments)))}},
getObject:function(b,c,d){if(!b)return null;b=b.split(".");c=c||window;for(var e=0,f;c&&(f=b[e]);e++)c=f in c?c[f]:d?(c[f]={}):undefined;return c},buildNode:function(b,c,d,e,f){a.debug("Util.buildNode");d||(d=document);var g=navigator.userAgent.match(/Firefox/)!=null;b.innerHTML=c||"";b=b.getElementsByTagName("script");var h=d.getElementsByTagName("head")[0];for(c=0;c<b.length;++c)if(g||b[c].src){var k=d.createElement("script");if(b[c].charset)k.charset=b[c].charset;if(b[c].src)k.src=b[c].src;if(b[c].innerHTML)k.innerHTML=
b[c].innerHTML;k.onload=k.onreadystatechange=function(){if(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")h.removeChild(k)};try{h.appendChild(k)}catch(m){a.warn("load script err: "+m)}}else{k=b[c].innerHTML;if(e)k=k.replace(/var fw_scope = document;/,"var fw_scope="+e+";");if(f)k=k.replace(/var fw_scope_window = window;/,"var fw_scope_window="+f+";");eval(k)}},replacePageSlot:function(b,c){a.debug("Util.replacePageSlot("+Array.prototype.slice.call(arguments).join(",")+")");
var d,e,f;try{d=document.getElementById(b)?document:parent.document.getElementById(b)?parent.document:null;e=document.getElementById(b)?"window":parent.document.getElementById(b)?"parent":null}catch(g){e=d=null}if(!d)for(var h=0;h<window.frames.length;h++)try{if(window.frames[h].document.getElementById(b)){d=window.frames[h].document;e="window.frames["+h+"]"}}catch(k){a.warn(k)}if(e)f=e+".document";a.log("replacing slot "+b+" in frame "+f);if(!d)throw"Slot element not found: "+b;h=d.getElementById("_fw_container_"+
b);a.Util.buildNode(h,c,d,f,e)},pingURLWithImage:function(b){(new Image(1,1)).src=b},pingURLWithForm:function(b,c,d){d=d?"_fw_request":"_fw_cb";if(c==null)c=Math.random();var e=document.createElement("iframe");e.name=d+"_iframe_"+c;e.id=d+"_iframe_"+c;e.style.position="absolute";e.style.left=-10000;e.style.width=1;e.style.visibility="hidden";var f=document.createElement("form");f.action=b;f.id=d+"_form_"+c;f.target=e.id;f.method="post";f.style.position="absolute";f.style.left=-10000;f.style.width=
1;f.style.visibility="hidden";if(document.body){document.body.appendChild(e);document.body.appendChild(f);f.submit();document.body.removeChild(f)}},pingURLWithScript:function(b){var c=document.getElementsByTagName("head")[0],d=document.createElement("script");d.src=b;d.onload=d.onreadystatechange=function(){if(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")c.removeChild(d)};c.appendChild(d)},pingURL:function(b){a.debug("send callback: "+b);if(b)a.Util.PLATFORM_IS_SAFARI&&
(a.Util.PLATFORM_IOS_VERSION==0||a.Util.PLATFORM_IOS_VERSION>3.2)?a.Util.pingURLWithForm(b,null,false):a.Util.pingURLWithImage(b)},pingURLs:function(b){for(var c=0;c<b.length;c++)a.Util.pingURL(b[c])},setParameterInURL:function(b,c,d){if(!b||!c||d===null)return null;var e=false,f;b=b.split("?");var g;d=encodeURIComponent(d);if(b[1]){g=b[1].split("&");for(var h=0;h<g.length;++h){f=g[h].split("=");if(f[0]==c){g[h]=f[0]+"="+d;e=true;break}}f=g.join("&");e||(f=c+"="+d+"&"+f)}else f=c+"="+d;return f=b[0]+
"?"+f},flashVersion:function(){var b="0,0,0,0";if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"])try{var c=navigator.plugins["Shockwave Flash"+(navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"")].description.split(" "),d=c[2].split("."),e=d[0],f=d[1],g=c[3];if(g=="")g=c[4];if(g[0]=="d")g=g.substring(1);else if(g[0]=="r"){g=g.substring(1);if(g.indexOf("d")>0)g=g.substring(0,g.indexOf("d"))}b=e+","+f+","+g+",0"}catch(h){a.warn("Flash detction failed on navigator method")}}else{var k;
try{k=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");var m=k.GetVariable("$version").split(" ")[1].split(",");if(m.length==3)b=m.join(",")+",0";else if(m.length==4)b=m.join(",")}catch(l){a.warn("Flash detction failed on ActiveX method")}}return b}};a.Util.detectPlatform();a.MediaState=function(){};a.MediaState.prototype={};a.MediaState.prototype.constructor=a.MediaState;a.Util.mixin(a.MediaState.prototype,{play:function(b){a.debug(this._name+" play("+b+")")},complete:function(b){a.debug(this._name+
" complete("+b+")")}});a.MediaInitState=function(){this._name="MediaInitState"};a.MediaInitState.prototype=new a.MediaState;a.MediaInitState.prototype.constructor=a.MediaInitState;a.Util.mixin(a.MediaInitState.prototype,{play:function(b){a.debug(this._name+" play("+b+")");b._state=a.MediaPlayingState.instance;b.onStartPlaying()}});a.MediaInitState.instance=new a.MediaInitState;a.MediaPlayingState=function(){this._name="MediaPlayingState"};a.MediaPlayingState.prototype=new a.MediaState;a.MediaPlayingState.prototype.constructor=
a.MediaPlayingState;a.Util.mixin(a.MediaPlayingState.prototype,{complete:function(b){a.debug(this._name+" complete("+b+")");b._state=a.MediaEndState.instance;b.onCompletePlaying()}});a.MediaPlayingState.instance=new a.MediaPlayingState;a.MediaReplayingState=function(){this._name="MediaReplayingState"};a.MediaReplayingState.prototype=new a.MediaState;a.MediaReplayingState.prototype.constructor=a.MediaReplayingState;a.Util.mixin(a.MediaReplayingState.prototype,{complete:function(b){a.debug(this._name+
" complete("+b+")");b._state=a.MediaEndState.instance;b.onCompleteReplaying()}});a.MediaReplayingState.instance=new a.MediaReplayingState;a.MediaEndState=function(){this._name="MediaEndState"};a.MediaEndState.prototype=new a.MediaState;a.MediaEndState.prototype.constructor=a.MediaEndState;a.Util.mixin(a.MediaEndState.prototype,{play:function(b){a.debug(this._name+" play("+b+")");b._state=a.MediaReplayingState.instance;b.onStartReplaying()}});a.MediaEndState.instance=new a.MediaEndState;a.RendererState=
function(){};a.RendererState.prototype={};a.RendererState.prototype.constructor=a.RendererState;a.Util.mixin(a.RendererState.prototype,{start:function(){},notifyStarted:function(){},stop:function(){},complete:function(){},notifyCompleted:function(){},fail:function(b){b._rendererState=a.RendererFailedState.instance;b._adInstance.complete()}});a.RendererInitState=function(){};a.RendererInitState.prototype=new a.RendererState;a.RendererInitState.prototype.constructor=a.RendererInitState;a.RendererInitState.instance=
new a.RendererInitState;a.Util.mixin(a.RendererInitState.prototype,{start:function(b){b._rendererState=a.RendererStartingState.instance;b._renderer.start(b)}});a.RendererStartingState=function(){};a.RendererStartingState.prototype=new a.RendererState;a.RendererStartingState.prototype.constructor=a.RendererStartingState;a.RendererStartingState.instance=new a.RendererStartingState;a.Util.mixin(a.RendererStartingState.prototype,{notifyStarted:function(b){b._rendererState=a.RendererStartedState.instance;
b._adInstance.play()}});a.RendererStartedState=function(){};a.RendererStartedState.prototype=new a.RendererState;a.RendererStartedState.prototype.constructor=a.RendererStartedState;a.RendererStartedState.instance=new a.RendererStartedState;a.Util.mixin(a.RendererStartedState.prototype,{complete:function(b){b._rendererState=a.RendererCompletingState.instance}});a.RendererCompletingState=function(){};a.RendererCompletingState.prototype=new a.RendererState;a.RendererCompletingState.prototype.constructor=
a.RendererCompletingState;a.RendererCompletingState.instance=new a.RendererCompletingState;a.Util.mixin(a.RendererCompletingState.prototype,{notifyCompleted:function(b){b._rendererState=a.RendererCompletedState.instance;b._adInstance.complete()}});a.RendererCompletedState=function(){};a.RendererCompletedState.prototype=new a.RendererState;a.RendererCompletedState.prototype.constructor=a.RendererCompletedState;a.RendererCompletedState.instance=new a.RendererCompletedState;a.RendererFailedState=function(){};
a.RendererFailedState.prototype=new a.RendererState;a.RendererFailedState.prototype.constructor=a.RendererFailedState;a.RendererFailedState.instance=new a.RendererFailedState;a.Ad=function(b){this._context=b;this._creatives=[]};a.Ad.prototype={};a.Ad.prototype.constructor=a.Ad;a.Util.mixin(a.Ad.prototype,{parse:function(b){if(b){this._id=b.adId||null;var c=0;for(b=b.creatives||[];c<b.length;c++){var d=b[c],e=new a.Creative(this._context);e.parse(d);this._creatives.push(e)}}},getCreative:function(b){for(i=
0;i<this._creatives.length;i++)if(this._creatives[i]._id==b)return this._creatives[i];return null}});a.Creative=function(b){this._context=b;this._duration=this._baseUnit=this._id=null;this._parameters={};this._creativeRenditions=[]};a.Creative.prototype={};a.Creative.prototype.constructor=a.Creative;a.Util.mixin(a.Creative.prototype,{parse:function(b){if(b){this._id=b.creativeId||null;this._baseUnit=b.baseUnit||null;this._duration=b.duration*1;for(var c=0,d=b.parameters||[];c<d.length;c++){var e=
d[c];this._parameters[e.name]=e.value}c=0;for(d=b.creativeRenditions||[];c<d.length;c++){e=d[c];b=new a.CreativeRendition(this._context);b.parse(e);b.setDuration(this._duration);b._baseUnit=this._baseUnit;this._creativeRenditions.push(b)}}},getCreativeRendition:function(b,c){for(var d=null,e=0,f=this._creativeRenditions||[];e<f.length;e++)if(f[e]._id==b){if(f[e]._replicaId==c)return f[e];if(!d||f[e]._replicaId<d._replicaId)d=f[e]}return d}});a.CreativeRendition=function(b){this._context=b;this._height=
this._width=this._preference=this._wrapperUrl=this._wrapperType=this._contentType=this._replicaId=this._id=null;this._parameters={};this._primaryCreativeRenditionAsset=null;this._otherCreativeRenditionAssets=[]};a.CreativeRendition.prototype={};a.CreativeRendition.prototype.constructor=a.CreativeRendition;a.Util.mixin(a.CreativeRendition.prototype,{getContentType:function(){return this._contentType?this._contentType:this._primaryCreativeRenditionAsset&&this._primaryCreativeRenditionAsset._contentType?
this._primaryCreativeRenditionAsset._contentType:null},setContentType:function(b){this._contentType=b},getWrapperType:function(){return this._wrapperType},setWrapperType:function(b){this._wrapperType=b},getWrapperUrl:function(){return this._wrapperUrl},setWrapperUrl:function(b){this._wrapperUrl=b},getBaseUnit:function(){return this._baseUnit},getPreference:function(){return this._preference},getWidth:function(){return this._width},setWidth:function(b){this._width=b},getHeight:function(){return this._height},
setHeight:function(b){this.height=b},getDuration:function(){return this._duration},setDuration:function(b){this._duration=b},getParameter:function(b){return this._parameters[b]},setParameter:function(b,c){if(c===null)delete this._parameters[b];else this._parameters[b]=c},getPrimaryCreativeRenditionAsset:function(){return this._primaryCreativeRenditionAsset},getOtherCreativeRenditionAssets:function(){return this._otherCreativeRenditionAssets},addCreativeRenditionAsset:function(){var b=new a.CreativeRenditionAsset(this._context);
if(this._primaryCreativeRenditionAsset)this._otherCreativeRenditionAssets.push(b);else this._primaryCreativeRenditionAsset=b;return b},parse:function(b){if(b){this._id=b.creativeRenditionId||null;this._replicaId=b.hasOwnProperty("adReplicaId")?b.adReplicaId*1:-1;this._contentType=b.contentType||null;this._wrapperType=b.wrapperType||null;this._wrapperUrl=b.wrapperUrl||null;this._preference=b.preference*1;this._width=b.width*1;this._height=b.height*1;for(var c=0,d=b.parameters||[];c<d.length;c++){var e=
d[c];this._parameters[e.name]=e.value}this._primaryCreativeRenditionAsset=new a.CreativeRenditionAsset(this._context);this._primaryCreativeRenditionAsset.parse(b.asset);c=0;for(d=b.otherAssets||[];c<d.length;c++){e=d[c];b=new a.CreativeRenditionAsset(this._context);b.parse(e);this._otherCreativeRenditionAssets.push(b)}}}});a.CreativeRenditionAsset=function(b){this._context=b;this._bytes=this._mimeType=this._contentType=this._content=this._url=this._name=this._id=null};a.CreativeRenditionAsset.prototype=
{};a.CreativeRenditionAsset.prototype.constructor=a.CreativeRenditionAsset;a.Util.mixin(a.CreativeRenditionAsset.prototype,{getName:function(){return this._name},setName:function(b){this._name=b},getUrl:function(){return this._url},setUrl:function(b){this._url=b},getContent:function(){return this._content},setContent:function(b){this._content=b},getMimeType:function(){return this._mimeType},setMimeType:function(b){this._mimeType=b},getBytes:function(){return this._bytes},setBytes:function(b){this._bytes=
b},parse:function(b){if(b){this._id=b.id||null;this._name=b.name||null;this._url=b.url||null;this._content=b.content||null;this._contentType=b.contentType||null;this._mimeType=b.mimeType||null;this._bytes=b.bytes*1}}});a.AdControlExtension=function(b){this._context=b;this._currentSlot=this._clickEvent=this._targetElement=null};a.AdControlExtension.prototype={start:function(){if(!this._clickEvent)this._clickEvent=a.Util.PLATFORM_IS_MOBILE?"touchend":"click";this._onAdClicked=a.Util.bind(this,function(){a.log("AdControlExtension",
"clicked on target element: "+this._targetElement.id);this._currentSlot&&this._currentSlot.getCurrentAdInstance()&&this._currentSlot.getCurrentAdInstance().getRendererController().processEvent({name:a.EVENT_AD_CLICK})});this._onSlotStarted=a.Util.bind(this,function(b){if(b.slot&&this._isTargetSlot(b.slot)){this._clearListener();this._attachListener(b.slot)}});this._onSlotEnded=a.Util.bind(this,function(b){b.slot&&this._isTargetSlot(b.slot)&&this._clearListener()});this._context.addEventListener(a.EVENT_SLOT_ENDED,
this._onSlotEnded);this._context.addEventListener(a.EVENT_SLOT_STARTED,this._onSlotStarted)},_onAdClicked:function(){},_onSlotStarted:function(){},_onSlotEnded:function(){},_attachListener:function(b){a.debug("AdControlExtension._attachListener");var c=this._context.getParameter(a.PARAMETER_EXTENSION_AD_CONTROL_CLICK_ELEMENT);if(c)if(this._targetElement=document.getElementById(c)){this._currentSlot=b;this._targetElement.addEventListener(this._clickEvent,this._onAdClicked,false)}else a.warn("Attempted to process click/tap via PARAMETER_EXTENSION_AD_CONTROL_CLICK_ELEMENT specified html element: '"+
c+"'. The specified element is not available on the current HTML page.")},_clearListener:function(){if(this._targetElement){this._targetElement.removeEventListener(this._clickEvent,this._onAdClicked,false);this._targetElement=null}this._currentSlot=null},_isTargetSlot:function(b){if(b.getType()==a.SLOT_TYPE_TEMPORAL&&b.getTimePositionClass()!=a.TIME_POSITION_CLASS_OVERLAY)return true;return false},dispose:function(){a.log("AdControlExtension.dispose()");this._clearListener();this._onAdClicked=null;
this._context.removeEventListener(a.EVENT_SLOT_ENDED,this._onSlotEnded);this._context.removeEventListener(a.EVENT_SLOT_STARTED,this._onSlotStarted);this._onSlotEnded=this._onSlotStarted=null}};a.AdControlExtension.prototype.constructor=a.AdControlExtension;a.AdInstance=function(b){this._context=b;this._primaryCreativeRendition=this._replicaId=this._creativeRenditionId=this._creativeId=this._adId=this._slot=null;this._creativeRenditions=[];this._companionAdInstances=[];this._eventCallbacks=[];this._externalEventCallbackUrlsDictionary=
{};this._rendererController=new a.RendererController(this._context);this._rendererController._adInstance=this;this._timer=new a.Timer;this._metr=0;this._state=a.MediaInitState.instance};a.AdInstance.prototype={};a.AdInstance.prototype.constructor=a.AdInstance;a.METR_MASK_QUARTILE=0;a.METR_MASK_MIDPOINT=1;a.METR_MASK_COMPLETE=2;a.METR_MASK_VOLUME=3;a.METR_MASK_SIZE=4;a.METR_MASK_CONTROL=5;a.METR_MASK_REWIND=6;a.METR_MASK_ACCEPT_INVITATION=7;a.METR_MASK_CLOSE=8;a.METR_MASK_MINIMIZE=9;a.METR_MASK_CLICK=
10;a.AdInstance._metrDictionary={};a.AdInstance._metrDictionary[a.EVENT_AD_FIRST_QUARTILE]=a.AdInstance._metrDictionary[a.EVENT_AD_THIRD_QUARTILE]=a.AdInstance._metrDictionary[a.EVENT_AD_QUARTILE]=1<<a.METR_MASK_QUARTILE|1<<a.METR_MASK_MIDPOINT|1<<a.METR_MASK_COMPLETE;a.AdInstance._metrDictionary[a.EVENT_AD_MIDPOINT]=1<<a.METR_MASK_MIDPOINT|1<<a.METR_MASK_COMPLETE;a.AdInstance._metrDictionary[a.EVENT_AD_COMPLETE]=1<<a.METR_MASK_COMPLETE;a.AdInstance._metrDictionary[a.EVENT_AD_MUTE]=1<<a.METR_MASK_VOLUME;
a.AdInstance._metrDictionary[a.EVENT_AD_UNMUTE]=1<<a.METR_MASK_VOLUME;a.AdInstance._metrDictionary[a.EVENT_AD_COLLAPSE]=1<<a.METR_MASK_SIZE;a.AdInstance._metrDictionary[a.EVENT_AD_EXPAND]=1<<a.METR_MASK_SIZE;a.AdInstance._metrDictionary[a.EVENT_AD_PAUSE]=1<<a.METR_MASK_CONTROL;a.AdInstance._metrDictionary[a.EVENT_AD_RESUME]=1<<a.METR_MASK_CONTROL;a.AdInstance._metrDictionary[a.EVENT_AD_REWIND]=1<<a.METR_MASK_REWIND;a.AdInstance._metrDictionary[a.EVENT_AD_ACCEPT_INVITATION]=1<<a.METR_MASK_ACCEPT_INVITATION;
a.AdInstance._metrDictionary[a.EVENT_AD_CLOSE]=1<<a.METR_MASK_CLOSE;a.AdInstance._metrDictionary[a.EVENT_AD_MINIMIZE]=1<<a.METR_MASK_MINIMIZE;a.AdInstance._metrDictionary[a.EVENT_AD_CLICK]=1<<a.METR_MASK_CLICK;a.Util.mixin(a.AdInstance.prototype,{getAdId:function(){return this._adId},getEventCallbackUrls:function(b,c){var d=[],e=c==a.EVENT_TYPE_CLICK,f=c==a.EVENT_TYPE_CLICK_TRACKING,g=a.EventCallback.getEventCallback(this._eventCallbacks,b,f?a.EVENT_TYPE_CLICK:c);if(!g)return d;if(e)g._showBrowser&&
d.push(g.getUrl());else if(f)g._showBrowser||d.push(g.getUrl());else d.push(g.getUrl());if(!e){e=0;for(g=g._trackingUrls;e<g.length;e++)d.push(g[e]);e=0;for(g=this.getExternalEventCallbackUrls(b,c);e<g.length;e++)d.push(g[e])}return d},addEventCallbackUrls:function(b,c,d){if(d&&this._isValidEventNameAndType(b,c))if(c==a.EVENT_TYPE_CLICK){b=this.getEventCallback(b,c);b.setUrlParameter(a.URL_PARAMETER_KEY_CR,d.length>0?d[0]:"");b._showBrowser=true}else{for(var e=this._externalEventCallbackUrlsDictionary[c+
"-"+b]||[],f=0;f<d.length;f++)e.push(d[f]);this._externalEventCallbackUrlsDictionary[c+"-"+b]=e}},schedule:function(){var b=new a.AdInstance(this._context);b._parent=this;b._adId=this._adId;b._creativeId=this._creativeId;b._slot=this.getSlot();for(var c=0;c<this._eventCallbacks.length;c++){var d=this._eventCallbacks[c].copy();d._adInstance=b;b._eventCallbacks.push(d)}b._externalEventCallbackUrlsDictionary=a.Util.copy(this._externalEventCallbackUrlsDictionary);return b},addCreativeRendition:function(){if(!this._primaryCreativeRendition)return this._primaryCreativeRendition=
new a.CreativeRendition(this._context);return null},getRendererController:function(){return this._rendererController},getSlot:function(){if(!this._slot)this._slot=this._context._adResponse.getSlotByCustomId(this._slotCustomId);return this._slot},getCompanionSlots:function(){for(var b=[],c=0;c<this._companionAdInstances.length;c++)b.push(this._companionAdInstances[c]._slot);return b},getPrimaryCreativeRendition:function(){return this._primaryCreativeRendition},setPrimaryCreativeRendition:function(b){this._primaryCreativeRendition=
b;for(var c=0,d=this._eventCallbacks||[];c<d.length;c++)d[c].setUrlParameter(a.URL_PARAMETER_KEY_CREATIVE_RENDITION_ID,b._id)},getAllCreativeRenditions:function(){for(var b=[this._primaryCreativeRendition],c=0;c<this._creativeRenditions.length;c++){var d=this._creativeRenditions[c];d!==this._primaryCreativeRendition&&b.push(d)}return b},parse:function(b){if(b){this._adId=b.adId;this._creativeId=b.creativeId;this._creativeRenditionId=b.creativeRenditionId;this._replicaId=b.hasOwnProperty("replicaId")?
b.replicaId*1:-1;this._primaryCreativeRendition=this._context._adResponse.getCreativeRendition(this._adId,this._creativeId,this._creativeRenditionId,this._replicaId);this._creativeRenditions=this._context._adResponse.getCreative(this._adId,this._creativeId)._creativeRenditions;for(var c=0,d=b.eventCallbacks||[];c<d.length;c++){var e=d[c],f=a.EventCallback.newEventCallback(this._context,e.name,e.type);if(f){f._adInstance=this;f.parse(e);this._eventCallbacks.push(f)}}c=0;for(d=b.companionAds||[];c<
d.length;++c)if((e=d[c])&&e.adSlotCustomId){b=new a.AdInstance(this._context);b._slotCustomId=e.adSlotCustomId;b.parse(e);this._companionAdInstances.push(b)}}},play:function(){this._state.play(this);if(a.MODULE_TYPE_RENDERER==this._rendererController._renderer.info()[a.INFO_KEY_MODULE_TYPE])for(var b=0;b<this._companionAdInstances.length;b++)this._companionAdInstances[b]._rendererController.play()},complete:function(){this._state.complete(this);this._rendererController._renderer=null;this._slot.playNextAdInstance()},
onStartPlaying:function(){this._timer.tick();var b=this.getEventCallback(a.EVENT_AD_IMPRESSION,a.EVENT_TYPE_IMPRESSION);if(this._slot._type==a.SLOT_TYPE_TEMPORAL){this._init="1";this._last="0"}else this._last=this._init="1";b&&b.process()},onCompletePlaying:function(){if(this._slot._type==a.SLOT_TYPE_TEMPORAL){this._init="0";this._last="1";var b=this.getEventCallback(a.EVENT_AD_IMPRESSION,a.EVENT_TYPE_IMPRESSION);b&&b.process()}},onStartReplaying:function(){this._timer.tick();var b=this.getEventCallback(a.EVENT_AD_IMPRESSION,
a.EVENT_TYPE_IMPRESSION);if(this._slot._type==a.SLOT_TYPE_TEMPORAL){this._init="2";this._last="0"}else{this._init="2";this._last="1"}b&&b.process()},onCompleteReplaying:function(){if(this._slot._type==a.SLOT_TYPE_TEMPORAL){this._init="2";this._last="1";var b=this.getEventCallback(a.EVENT_AD_IMPRESSION,a.EVENT_TYPE_IMPRESSION);b&&b.process()}},getEventCallback:function(b,c){return a.EventCallback.getEventCallback(this._eventCallbacks,b,c)},setMetr:function(b,c){var d=a.AdInstance._metrDictionary[b];
if(d){if(b==a.EVENT_AD_CLICK)c=!c;if(c==a.CAPABILITY_STATUS_ON)this._metr|=d;else this._metr&=~d}},getExternalEventCallbackUrls:function(b,c){return this._externalEventCallbackUrlsDictionary[c+"-"+b]||[]},reset:function(){this._rendererController.reset();for(var b=0;b<this._companionAdInstances.length;b++){var c=this._companionAdInstances[b];if(c._state==a.MediaPlayingState.instance||c._state==a.MediaReplayingState.instance)c.complete();c._rendererController.reset()}},_isValidEventNameAndType:function(b,
c){if(a.Util.isBlank(b)||a.Util.isBlank(c))return false;return c==a.EVENT_TYPE_CLICK||c==a.EVENT_TYPE_CLICK_TRACKING||c==a.EVENT_TYPE_IMPRESSION&&(b==a.EVENT_AD_IMPRESSION||b==a.EVENT_AD_FIRST_QUARTILE||b==a.EVENT_AD_MIDPOINT||b==a.EVENT_AD_THIRD_QUARTILE||b==a.EVENT_AD_COMPLETE)||c==a.EVENT_TYPE_STANDARD&&(b==a.EVENT_AD_PAUSE||b==a.EVENT_AD_RESUME||b==a.EVENT_AD_REWIND||b==a.EVENT_AD_MUTE||b==a.EVENT_AD_UNMUTE||b==a.EVENT_AD_COLLAPSE||b==a.EVENT_AD_EXPAND||b==a.EVENT_AD_MINIMIZE||b==a.EVENT_AD_CLOSE||
b==a.EVENT_AD_ACCEPT_INVITATION)},toString:function(){return"[AdInstance "+this._adId+"]"}});a.AdManager=function(){var b=this;this._context=this.newContext();this._context.addEventListener(a.EVENT_REQUEST_COMPLETE,function(c){b.onRequestComplete(c)});this._networkId=this._serverURL="";this._onRequestComplete=this._location=null};a.AdManager.prototype={setNetwork:function(b){a.debug("AdManager.setNetwork("+Array.prototype.slice.call(arguments).join(",")+")");if(typeof b=="number"&&b>0)this._networkId=
b},setServerURL:function(b){a.debug("AdManager.setServerURL("+Array.prototype.slice.call(arguments).join(",")+")");a.warn("AdManager.setServerURL method is DEPRECATED, use AdManager.setServer instead.");this.setServer(b)},setServer:function(b){a.debug("AdManager.setServer("+Array.prototype.slice.call(arguments).join(",")+")");if(!b||typeof b!="string")a.warn("AdManager.setServer","server url required");else this._serverURL=b},setLocation:function(b){a.debug("AdManager.setLocation("+Array.prototype.slice.call(arguments).join(",")+
")");this._location=b},newContext:function(){a.debug("AdManager.newContext("+Array.prototype.slice.call(arguments).join(",")+")");return new a.Context(this)},setParameter:function(b,c,d){a.debug("AdManager.setParameter("+Array.prototype.slice.call(arguments).join(",")+")");this._context.setParameter(b,c,d)},getParameter:function(b){return this._context.getParameter(b)},submitRequest:function(b,c){a.debug("AdManager.submitRequest()");if(b&&typeof b=="function")this._onRequestComplete=b;else a.warn("AdManager.submitRequest(): callback function required");
this._context.submitRequest(c/1E3)},onRequestComplete:function(b){a.debug("AdManager.onRequestComplete("+Array.prototype.slice.call(arguments).join(",")+")");if(this._onRequestComplete){this._onRequestComplete({success:b.success,response:b.response});this._onRequestComplete=null}},registerVideoDisplayBase:function(b){a.debug("AdManager.registerVideoDisplayBase("+Array.prototype.slice.call(arguments).join(",")+")");this._context.registerVideoDisplayBase(b)},setVideoAsset:function(b,c){a.debug("AdManager.setVideoAsset("+
Array.prototype.slice.call(arguments).join(",")+")");this._context.setVideoAsset(b,c)},setSiteSection:function(b){a.debug("AdManager.setSiteSection("+Array.prototype.slice.call(arguments).join(",")+")");this._context.setSiteSection(b)},addKeyValue:function(b,c){a.debug("AdManager.addKeyValue("+Array.prototype.slice.call(arguments).join(",")+")");this._context.addKeyValue(b,c)},setVideoDisplayCompatibleSizes:function(b){a.debug("AdManager.setVideoDisplayCompatibleSizes("+Array.prototype.slice.call(arguments).join(",")+
")");this._context.setVideoDisplayCompatibleSizes(b)},playSlots:function(b,c){a.debug("AdManager.playSlots("+b+")");if(typeof b=="string")b=b.toUpperCase();this._fillVideoPool(b,a.Util.bind(this,this._playSlots,b,c))},_playSlots:function(b,c){if(typeof c!="function")c=function(){};if(this._context._adResponse){for(var d=[],e=this._context.getTemporalSlots(),f=0;f<e.length;++f){var g=e[f];if(Math.abs(g._timePosition-b)<0.1||b==g._timePositionClass.toUpperCase())d.push(g)}if(d.length===0){a.warn("AdManager.playSlots",
"no slot matches",b);c()}else if(b==a.TIME_POSITION_CLASS_OVERLAY||b==a.TIME_POSITION_CLASS_MIDROLL)for(f=0;f<d.length;f++)(function(h){if(!h._onContentVideoTimeUpdate){var k=h.getBase()._fw_contentVideo,m=h._onContentVideoTimeUpdate=function(){if(!k.paused&&k._fw_videoAdPlaying!==true&&k.currentTime-h._timePosition>=0&&k.currentTime-h._timePosition<1){k.removeEventListener("timeupdate",m,false);h._play(function(){var l=setInterval(function(){if(!k.paused&&Math.abs(k.currentTime-h._timePosition)>
2){k.addEventListener("timeupdate",m,false);clearInterval(l)}},1E3)})}};k.addEventListener("timeupdate",m,false)}})(d[f]);else(function(){var h=d.shift();h?h._play(arguments.callee):c()})()}else{a.warn("AdManager._playSlots","request is not completed");c()}},dispose:function(){a.debug("AdManager.dispose()");this._context.dispose();this._onRequestComplete=null},_fillVideoPool:function(b,c){a.debug("AdManager._fillVideoPool()");this._context._fillVideoPool(b,c)}};a.AdManager.prototype.constructor=a.AdManager;
a.AdRequest=function(b){this._context=b;this._capabilities=new a.Capabilities;this._keyValues=[];this._playerProfile="";this._compatibleDimensions=this._videoState=null;this._temporalSlots=[];this._assetLocation=this._assetNetworkId=this._assetDuration=this._assetCustomId=this._assetId="";this._assetAutoPlayType=a.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED;this._assetViewRandom=this._assetFallbackId=0;this._siteSectionNetworkId=this._siteSectionId=this._siteSectionCustomId="";this._siteSectionViewRandom=
this._siteSectionFallbackId=0;this._visitorCustomId="";this._slotScanner=new a.PageSlotScanner;this._urlParams={};this._urlKeyValues=[];this._customInfo=""};a.AdRequest.prototype={setCapability:function(b,c){this._capabilities.setCapability(b,c)},addKeyValue:function(b,c){if(typeof b!="string"||typeof c!="string"||b.length==0)a.warn("AdRequest.addKeyValue:","key and value required");else{b=encodeURIComponent(b)+"="+encodeURIComponent(c);this._keyValues.indexOf(b)<0&&this._keyValues.push(b)}},setProfile:function(b){if(typeof b!=
"string")a.warn("AdRequest.setProfile:","player profile required");else this._playerProfile=b},setVideoState:function(b){this._videoState=b},setVideoDisplayCompatibleSizes:function(b){if(!b||!b.length)a.warn("AdRequest.setVideoDisplayCompatibleSizes:","compatilble dimensions required");else{for(var c=[],d={},e=0;e<b.length;++e){a.debug("dimension is:",b[e].width,"X",b[e].height);if(b[e].width>0&&b[e].height>0){var f=b[e].width+","+b[e].height;if(d[f]==null){d[f]="";c.push(f)}}}if(c.length>0)this._compatibleDimensions=
c.join("|")}},setVideoAsset:function(b,c,d,e,f,g,h,k){if(b){switch(h){case a.ID_TYPE_FW:this._assetId=b;break;case a.ID_TYPE_GROUP:this._assetId="g"+b;break;default:this._assetCustomId=b;break}if(typeof c=="number")this._assetDuration=Math.round(c*10)/10;if(typeof d=="number")this._assetNetworkId=d;if(typeof e=="string")this._assetLocation=e;if(typeof f=="number")this._assetAutoPlayType=f;if(typeof g=="number")this._assetViewRandom=g;if(typeof k=="number")this._assetFallbackId=k}else a.warn("AdRequest.setVideoAsset",
"id required")},setSiteSection:function(b,c,d,e,f){if(b){switch(e){case a.ID_TYPE_FW:this._siteSectionId=b;break;case a.ID_TYPE_GROUP:this._siteSectionId="g"+b;break;default:this._siteSectionCustomId=b;break}if(typeof c=="number")this._siteSectionNetworkId=c;if(typeof d=="number")this._siteSectionViewRandom=d;if(typeof f=="number")this._siteSectionFallbackId=f}else a.warn("AdRequest.setSiteSection: id required")},setVisitor:function(b){if(typeof b!="string")a.warn("AdRequest.setVisitor:","customId required");
else this._visitorCustomId=b},addTemporalSlot:function(b,c,d,e){if(a.Util.isBlank(b)||a.Util.isBlank(c)||!(d>=0))a.warn("AdRequest.addTemporalSlot:","invalid parameters");else{for(var f=0;f<this._temporalSlots.length;f++)if(this._temporalSlots[f].getCustomId()==b){a.warn("AdRequest.addTemporalSlot:","slot is already existed, ignored");return}f=new a.Slot;f._customId=b;f._adUnit=c;f._timePosition=d;f._slotProfile=e;this._temporalSlots.push(f)}},scanPageSlots:function(){this._slotScanner.scanPageSlots()},
generateTypeBRequestUrl:function(){var b=this._context._adManager._serverURL.split("?"),c=b[0],d=[/fwmrm\.net$/,/fwmrm\.net\/$/,/fwmrm\.net\/ad$/,/fwmrm\.net\/ad\/$/,/fwmrm\.net\/ad\/g$/,/fwmrm\.net\/ad\/g\/$/,/fwmrm\.net\/ad\/g\/1$/];if(c.indexOf("http://")==0||c.indexOf("https://")==0)for(var e in d)if(c.match(d[e])){c=c.slice(0,c.indexOf("fwmrm.net")+9)+"/ad/g/1";break}this.parseQueryStr(b.slice(1).join("?"));b=this.generateGlobalParametersQueryStr()+";"+this.generateKeyValuesStr()+";"+this.generateSlotsTypeBStr();
a.Util.isBlank(this._customInfo)||(b+=";"+this._customInfo);return c+"?"+b},parseQueryStr:function(b){a.debug("AdRequest.parseQueryStr("+Array.prototype.slice.call(arguments).join(",")+")");this._urlParams={};this._urlKeyValues=[];this._customInfo="";if(b){if(b.charAt(b.length-1)==";")b=b.substring(0,b.length-1);var c=b.split(";");if(c[0])for(var d=c[0].split("&"),e=0;e<d.length;++e){var f=d[e].split("=");if(f.length==2)this._urlParams[f[0]]=f[1]}if(c[1]){d=c[1].split("&");for(e=0;e<d.length;++e)this._urlKeyValues.push(d[e])}if(c[2])this._customInfo=
c.slice(2).join(";")}},generateGlobalParametersQueryStr:function(){a.debug("AdRequest.generateGlobalParametersQueryStr");for(var b=[["prof",this._playerProfile,"string"],["nw",this._context._adManager._networkId,"number"],["caid",this._assetCustomId,"string"],["asid",this._assetId,"string"],["vdur",this._assetDuration,"number"],["asnw",this._assetNetworkId,"number"],["asml",this._assetLocation,"string"],["vprn",this._assetViewRandom,"number"],["afid",this._assetFallbackId,"number"],["csid",this._siteSectionCustomId,
"string"],["ssid",this._siteSectionId,"string"],["ssnw",this._siteSectionNetworkId,"number"],["pvrn",this._siteSectionViewRandom,"number"],["sfid",this._siteSectionFallbackId,"number"],["vcid",this._visitorCustomId,"string"],["cd",this._compatibleDimensions||this.detectScreenDimension(),"string"],["vclr",a.version,"string"],["resp",a.Util.PLATFORM_IS_SAFARI&&(a.Util.PLATFORM_IOS_VERSION==0||a.Util.PLATFORM_IOS_VERSION>3.2)?"json2":"json","string"],["orig",window.location.protocol+"//"+window.location.host,
"string"],["cbfn","tv.freewheel.SDK._instanceQueue['Context_"+this._context._instanceId+"'].requestComplete","string"]],c=0;c<b.length;c++){var d=b[c];switch(d[2]){case "string":a.Util.isBlank(d[1])||(this._urlParams[d[0]]=encodeURIComponent(d[1]));break;case "number":if(d[1]>0)this._urlParams[d[0]]=d[1];break}}b="";for(key in this._urlParams)Object[key]||(b+=key+"="+this._urlParams[key]+"&");b=b.substring(0,b.length-1);if(this._slotScanner._candidateAds.length>0){this._capabilities._capabilities[a.CAPABILITY_CHECK_COMPANION]==
null&&this._capabilities.setCapability(a.CAPABILITY_CHECK_COMPANION,a.CAPABILITY_STATUS_ON);this._capabilities._capabilities[a.CAPABILITY_CHECK_TARGETING]==null&&this._capabilities.setCapability(a.CAPABILITY_CHECK_TARGETING,a.CAPABILITY_STATUS_OFF)}b=this._capabilities.parseCapabilites(b);c="";switch(this._assetAutoPlayType){case a.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED:c="+play+uapl";break;case a.VIDEO_ASSET_AUTO_PLAY_TYPE_NON_AUTO_PLAY:c="-play";break;default:c="+play-uapl";break}return b=b.replace(/flag=/,
"flag="+encodeURIComponent(c))},generateKeyValuesStr:function(){a.debug("AdRequest.generateKeyValuesStr");var b=a.Util.flashVersion();b=this._keyValues.concat("_fw_h_x_flash_version="+encodeURIComponent(b));for(var c=0;c<this._urlKeyValues.length;c++){var d=this._urlKeyValues[c];b.indexOf(d)<0&&b.push(d)}(c=this._context._adManager._location)&&b.push("ltlg="+encodeURIComponent(Math.round(c.coords.latitude*1E4)/1E4+","+Math.round(c.coords.longitude*1E4)/1E4));return b.join("&")},generateSlotsTypeBStr:function(){a.debug("AdRequest.generateSlotsTypeBStr");
for(var b="",c=[],d=0;d<this._temporalSlots.length;d++){var e=this._temporalSlots[d];e=[["slid",e._customId,"string"],["slau",e._adUnit,"string"],["ptgt","a","string"],["tpos",e._timePosition,"number"],["envp",e._slotProfile,"string"]];for(var f=[],g=0;g<e.length;g++){var h=e[g];switch(h[2]){case "string":a.Util.isBlank(h[1])||f.push(h[0]+"="+encodeURIComponent(h[1]));break;case "number":h[1]>=0&&f.push(h[0]+"="+h[1]);break}}c.push(f.join("&"))}if(c.length>0)b=c.join(";")+";";b+=this._slotScanner.slotsToTypeBStr();
return b},detectScreenDimension:function(){a.debug("AdRequest.detectScreenDimension:",screen.width+","+screen.height);return screen.width+","+screen.height}};a.AdResponse=function(b){this._context=b};a.AdResponse.prototype={};a.AdResponse.prototype.constructor=a.AdResponse;a.Util.mixin(a.AdResponse.prototype,{parse:function(b,c){this._data=b;this._temporalSlots=[];this._videoPlayerNonTemporalSlots=[];this._siteSectionNonTemporalSlots=[];this._profileParameters={};this._ads=[];var d,e;e=a.Util.getObject("parameters",
b)||[];for(d=0;d<e.length;++d){var f=e[d];this._profileParameters[f.name]=f.value}e=a.Util.getObject("ads.ads",b)||[];for(d=0;d<e.length;++d){f=new a.Ad(this._context);f.parse(e[d]);this._ads.push(f)}e=a.Util.getObject("siteSection.videoPlayer.videoAsset.adSlots",b)||[];for(d=0;d<e.length;++d){f=new a.Slot(this._context);f._type=a.SLOT_TYPE_TEMPORAL;f._base=c;f.parse(e[d]);this._temporalSlots.push(f)}e=a.Util.getObject("siteSection.videoPlayer.adSlots",b)||[];for(d=0;d<e.length;++d){f=new a.Slot(this._context);
f._type=a.SLOT_TYPE_VIDEOPLAYER_NONTEMPORAL;f.parse(e[d]);f._timePositionClass=a.TIME_POSITION_CLASS_DISPLAY;this._initSlotData(f);this._videoPlayerNonTemporalSlots.push(f)}e=a.Util.getObject("siteSection.adSlots",b)||[];for(d=0;d<e.length;++d){f=new a.Slot(this._context);f._type=a.SLOT_TYPE_SITESECTION_NONTEMPORAL;f.parse(e[d]);f._timePositionClass=a.TIME_POSITION_CLASS_DISPLAY;this._initSlotData(f);this._siteSectionNonTemporalSlots.push(f)}},getCreativeRendition:function(b,c,d,e){return(b=this.getCreative(b,
c))?b.getCreativeRendition(d,e):null},getCreative:function(b,c){for(var d=0;d<this._ads.length;d++){var e=this._ads[d];if(e._id==b)return e.getCreative(c)}return null},getTemporalSlots:function(){return this._temporalSlots},getSiteSectionNonTemporalSlots:function(){return this._siteSectionNonTemporalSlots},getVideoPlayerNonTemporalSlots:function(){return this._videoPlayerNonTemporalSlots},getSlotByCustomId:function(b){for(var c=0;c<this._temporalSlots.length;++c)if(this._temporalSlots[c]._customId==
b)return this._temporalSlots[c];for(c=0;c<this._videoPlayerNonTemporalSlots.length;++c)if(this._videoPlayerNonTemporalSlots[c]._customId==b)return this._videoPlayerNonTemporalSlots[c];for(c=0;c<this._siteSectionNonTemporalSlots.length;++c)if(this._siteSectionNonTemporalSlots[c]._customId==b)return this._siteSectionNonTemporalSlots[c];a.warn("getSlotByCustomId(): not found",b);return null},_initSlotData:function(b){for(var c=0;c<this._context._adRequest._slotScanner._knownSlots.length;c++){var d=this._context._adRequest._slotScanner._knownSlots[c];
if(b._customId==d.id){b._width=d.width;b._height=d.height}}}});a.Capabilities=function(){this._capabilities={};this.init()};a.Capabilities.prototype={init:function(){for(var b=[a.CAPABILITY_SLOT_TEMPLATE,a.CAPABILITY_MULTIPLE_CREATIVE_RENDITIONS,a.CAPABILITY_RECORD_VIDEO_VIEW,a.CAPABILITY_FALLBACK_UNKNOWN_ASSET,a.CAPABILITY_FALLBACK_UNKNOWN_SITE_SECTION,a.CAPABILITY_SLOT_CALLBACK,a.CAPABILITY_NULL_CREATIVE],c=0;c<b.length;c++)this._capabilities[b[c]]=a.CAPABILITY_STATUS_ON},setCapability:function(b,
c){this._capabilities[b]=c},parseCapabilites:function(b){b=b;var c="";for(var d in this._capabilities){switch(this._capabilities[d]){case a.CAPABILITY_STATUS_ON:c+="+"+d;break;case a.CAPABILITY_STATUS_OFF:c+="-"+d;break}b=b.replace(new RegExp("(%2B|-|\\+)"+d,"g"),"")}c=encodeURIComponent(c);if(b.indexOf("flag=")>-1)b=b.replace(/flag=/,"flag="+c);else b+="&flag="+c;return b}};a.ContentVideoExtension=function(b){this._context=b;this._contentVideo=null};a.ContentVideoExtension.prototype={_resume:function(){},
_pause:function(){},_onAttach:function(){},_onDetach:function(){},start:function(b){a.debug("ContentVideoExtension.start("+Array.prototype.slice.call(arguments).join(",")+")");this._contentVideo=b._fw_contentVideo;this._resume=a.Util.bind(this,function(){if(this._isDisabled())this.dispose();else{a.log("ContentVideoExtension:","EVENT_CONTENT_VIDEO_RESUME_REQUEST","resume content video");if(a.Util.PLATFORM_ANDROID_VERSION>=3.1){var c=this._context.getVideoDisplaySize();this._contentVideo.style.position=
c.position;this._contentVideo.style.left=c.left;this._contentVideo.style.top=c.top}else if(a.Util.PLATFORM_IOS_VERSION==0||a.Util.PLATFORM_IOS_VERSION>=3.2)if(a.Util.PLATFORM_IS_IPAD&&this._context.getParameter(a.PARAMETER_PLAY_MIDROLL_BY_CURRENT_VIDEO_ELEMENT)==true){a.debug("ContentVideoExtension:","play midroll with content video","no nedd to show/hide and play");this._contentVideo.controls=this._controls;return}else this._contentVideo.style.display="";this._contentVideo.play();if(a.Util.PLATFORM_IOS_VERSION>
0&&a.Util.PLATFORM_IS_IPAD)if(this._context.getParameter(a.PARAMETER_EXTENSION_CONTENT_VIDEO_AUTO_SEEK_BACK)!=false){if(this._fixContentVideoCurrentTime){this._contentVideo.removeEventListener("timeupdate",this._fixContentVideoCurrentTime,false);this._fixContentVideoCurrentTime=null}this._fixContentVideoCurrentTime=a.Util.bind(this,function(){if(!(this._contentVideo.currentTime<=0||this._contentVideo.seekable.length<=0)){this._contentVideo.removeEventListener("timeupdate",this._fixContentVideoCurrentTime,
false);this._fixContentVideoCurrentTime=null;if(this._contentVideo.currentTime>0&&this._contentVideo.currentTime<1){a.log("ContentVideoExtension: seeking to original time "+this._originalTime);try{this._contentVideo.currentTime=this._originalTime}catch(d){a.warn("ContentVideoExtension: seek error")}}}});this._contentVideo.addEventListener("timeupdate",this._fixContentVideoCurrentTime,false)}}});this._pause=a.Util.bind(this,function(){if(this._isDisabled())this.dispose();else{a.log("ContentVideoExtension:",
"EVENT_CONTENT_VIDEO_PAUSE_REQUEST","pause content video");this._originalTime=this._contentVideo.currentTime;this._contentVideo.pause();if(a.Util.PLATFORM_IS_IPAD&&this._context.getParameter(a.PARAMETER_PLAY_MIDROLL_BY_CURRENT_VIDEO_ELEMENT)==true){a.debug("ContentVideoExtension:","play midroll with content video","no nedd to hide/show");this._controls=this._contentVideo.controls}else if(a.Util.PLATFORM_ANDROID_VERSION>=3.1){this._contentVideo.style.position="absolute";this._contentVideo.style.left=
"-10000";this._contentVideo.style.top="-10000"}else if(a.Util.PLATFORM_IOS_VERSION==0||a.Util.PLATFORM_IOS_VERSION>=3.2)this._contentVideo.style.display="none"}});this._onAttach=a.Util.bind(this,function(){if(this._isDisabled())this.dispose();else{a.log("ContentVideoExtension: EVENT_CONTENT_VIDEO_ATTACH");this._src=this._contentVideo.src;this._controls=this._contentVideo.controls;this._contentVideo.paused||this._contentVideo.pause()}});this._onDetach=a.Util.bind(this,function(c){if(this._isDisabled())this.dispose();
else{a.log("ContentVideoExtension: EVENT_CONTENT_VIDEO_DETACH restore contentVideo.src:"+this._src);this._contentVideo.src=this._src;this._contentVideo.controls=this._controls;c&&c.slot&&c.slot.getTimePositionClass()==a.TIME_POSITION_CLASS_PREROLL&&this._contentVideo.load()}});this._context.addEventListener(a.EVENT_CONTENT_VIDEO_PAUSE_REQUEST,this._pause);this._context.addEventListener(a.EVENT_CONTENT_VIDEO_RESUME_REQUEST,this._resume);this._context.addEventListener(a.EVENT_CONTENT_VIDEO_ATTACH,this._onAttach);
this._context.addEventListener(a.EVENT_CONTENT_VIDEO_DETACH,this._onDetach)},_isDisabled:function(){if(this._context.getParameter(a.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED)===false){a.log("Content Video Extension disabled");return true}return false},dispose:function(){a.debug("ContentVideoExtension.dispose()");if(this._context){this._context.removeEventListener(a.EVENT_CONTENT_VIDEO_PAUSE_REQUEST,this._pause);this._context.removeEventListener(a.EVENT_CONTENT_VIDEO_RESUME_REQUEST,this._resume);this._context.removeEventListener(a.EVENT_CONTENT_VIDEO_ATTACH,
this._onAttach);this._context.removeEventListener(a.EVENT_CONTENT_VIDEO_DETACH,this._onDetach);if(this._contentVideo&&this._fixContentVideoCurrentTime){this._contentVideo.removeEventListener("timeupdate",this._fixContentVideoCurrentTime,false);this._fixContentVideoCurrentTime=null}this._context=null}}};a.ContentVideoExtension.prototype.constructor=a.ContentVideoExtension;a._instanceCounter=0;a._instanceQueue={};a.Context=function(b){this._adManager=b;this._adRequest=new a.AdRequest(this);this._videoDisplaySize=
this._temporalSlotBase=this._adResponse=null;this._globalLevelParameterDictionary={};this._overrideLevelParameterDictionary={};this._rendererManifest={};this._eventDispatcher=new a.EventDispatcher;this._requestState=0;this._adControlExtension=new a.AdControlExtension(this);this._instanceId=a._instanceCounter;a._instanceQueue["Context_"+a._instanceCounter]=this;a._instanceCounter++};a.Context.prototype={setCapability:function(b,c){a.debug("Context.setCapability",b,c);this._adRequest.setCapability(b,
c)},addKeyValue:function(b,c){a.debug("Context.addKeyValue",b,c);this._adRequest.addKeyValue(b,c)},setParameter:function(b,c,d){a.debug("Context.setParameter",b,c,d);var e=null;if(d==a.PARAMETER_LEVEL_GLOBAL)e=this._globalLevelParameterDictionary;else if(d==a.PARAMETER_LEVEL_OVERRIDE)e=this._overrideLevelParameterDictionary;else return;if(c===null)delete e[b];else e[b]=c},getParameter:function(b,c){if(c==a.PARAMETER_LEVEL_GLOBAL)return this._globalLevelParameterDictionary[b];else if(c==a.PARAMETER_LEVEL_OVERRIDE)return this._overrideLevelParameterDictionary[b];
else{if(this._overrideLevelParameterDictionary.hasOwnProperty(b))return this._overrideLevelParameterDictionary[b];if(this._adResponse&&this._adResponse._profileParameters.hasOwnProperty(b))return this._adResponse._profileParameters[b];if(this._globalLevelParameterDictionary.hasOwnProperty(b))return this._globalLevelParameterDictionary[b];return null}},setVideoState:function(b){a.debug("Context.setVideoState",b);this._adRequest.setVideoState(b)},registerVideoDisplayBase:function(b){a.debug("Context.registerVideoDisplayBase",
b);if(!b||typeof b!="string")a.warn("Context.registerVideoDisplayBase","id required");this._registeredTemporalSlotBaseId=b;this.setContentVideoElement(document.getElementById(b).getElementsByTagName("video")[0])},setContentVideoElement:function(b){a.debug("Context.setContentVideoElement()");if(!b||!b.parentNode)a.warn("Context.setContentVideoElement","contentVideo and contentVideo.parentNode is required");else{if(this._registeredTemporalSlotBaseId){this._temporalSlotBase=document.getElementById(this._registeredTemporalSlotBaseId);
delete this._registeredTemporalSlotBaseId}else this._temporalSlotBase=b.parentNode;this._temporalSlotBase._fw_contentVideo=b;this._videoDisplaySize||this.setVideoDisplaySize(b.style.left,b.style.top,b.offsetWidth?b.offsetWidth:b.style.pixelWidth,b.offsetHeight?b.offsetHeight:b.style.pixelHeight,b.style.position);if(this.getParameter(a.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED)===false)a.log("Content Video Extension disabled");else{this._contentVideoExtension&&this._contentVideoExtension.dispose();
this._contentVideoExtension=new a.ContentVideoExtension(this);this._contentVideoExtension.start(this._temporalSlotBase)}}},setVideoDisplaySize:function(b,c,d,e,f){a.debug("Context.setVideoDisplaySize("+Array.prototype.slice.call(arguments).join(",")+")");this._videoDisplaySize={left:b,top:c,width:d,height:e,position:f}},getVideoDisplaySize:function(){return this._videoDisplaySize},setVideoDisplayCompatibleSizes:function(b){a.debug("Context.setVideoDisplayCompatibleSizes",b);this._adRequest.setVideoDisplayCompatibleSizes(b)},
setProfile:function(b){a.debug("Context.setProfile",b);this._adRequest.setProfile(b)},setVideoAsset:function(b,c,d,e,f,g,h,k){a.debug("Context.setVideoAsset("+Array.prototype.slice.call(arguments).join(",")+")");this._adRequest.setVideoAsset(b,c,d,e,f,g,h,k)},setSiteSection:function(b,c,d,e,f){a.debug("Context.setSiteSection("+Array.prototype.slice.call(arguments).join(",")+")");this._adRequest.setSiteSection(b,c,d,e,f)},setVisitor:function(b){a.debug("Context.setVisitor("+Array.prototype.slice.call(arguments).join(",")+
")");this._adRequest.setVisitor(b)},addTemporalSlot:function(b,c,d,e){a.debug("Context.addTemporalSlot("+Array.prototype.slice.call(arguments).join(",")+")");this._adRequest.addTemporalSlot(b,c,d,e)},getTemporalSlots:function(){return this._adResponse?this._adResponse._temporalSlots.slice():[]},getSlotsByTimePositionClass:function(b){var c=[];if(this._adResponse)for(var d=0;d<this._adResponse._temporalSlots.length;d++)this._adResponse._temporalSlots[d].getTimePositionClass()==b&&c.push(this._adResponse._temporalSlots[d]);
return c},submitRequest:function(b){a.debug("Context.submitRequest",b);if(this._requestState)a.warn("Context.submitRequest: request already submitted");else if(a.Util.isBlank(this._adManager._serverURL))a.warn("Context.submitRequest: serverURL is not set");else{this._requestState=1;this._adRequest.scanPageSlots();var c=this._adManager._serverURL;if(c.substring(c.length-3,c.length)!=".js")c=this._adRequest.generateTypeBRequestUrl();var d=this;if(typeof b!="number"||b<=0||!b)b=5;setTimeout(function(){if(d._requestState==
1){a.warn("Context.submitRequest: request timeout");d.requestComplete(null)}},b*1E3);a.log("Context.submitRequest: sending request to",c,"timeout",b);if(a.Util.PLATFORM_IS_SAFARI&&(a.Util.PLATFORM_IOS_VERSION==0||a.Util.PLATFORM_IOS_VERSION>3.2)){a.debug("Context.submitRequest:","use json2");a.Util.pingURLWithForm(c,this._instanceId,true);d._onMessagePosted=function(e){typeof e.data=="object"&&e.data.hasOwnProperty("cbfn")&&e.data.cbfn.indexOf("['Context_"+d._instanceId+"']")>-1&&d.requestComplete(e.data.response)};
window.addEventListener("message",d._onMessagePosted,false)}else a.Util.pingURLWithScript(c)}},requestComplete:function(b){if(this._requestState!=1)a.warn("ad request complete after timeout");else{this._requestState=2;a.debug("Context.requestComplete");if(a.Util.PLATFORM_IS_SAFARI&&(a.Util.PLATFORM_IOS_VERSION==0||a.Util.PLATFORM_IOS_VERSION>3.2)){window.removeEventListener("message",this._onMessagePosted,false);var c=document.getElementById("_fw_request_iframe_"+this._instanceId);document.body.removeChild(c)}if(b!==
null){this._adControlExtension.start();a._instanceQueue["Context_"+this._isntanceId]=null;this._adResponse=new a.AdResponse(this);this._adResponse.parse(b,this._temporalSlotBase);var d=false;for(c=0;c<this._adResponse._temporalSlots.length;c++)if(this._adResponse._temporalSlots[c].getTimePositionClass()==a.TIME_POSITION_CLASS_PREROLL){d=true;break}if(!d){c=new a.Slot(this);c._customId="_fw_empty_preroll_slot";c._adUnit="preroll";c._timePosition=0;c._timePositionClass=a.TIME_POSITION_CLASS_PREROLL;
c._base=this._temporalSlotBase;c._type=a.SLOT_TYPE_TEMPORAL;this._adResponse._temporalSlots.push(c)}a.log("Ad request succeeded");this.dispatchEvent(a.EVENT_REQUEST_COMPLETE,{success:true,response:b});b=this._adResponse.getSiteSectionNonTemporalSlots();for(c=0;c<b.length;++c)b[c].play();b=this._adResponse.getVideoPlayerNonTemporalSlots();for(c=0;c<b.length;++c)b[c].play()}else{a.warn("Ad request failed");this.dispatchEvent(a.EVENT_REQUEST_COMPLETE,{success:false})}}},addEventListener:function(b,c){a.debug("Context.addEventListener",
b);this._eventDispatcher.addEventListener(b,c)},removeEventListener:function(b,c){a.debug("Context.removeEventListener",b);this._eventDispatcher.removeEventListener(b,c)},dispatchEvent:function(b,c){a.log("Context.dispatchEvent",b,c);c=c||{};c.type=b;c.target=this;this._eventDispatcher.dispatchEvent(c)},dispose:function(){a.debug("Context.dispose");if(this._adResponse){if(this._contentVideoExtension){this._contentVideoExtension.dispose();this._contentVideoExtension=null}this._adControlExtension.dispose();
for(var b=0,c=this._adResponse._temporalSlots||[];b<c.length;++b){var d=c[b];if(d._onContentVideoTimeUpdate){d.getBase()._fw_contentVideo.removeEventListener("timeupdate",d._onContentVideoTimeUpdate,false);d._onContentVideoTimeUpdate=null}}}},_fillVideoPool:function(b,c){a.debug("Context._fillVideoPool",b);a._videoPool=a._videoPool||[];var d=this._temporalSlotBase._fw_contentVideo;if(a.Util.PLATFORM_IOS_VERSION>=4.2&&b==a.TIME_POSITION_CLASS_PREROLL&&this.getSlotsByTimePositionClass(a.TIME_POSITION_CLASS_MIDROLL).length>
0){a._videoPoolSize=this.getParameter(a.PARAMETER_VIDEO_POOL_SIZE)||a._videoPoolSize||1;var e=a._videoPoolSize-a._videoPool.length+1,f=0,g=false,h=this,k=function(){if(!g){g=true;h.dispatchEvent(a.EVENT_CONTENT_VIDEO_DETACH);setTimeout(c,0)}};setTimeout(k,this.getParameter(a.PARAMETER_VIDEO_POOL_TIMEOUT)||2E3);this.dispatchEvent(a.EVENT_CONTENT_VIDEO_ATTACH,{});for(b=0;b<e;b++){var m=b?document.createElement("video"):d;m.src="http://127.0.0.1:1/404.mp4";m.addEventListener("error",function(l){l.target.removeEventListener("error",
arguments.callee,true);f++;a.log("Context._fillVideoPool:","pre-played <video> "+f+"/"+e);f==e&&k()},true);m.load();if(b>0){m._fw_fromVideoPool=true;a._videoPool.push(m);m.style.display="none";d.parentNode.appendChild(m)}}}else{a.log("skip video pool");c()}}};a.Context.prototype.constructor=a.Context;a.DisplayAdRenderer=function(){};a.DisplayAdRenderer.prototype={start:function(b){var c=b.getAdInstance(),d=c.getSlot()._customId;if(c=c.getPrimaryCreativeRendition().getPrimaryCreativeRenditionAsset().getContent()){try{a.Util.replacePageSlot(d,
c)}catch(e){b.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorModule:"DisplayAdRenderer",errorInfo:e}});return}b.processEvent({name:a.RENDERER_STATE_STARTED})}else b.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorModule:"DisplayAdRenderer",errorCode:a.ERROR_NULL_ASSET}})},info:function(){return{moduleType:a.MODULE_TYPE_RENDERER}}};a.DisplayAdRenderer.prototype.constructor=a.DisplayAdRenderer;a.EventCallback=function(){this._url=this._name=this._type=null;this._showBrowser=false;this._trackingUrls=
[];this._adInstance=this._slot=null};a.EventCallback.prototype={};a.EventCallback.prototype.constructor=a.EventCallback;a.EventCallback.getEventCallback=function(b,c,d){for(var e=0;e<b.length;e++){var f=b[e];if(f._name==c&&f._type==d)return f}for(e=0;e<b.length;e++){f=b[e];if(f._type==a.EVENT_TYPE_GENERIC){c=a.EventCallback.newEventCallback(f._context,c,d);c.setUrl(f.getUrl());c._slot=f._slot;c._adInstance=f._adInstance;c&&b.push(c);return c}}return null};a.EventCallback.newEventCallback=function(b,
c,d){var e=null;if(d==a.EVENT_TYPE_GENERIC)e=new a.EventCallback(b);else if(d==a.EVENT_TYPE_ERROR)e=new a.ErrorEventCallback(b);else if(d==a.EVENT_TYPE_CLICK)e=new a.AdClickEventCallback(b);else if(d==a.EVENT_TYPE_STANDARD)e=new a.AdStandardEventCallback(b);else if(c==a.EVENT_SLOT_IMPRESSION)e=new a.SlotImpressionEventCallback(b);else if(c==a.EVENT_AD_IMPRESSION)e=new a.AdImpressionEventCallback(b);else if(c==a.EVENT_VIDEO_VIEW)e=new a.VideoViewEventCallback(b);else if(c==a.EVENT_RESELLER_NO_AD)e=
new a.ResellerNoAdEventCallback(b);else if(c==a.EVENT_AD_FIRST_QUARTILE||c==a.EVENT_AD_MIDPOINT||c==a.EVENT_AD_THIRD_QUARTILE||c==a.EVENT_AD_COMPLETE)e=new a.AdQuartileEventCallback(b);else return null;e._name=c;e._type=d;return e};a.Util.mixin(a.EventCallback.prototype,{parse:function(b){if(b){this._usage=b.use;this._type=b.type;this._name=b.name;this.setUrl(b.url);this._showBrowser=b.showBrowser;this._trackingUrls=[];var c=0;for(b=b.trackingUrls||[];c<b.length;c++)this._trackingUrls.push(b[c].value)}},
copy:function(){var b=new this.constructor(this._context);b._type=this._type;b._name=this._name;b.setUrl(this.getInternalUrl());b._showBrowser=this._showBrowser;b._trackingUrls=this._trackingUrls.slice();b._slot=this._slot;b._adInstance=this._adInstance;return b},getUrl:function(){this._url.setParameter(a.URL_PARAMETER_KEY_ET,this._getShortType());this._url.setParameter(a.URL_PARAMETER_KEY_CN,this._name);return this._url.toString()},setUrl:function(b){this._originalUrl=b;this._url=new a.Url(b)},getUrlParameter:function(b){return this._url?
this._url.getParameter(b):null},setUrlParameter:function(b,c){this._url&&this._url.setParameter(b,c)},process:function(b){b=b||{};this._prepareUrlParameters(b);this._send(b)},getInternalUrl:function(){var b=new a.Url(this._originalUrl);b.setParameter(a.URL_PARAMETER_KEY_ET,this._getShortType());b.setParameter(a.URL_PARAMETER_KEY_CN,this._name);var c=this.getUrlParameter(a.URL_PARAMETER_KEY_CR);c&&b.setParameter(a.URL_PARAMETER_KEY_CR,c);return b.toString()},_prepareUrlParameters:function(){},_shouldSkipSendingTrackingAndExternalUrls:function(){return false},
_send:function(){if(!this._shouldSkipSendingTrackingAndExternalUrls()){a.Util.pingURLs(this._trackingUrls);this._adInstance&&a.Util.pingURLs(this._adInstance.getExternalEventCallbackUrls(this._name,this._type))}a.Util.pingURL(this.getUrl())},_getShortType:function(){return this._type==a.EVENT_TYPE_IMPRESSION?a.SHORT_EVENT_TYPE_IMPRESSION:this._type==a.EVENT_TYPE_CLICK?a.SHORT_EVENT_TYPE_CLICK:this._type==a.EVENT_TYPE_STANDARD?a.SHORT_EVENT_TYPE_STANDARD:this._type==a.EVENT_TYPE_ERROR?a.SHORT_EVENT_TYPE_ERROR:
""}});a.AdClickEventCallback=function(){};a.AdClickEventCallback.prototype=new a.EventCallback;a.AdClickEventCallback.prototype.constructor=a.AdClickEventCallback;a.Util.mixin(a.AdClickEventCallback.prototype,{_send:function(b){var c=this.getUrl();a.Util.pingURLs(this._trackingUrls);a.Util.pingURLs(this._adInstance.getExternalEventCallbackUrls(this._name,a.EVENT_TYPE_CLICK));(b.hasOwnProperty(a.INFO_KEY_SHOW_BROWSER)?b[a.INFO_KEY_SHOW_BROWSER]===true:this._showBrowser===true)&&!a.Util.isBlank(c)?
window.open(c):a.Util.pingURL(c)}});a.AdImpressionEventCallback=function(){};a.AdImpressionEventCallback.prototype=new a.EventCallback;a.AdImpressionEventCallback.prototype.constructor=a.AdImpressionEventCallback;a.Util.mixin(a.AdImpressionEventCallback.prototype,{_prepareUrlParameters:function(){this._url.setParameter(a.URL_PARAMETER_KEY_METR,this._adInstance._metr);this._url.setParameter(a.URL_PARAMETER_KEY_CT,this._adInstance._timer.tick());this._url.setParameter(a.URL_PARAMETER_KEY_INIT,this._adInstance._init);
this._url.setParameter(a.URL_PARAMETER_KEY_LAST,this._adInstance._last)},_shouldSkipSendingTrackingAndExternalUrls:function(){return this._adInstance._init!="1"},process:function(b){a.MODULE_TYPE_TRANSLATOR!=this._adInstance._rendererController._renderer.info()[a.INFO_KEY_MODULE_TYPE]&&a.EventCallback.prototype.process.call(this,b)}});a.AdQuartileEventCallback=function(){};a.AdQuartileEventCallback.prototype=new a.EventCallback;a.AdQuartileEventCallback.prototype.constructor=a.AdQuartileEventCallback;
a.Util.mixin(a.AdQuartileEventCallback.prototype,{_prepareUrlParameters:function(){this._url.setParameter(a.URL_PARAMETER_KEY_METR,this._adInstance._metr);this._url.setParameter(a.URL_PARAMETER_KEY_CT,this._adInstance._timer.tick())},process:function(b){if(!this._processed){this._processed=true;a.EventCallback.prototype.process.call(this,b)}}});a.AdStandardEventCallback=function(){};a.AdStandardEventCallback.prototype=new a.EventCallback;a.AdStandardEventCallback.prototype.constructor=a.AdStandardEventCallback;
a.ErrorEventCallback=function(){};a.ErrorEventCallback.prototype=new a.EventCallback;a.ErrorEventCallback.prototype.constructor=a.ErrorEventCallback;a.Util.mixin(a.ErrorEventCallback.prototype,{_prepareUrlParameters:function(b){a.EventCallback.prototype._prepareUrlParameters();var c=b[a.INFO_KEY_ERROR_CODE];if(!c)c=a.ERROR_UNKNOWN;var d=b[a.INFO_KEY_ERROR_INFO];d||(d="");(b=b[a.INFO_KEY_ERROR_MODULE])||(b="");this._url.setParameter(a.URL_PARAMETER_KEY_CN,c);this._url.setParameter(a.URL_PARAMETER_KEY_KEY_VALUE,
encodeURIComponent(a.URL_PARAMETER_KEY_ERROR_MODULE)+"="+encodeURIComponent(b)+"&"+encodeURIComponent(a.URL_PARAMETER_KEY_ERROR_INFO)+"="+a.Util.PLATFORM_ID+"/"+encodeURIComponent(d))},getUrl:function(){this._url.setParameter(a.URL_PARAMETER_KEY_ET,this._getShortType());return this._url.toString()}});a.ResellerNoAdEventCallback=function(){};a.ResellerNoAdEventCallback.prototype=new a.EventCallback;a.ResellerNoAdEventCallback.prototype.constructor=a.ResellerNoAdEventCallback;a.Util.mixin(a.ResellerNoAdEventCallback.prototype,
{process:function(b){if(!this._processed){this._processed=true;a.EventCallback.prototype.process.call(this,b)}}});a.SlotImpressionEventCallback=function(){};a.SlotImpressionEventCallback.prototype=new a.EventCallback;a.SlotImpressionEventCallback.prototype.constructor=a.SlotImpressionEventCallback;a.Util.mixin(a.SlotImpressionEventCallback.prototype,{_prepareUrlParameters:function(){this._url.setParameter(a.URL_PARAMETER_KEY_INIT,this._slot._init)},_shouldSkipSendingTrackingAndExternalUrls:function(){return this._slot._init!=
"1"}});a.VideoViewEventCallback=function(){};a.VideoViewEventCallback.prototype=new a.EventCallback;a.VideoViewEventCallback.prototype.constructor=a.VideoViewEventCallback;a.Util.mixin(a.VideoViewEventCallback.prototype,{});a.EventDispatcher=function(){this._listeners={}};a.EventDispatcher.prototype={addEventListener:function(b,c){if(typeof this._listeners[b]=="undefined")this._listeners[b]=[];this._listeners[b].push(c)},dispatchEvent:function(b){if(typeof b=="string")b={type:b};if(!b.target)b.target=
this;if(b.type)if(this._listeners[b.type]instanceof Array)for(var c=this._listeners[b.type],d=0,e=c.length;d<e;d++)try{c[d]&&c[d].call(this,b)}catch(f){a.warn("EventDispatcher.dispatchEvent",b.type,f)}},removeEventListener:function(b,c){if(this._listeners[b]instanceof Array){var d=this._listeners[b];if(c==null)this._listeners[b]=[];else{b=0;for(var e=d.length;b<e;b++)if(d[b]===c){d.splice(b,1);break}}}}};a.EventDispatcher.prototype.constructor=a.EventDispatcher;a.Hash=function(){this._keys=[];this._dictionary=
{}};a.Hash.prototype={};a.Hash.prototype.constructor=a.Hash;a.Util.mixin(a.Hash.prototype,{setKeyValue:function(b,c,d){if(b){this._dictionary.hasOwnProperty(b)||(d===0?this._keys.unshift(b):this._keys.push(b));this._dictionary[b]=c}},move:function(b){for(var c=0;c<this._keys.length;c++){var d=this._keys[c];if(d==b){this._keys.splice(c,1);this._keys.push(d);return}}},getValue:function(b){return this._dictionary[b]}});a.NullAdRenderer=function(){};a.NullAdRenderer.prototype={start:function(b){b.setCapability(a.EVENT_AD_CLICK,
a.CAPABILITY_STATUS_OFF);b.processEvent({name:a.RENDERER_STATE_STARTED});b.processEvent({name:a.RENDERER_STATE_COMPLETING});b.processEvent({name:a.RENDERER_STATE_COMPLETED})},info:function(){return{moduleType:a.MODULE_TYPE_RENDERER}}};a.NullAdRenderer.prototype.constructor=a.NullAdRenderer;a.OverlayAdRenderer=function(){};a.OverlayAdRenderer.prototype={start:function(b){if(a.Util.PLATFORM_IS_IPHONE_IPOD||a.Util.PLATFORM_ANDROID_VERSION>0&&a.Util.PLATFORM_ANDROID_VERSION<3.1)b.processEvent({name:a.RENDERER_STATE_FAILED,
info:{errorModule:"OverlayAdRenderer",errorCode:a.ERROR_DEVICE_LIMIT,errorInfo:"overlay"}});else{a.log("OverlayAdRenderer.start");var c=b.getAdInstance();this._isImageAsset(c.getPrimaryCreativeRendition().getPrimaryCreativeRenditionAsset())||b.setCapability(a.EVENT_AD_CLICK,a.CAPABILITY_STATUS_OFF);this._render(b,c);b.processEvent({name:a.RENDERER_STATE_STARTED})}},_render:function(b,c){a.debug("OverlayAdRenderer._render");var d=c.getSlot(),e=d.getBase(),f=c.getPrimaryCreativeRendition(),g=f.getPrimaryCreativeRenditionAsset();
this._videoBaseWidth=d.getVideoDisplaySize().width;this._videoBaseHeight=d.getVideoDisplaySize().height;this._renditionWidth=f.getWidth();var h=function(){a.log("OverlayAdRenderer.complete");if(k==a.TIME_POSITION_CLASS_PREROLL||k==a.TIME_POSITION_CLASS_POSTROLL)m.controls=l;var o=document.getElementById("fw_ad_container_div");if(o){b.processEvent({name:a.RENDERER_STATE_COMPLETING});o.parentNode.removeChild(o);b.processEvent({name:a.RENDERER_STATE_COMPLETED})}},k=d.getTimePositionClass();d=b.getParameter("renderer.overlay.mode")||
this._layoutMode(k);a.log("OverlayAdRenderer mode:",d);if(d=="overlay"){if(this._renditionWidth<=0||this._renditionWidth>this._videoBaseWidth)this._renditionWidth=this._videoBaseWidth;this._renditionHeight=f.getHeight();if(this._renditionHeight<=0)this._renditionHeight=0.25*this._videoBaseHeight;else if(this._renditionHeight>this._videoBaseHeight)this._renditionHeight=this._videoBaseHeight;d=document.createElement("div");d.id="fw_ad_container_div";e.appendChild(d);e.style.position="relative";this._layoutOverlayNode(b,
d,e,f);this._injectAd(d,g,c);setTimeout(h,1E3*f.getDuration())}else{if(k==a.TIME_POSITION_CLASS_PREROLL||k==a.TIME_POSITION_CLASS_POSTROLL){var m=e._fw_contentVideo,l=m.controls;m.controls=false}this._videoBaseWidth=b.getParameter("renderer.overlay.baseWidth")||this._videoBaseWidth;this._videoBaseHeight=b.getParameter("renderer.overlay.baseHeight")||this._videoBaseHeight;this._renditionWidth=f.getWidth();if(this._renditionWidth<=0||this._renditionWidth>this._videoBaseWidth)this._renditionWidth=this._videoBaseWidth;
this._renditionHeight=f.getHeight();if(this._renditionHeight<=0||this._renditionHeight>this._videoBaseHeight)this._renditionHeight=this._videoBaseHeight;e.style.position="relative";e=this._createBaseDiv(b,e);this._injectAd(this._createDisplayDiv(b,e),g,c);if((b.getParameter("renderer.overlay.supportDuration")||"true")=="true")setTimeout(h,1E3*f.getDuration());else{c=b.getParameter("renderer.overlay.closeCallback")||"closeFWAd";window[c]=h}}},_createBaseDiv:function(b,c){var d=document.createElement("div");
d.id="fw_ad_container_div";c.appendChild(d);c=b.getAdInstance().getSlot();var e=c.getTimePositionClass()==a.TIME_POSITION_CLASS_MIDROLL,f=c.getVideoDisplaySize();c=b.getParameter("renderer.overlay.zIndex")||"100000";var g=b.getParameter("renderer.overlay.baseX")||(e?f.left:"0px"),h=b.getParameter("renderer.overlay.baseY")||(e?f.top:"0px");e=e?f.position:"absolute";if(f=b.getParameter("renderer.overlay.backgroundColor")||"0x000000")f=f.toLowerCase().split("0x").join("#");a.debug(f,b.getParameter("renderer.overlay.backgroundColor"));
d.style.position=e;d.style.overflow="hidden";d.style.zIndex=c;d.style.left=g;d.style.top=h;d.style.width=this._videoBaseWidth;d.style.height=this._videoBaseHeight;d.style.backgroundColor=f;return d},_createDisplayDiv:function(b,c){var d=document.createElement("div");c.appendChild(d);a.debug(c.style.pixelWidth,this._renditionWidth,c.style.pixelHeight,this._renditionHeight);c=b.getParameter("renderer.overlay.adMarginLeft")||0.5*(this._videoBaseWidth-this._renditionWidth);b=b.getParameter("renderer.overlay.adMarginTop")||
0.5*(this._videoBaseHeight-this._renditionHeight);d.style.position="absolute";d.style.overflow="hidden";d.style.width=this._renditionWidth;d.style.height=this._renditionHeight;d.style.left=c;d.style.top=b;return d},_injectAd:function(b,c,d){var e=true,f=c.getUrl();if(a.Util.isBlank(f)){e=false;f=c.getContent()}else if(this._isImageAsset(c))if((c=d.getEventCallbackUrls("defaultClick",a.EVENT_TYPE_CLICK))&&c.length>0){e=false;f='<a href="'+c[0]+'" target="_blank" style="border:none 0"><img alt="" src="'+
f+'"/></a>'}if(e){e=document.createElement("iframe");e.frameBorder=0;e.scrolling="no";e.src=f;e.width=this._renditionWidth;e.height=this._renditionHeight;b.appendChild(e)}else a.Util.buildNode(b,f)},_isImageAsset:function(b){if(b&&!a.Util.isBlank(b.getUrl())&&b.getMimeType().match(/image\//))return true;return false},info:function(){return{moduleType:a.MODULE_TYPE_RENDERER}},_layoutMode:function(b){a.debug("OverlayAdRenderer._layoutMode",b);return b==a.TIME_POSITION_CLASS_OVERLAY?"overlay":"div"},
_layoutOverlayNode:function(b,c){c.style.width=this._renditionWidth;c.style.height=this._renditionHeight;c.style.position="absolute";c.style.overflow="hidden";var d=b.getParameter("renderer.overlay.zIndex")||"100000";c.style.zIndex=d;b=b.getParameter("renderer.overlay.primaryAnchor")||"bc";if(b=="tl")c.style.left=c.style.top=0;else if(b=="tr")c.style.right=c.style.top=0;else if(b=="bl")c.style.left=c.style.bottom=0;else if(b=="br")c.style.right=c.style.bottom=0;else if(b=="tc"){c.style.left=(this._videoBaseWidth-
this._renditionWidth)*0.5;c.style.top=0}else if(b=="lm"){c.style.top=(this._videoBaseHeight-this._renditionHeight)*0.5;c.style.left=0}else if(b=="rm"){c.style.top=(this._videoBaseHeight-this._renditionHeight)*0.5;c.style.right=0}else{c.style.left=(this._videoBaseWidth-this._renditionWidth)*0.5;c.style.bottom=0}}};a.OverlayAdRenderer.prototype.constructor=a.OverlayAdRenderer;a.PageSlotScanner=function(){this._knownSlots=[];this._slots={};this._candidateAds=[]};a.PageSlotScanner.prototype={isSlotDuplicate:function(b){for(var c=
0;c<this._knownSlots.length;++c)if(this._knownSlots[c].id==b)return true;return false},findPageSlotByScope:function(b){var c=b.document,d,e=/(^|\s)_fwph(\s|$)/,f=c.getElementsByTagName("span");if(!b._fw_admanager)b._fw_admanager={};b._fw_admanager.pageScanState=true;for(b=0;b<f.length;++b){var g;d=f[b];if(e.test(d.className)){d=d.getAttribute("id");if((g=c.getElementById("_fw_input_"+d))&&!this.isSlotDuplicate(d))if(g=g.getAttribute("value")){if(g.charAt(g.length-1)!=";")g+=";";g=g.split(";");var h=
g[g.length-2];g=false;if(h.search("lo=i")!=-1)g=true;var k=false;if(h.search("prct=")!=-1)k=true;if(h.search("flag=")<0)h+="&flag=";if(h.search("ptgt=")<0)h="ptgt=s&"+h;var m=[];h=h.split("&");for(var l,o,j,p=0;p<h.length;++p){l=h[p].split("=");if(l.length==2){l[1]=decodeURIComponent(l[1]);if(l[0]=="ssct")if(k)continue;else{k=true;l[0]="prct"}if(l[0]=="flag"){if(l[1].search(/[-\+]cmpn/)==-1)l[1]+="+cmpn";if(l[1].charAt(0)!="+"&&l[1].charAt(0)!="-")l[1]="+"+l[1];if(g&&l[1].search("-init")==-1)l[1]+=
"-init";if(l[1].search("-nrpl")!=-1)l[1]=l[1].replace("-nrpl","+cmpn")}else if(l[0]=="w")o=Number(l[1]);else if(l[0]=="h")j=Number(l[1]);else l[0]=="cana"&&this._addCandidateAds(l[1]);l=encodeURIComponent(l[0])+"="+encodeURIComponent(l[1]);m.push(l)}}k||m.push("prct="+encodeURIComponent("text/html_lit_js_wc_nw"));this._slots[d]=m.join("&")+";";this._knownSlots.push({id:d,width:o,height:j})}}}},scanPageSlots:function(){for(var b=0;b<window.frames.length;++b)try{a.debug("scanPageSlots in frame",b);
this.findPageSlotByScope(window.frames[b])}catch(c){}try{if(window.parent&&window.parent!=window){a.debug("scanPageSlots in parent frame");this.findPageSlotByScope(window.parent)}}catch(d){}try{a.debug("scanPageSlots in current window");this.findPageSlotByScope(window)}catch(e){}},slotsToTypeBStr:function(){var b="";for(slotId in this._slots)if(!Object[slotId]){var c=this._slots[slotId];if(c.search("slid=")==-1)c="slid="+encodeURIComponent(slotId)+"&"+c;b+=c;if(b.charAt(b.length-1)!=";")b+=";"}if(b)b=
b.substring(0,b.length-1);return b},_addCandidateAds:function(b){b=b.split(",");for(var c=0;c<b.length;c++){var d=parseInt(b[c]);d>0&&this._candidateAds.push(d)}}};a.PageSlotScanner.prototype.constructor=a.PageSlotScanner;a.RendererController=function(b,c){this._context=b;this._adInstance=c;this._renderer=null;this._rendererState=a.RendererInitState.instance};a.RendererController.prototype={};a.RendererController.prototype.constructor=a.RendererController;a.Util.mixin(a.RendererController.prototype,
{getAdInstance:function(){return this._adInstance},getContext:function(){return this._context},processEvent:function(b){var c=b.name;if(c==a.RENDERER_STATE_STARTED)this._rendererState.notifyStarted(this);else if(c==a.RENDERER_STATE_COMPLETING)this._rendererState.complete(this);else if(c==a.RENDERER_STATE_COMPLETED)this._rendererState.notifyCompleted(this);else if(c==a.RENDERER_STATE_FAILED){this._adInstance.getSlot()._scheduledAdInstance=null;this._adInstance.getEventCallback(a.EVENT_ERROR,a.EVENT_TYPE_ERROR).process(b.info);
this._rendererState.fail(this)}else{var d=this._inferEventType(c);if(d){if(d==a.EVENT_TYPE_CLICK&&b.info&&b.info[a.INFO_KEY_CUSTOM_EVENT_NAME])c=b.info[a.INFO_KEY_CUSTOM_EVENT_NAME];(c=this._adInstance.getEventCallback(c,d))&&c.process(b.info)}}},setCapability:function(b,c){this._adInstance.setMetr(b,c)},getVersion:function(){return this._context._adManager.getVersion()},getParameter:function(b){if(!b)return null;if(this._context._overrideLevelParameterDictionary.hasOwnProperty(b))return this._context._overrideLevelParameterDictionary[b];
if(this._adInstance._primaryCreativeRendition&&this._adInstance._primaryCreativeRendition._parameters.hasOwnProperty(b))return this._adInstance._primaryCreativeRendition._parameters[b];var c=this._context._adResponse.getCreative(this._adInstance._adId,this._adInstance._creativeId);if(c&&c._parameters.hasOwnProperty(b))return c._parameters[b];if(this._adInstance.getSlot()._parameters.hasOwnProperty(b))return this._adInstance.getSlot()._parameters[b];if(this._context._adResponse._profileParameters.hasOwnProperty(b))return this._context._adResponse._profileParameters[b];
if(this._context._globalLevelParameterDictionary.hasOwnProperty(b))return this._context._globalLevelParameterDictionary[b];return null},scheduleAdInstances:function(b){b=b||[];var c=[];if(b.length===0)return c;var d=b[0],e=d._currentAdInstance;d=d.scheduleAdInstance();c.push(d);var f=0;for(e=e._companionAdInstances;f<e.length;f++)for(var g=e[f],h=1;h<b.length;h++)if(b[h]==g._slot){g=g.schedule();d._companionAdInstances.push(g);c.push(g);break}return c},playable:function(){return this._rendererState==
a.RendererInitState.instance},reset:function(){this._rendererState=a.RendererInitState.instance},play:function(){var b=a.Util.getObject(this._matchRendererClassName(this._adInstance._primaryCreativeRendition));if(b)this._renderer=new b;this._renderer?this._rendererState.start(this):this.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorCode:a.ERROR_NO_RENDERER}})},dispatchEvent:function(b,c){this._context.dispatchEvent(b,c)},_matchRendererClassName:function(b){var c=b.getContentType();b=b.getWrapperType();
if(a.Util.isBlank(c)&&a.Util.isBlank(b))return null;var d=this._context._rendererManifest["*"];d||(d=this._context._rendererManifest[b]);d||(d=this._context._rendererManifest[c]);if(d)return d;b=this._adInstance.getSlot();d=b.getType();if(c=="null/null")return t+".NullAdRenderer";else if(d==a.SLOT_TYPE_SITESECTION_NONTEMPORAL||d==a.SLOT_TYPE_VIDEOPLAYER_NONTEMPORAL)return t+".DisplayAdRenderer";else if(d==a.SLOT_TYPE_TEMPORAL)return b.getTimePositionClass()==a.TIME_POSITION_CLASS_OVERLAY?t+".OverlayAdRenderer":
c.indexOf("text/html")==0||c.indexOf("image/")==0?t+".OverlayAdRenderer":t+".VideoAdRenderer";return null},_inferEventType:function(b){if(b==a.EVENT_ERROR)return a.EVENT_TYPE_ERROR;else if(b==a.EVENT_AD_CLICK)return a.EVENT_TYPE_CLICK;else if(b==a.EVENT_AD_IMPRESSION||b==a.EVENT_AD_FIRST_QUARTILE||b==a.EVENT_AD_MIDPOINT||b==a.EVENT_AD_THIRD_QUARTILE||b==a.EVENT_AD_COMPLETE||b==a.EVENT_RESELLER_NO_AD)return a.EVENT_TYPE_IMPRESSION;else if(b==a.EVENT_AD_PAUSE||b==a.EVENT_AD_RESUME||b==a.EVENT_AD_REWIND||
b==a.EVENT_AD_MUTE||b==a.EVENT_AD_UNMUTE||b==a.EVENT_AD_COLLAPSE||b==a.EVENT_AD_EXPAND||b==a.EVENT_AD_MINIMIZE||b==a.EVENT_AD_CLOSE||b==a.EVENT_AD_ACCEPT_INVITATION)return a.EVENT_TYPE_STANDARD;return null}});a.RenditionSelector=function(b,c,d,e){this._targetByterate=b;this._arWeight=c;this._pxWeight=d;this._conversionFactor=e};a.RenditionSelector.prototype={getBestFitRendition:function(b,c,d){b=this.filterRenditionsByBitrate(b,this._targetByterate);if(b.length>0){for(var e=b[0],f=1;f<b.length;++f){var g=
this.compareVisualMetrics(e,b[f],c,d);if(g)e=g}return e}return null},filterRenditionsByBitrate:function(b,c){for(var d=[],e,f=0;f<b.length;++f)if(this.validateCreativeRendition(b[f]))if(this.getBitrate(b[f])<=c)d.push(b[f]);else if(!e||this.getBitrate(b[f])<this.getBitrate(e))e=b[f];d.length===0&&e&&d.push(e);var g=this;d.sort(function(h,k){h=g.getBitrate(h);k=g.getBitrate(k);return h>k?-1:h<k?1:0});return d},compareVisualMetrics:function(b,c,d,e){var f=this.calculateVisualRatios(b._width,b._height,
d,e);e=this.calculateVisualRatios(c._width,c._height,d,e);if(!f&&e)return c;if(f&&!e)return b;if(!f&&!e)return null;d=this._conversionFactor*this._arWeight*Math.log(f.arRatio);var g=this._pxWeight*Math.log(f.pixelation);f=this._conversionFactor*this._arWeight*Math.log(e.arRatio);e=this._pxWeight*Math.log(e.pixelation);d=this.findDistance(d,g,0,0);f=this.findDistance(f,e,0,0);if(d==f)return null;return d<f?b:c},calculateVisualRatios:function(b,c,d,e){if(b>0&&c>0&&d>0&&e>0){var f=b/c,g=d/e;b=b*c;if(f>
g){d=d;e=d/f}else{e=e;d=e*f}return{arRatio:f/g,pixelation:b/(d*e)}}return null},findDistance:function(b,c,d,e){return isNaN(b)||isNaN(d)||isNaN(c)||isNaN(e)?NaN:Math.sqrt(Math.pow(d-b,2)+Math.pow(e-c,2))},validateCreativeRendition:function(b){if(!b)return false;b=b._primaryCreativeRenditionAsset;if(!b)return false;if(a.Util.isBlank(b._url)&&a.Util.isBlank(b._content))return false;return true},validateProtocol:function(b){for(var c=["http","https","rtmp"],d=0;d<c.length;++d)if(b.toLowerCase().indexOf(c[d]+
"://")===0)return true;return false},getBitrate:function(b){var c=b.getDuration();return(b=b._primaryCreativeRenditionAsset._bytes)&&c&&!isNaN(b)&&!isNaN(c)&&b>0&&c>0?b*8/1E3/c:-1}};a.RenditionSelector.prototype.constructor=a.RenditionSelector;a.Slot=function(b){this._context=b;this._customId="";this._scheduledAdInstance=this._currentAdInstance=this._slotProfile=this._type=null;this._adInstances=[];this._eventCallbacks=[];this._parameters={};this._onSlotEnded=this._last=this._init=null;this._state=
a.MediaInitState.instance};a.Slot.prototype={};a.Slot.prototype.constructor=a.Slot;a.Util.mixin(a.Slot.prototype,{setParameter:function(b,c){if(c===null)delete this._parameters[b];else this._parameters[b]=c},getCustomId:function(){return this._customId},getType:function(){return this._type},getTimePosition:function(){return this._timePosition},getTimePositionClass:function(){return this._timePositionClass?this._timePositionClass.toUpperCase():null},getWidth:function(){return this._width},getHeight:function(){return this._height},
getBase:function(){return this._base},getVideoDisplaySize:function(){return this._context.getVideoDisplaySize()},dispose:function(){this._onTimeUpdate&&this._contentVideo.removeEventListener("timeupdate",this._onTimeUpdate,false)},parse:function(b){if(b){this._customId=b.customId;this._timePosition=b.timePosition*1;this._timePositionClass=b.timePositionClass;this._adUnit=b.adUnit;for(var c=0,d=b.eventCallbacks||[];c<d.length;c++){var e=d[c],f=a.EventCallback.newEventCallback(this._context,e.name,
e.type);if(f){f._slot=this;f.parse(e);this._eventCallbacks.push(f)}}c=0;for(d=b.selectedAds||[];c<d.length;c++){e=d[c];b=new a.AdInstance(this._context);b._slot=this;b.parse(e);this._adInstances.push(b)}}},copy:function(){var b=new a.Slot;b._context=this._context;b._type=this._type;b._width=this._width;b._height=this._height;b._customId=this._customId;b._adUnit=this._adUnit;b._slotProfile=this._slotProfile;b._timePositionClass=this._timePositionClass;b._acceptPrimaryContentType=this._acceptPrimaryContentType;
b._acceptContentType=this._acceptContentType;return b},getCurrentAdInstance:function(){return this._currentAdInstance},schduleAdInstance:function(){return this._scheduledAdInstance=this._currentAdInstance.schedule()},play:function(b){a.log("Slot.play",this.getTimePositionClass());this.getTimePositionClass()==a.TIME_POSITION_CLASS_PREROLL?this._context._fillVideoPool(this.getTimePositionClass(),a.Util.bind(this,this._play,b)):this._play(b)},_play:function(b){this._onSlotEnded=this._onSlotEnded||b;
this._state.play(this)},onStartPlaying:function(){this._init="1";this._onStartPlaying()},onStartReplaying:function(){this._init="2";this._onStartPlaying()},onCompletePlaying:function(){this._onCompletePlaying()},onCompleteReplaying:function(){this._onCompletePlaying()},playNextAdInstance:function(){this._playNextAdInstance()||this._state.complete(this)},scheduleAdInstance:function(){return this._scheduledAdInstance=this._currentAdInstance.schedule()},_onStartPlaying:function(){if(this._type==a.SLOT_TYPE_TEMPORAL){var b=
a.EventCallback.getEventCallback(this._eventCallbacks,a.EVENT_SLOT_IMPRESSION,a.EVENT_TYPE_IMPRESSION);b&&b.process()}for(b=0;b<this._adInstances.length;b++)this._adInstances[b].reset();this.getTimePositionClass()==a.TIME_POSITION_CLASS_MIDROLL&&this._adInstances.length>0&&this._context.dispatchEvent(a.EVENT_CONTENT_VIDEO_PAUSE_REQUEST,{slot:this});this._context.dispatchEvent(a.EVENT_SLOT_STARTED,{slot:this});this.playNextAdInstance()},_onCompletePlaying:function(){if(this.getTimePositionClass()==
a.TIME_POSITION_CLASS_PREROLL||this.getTimePositionClass()==a.TIME_POSITION_CLASS_POSTROLL){if(this._contentVideoAttached){this._context.dispatchEvent(a.EVENT_CONTENT_VIDEO_DETACH,{slot:this});this._contentVideoAttached=false}}else this.getTimePositionClass()==a.TIME_POSITION_CLASS_MIDROLL&&this._adInstances.length>0&&this._context.dispatchEvent(a.EVENT_CONTENT_VIDEO_RESUME_REQUEST,{slot:this});var b=this._onSlotEnded;this._onSlotEnded=null;b&&b();this._context.dispatchEvent(a.EVENT_SLOT_ENDED,{slot:this})},
_playNextAdInstance:function(){if(this._state!=a.MediaPlayingState.instance&&this._state!=a.MediaReplayingState.instance)return false;this._commitScheduledAdInstance();this._currentAdInstance=this._nextPlayableAdInstance();if(!this._currentAdInstance)return false;if(this.getTimePositionClass()==a.TIME_POSITION_CLASS_PREROLL||this.getTimePositionClass()==a.TIME_POSITION_CLASS_POSTROLL){var b=this._currentAdInstance._rendererController._matchRendererClassName(this._currentAdInstance._primaryCreativeRendition);
if(!this._contentVideoAttached&&b==t+".VideoAdRenderer"){this._context.dispatchEvent(a.EVENT_CONTENT_VIDEO_ATTACH,{slot:this});this._contentVideoAttached=true}}this._currentAdInstance._rendererController.play();return true},_commitScheduledAdInstance:function(){if(this._scheduledAdInstance)for(var b=0;b<this._adInstances.length;b++)if(this._adInstances[b]==this._currentAdInstance){this._adInstances.splice(b,1,this._scheduledAdInstance);this._scheduledAdInstance=null}},_nextPlayableAdInstance:function(){for(var b=
0;b<this._adInstances.length;b++)if(this._adInstances[b]._rendererController.playable())return this._adInstances[b];return null},toString:function(){return"[Slot "+this._customId+"]"}});a.Timer=function(){this._lastTickDate=new Date};a.Timer.prototype={};a.Timer.prototype.constructor=a.Timer;a.Util.mixin(a.Timer.prototype,{tick:function(){var b=new Date,c=Math.round((b.getTime()-this._lastTickDate.getTime())/1E3);this._lastTickDate=b;return c},pause:function(){},resume:function(){}});a.Url=function(b){this._session=
this._base="";this._parameters=new a.Hash;this.setString(b)};a.Url.prototype={};a.Url.prototype.constructor=a.Url;a.Util.mixin(a.Url.prototype,{setString:function(b){if(!(this._string==b||!b)){this._string=b;b=b.split("?");this._base=b[0];this._parameters=new a.Hash;if(b[1]){var c=b[1].indexOf(";");if(c>0&&b[1].indexOf("session=")===0){this._session=b[1].substring(0,c+1);b=b[1].substring(c+1)}else b=b[1];b=b.split("&");for(var d=0;d<b.length;d++){var e=b[d];c=e.indexOf("=");if(!(c<0)){var f=decodeURIComponent(e.substring(0,
c));c=decodeURIComponent(e.substring(c+1));this._parameters.setKeyValue(f,c)}}}}},setParameter:function(b,c){this._parameters.setKeyValue(b,c,0);this._string=null},getParameter:function(b){return this._parameters.getValue(b)},toString:function(){if(this._string)return this._string;this._parameters.move("cr",-1);for(var b=this._parameters._keys,c=[],d=0;d<b.length;d++){var e=b[d],f=this._parameters.getValue(e);c.push(encodeURIComponent(e)+"="+encodeURIComponent(f))}return this._string=this._base+"?"+
this._session+c.join("&")}});a.VideoAdRenderer=function(){};a.VideoAdRenderer.prototype={start:function(b){var c=b.getAdInstance(),d=c.getSlot();if(a.Util.PLATFORM_ANDROID_VERSION>0){if(a.Util.PLATFORM_ANDROID_VERSION<2.2||d.getTimePositionClass()==a.TIME_POSITION_CLASS_MIDROLL&&a.Util.PLATFORM_ANDROID_VERSION<3.1){b.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorModule:"VideoAdRenderer",errorCode:a.ERROR_DEVICE_LIMIT,errorInfo:d.getTimePositionClass()}});return}}else if(a.Util.PLATFORM_IOS_VERSION>
0&&a.Util.PLATFORM_IOS_VERSION<3.2&&d.getTimePositionClass()==a.TIME_POSITION_CLASS_MIDROLL){b.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorModule:"VideoAdRenderer",errorCode:a.ERROR_DEVICE_LIMIT,errorInfo:"midroll"}});return}a.log("VideoAdRenderer.start");var e=d.getBase()._fw_contentVideo;if(d.getTimePositionClass()==a.TIME_POSITION_CLASS_MIDROLL&&a.Util.PLATFORM_IOS_VERSION>=4.2&&a.Util.PLATFORM_IS_IPAD&&e.webkitDisplayingFullscreen)b.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorModule:"VideoAdRenderer",
errorInfo:"main video full screen"}});else{var f=d.getVideoDisplaySize().width,g=d.getVideoDisplaySize().height,h=c.getAllCreativeRenditions();h=(new a.RenditionSelector(1E3,1,1,0.2)).getBestFitRendition(h,f,g);c.setPrimaryCreativeRendition(h);var k=h?h.getPrimaryCreativeRenditionAsset():null;if(!k||!k.getUrl())b.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorModule:"VideoAdRenderer",errorCode:a.ERROR_NULL_ASSET}});else{b.setCapability(a.EVENT_AD_QUARTILE,a.CAPABILITY_STATUS_ON);var m=!a.Util.PLATFORM_IS_IPHONE_IPOD&&
!(a.Util.PLATFORM_IOS_VERSION==3.2&&d.getTimePositionClass()==a.TIME_POSITION_CLASS_MIDROLL);m||b.setCapability(a.EVENT_AD_CLICK,a.CAPABILITY_STATUS_OFF);var l=a.Util.PLATFORM_IS_MOBILE?"touchend":"click",o=d.getTimePositionClass()==a.TIME_POSITION_CLASS_PREROLL||d.getTimePositionClass()==a.TIME_POSITION_CLASS_POSTROLL||b.getParameter(a.PARAMETER_PLAY_MIDROLL_BY_CURRENT_VIDEO_ELEMENT)==true&&a.Util.PLATFORM_IS_IPAD,j;if(o){a.debug("VideoAdRenderer","use content video element");a.debug(d.getTimePositionClass(),
"PARAMETER_PLAY_MIDROLL_BY_CURRENT_VIDEO_ELEMENT:",b.getParameter(a.PARAMETER_PLAY_MIDROLL_BY_CURRENT_VIDEO_ELEMENT));j=e;j.controls=false}else{j=a._videoPool&&a._videoPool[0]||document.createElement("video");j.width=f;j.height=g;j.style.position=d.getVideoDisplaySize().position;j.style.left=d.getVideoDisplaySize().left;j.style.top=d.getVideoDisplaySize().top;j.style.background="black";j.controls=false;if(a.Util.PLATFORM_IOS_VERSION>=4.2)j.style.display="";else e.parentNode.appendChild(j)}var p=this,
s=null,v=null,w=null,I=function(n){a.debug("VideoAdRenderer.checkTimeUpdate timeout");B(n)},y=function(){if(v){clearTimeout(v);v=null}},C=function(n){if(j.paused&&a.Util.PLATFORM_ANDROID_VERSION>=3.1)j.play();else if(!b.getParameter(a.PARAMETER_EXTENSION_AD_CONTROL_CLICK_ELEMENT)){a.debug("Ad video event "+n.type);b.processEvent({name:a.EVENT_AD_CLICK})}},D=function(n){a.debug("Ad video event "+n.type);j.controls=true;y()},E=function(n){a.debug("Ad video event "+n.type);j.controls=false},F=false,
G=function(){y();if(!j.paused){var n=b.getParameter(a.PARAMETER_RENDERER_VIDEO_PROGRESS_DETECT_TIMEOUT)||8E3;v=setTimeout(I,n,n+"ms timeout when playing")}if(!F){F=true;if(s){clearTimeout(s);s=null}p._quartileTimerId=setInterval(function(){var r=j.currentTime,x=j.duration;if(!(typeof r!=="number"||typeof x!=="number"||w)){r>=x*0.25&&b.processEvent({name:a.EVENT_AD_FIRST_QUARTILE});r>=x*0.5&&b.processEvent({name:a.EVENT_AD_MIDPOINT});if(r>=x*0.75){clearInterval(p._quartileTimerId);p._quartileTimerId=
null;b.processEvent({name:a.EVENT_AD_THIRD_QUARTILE})}}},1E3);b.processEvent({name:a.RENDERER_STATE_STARTED})}},u=function(n){var r=w;n&&n.type&&a.debug("Ad video event "+n.type);y();if(s){clearTimeout(s);s=null}m&&j.removeEventListener(l,C,false);j.removeEventListener("ended",u,false);j.removeEventListener("error",u,true);j.removeEventListener("pause",D,false);j.removeEventListener("playing",E,false);j.removeEventListener("timeupdate",G,false);if(!j.paused){a.debug("try pausing video before complete");
j.pause()}if(j.error)r="error:"+j.error+",code:"+j.error.code;n=function(){a.log("VideoAdRenderer.complete");delete j._fw_videoAdPlaying;if(p._quartileTimerId){clearInterval(p._quartileTimerId);p._quartileTimerId=null}if(r)b.processEvent({name:a.RENDERER_STATE_FAILED,info:{errorModule:"VideoAdRenderer",errorInfo:r}});else{b.processEvent({name:a.EVENT_AD_FIRST_QUARTILE});b.processEvent({name:a.EVENT_AD_MIDPOINT});b.processEvent({name:a.EVENT_AD_THIRD_QUARTILE});b.processEvent({name:a.EVENT_AD_COMPLETE});
b.processEvent({name:a.RENDERER_STATE_COMPLETED})}};b.processEvent({name:a.RENDERER_STATE_COMPLETING});if(o)n();else{if(a.Util.PLATFORM_IOS_VERSION>=4.2){a.debug("try empty ad video from videoPool");j.src="http://127.0.0.1:1/404.mp4";j.load();j.style.display="none"}else j.parentNode.removeChild(j);setTimeout(n,100)}},B=function(n){w=n;a.warn(w);a.Util.PLATFORM_ANDROID_VERSION>0&&a.Util.PLATFORM_ANDROID_VERSION<3.1||u()};if(o)j._fw_videoAdPlaying=true;var H=false,z=function(){if(!H){H=true;m&&j.addEventListener(l,
C,false);j.addEventListener("ended",u,false);j.addEventListener("error",u,true);j.addEventListener("pause",D,false);j.addEventListener("playing",E,false);j.addEventListener("timeupdate",G,false);j.src=k.getUrl();a.log("VideoAdRenderer play video ad "+j.src);j.load();if(j._fw_fromVideoPool||a.Util.PLATFORM_IOS_VERSION===0||a.Util.PLATFORM_IOS_VERSION>=3.2&&a.Util.PLATFORM_IOS_VERSION<4.2){var n=b.getParameter(a.PARAMETER_RENDERER_VIDEO_START_DETECT_TIMEOUT)||5E3;s=setTimeout(B,n,n+"ms timeout before playing")}if(a.Util.PLATFORM_ANDROID_VERSION>
0){n=b.getParameter(a.PARAMETER_RENDERER_VIDEO_ANDROID_DELAY)||100;setTimeout(function(){j.play()},n)}else a.Util.PLATFORM_IS_IPHONE_IPOD&&a.Util.PLATFORM_IOS_VERSION<3.2?j.play():setTimeout(function(){j.play()},100)}};if(!a.VideoAdRenderer._fw_playedDummyVideo&&d.getTimePositionClass()==a.TIME_POSITION_CLASS_PREROLL&&a.Util.PLATFORM_IOS_VERSION<4.2&&a.Util.PLATFORM_IOS_VERSION>=3.2){a.VideoAdRenderer._fw_playedDummyVideo=true;a.debug("play dummy video for iOS 3.2-4.1");j.src="http://127.0.0.1:1/404.mp4";
j.load();j.play();j._fw_videoAdPlaying=true;j.addEventListener("error",function(){event.target.removeEventListener("error",arguments.callee,true);z()},true);setTimeout(z,a.Util.PLATFORM_IOS_VERSION<4?500:5E3)}else z()}}},info:function(){return{moduleType:a.MODULE_TYPE_RENDERER}}};a.VideoAdRenderer.prototype.constructor=a.VideoAdRenderer;return a};if(!q.tv.freewheel.SDK)q.tv.freewheel.SDK=q.tv.freewheel[A]("tv.freewheel.SDK");return q})();

