if(tmObj==undefined){var tmObj=function(){var win=window;var doc=document;var nav=navigator;var programCount=0;var players=new Array();var programs={};var started=false;var queue=new Array();var ua=function(){var w3cdom=typeof doc.getElementById!=undefined&&typeof doc.getElementsByTagName!=undefined&&typeof doc.createElement!=undefined;var p=nav.platform.toLowerCase();var ie=false,windows=p?/win/.test(p):/win/.test(u),mac=p?/mac/.test(p):/mac/.test(u);/*@cc_on ie=true;@if(@_win32)windows=true;@elif(@_mac)mac=true;@end @*/return{w3cdom:w3cdom,ie:ie,win:windows,mac:mac};}();var onDomLoad=function(){if(!ua.w3cdom){construct();}
if(ua.ie&&ua.win){try{doc.write("<scr"+"ipt id=__ie_ondomload defer=true src=//:></scr"+"ipt>");script=document.getElementById("__ie_ondomload");script.onreadystatechange=function(){if(this.readyState=="complete"){try{if(parent.document.readyState!="complete"){parent.document.onreadystatechange=function(){if(parent.document.readyState=="complete"){construct();}}}else{construct();}}catch(e){construct();}}}}
catch(e){}}else if(typeof doc.addEventListener!=undefined){doc.addEventListener("DOMContentLoaded",construct,null);}}();function construct(){started=true;for(var i=0;i<queue.length;i++){programs[queue[i].instance_id].start(queue[i].programid,queue[i].instance_id);}}
function programIndex(instance_id,start){if(instance_id==undefined){instance_id=1;}
if(start&&programs[instance_id]==undefined&&typeof programs[1]=="object"){index=1;}
if(typeof programs[instance_id]!="object"){var options=players[programCount];options.prefix=programCount;programs[instance_id]=new tmPlayer(options);programCount++;}
return instance_id;}
return{set:function(key,value,instance_id){var index=programIndex(instance_id,false);programs[index].set(key,value);},run:function(programid,instance_id){this.start(programid,null,instance_id);},start:function(programid,user_id,instance_id){instance_id=programIndex(instance_id,true);if(started==false){queue.push({instance_id:instance_id,programid:programid});}else{programs[instance_id].start(programid);}},addPlayer:function(config){players.push(config);},getInitialParameters:function(instance_id,format){var index=programIndex(instance_id,true);return programs[index].getInitialParameters(format);},register:function(event,instance_id){var index=programIndex(instance_id,false);return programs[index].register(event);},reloadVideo:function(instance_id){var index=programIndex(instance_id,false);return programs[index].reloadVideo();},resetVideo:function(instance_id){var index=programIndex(instance_id,false);return programs[index].resetVideo();}};function tmPlayer(options){this.template=null;this.options=null;this.wrapper=null;this.started=false;this.prefix='tm';this.customerId=null;this.isIE=false;this.flashEnabled=false;this.handlers=new Array();this.optionMap={'ProgramID':'program_id','ContentType':'content_type','PlayerPath':'path','AdManagerPath':'admanager_lib','ProgramPath':'program_id_prefix_url','AdPolicyUrl':'rule_url','AdPolicyXml':'rule_xml','AutoPlay':'autostart','EndSlateURL':'end_state_url','PreviewImageURL':'preview_image_url','VideoID':'video_id','Channel':'channel','VideoDescriptionURL':'video_description_url','VideoURL':'video_url','CampaignID':'campaignId','AdId':'adId','CreativeID':'creativeId','CountdownTextEnabled':'countdownTextEnabled','CountdownText':'countdownText','VideoTitle':'video_title','ContentPath':'content_path','LogCallback':'log_callback','ctl_fullscreen':'usefullscreen','ctl_timecode':'showdigits','Volume':'volume','logo_path':'logo','CustomerID':'customer_id','Category':'category','Midroll_CuePoint':'midroll_cuepoint','Overlay_CuePoint':'overlay_cuepoint','Description':'description','Keywords':'keywords','ScanScoutAdDesign':'scanscout_ad_design','distributorId':'comScore_distributorId','publisherId':'comScore_publisherId','siteId':'comScore_siteId','brandId':'comScore_brandId','genreId':'comScore_genreId','ContentOwner':'content_owner','segment1':'segment1','segment2':'segment2','segment3':'segment3','BumperFormat':'bumper_format','BumperURL':'bumper_url','BumperDuration':'bumper_duration','BumperPath':'bumper_path','BumperDisplay':'bumper_display','compDivId':'compDivId','EscapeAdRequests':'escapeAdRequests','DisplayErrorMessages':'displayErrorMessages','javascriptEvents':'javascriptEvents','NoContentMsgEnabled':'noContentMsgEnabled','NoContentMsgText':'noContentMsgText','NoAds':'no_ads','Dbg':'debug'};this.objectTag='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="%%WIDTH%%" height="%%HEIGHT%%" id="%%NAME%%"><param name="movie" value="%%SWF%%%%PARAMS%%" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashVars" value="%%FLASHVARS%%" /><!--[if !IE]>--><object type="application/x-shockwave-flash" data="%%SWF%%%%PARAMS%%" width="%%WIDTH%%" height="%%HEIGHT%%" name="%%NAME%%"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashVars" value="%%FLASHVARS%%" /><!--<![endif]--><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><!--[if !IE]>--></object><!--<![endif]--></object>';this.construct=function(options){if(navigator.appName.indexOf("Microsoft")!=-1){this.isIE=true;}
this.options=options;this.template=options.template;if(options.prefix){this.prefix=options.prefix;}
this.clientId=this.readCookie("clientId");if(this.clientId==null){this.writeCookie("clientId",this.generateUuid(),30);this.clientId=this.readCookie("clientId");}
this.options["player"]["client_id"]=this.clientId;this.options["player"]["host"]=window.location.hostname;this.options["player"]["path"]="http://objects.tremormedia.com/embed/swf/acudeoplayer.swf";this.options["player"]["admanager_lib"]="http://objects.tremormedia.com/embed/swf/AdManager.swf";this.options["player"]["program_id_prefix_url"]="http://objects.tremormedia.com/embed/xml/policies/";this.options["player"]["compDivId"]=this.prefix+"comp_ad";if(this.options["template"]["comp_ad"]==undefined){this.options["player"]["compDivId"]=undefined;}
document.writeln("<div id='"+this.prefix+"VideoApplication' style='"+
this.style('relative','wrapper')
+"'></div>");this.wrapper=document.getElementById(this.prefix+"VideoApplication");};this.start=function(programid,instance_id){if(this.options["programid"]==undefined){this.set("ProgramID",programid);}
this.checkFlash();this.set("instance_id",instance_id);for(var elem in this.template){if(elem!='wrapper'){this.createDiv(elem);}}
for(var elem in this.template){if(eval("this."+elem+"Content")){eval("this."+elem+"Content()");}}
this.started=true;};this.set=function(key,value){key=this.trim(key);if(typeof value=="string"){value=this.trim(value);}
if(this.optionMap[key]){this.PlayerSet(key,value);}
if(eval("this."+key+"Set")){this[key+"Set"](value);}else{this.options[key.toLowerCase()]=value;}};this.register=function(event){if(event==undefined||event['type']==undefined||event['callback']==undefined)
return false;this.handlers.push(event);return true;};this.EndSlateSet=function(url){if(this.options["video"]==undefined){this.options["video"]={};}
var wrapper=document.getElementById(this.prefix+'video');var old_element=document.getElementById(this.prefix+"video_element");if(old_element){wrapper.removeChild(old_element);}
if(url!=null&&url!=''&&url!="null"){wrapper.style.zIndex=100;if(url.match(/.swf$/)!=null){this.options["video"]["path"]=url;this.createSwfObject("video");}else{this.options["video"]["url"]=url;this.createIframe("video");}}else{wrapper.style.zIndex=-100;}}
this.ProgrammableAreaURLSet=function(url){if(this.options['prog_area']==undefined){this.options['prog_area']={};}
this.options['prog_area']['url']=url;if(this.started){this.prog_areaContent();}}
this.HideCompAdSet=function(){this.callExternalHandlers("hideCompAd");}
this.CompAdSet=function(ad){if(this.options['comp_ad']==undefined){this.options['comp_ad']={};}
oldAd=[];if(this.options['comp_ad']['url']!=undefined&&this.options['comp_ad']['type']!=undefined){oldAd=[this.options['comp_ad']['url'],this.options['comp_ad']['type']];}
if(typeof ad=="string"){this.options['comp_ad']['url']=ad;this.options['comp_ad']['type']='iframe';}else{if(this.template["comp_ad"]!=undefined){var key="_"+this.template["comp_ad"][2]+"x"+this.template["comp_ad"][3];var match=null;if(typeof ad[key]=="object"){match=ad[key];}else if(typeof ad["_default"]=="object"){match=ad["_default"];}else{var best=999;var aspect=this.template["comp_ad"][2]/this.template["comp_ad"][3];for(var i in ad){var diff=Math.abs(aspect-(ad[i]['width']/ad[i]['height']));if(diff<best){best=diff;match=ad[i];}}}}
if(match){this.options['comp_ad']['url']=match.url;this.options['comp_ad']['link']=match.clickUrl;this.options['comp_ad']['type']=match.type;this.options['comp_ad']['source']=match.source;this.options['comp_ad']['bannerimpression']=ad.tracking.impressionUrls;this.options['comp_ad']['bannerclick']=ad.tracking.clickTrackUrl;this.options['comp_ad']['playerindex']=ad.tracking.playerIndex;this.options['comp_ad']['bannerguid']=match.guid;}}
newAd=[this.options['comp_ad']['url'],this.options['comp_ad']['type']];if(this.started){if(oldAd.toString()!=newAd.toString()){this.comp_adContent();}
this.callExternalHandlers("compAd",ad);}}
this.VideoTitleSet=function(title){if(this.options['content_title']==undefined){this.options['content_title']={};}
this.options['content_title']['text']=title;if(this.started){this.content_titleContent();}}
this.AdTitleSet=function(title){if(this.options['ad_title']==undefined){this.options['ad_title']={};}
this.options['ad_title']['label']=title;if(this.started){this.ad_titleContent();}}
this.PlayerSet=function(key,value){if(this.options['player']==undefined){this.options['player']={};}
if(this.optionMap[key]){key=this.optionMap[key];}
this.options['player'][key]=value;};this.createDiv=function(name){var obj=document.createElement("div");obj.setAttribute("id",this.prefix+name);obj.style.cssText=this.style('absolute',name);this.wrapper.appendChild(obj);};this.style=function(position,name){var style=new Array();if(this.template[name]["style"]&&this.template[name]['style']){style=style.concat(this.template[name]['style']);}
if(this.options[name]&&this.options[name]['style']){style=style.concat(this.options[name]['style']);}
style.push("overflow: hidden;");style.push("position: "+position+";");if(this.template[name][0]){style.push("left: "+this.template[name][0]+"px;");}
if(this.template[name][1]){style.push("top: "+this.template[name][1]+"px;");}
style.push("width: "+this.template[name][2]+"px;");style.push("height: "+this.template[name][3]+"px;");return style.join(";");};this.content_titleContent=function(){if(!this.options["content_title"]){return false;}
var label=document.createElement("span");label.setAttribute("id",this.prefix+"content_title_label");var title=document.createElement("span");title.setAttribute("id",this.prefix+"content_title_content");if(this.options["content_title"]["labelStyle"]){label.style.cssText="float: left; "+this.options["content_title"]["labelStyle"];}
if(this.options["content_title"]["titleStyle"]){title.style.cssText=this.options["content_title"]["titleStyle"];}
if(this.options["content_title"]["label"]){label.appendChild(document.createTextNode(this.options["content_title"]["label"]));}
if(this.options["content_title"]["text"]!=undefined){title.appendChild(document.createTextNode(this.options["content_title"]["text"]));}
var wrapper=document.getElementById(this.prefix+"content_title");var old_title=document.getElementById(this.prefix+"content_title_content");if(old_title){wrapper.removeChild(old_title);}
var old_label=document.getElementById(this.prefix+"content_title_label");if(old_label){wrapper.removeChild(old_label);}
wrapper.appendChild(label);wrapper.appendChild(title);return true;};this.prog_areaContent=function(){if(!this.options["prog_area"]||!this.template['prog_area']||!this.options["prog_area"]["url"]){return true;}
this.createIframe("prog_area");return true;};this.comp_adContent=function(){if(!this.options["comp_ad"]||!this.template['comp_ad']||!(this.options["comp_ad"]["url"]||this.options["comp_ad"]["source"])){return true;}
switch(this.options["comp_ad"]["type"]){case"image":succ=this.compAdImage();break;case"iframe":succ=this.createIframe("comp_ad");break;case"swf":succ=this.createSwfObject("comp_ad");break;case"htmlSource":succ=this.compAdHtml();break;}
if(succ){this.bannerImpression();}
return true;};this.compAdImage=function(){var elm=document.createElement("a");elm.setAttribute("href",this.options["comp_ad"]["link"]);elm.setAttribute("target","_blank");elm.bannerguid=this.options['comp_ad']['bannerguid'];elm.playerindex=this.options['comp_ad']['playerindex'];onClickUrl=this.options['comp_ad']['bannerclick'];elm.onclick=function(){if(onClickUrl!=undefined){var img=new Image();img.src=onClickUrl;return true;}else if(acudeoComponents&&this.playerindex>=0){acudeoComponents[this.playerindex].tmSendEvent("bannerClick",{banner:{guid:bannerguid}});return true;}
return true;};img=document.createElement("img");img.setAttribute("src",this.options["comp_ad"]["url"]);img.setAttribute("border",0);img.setAttribute("width",this.template["comp_ad"][2]);img.setAttribute("height",this.template["comp_ad"][3]);elm.appendChild(img);elm.setAttribute("id",this.prefix+"comp_ad_element");var wrapper=document.getElementById(this.prefix+"comp_ad");this.clearWrapper(this.prefix+"comp_ad");wrapper.appendChild(elm);return true;}
this.compAdHtml=function(){var elm=document.createElement("div");elm.setAttribute("id",this.prefix+"comp_ad_element");elm.innerHTML=this.options["comp_ad"]["source"];this.clearWrapper(this.prefix+"comp_ad");var wrapper=document.getElementById(this.prefix+"comp_ad");wrapper.appendChild(elm);return true;}
this.clearWrapper=function(id){if(!id)
return true;var wrapper=document.getElementById(id);if(null===wrapper)
return true;while(wrapper.hasChildNodes()){wrapper.removeChild(wrapper.lastChild);}
return true;}
this.createIframe=function(location){var wrapper=document.getElementById(this.prefix+location);var old_iframe=document.getElementById(this.prefix+location+"_element");if(old_iframe){wrapper.removeChild(old_iframe);}
if(this.options[location]["url"]==""){return false;}
var iframe=document.createElement("iframe");iframe.setAttribute("id",this.prefix+location+"_element");iframe.style.width=this.template[location][2]+"px";iframe.style.height=this.template[location][3]+"px";iframe.style.border="0";iframe.scrolling="no";iframe.marginWidth="0";iframe.marginHeight="0";iframe.frameBorder="no";wrapper.appendChild(iframe);var parentAdDiv=document.getElementById(this.prefix+location);if(parentAdDiv.style.visibility&&parentAdDiv.style.visibility=="hidden"){parentAdDiv.style.visibility="visible";}
var new_iframe=document.getElementById(this.prefix+location+"_element");new_iframe.src=this.options[location]["url"];new_iframe.frameborder="no";return true;}
this.createSwfObject=function(location,params,flashVars,cache){var wrapper=document.getElementById(this.prefix+location);var old_swf=document.getElementById(this.prefix+location+"_element");if(old_swf){wrapper.removeChild(old_swf);}
params=params||'';flashVars=flashVars||'';cache=cache||false;if(!cache){params="rand="+Math.random()+"&"+params;}
var swf=this.options[location]["path"];if(swf==undefined){swf=this.options[location]["url"];}
var thisObj=this.objectTag;thisObj=thisObj.replace(/%%NAME%%/g,this.prefix+location+"SWF");thisObj=thisObj.replace(/%%WIDTH%%/g,this.template[location][2]);thisObj=thisObj.replace(/%%HEIGHT%%/g,this.template[location][3]);thisObj=thisObj.replace(/%%SWF%%/g,swf);if(params){params="?"+params;}
thisObj=thisObj.replace(/%%PARAMS%%/g,params);thisObj=thisObj.replace(/%%FLASHVARS%%/g,flashVars);var swf_wrapper=document.createElement("span");swf_wrapper.id=this.prefix+location+"_element";if(this.isIE){wrapper.appendChild(swf_wrapper);var swf_wrapper=document.getElementById(this.prefix+location+"_element");swf_wrapper.innerHTML=thisObj;}else{swf_wrapper.innerHTML=thisObj;wrapper.appendChild(swf_wrapper);}
return true;}
this.createHtml5Video=function(location){var this_=this;var video=document.createElement("video");var playerID="player"+new Date().getTime();video.setAttribute("id",playerID);video.setAttribute("src",this.options["html5contenturl"]);video.setAttribute("width",this.options.template.player[2]);video.setAttribute("height",this.options.template.player[3]);video.setAttribute("controls","controls");var wrapper=document.getElementById(this.prefix+location);var old_swf=document.getElementById(this.prefix+location+"_element");if(old_swf){wrapper.removeChild(old_swf);}
wrapper.appendChild(video);var html5=document.createElement("script");html5.setAttribute("src","http://objects.tremormedia.com/embed/sjs/acudeo.js");html5.setAttribute("type","text/javascript");html5.onload=function(){ACUDEO.Player({player:playerID,banner:"tmcomp_ad",policy:this_.options.html5adpolicyid});};document.getElementsByTagName('head')[0].appendChild(html5);}
this.bannerImpression=function(){urlList=this.options["comp_ad"]["bannerimpression"];if(urlList==undefined){if(acudeoComponents&&this.options["comp_ad"]["playerindex"]>=0){acudeoComponents[this.options["comp_ad"]["playerindex"]].tmSendEvent("bannerDisplayed",{banner:{guid:this.options["comp_ad"]["bannerguid"]}});return true;}else{return false;}}
for(var i=0;i<urlList.length;i++){var img=new Image();img.src=urlList[i];}};this.ad_titleContent=function(){if(this.options['ad_title']==undefined){this.options['ad_title']={};}
var title=document.createElement("div");if(this.options["ad_title"]["label"]){title.appendChild(document.createTextNode(this.options["ad_title"]["label"]));}
if(this.options["ad_title"]["labelStyle"]){title.style.cssText=this.options["ad_title"]["labelStyle"];}
var wrapper=document.getElementById(this.prefix+"ad_title");wrapper.appendChild(title);return true;};this.playerContent=function(){if(this.flashEnabled){this.createSwfObject("player",this.getInitialParameters('url'),this.getInitialParameters('flashVars'),true);}else{this.createHtml5Video("player");}
return true;};this.getInitialParameters=function(format){format=format||"flash";if(this.options['player']==undefined){this.options['player']={};}
if(format=="url"){return"";}
switch(format){case"flash":var flashOptions={};break;case"flashVars":var flashOptions=[];break;}
for(var key in this.options['player']){keyname=key;if(this.optionMap[key]){keyname=this.optionMap[key];}
switch(keyname){case"path":case"style":break;default:switch(format){case"flash":flashOptions[keyname]=this.options['player'][key];break;case"flashVars":flashOptions.push(keyname+"="+encodeURIComponent(this.options['player'][key]));break;}
break;}}
switch(format){case"flash":return flashOptions;case"flashVars":return flashOptions.join("&");case"url":var urlString='instance_id='+this.options["instance_id"];return'';}
return{};};this.bind=function(method){return this[method]();};this.callExternalHandlers=function(type,data){if(type==undefined){return true;}
var len=this.handlers.length;for(var i=0;i<len;i++){if(this.handlers[i]['type']==type&&this.handlers[i]['callback']!=undefined&&typeof(this.handlers[i]['callback'])=="function"){this.handlers[i]['callback'](data);}}};this.reloadVideo=function(){this.playerContent();};this.resetVideo=function(){if(typeof acudeoComponents!="object")return;var obj;try{obj=doc.getElementById(this.prefix+"player_element").childNodes[0];if(!obj.tmAcudeoPlayerReset){obj=obj.getElementsByTagName("object")[0];}
if(obj.tmAcudeoPlayerReset){obj.tmAcudeoPlayerReset(this.getInitialParameters());}}catch(e){}};this.generateUuid=function(){var ts=new Date().getTime()-new Date(1582,10,15,0,0,0,0).getTime();var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";ts=ts.toString(16)+"0000";var uuid=ts.substr(0,8)+ts.substr(8,4);for(var i=0;i<20;i++){var rnum=Math.floor(Math.random()*chars.length);uuid+=chars.substring(rnum,rnum+1);}
return uuid.substr(0,8)
+"-"+uuid.substr(8,4)
+"-"+uuid.substr(12,4)
+"-"+uuid.substr(16,4)
+"-"+uuid.substr(20,12);};this.readCookie=function(name){name=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(name)==0){return c.substring(name.length,c.length);}}
return null;};this.writeCookie=function(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else{var expires="";}
document.cookie=name+"="+value+expires+"; path=/";};this.trim=function(val){if(typeof val!="string"){return val;}
return val.replace(/^\s+|\s+$/g,"");}
this.checkFlash=function(){if(typeof nav.plugins!=undefined&&typeof nav.plugins["Shockwave Flash"]=="object"){d=nav.plugins["Shockwave Flash"].description;if(d&&!(typeof nav.mimeTypes!=undefined&&nav.mimeTypes["application/x-shockwave-flash"]&&!nav.mimeTypes["application/x-shockwave-flash"].enabledPlugin)){this.flashEnabled=true;}}else if(typeof win.ActiveXObject!=undefined){try{var a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(a){this.flashEnabled=true;}}catch(e){}}
if(!this.flashEnabled){var noFlashImg="http://dc.tremormedia.com/comp_59043.gif?eid=programdata&pid=%%POLICY%%&key=flashnotavailable&value=true&r=%%RAND%%";noFlashImg=noFlashImg.replace(/%%POLICY%%/g,this.options["programid"]);noFlashImg=noFlashImg.replace(/%%RAND%%/g,Math.random());img=document.createElement("img");img.setAttribute("src",noFlashImg);img.setAttribute("border",0);img.setAttribute("width",0);img.setAttribute("height",0);this.wrapper.appendChild(img);}}
this.construct(options);};}();}
