var mDialogVideoLib=new (function(){this.host=".mdialog.com";this.version="v8";this.embedders={};this.videoQueue=[];this.validVideoCache={};this.assetHost="http://livestream.mdialog.com/mdialog/player_"+this.version+"/";this.head=document.getElementsByTagName("head")[0];this.GEOLOCATION_CHECK_INTERVAL=250;this.GEOLOCATION_TIMEOUT=5E3;this.initialize=function(){mDialogVideoLib.ready=false;mDialogVideoLib.loadAdditionalScriptsAndStyles();mDialogVideoLib.requestGeolocation()};this.loadAdditionalScriptsAndStyles=
function(){var a,b;a=document.createElement("script");a.type="text/javascript";a.src=mDialogVideoLib.assetHost+"embedInstance.js";a.onload=function(){mDialogVideoLib.processQueue()};b=document.createElement("link");b.rel="stylesheet";b.type="text/css";b.href=mDialogVideoLib.assetHost+"html5.css";mDialogVideoLib.head.appendChild(a);mDialogVideoLib.head.appendChild(b)};this.insertVideo=function(a,b,c,d){if(d===null||d===undefined)d={};mDialogVideoLib.ready?mDialogVideoLib.processQueueItem(a,b,c,d):
mDialogVideoLib.videoQueue.push([a,b,c,d])};this.processQueue=function(){for(mDialogVideoLib.ready=true;mDialogVideoLib.videoQueue.length>0;){var a=mDialogVideoLib.videoQueue.pop();mDialogVideoLib.processQueueItem(a[0],a[1],a[2],a[3])}};this.processQueueItem=function(a,b,c,d){mDialogVideoLib.embedders[c+(d.externalKey?"-external-":"-")+a+"-"+b]=new VideoInstance(a,b,c,d)};this.requestGeolocation=function(){navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(a){mDialogVideoLib.hasLatLon=
true;mDialogVideoLib.latitude=a.coords.latitude;mDialogVideoLib.longitude=a.coords.longitude},function(){mDialogVideoLib.hasLatLon=false},{enableHighAccuracy:true,maximumAge:6E5,timeout:mDialogVideoLib.GEOLOCATION_TIMEOUT})};this.isValidUserAgent=function(){return true};this.isValidVideo=function(){var a,b,c,d,f;if(arguments.length===4){a=arguments[0];b=arguments[1];c=false;d=arguments[2];f=arguments[3]}else if(arguments.length==5){a=arguments[0];b=arguments[1];c=arguments[2]===true;d=arguments[3];
f=arguments[4]}else return;if(a===undefined||a===null||b===undefined||b===null)if(f)f();else return;mDialogVideoLib.validVideoCache.hasOwnProperty(b+(c?"-external-":"-")+elementId+"-"+a)||mDialogVideoLib.performValidVideoCheck(null,a,b,c,d,f)};this.playVideo=function(a,b){mDialogVideoLib.embedders[a].playVideo(b)};this.displayErrorMessage=function(a,b){mDialogVideoLib.embedders[a].displayErrorMessage(b)};this.getDeviceId=function(){var a=mDialogVideoLib.getCookie("md_udeviceid");if(a===undefined||
a===null||a===""){a="iphone_web_"+(new Date).valueOf().toString()+"_"+mDialogVideoLib.randomString(8);mDialogVideoLib.setCookie("md_udeviceid",a,365)}return a};this.randomString=function(a){var b,c,d="";for(b=0;b<a;b++){c=Math.floor(Math.random()*61);d+="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".substring(c,c+1)}return d};this.setCookie=function(a,b,c){var d=new Date;d.setDate(d.getDate()+c);document.cookie=a+"="+escape(b)+(c===null?"":";expires="+d.toGMTString())};this.getCookie=
function(a){if(document.cookie.length>0){var b=document.cookie.indexOf(a+"="),c=0;if(b!==-1){b=b+a.length+1;c=document.cookie.indexOf(";",b);if(c===-1)c=document.cookie.length;return unescape(document.cookie.substring(b,c))}}return""};this.performValidVideoCheck=function(a,b,c,d,f,i){var j,g,e=c+(d?"-external-":"-")+a+"-"+b,h;if(mDialogVideoLib.validVideoCache.hasOwnProperty(e)&&mDialogVideoLib.validVideoCache[e]!==undefined)if(a!==null)mDialogVideoLib.validVideoCache[e]===false?mDialogVideoLib.embedders[e].videoErrorOccurred():
mDialogVideoLib.embedders[e].requestPlaylist();else{mDialogVideoLib.validVideoCache[e]&&f&&f();!mDialogVideoLib.validVideoCache[e]&&i&&i()}else{b="https://"+c+mDialogVideoLib.host+"/embed/check_segment/"+b+"/check.js";g="jsonp"+(new Date).getTime().toString()+Math.floor(Math.random()*1E6);h=document.createElement("script");b+=d?"?external_key=true&callback="+g:"?callback="+g;window[g]=function(k){j=k;if(j.hasOwnProperty("valid_segment")&&j.valid_segment===true){mDialogVideoLib.validVideoCache[e]=
true;if(a===null&&f)f();else a!==null&&mDialogVideoLib.embedders[e].requestPlaylist()}else{mDialogVideoLib.validVideoCache[e]=false;if(a!==null)mDialogVideoLib.embedders[e].videoErrorOccurred();else i&&i()}window[g]=undefined;try{delete window[g]}catch(l){}mDialogVideoLib.head&&mDialogVideoLib.head.removeChild(h)};h.src=b;h.type="text/javascript";mDialogVideoLib.head.appendChild(h)}}});
mDialogUtility={createElement:function(a,b){var c=document.createElement(a);for(var d in b)c.setAttribute(d,b[d]);return c}};mDialogVideoLib.initialize();

