if(typeof ns_API=="undefined")var ns_API={loadEvents:[],reservedLabels:new RegExp(/^\s*(ns\_.*|agent|availscreen|colordepth|cookie|corporate|day|full\_loading\_time|html\_loading\_time|httpreferer|innersize|ip|java|lang|mimetypes|name|newcookie|offset|or|outersize|p|pie|plugins|referrer|screen|site|\_t|time|type|url|ver)\s*$/i),regCounter:new RegExp(/(?:https?):\/\/([^\/]+)\/([^\/]+)\/([^\/]+)\/s\?([\w_\-\.\[\]\(\)\$\~\{\}\*\^\,]{1,200})/)};if(typeof ns_API.addEvent=="undefined")ns_API.addEvent=(document.addEventListener)?(function(element,type,handler){element.addEventListener(type,handler,false)}):(document.attachEvent)?(function(element,type,handler){element.attachEvent("on"+type,handler)}):new Function;if(typeof ns_API.isIE=="undefined")ns_API.isIE=/*@cc_on!@*/false;;if(typeof ns_API.isIE7=="undefined")ns_API.isIE7=(ns_API.isIE&&/MSIE\s*7/i.test(navigator.userAgent))?true:false;if(typeof ns_API.getJSPageURL=="undefined")ns_API.getJSPageURL=function(){
return(document.URL)?document.URL:document.location.domain+document.location.pathname+document.location.search};if(typeof ns_API.onDocumentReady=="undefined")ns_API.onDocumentReady=function(func){try{if(document.addEventListener&&!/webkit/i.test(navigator.userAgent)){document.addEventListener("DOMContentLoaded",func,false);}else if(/msie/i.test(navigator.userAgent)){var id="__ie_onload_"+new Date().getTime();document.write("<script id=\"ns_api_defered"+id+"\" defer src=\"javascript:void(0)\"><\/script>");var script=document.getElementById(id);script.onreadystatechange=function(){if(/complete/i.test(this.readyState))func();}}else if(/webkit/i.test(navigator.userAgent)){var _timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(_timer);func();}},10);}else{throw 0;}}catch(e){ns_API.addEvent(window,"load",func);}};if(typeof ns_API.addLoadEvent=="undefined")ns_API.addLoadEvent=function(func){ns_API.loadEvents.push(func);if(!ns_API.loadEventHandler)ns_API.loadEventHandler=ns_API.onDocumentReady(function(){for(var i=0,loadEvent;(loadEvent=ns_API.loadEvents[i]);i++)if(loadEvent instanceof Function)loadEvent()});};if(typeof ns_API.constructLabel=="undefined")ns_API.constructLabel=function(label){
return label.replace(/[^\-_\.a-zA-Z0-9]/g,"___");};if(typeof ns_API.startTime=="undefined")ns_API.startTime=ns_API.addLoadEvent(function(){ns_API.startTime=new Date().getTime()});if(typeof ns_API.streaming=="undefined"){ns_API.streaming=function(){
return{version:"2.1.1",DEBUG:false,COMPATIBILITY_MODE:false,DEVELOPER:false,players:{},cntPlayers:0,url:"",label_prefix:"ns_st_",incLogs:0,uniqueIds:{},keepAliveInterval:20,players:[],events:{"play":["pb","pl","cn","pr","ep","pn","tp","el","dt","ty","br","cs","st","cl","ca","ub","bt","mp","mv","fee","id","po","sq","sp","sv","cu","li","jspageurl","er"],"pause":["pl","pr","cc","ep","pn","tp","el","dt","ty","st","id","po","li","cn"],"end":["pe","pl","pr","cp","cn","ep","pn","tp","el","dt","ty","br","cs","st","cl","ca","ub","bt","bp","mp","mv","fee","pt","pa","id","po","pc","pp","sv","cu","sp","li","jspageurl","er"],"keep-alive":"jspageurl"},addCustomEvent:function(ev,labels){if(/^\s*(play|pause|end|keep-alive)\s*$/i.test(ev))
return;this.events[ev]=labels;
return true;},clearCustomEvent:function(ev){if(this.events[ev])delete this.events[ev];},getScriptVersion:function(){
return this.version},init:function(){try{if(this.url=="")this.url=window.ns_pixelUrl.match(ns_API.regCounter)[0];for(var i=0,player;(player=this.players[i]);i++){if(player.isInitialized)continue;if(player.onInit instanceof Function){try{if(this.COMPATIBILITY_MODE){var func=function(a_player){var _player=a_player;
return function(){if(!_player.isCompatible())ns_API.streaming.logIncompatible(_player)}}(player);setTimeout(func,0);}player.onInit.call(player);}catch(e){this.throwException(e)}}}}catch(e){this.throwException(e);}},throwException:function(e){if(this.DEBUG)alert("Streaming API\n"+(e.message||e));},uniqueID:function(){var time=new Date().getTime();if(!this.uniqueIds[time])this.uniqueIds[time]=0;this.uniqueIds[time]++;
return String(time+"#"+this.uniqueIds[time]);},setKeepAlive:function(player){var _player=player;var func=function(){ns_API.streaming.setKeepAlive.call(ns_API.streaming,_player);};if(!player.keepalive)player.keepalive=setInterval(func,this.keepAliveInterval*6e4);else this.log("keep-alive",{});},enableKeepAlive:function(player){if(!player.keepalive)this.setKeepAlive(player);},clearKeepAlive:function(player){if(player&&player.keepalive)clearInterval(player.keepalive);},log:function(ev,labels,callback){if(!labels)
return;try{if(this.url=="")throw "Please specify a valid sitestat url";var qs=["&"+this.label_prefix+"ev="+ev,"ns_type=hidden","ns_ts="+new Date().getTime()];if(!this.events[ev])
return;var regex;for(var label in labels){if(ns_API.reservedLabels.test(label))continue;regex=new RegExp(label+"[;|$]?","i");if(((labels[label]!=""&&labels[label]!="null")||labels[label]==0)&&labels[label]!=null&&typeof labels[label]!="undefined"&&(regex.test(this.events[ev]))){if(/cu/i.test(label))qs=qs.concat(labels[label].split("&"));else qs.push((/jspageurl/i.test(label))?"ns_jspageurl="+escape(labels[label]):((callback instanceof Function&&callback(label)||!new RegExp(label+"[\||$]","i").test(this.events[ev].join("|")))?"":this.label_prefix)+label+"="+String(escape(labels[label]).substring(0,200)));}}window["ns_img"+this.incLogs]=new Image();window["ns_img"+this.incLogs].src=this.url+qs.join("&");if(this.DEVELOPER){if(this.debugLabels){var arr=[];for(var j=0;j<qs.length;j++){if(this.debugLabels.test(qs[j]))arr.push(qs[j]);}qs=arr;}document.getElementById("debug").innerHTML="<HR>"+qs.sort().join("&").replace(/ns_(type|ts)\=[^&]+&/gi,"").replace(/\=(play|pause|end)/gi,"=<font color='blue'>$1</font>").replace(/(dev\-[^\=]+)\=([^&]+)/gi,"<font color='gray'>$1</font>=<b>$2</b>").replace(/(ns_st_[^\=]+)\=([^&]+)/gi,"<font color='red'>$1</font>=<b>$2</b>").substring(1).replace(/&/g,"<br/>")+document.getElementById("debug").innerHTML;}this.incLogs++;}catch(e){this.throwException(e)}},logIncompatible:function(player){var labels=player.getLabelValues.call(player,"play");player.clear();this.log("play",labels);},getLabels:function(ev){
return(this.events[ev])?this.events[ev]:null},getURL:function(){
return this.url;},setURL:function(_url){this.url=_url;},register:function(player){this.players.push(player);},_construct:ns_API.addLoadEvent(function(){ns_API.streaming.init.apply(ns_API.streaming)})}}();};ns_API.streaming.playlist=function(){this.entries=[];this.uid=ns_API.streaming.uniqueID();this.sequence=1;};ns_API.streaming.playlist.prototype.addEntry=function(entry){this.entries.push(entry);entry.uid=this.uid;entry.clip=this.entries.length;};ns_API.streaming.playlist.prototype.getTotalValues=function(key){var total=0,value;for(var i=0,entry;(entry=this.entries[i]);i++){value=/duration/i.test(key)?entry["info"][key]:entry[key];total+=(value=="undefined"||isNaN(parseInt(value))?0:parseInt(value));}
return total;};ns_API.streaming.playlist.prototype.getTotalPlayingTime=function(){
return this.getTotalValues("totalPlayed");};ns_API.streaming.playlist.prototype.getTotalEvents=function(){
return this.getTotalValues("events");};ns_API.streaming.playlist.prototype.getPlayListLength=function(){
return this.getTotalValues("duration");};ns_API.streaming.playlist.prototype.getTotalBufferTime=function(){var total=0;for(var i=0,entry;(entry=this.entries[i]);i++)total+=entry.getBufferTime();
return total;};ns_API.streaming.playlistItem=function(options){options=options||{};this.uid=0;this.sequence=0;this.buffer=[];this.__bufferstart=0;this.currentPosition=0;this.events=0;this.playStart=0;this.totalPlayed=0;this.playTime=0;this.episodeLength=options.episodeLength||0;this.clip=options.clip||1;this.info={date:options.date,duration:(options.duration)?options.duration==""?0:options.duration:0,station:options.station,streamtype:options.streamtype,totalparts:options.totalparts||1,fee:options.fee,part:options.part||1,episode:options.episode||1,program:options.program,custom:options.custom||""};this.playing=false;this.paused=false;this.buffering=false;this.timer=null;this.onPlayingCallback=options.onPlayingCallback;};ns_API.streaming.playlistItem.prototype.clear=function(){this.buffer=[];this.events=0;this.playStart=0;this.playTime=0;this.totalPlayed=0;};ns_API.streaming.playlistItem.prototype.play=function(player){if(this.buffering)this.bufferEnd();if(this.playing)
return;this.playStart=new Date().getTime();var scope=this;this.timer=window.setInterval(function(){try{scope.onPlaying.call(scope)}catch(e){}},100);this.playing=true;this.paused=false;ns_API.streaming.enableKeepAlive(this);};ns_API.streaming.playlistItem.prototype.pause=function(player){this.events++;this.paused=true;if(this.timer)window.clearInterval(this.timer);this.playing=false;};ns_API.streaming.playlistItem.prototype.end=function(player){if(!this.playing&&this.playing!=null)
return;ns_API.streaming.clearKeepAlive(this);if(this.timer)window.clearInterval(this.timer);this.playing=false;this.paused=false;};ns_API.streaming.playlistItem.prototype.onPlaying=function(){if(this.onPlayingCallback instanceof Function)this.currentPosition=this.onPlayingCallback();};ns_API.streaming.playlistItem.prototype.addPlayingTime=function(){this.totalPlayed+=(new Date().getTime()-this.playStart);this.playStart=new Date().getTime();};ns_API.streaming.playlistItem.prototype.bufferStart=function(player){if(this.playing){this.addPlayingTime();player.dispatchState("end",this);this.playing=false;this.buffering=true;}this.__bufferstart=new Date().getTime()};ns_API.streaming.playlistItem.prototype.bufferEnd=function(player){this.buffering=false;if(this.__bufferstart&&parseInt(this.__bufferstart)>0)this.buffer.push(new Date().getTime()-this.__bufferstart);};ns_API.streaming.playlistItem.prototype.getBufferTime=function(){var buffer=0;for(var i=0;i<this.buffer.length;i++)buffer+=parseInt(this.buffer[i]);
return buffer;};ns_API.streaming.playlistItem.prototype.getItemInfo=function(_key){if(this.info[_key])
return this.info[_key];};ns_API.streaming.playlistItem.prototype.setItemInfo=function(_key,_value){if(typeof _value!="undefined"&&_value!="")this.info[_key]=_value;};ns_API.streaming.player=function(ref){this._base=ns_API.streaming;this.ref=ref;this.keepalive=null;this.player=null;this.playerVersion="x.x";this.userPlaylist={title:"",clips:[]};this.playLists={};this.playList=null;this.classId=null;this.hasPlaylist=false;this.embedType=null;this.currentItem=null;this.isInitialized=false;this.doPlaylistEndEvent=false;this.doPlaylistStartEvent=true;if(!!arguments.length)this.construct();};ns_API.streaming.player.prototype.construct=function(){this._base.register(this);};ns_API.streaming.player.prototype.clear=function(){};ns_API.streaming.player.prototype.isCompatible=function(){
return true;};ns_API.streaming.player.prototype.onInit=function(){this.isInitialized=true;this.player=(typeof this.ref=="string")?((document.getElementById(this.ref)!=null)?document.getElementById(this.ref):(window[this.ref])?window[this.ref]:document[this.ref]):this.ref;if(!ns_API.isIE&&this.player&&!/embed/i.test(this.player.tagName))this.player=document[this.player.getElementsByTagName("embed")[0].name];if(!this.player||!this.player.tagName)throw("DomElement not found");};ns_API.streaming.player.prototype.clearPlaylist=function(){this.playList=null;this.userPlaylist={title:"",clips:[]};this.playLists={}};ns_API.streaming.player.prototype.getLabelValues=function(state,player){var obj={};if(ns_API.streaming.events[state]){var labels=ns_API.streaming.events[state];for(var i=0,label;(label=labels[i]);i++)if(this["getLabelValue_"+label.toUpperCase()] instanceof Function){try{obj[label]=this["getLabelValue_"+label.toUpperCase()]();}catch(e){}}}
return obj;};ns_API.streaming.player.prototype.dispatchState=function(state,entry){if(!entry||!entry[state] instanceof Function)
return;if(entry&&entry.buffering&&entry.bufferEnd instanceof Function)entry.bufferEnd();if(entry.playing)entry.addPlayingTime();if((state=="end"&&(entry.playing==null)||entry.playing||(entry.paused&&state!="pause"))||state!="end")this._base.log(state,this.getLabelValues(state));entry[state].call(entry,this);this.doPlaylistStartEvent=false;};ns_API.streaming.player.prototype.onOpenStateChange=function(state){if(this["onOpenState_"+this.openStates[state]] instanceof Function)this["onOpenState_"+this.openStates[state]].apply(this,arguments);};ns_API.streaming.player.prototype.onPlayStateChange=function(state){if(this["onPlayState_"+this.playStates[state]] instanceof Function)this["onPlayState_"+this.playStates[state]].apply(this,arguments);};ns_API.streaming.player.prototype.onBuffering=function(start){var entry=this.getSelectedItem();if(!entry)
return;entry["buffer"+((start)?"Start":"End")](this);};ns_API.streaming.player.prototype.getDurationFromString=function(durationString){var arr=durationString.split(":"),duration=0;for(var i=arr.length-1,j=0;i>=0;i--,j++)duration+=isNaN(parseInt(arr[i]))?0:parseInt(arr[i])*(Math.pow(60,j)*1000);
return duration;};ns_API.streaming.player.prototype.setPlaylistTitle=function(a_title){this.userPlaylist.title=a_title;};ns_API.streaming.player.prototype.setClipDetails=function(a_clip_nr,a_duration,a_program,a_episode,a_totalparts,a_part,a_date,a_fee,a_station,a_streamtype,a_custom){a_clip_nr=(a_clip_nr&&!isNaN(parseInt(a_clip_nr)))?parseInt(a_clip_nr):1;if(!this.userPlaylist.clips)this.userPlaylist.clips=[];if(this.userPlaylist.clips.length<a_clip_nr)this.userPlaylist.clips.length=a_clip_nr;this.userPlaylist.clips[a_clip_nr-1]=new this._base.playlistItem({clip:a_clip_nr,duration:a_duration,date:a_date,station:a_station,streamtype:a_streamtype,totalparts:a_totalparts,part:a_part,episode:a_episode,program:a_program,custom:a_custom});};ns_API.streaming.player.prototype.getClipInfo=function(key,clip_nr,entry,callback){if(this.userPlaylist&&this.userPlaylist.clips&&this.userPlaylist.clips[clip_nr])
return(callback instanceof Function)?callback(this.userPlaylist.clips[clip_nr].getItemInfo(key)):this.userPlaylist.clips[clip_nr].getItemInfo(key);else if(entry&&entry.getItemInfo instanceof Function)
return entry.getItemInfo(key);};ns_API.streaming.player.prototype.getPlaylistClip=function(clip_nr){if(this.userPlaylist&&this.userPlaylist.clips&&this.userPlaylist.clips[clip_nr])
return this.userPlaylist.clips[clip_nr]};ns_API.streaming.player.prototype.clearClipIncrements=function(playlist){for(var i=0,entry;(entry=playlist.entries[i]);i++)entry.clear();};ns_API.streaming.player.prototype.incrementPlaylist=function(){var playlist=this.getCurrentPlaylist();this.clearClipIncrements(playlist);playlist.sequence++;};ns_API.streaming.player.prototype.getCurrentPlaylist=function(){};ns_API.streaming.player.prototype.getLabelValue_PB=function(){
return(this.doPlaylistStartEvent)?1:null};ns_API.streaming.player.prototype.getLabelValue_PE=function(){
return(this.doPlaylistEndEvent)?1:null};ns_API.streaming.player.prototype.getLabelValue_MP=function(){
return this.type};ns_API.streaming.player.prototype.getLabelValue_MV=function(){
return this.playerVersion};ns_API.streaming.player.prototype.getLabelValue_SV=function(){
return this._base.version};ns_API.streaming.player.prototype.getLabelValue_EL=function(){
return this.getSelectedItem().episodeLength};ns_API.streaming.player.prototype.getLabelValue_CN=function(){
return this.getSelectedItem().clip};ns_API.streaming.player.prototype.getLabelValue_PT=function(){
return this.getSelectedItem().totalPlayed};ns_API.streaming.player.prototype.getLabelValue_PC=function(){
return this.getSelectedItem().events};ns_API.streaming.player.prototype.getLabelValue_SQ=function(){var entry=this.getSelectedItem();entry.sequence=Math.max(1,entry.sequence);
return entry.sequence};ns_API.streaming.player.prototype.getLabelValue_PO=function(){
return this.getSelectedItem().currentPosition};ns_API.streaming.player.prototype.getLabelValue_CL=function(){
return this.getClipInfo("duration",this.getIndex(),this.getSelectedItem(),this.getDurationFromString)};ns_API.streaming.player.prototype.getLabelValue_BT=function(){
return this.getSelectedItem().getBufferTime()};ns_API.streaming.player.prototype.getLabelValue_PR=function(){
return this.getClipInfo("program",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_EP=function(){
return this.getClipInfo("episode",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_PN=function(){
return this.getClipInfo("part",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_DT=function(){
return this.getClipInfo("date",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_FEE=function(){
return this.getClipInfo("fee",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_TY=function(){
return this.getClipInfo("streamtype",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_ST=function(){
return this.getClipInfo("station",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_TP=function(){
return this.getClipInfo("totalparts",this.getIndex(),this.getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_ID=function(){
return this.getSelectedItem().uid};ns_API.streaming.player.prototype.getLabelValue_SP=function(){
return this.getCurrentPlaylist().sequence};ns_API.streaming.player.prototype.getLabelValue_CA=function(){
return(this.doPlaylistEndEvent)?this.getCurrentPlaylist().getPlayListLength():null};ns_API.streaming.player.prototype.getLabelValue_BP=function(){
return(this.doPlaylistEndEvent)?this.getCurrentPlaylist().getTotalBufferTime():null};ns_API.streaming.player.prototype.getLabelValue_PA=function(){
return(this.doPlaylistEndEvent)?this.getCurrentPlaylist().getTotalPlayingTime():null};ns_API.streaming.player.prototype.getLabelValue_PP=function(){
return(this.doPlaylistEndEvent)?this.getCurrentPlaylist().getTotalEvents():null};ns_API.streaming.player.prototype.getLabelValue_CP=function(){
return this.getCurrentPlaylist().entries.length};ns_API.streaming.player.prototype.getLabelValue_PL=function(){
return(this.userPlaylist.title.replace(/\s/g,"")!="")?this.userPlaylist.title:null};ns_API.streaming.player.prototype.getLabelValue_JSPAGEURL=function(){
return ns_API.getJSPageURL()};ns_API.streaming.player.prototype.getLabelValue_UB=function(){};ns_API.streaming.player.prototype.getLabelValue_CS=function(){};ns_API.streaming.player.prototype.getLabelValue_BR=function(){};ns_API.streaming.player.prototype.getLabelValue_ER=function(){};ns_API.streaming.player.prototype.getLabelValue_LI=function(){};ns_API.streaming.mediaPlayer=function(){this._super.apply(this,arguments);this.type="MediaPlayer";this.classId=new RegExp(/6BF52A52-394A-11D3-B153-00C04F79FAA6/i);this.embedType="";this.openStates=["undefined","PlaylistChanging","PlaylistLocating","PlaylistConnecting","PlaylistLoading","PlaylistOpening","PlaylistOpenNoMedia","PlaylistChanged","MediaChanging","MediaLocating","MediaConnecting","MediaLoading","MediaOpening","MediaOpen","BeginCodecAcquisition","EndCodecAcquisition","BeginLicenseAcquisition","EndLicenseAcquisition","BeginIndividualization","EndIndividualization","MediaWaiting","OpeningUnknownUrl"];this.playStates=["undefined","Stopped","Paused","Playing","ScanForward","ScanReverse","Buffering","Waiting","MediaEnded","Transitioning","Ready","Reconnecting"];};ns_API.streaming.mediaPlayer.prototype=new ns_API.streaming.player();ns_API.streaming.mediaPlayer.prototype._super=ns_API.streaming.player;ns_API.streaming.mediaPlayer.prototype.constructor=ns_API.streaming.mediaPlayer;ns_API.streaming.mediaPlayer.prototype.onInit=function(){if(this.isInitialized)
return;this._super.prototype.onInit.call(this);if(!this.isCompatible())throw "Internet Explorer needed";if(!this.classId.test(this.player.classid))throw "Invalid classid for element\nrequired:"+this.classId.toString();if(this._base.DEBUG)this.player.settings.mute=true;this.playerVersion=this.player.versionInfo;this.setEventHandlers();};ns_API.streaming.mediaPlayer.prototype.isCompatible=function(){var success=false;try{success=(this.player&&this.player.currentMedia&&this.classId.test(this.player.classid))?true:false;}catch(e){}
return success;};ns_API.streaming.mediaPlayer.prototype.setEventHandlers=function(){var scope=this;this.player.SendPlayStateChangeEvents=1;this.player.SendOpenStateChangeEvents=1;this.player.attachEvent("PositionChange",function(){try{scope.onPositionChange.apply(scope,arguments)}catch(e){}});this.player.attachEvent("PlayStateChange",function(){try{scope.onPlayStateChange.apply(scope,arguments)}catch(e){}});this.player.attachEvent("OpenStateChange",function(){try{scope.onOpenStateChange.apply(scope,arguments)}catch(e){}});this.player.attachEvent("buffering",function(){try{scope.onBuffering.apply(scope,arguments)}catch(e){}});};ns_API.streaming.mediaPlayer.prototype.initPlaylist=function(){var playlist=this.player.currentPlaylist,scope=this;if(!this.playLists[playlist.name])this.playLists[playlist.name]=new this._base.playlist();for(var i=0,entry,playlistitem;i<playlist.count&&(entry=playlist.item(i));i++){if(this.playLists[this.player.currentPlaylist.name].entries[i]){this.playLists[this.player.currentPlaylist.name].entries[i].setItemInfo("duration",this.calculateDuration(entry));}else{playlistitem=new ns_API.streaming.playlistItem({onPlayingCallback:function(){
return Math.floor(scope.player.controls.currentPosition)*1000},episodeLength:this.getEpisodeLength(entry),clip:i+1,duration:this.calculateDuration(entry),date:entry.getItemInfo("date"),station:entry.getItemInfo("station"),streamtype:entry.getItemInfo("streamtype"),totalparts:entry.getItemInfo("totalparts"),fee:entry.getItemInfo("fee"),part:entry.getItemInfo("part"),episode:entry.getItemInfo("episode"),program:entry.getItemInfo("program"),custom:entry.getItemInfo("custom")});playlistitem.uid=this.playLists[this.player.currentPlaylist.name].uid;this.playLists[playlist.name].addEntry(playlistitem);}}};ns_API.streaming.mediaPlayer.prototype.getEpisodeLength=function(_entry){var episode=_entry.getItemInfo("episode");if(episode=="")
return this.calculateDuration(_entry);var total=0;for(var i=0,entry;i<this.player.currentPlaylist.count&&(entry=this.player.currentPlaylist.item(i));i++)if(entry.getItemInfo("episode")==episode)total+=this.calculateDuration(entry);
return(total==0)?null:total;};ns_API.streaming.mediaPlayer.prototype.calculateDuration=function(_entry){if(!_entry)
return 0;else return parseFloat((_entry.getItemInfo("Duration")=="")?0:_entry.getItemInfo("Duration").replace(",","."))*1000;};ns_API.streaming.mediaPlayer.prototype.getLabelValue_UB=function(){
return this.player.network.bandWidth;};ns_API.streaming.mediaPlayer.prototype.getLabelValue_PL=function(){if(this.userPlaylist.title.replace(/\s/g,"")!=""){
return this.userPlaylist.title;}else{var title=this.player.currentPlaylist.getItemInfo("playlist");try{
return(/^\s*$/.test(title))?null:title;}catch(e){}}};ns_API.streaming.mediaPlayer.prototype.getLabelValue_CS=function(){try{
return String(this.player.currentMedia.imageSourceWidth+"x"+String(this.player.currentMedia.imageSourceHeight));}catch(e){}};ns_API.streaming.mediaPlayer.prototype.getLabelValue_BR=function(){try{
return this.player.currentMedia.getItemInfo("Bitrate");}catch(e){}};ns_API.streaming.mediaPlayer.prototype.getLabelValue_ER=function(){
return(this.player&&this.player.currentMedia&&this.player.currentMedia.error)?this.player.currentMedia.error.errorDescription:null;};ns_API.streaming.mediaPlayer.prototype.onPositionChange=function(){this.getSelectedItem().currentPosition=Math.floor(this.player.controls.currentPosition*1000);};ns_API.streaming.mediaPlayer.prototype.onPlayStateChange=function(state){if(state==1)this.doPlaylistEndEvent=true;this._base.player.prototype.onPlayStateChange.apply(this,arguments);};ns_API.streaming.mediaPlayer.prototype.getSelectedItem=function(){try{var currentPlaylist=this.player.currentPlaylist;var playlist=this.playLists[currentPlaylist.name];if(!playlist)this.initPlaylist();playlist=this.playLists[currentPlaylist.name];for(var i=0,entry;i<currentPlaylist.count&&(entry=currentPlaylist.item(i));i++)if(this.player.currentMedia.isIdentical(entry))
return playlist.entries[i];}catch(e){
return this.currentItem}};ns_API.streaming.mediaPlayer.prototype.getIndex=function(){try{var currentPlaylist=this.player.currentPlaylist,playlist=this.playLists[currentPlaylist.name];if(!playlist)this.initPlaylist();playlist=this.playLists[currentPlaylist.name];for(var i=0,entry;i<currentPlaylist.count&&(entry=currentPlaylist.item(i));i++)if(this.player.currentMedia.isIdentical(entry))
return i;}catch(e){
return 0;}};ns_API.streaming.mediaPlayer.prototype.getCurrentPlaylist=function(){try{
return this.playLists[this.player.currentPlaylist.name];}catch(e){}};ns_API.streaming.mediaPlayer.prototype.onPlayState_Playing=function(){this.getSelectedItem().currentPosition=Math.floor(this.player.controls.currentPosition*1000);this.dispatchState("play",this.getSelectedItem());};ns_API.streaming.mediaPlayer.prototype.onPlayState_Paused=function(){this.dispatchState("pause",this.getSelectedItem());};ns_API.streaming.mediaPlayer.prototype.onPlayState_Stopped=function(){var entry=this.getSelectedItem();this.doPlaylistEndEvent=true;this.dispatchState("end",entry);this.incrementPlaylist();this.doPlaylistEndEvent=false;this.doPlaylistStartEvent=true;};ns_API.streaming.mediaPlayer.prototype.onOpenState_MediaChanging=function(){this.setEndEventState(this.currentItem);this.dispatchState("end",this.currentItem);};ns_API.streaming.mediaPlayer.prototype.setEndEventState=function(entry){if(entry.clip==this.getCurrentPlaylist().entries.length)this.doPlaylistEndEvent=true;};ns_API.streaming.mediaPlayer.prototype.onPlayState_MediaEnded=function(){var entry=this.getSelectedItem();this.setEndEventState(entry);this.dispatchState("end",entry);if(this.doPlaylistEndEvent)this.incrementPlaylist();};ns_API.streaming.mediaPlayer.prototype.onOpenState_MediaOpen=function(){this.initPlaylist();var entry=this.getSelectedItem();entry.sequence++;this.currentItem=entry;this.doPlaylistEndEvent=false;entry.events=0;entry.totalPlayed=0;entry.playing=null;entry.buffering=false;if(entry.clip==1)this.doPlaylistStartEvent=true;};ns_API.streaming.realPlayer=function(){this.version="1.0.0";this._super.apply(this,arguments);this.type="RealPlayer";this.playStates=["Stopped","Contacting","Buffering","Playing","Paused","Seeking"];this.classId=new RegExp(/CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA/i);this.embedType="";this.realTag="object";this.bufferState=-1;this.doClipEndEvent=false;};ns_API.streaming.realPlayer.prototype=new ns_API.streaming.player;ns_API.streaming.realPlayer.prototype._super=ns_API.streaming.player;ns_API.streaming.realPlayer.prototype.constructor=ns_API.streaming.realPlayer;ns_API.streaming.realPlayer.prototype.onInit=function(){if(this.isInitialized)
return;this._super.prototype.onInit.call(this);try{if(!this.classId.test(this.player.classid))throw "Invalid classid for element\nrequired:"+this.classId.toString();this.realTag="object";}catch(e){this.realTag="embed";}this.setEventHandlers();};ns_API.streaming.realPlayer.prototype.clear=function(){if(this.player){this.player.removeAttribute("SCRIPTCALLBACKS");this.player.removeAttribute("scriptcallbacks");}};ns_API.streaming.realPlayer.prototype.isCompatible=function(){var success=false;try{var version=this.player.GetVersionInfo();success=true;}catch(e){}
return success;};ns_API.streaming.realPlayer.prototype.setEventHandlers=function(){try{var scope=this;if(/object/i.test(this.realTag)&&ns_API.isIE){if(ns_API.isIE7){var lastState;var func=function(){var newState=scope.player.GetPlayState();if(newState!=lastState){try{if(/seeking/i.test(scope.playStates[newState])){scope.onClipClosed.call(scope);}else if(/buffering/i.test(scope.playStates[newState])){scope.onBuffering.call(scope,0);}else if(/contacting/i.test(scope.playStates[newState]))scope.onClipOpened.call(scope);else{if(/buffering/i.test(scope.playStates[lastState]))scope.onBuffering.call(scope,2);if(scope.currentItem&&scope.currentItem!=scope.getSelectedItem())scope.onClipClosed.call(scope);if(!scope.getSelectedItem().isOpened)scope.onClipOpened.call(scope);scope.onPlayStateChange.call(scope,newState);}}catch(e){}}lastState=scope.player.GetPlayState();};setInterval(func,50);}else{this.player.attachEvent("onPostSeek",function(){try{scope.onPostSeek.apply(scope,arguments)}catch(e){}});this.player.attachEvent("onClipOpened",function(){try{scope.onClipOpened.apply(scope,arguments)}catch(e){}});this.player.attachEvent("onBuffering",function(){try{scope.onBuffering.apply(scope,arguments)}catch(e){}});this.player.attachEvent("onPlayStateChange",function(){try{scope.onPlayStateChange.apply(scope,arguments)}catch(e){}});this.player.attachEvent("onClipClosed",function(){try{scope.onClipClosed.apply(scope,arguments)}catch(e){}});}}else{var name=this.player.getAttribute("name");window[name+"_onPostSeek"]=function(){try{scope.onPostSeek.apply(scope,arguments)}catch(e){}};window[name+"_OnBuffering"]=function(){try{scope.onBuffering.apply(scope,arguments)}catch(e){}};window[name+"_OnPlayStateChange"]=function(){try{scope.onPlayStateChange.call(scope,arguments[1])}catch(e){}};window[name+"_onClipOpened"]=function(){try{scope.onClipOpened.apply(scope,arguments)}catch(e){}};window[name+"_onClipClosed"]=function(){try{scope.onClipClosed.apply(scope,arguments)}catch(e){}}}ns_API.addEvent(window,"beforeunload",function(){try{scope._base.clearKeepAlive();scope.onClipClosed.apply(scope)}catch(e){}});}catch(e){throw e.message||e;}};ns_API.streaming.realPlayer.prototype.initPlayList=function(){if(!this.playList){this.playList=new this._base.playlist();this.doPlaylistStartEvent=true;}else if(this.playList&&this.playList.entries>0&&this.playList.entries.length==this.player.GetNumEntries()){
return;}var scope=this;for(var i=0;i<this.player.GetNumEntries();i++){if(!this.playList.entries[i]){var playlistitem=new ns_API.streaming.playlistItem({onPlayingCallback:function(){
return function(){
return(this.getSelectedItem()==this.currentItem)?this.player.GetPosition():this.currentItem.currentPosition;}.apply(scope)},episodeLength:0,clip:i+1,duration:0});playlistitem.uid=this.playList.uid;playlistitem.sequence=0;this.playList.addEntry(playlistitem);}}};ns_API.streaming.realPlayer.prototype.getSelectedItem=function(){this.initPlayList();try{try{if(/stopped/i.test(this.playStates[this.player.GetPlayState()])||this.doClipEndEvent)
return(this.currentItem)?this.currentItem:this.playList.entries[this.player.GetCurrentEntry()];}catch(e){}
return this.playList.entries[this.player.GetCurrentEntry()];}catch(e){
return null}};ns_API.streaming.realPlayer.prototype.getIndex=function(){try{
return this.currentItem.clip-1;}catch(e){
return 0;}};ns_API.streaming.realPlayer.prototype.getCurrentPlaylist=function(){
return this.playList;};ns_API.streaming.realPlayer.prototype.onPostSeek=function(){if(this.player.GetPosition()==this.player.GetLength())this.dispatchState("end",this.getSelectedItem());this.getSelectedItem().currentPosition=this.player.GetPosition();};ns_API.streaming.realPlayer.prototype.onPlayStateChange=function(state){var entry=this.getSelectedItem();if(this.playStates[state]&&/stopped/i.test(this.playStates[state])){var entry=this.getSelectedItem();this.doPlaylistEndEvent=true;if(entry)entry.sequence++;};this._base.player.prototype.onPlayStateChange.apply(this,arguments);if(this.playStates[state]&&/playing/i.test(this.playStates[state]))this.doPlaylistStartEvent=false;};ns_API.streaming.realPlayer.prototype.onPlayState_Playing=function(){var entry=this.getSelectedItem();if(!entry)
return;if(!entry.isOpened)this.onClipOpened();this.doClipEndEvent=false;if(this.currentItem!=entry&&this.currentItem&&this.currentItem.playing){this.doClipEndEvent=true;this.dispatchState("end",this.currentItem);}else{this.doClipEvent=false;}this.currentItem=entry;if(this.player.GetPosition()==this.player.GetLength()&&!this.player.GetLiveState())
return;this.playerVersion=(this.player.GetVersionInfo().replace(/\s/g,"")!="")?this.player.GetVersionInfo():this.playerVersion;this.dispatchState("play",entry);};ns_API.streaming.realPlayer.prototype.onPlayState_Stopped=function(){var entry=this.getSelectedItem();if(!entry)
return;this.doPlaylistEndEvent=true;this.doPlaylistStartEvent=true;this.doClipEndEvent=true;this.dispatchState("end",entry);entry.isOpened=false;this.incrementPlaylist();this.doPlaylistEndEvent=false;};ns_API.streaming.realPlayer.prototype.onPlayState_Paused=function(){this.dispatchState("pause",this.getSelectedItem());};ns_API.streaming.realPlayer.prototype.onClipOpened=function(){if(this._base.DEBUG)this.player.SetMute(true);var entry=this.getSelectedItem();if(!entry)
return;entry.isOpened=true;this.doPlaylistStartEvent=(this.doClipEndEvent||this.doPlayListStartEvent||(!this.currentItem||(this.currentItem.clip!=entry.clip&&entry.clip==1)))?true:false;if(entry!=this.currentItem)entry.sequence++;this.doClipEndEvent=false;entry.currentPosition=0;entry.playing=false;entry.events=0;entry.bufferState=-1;entry.buffering=false;};ns_API.streaming.realPlayer.prototype.onClipClosed=function(){this.doClipEndEvent=true;this.currentItem.isOpened=false;this.dispatchState("end",this.currentItem);};ns_API.streaming.realPlayer.prototype.onPlayState_Buffering=function(){var entry=this.getSelectedItem();this._base.player.prototype.onBuffering.call(this,true);};ns_API.streaming.realPlayer.prototype.onBuffering=function(state){var entry=this.getSelectedItem();if(!entry)
return;if(state!=this.bufferState){this.bufferState=state;this._base.player.prototype.onBuffering.call(this,(state==0)?true:false);}};ns_API.streaming.realPlayer.prototype.setBitrate=function(a_clip_nr,a_bitrate){a_clip_nr=parseInt(a_clip_nr);if(isNaN(a_clip_nr))
return;if(this.userPlaylist&&this.userPlaylist.clips[a_clip_nr-1])this.userPlaylist.clips[a_clip_nr-1].setItemInfo("bitrate",a_bitrate);};ns_API.streaming.realPlayer.prototype.getLabelValue_CA=function(){var playlist=this.getCurrentPlaylist();if(!playlist)
return;var total=0;for(var i=0,value,entry;(entry=playlist.entries[i]);i++){value=entry["info"]["duration"];total+=(value=="undefined"||isNaN(parseInt(value))?0:parseInt(value));if(value==0){value=this.getClipInfo("duration",i,null,this.getDurationFromString);total+=(value=="undefined"||isNaN(parseInt(value))?0:parseInt(value));}}
return total};ns_API.streaming.realPlayer.prototype.getLabelValue_LI=function(){
return this.player.GetLiveState()};ns_API.streaming.realPlayer.prototype.getLabelValue_UB=function(){
return this.player.GetBandwidthAverage();};ns_API.streaming.realPlayer.prototype.getLabelValue_CS=function(){
return String(this.player.GetClipWidth()+"x"+String(this.player.GetClipHeight()));};ns_API.streaming.realPlayer.prototype.getLabelValue_BR=function(){
return this.getClipInfo("bitrate",this.getIndex(),this.getSelectedItem())};ns_API.streaming.realPlayer.prototype.getLabelValue_ER=function(){
return(this.player.GetLastErrorUserString()!="")?this.player.GetLastErrorUserString():null;};ns_API.streaming.realPlayer.prototype.getEpisodeLength=function(_entry){var episode=_entry.getItemInfo("episode"),total=0;if(episode=="")
return _entry.getItemInfo("duration");for(var i=0,entry;(entry=this.playList.entries[0]);i++){if(entry.getItemInfo("episode")==episode)total+=entry.getItemInfo("duration");}
return(total==0)?null:total;};ns_API.streaming.exceptions={};ns_API.streaming.exceptions.ReservedLabelException=function(){
return{message:"Label is reserved."}};ns_API.streaming.exceptions.InvalidLabelException=function(){
return{message:"Label format is invalid."}};ns_API.streaming.exceptions.ReservedEventException=function(){
return{message:"Event is reserved."}};ns_API.streaming.eventRegExp=function(){
return{"play":new RegExp(ns_API.streaming.events.play.join("|"),"i"),"pause":new RegExp(ns_API.streaming.events.pause.join("|"),"i"),"end":new RegExp(ns_API.streaming.events.end.join("|"),"i")}}();ns_API.streaming.player.prototype.addEndEventLabel=function(a_label,a_callback){if(this._base.eventRegExp["end"].test(a_label))if(this._base.DEBUG)throw new this._base.exceptions["ReservedLabelException"];else return;if(!/^[a-z]{1,50}$/i.test(a_label))if(this._base.DEBUG)throw new this._base.exceptions["InvalidLabelException"];else return;var reg=new RegExp(this._base.events.end.join("|"),"i");if(!reg.test(a_label))this._base.events.end.push(a_label);var callback=a_callback;this["getLabelValue_"+a_label.toUpperCase()]=function(){
return(this.doPlaylistEndEvent)?(callback instanceof Function)?callback():callback:null}};ns_API.streaming.player.prototype.resetEndEventLabels=function(){this._base.events.end=this._base.eventRegExp["end"].source.split("|");};ns_API.streaming.player.prototype.dispatchEvent=function(a_event,a_labels){a_event=a_event||new String();a_labels=a_labels||new String();if(/^\s*(play|pause|end|keep-alive)\s*$/i.test(a_event))if(this._base.DEBUG)throw new this._base.exceptions["ReservedEventException"];else return;this._base.events[a_event]=this._base.eventRegExp["pause"].source.split("|");var labels=this.getLabelValues(a_event)||{},arrCustom=a_labels.split(";");var reg=new RegExp(/([^\=]+)(?:\=([^&]+))?/i);for(var i=0,custom,pair;(custom=arrCustom[i]);i++){pair=reg.exec(custom);if(!pair)continue;if(ns_API.reservedLabels.test(pair[1]))if(this._base.DEBUG)throw new this._base.exceptions["InvalidLabelException"];else continue;this._base.events[a_event].push(pair[1]);labels[pair[1]]=pair[2];}this._base.log(a_event,labels,function(label){
return!ns_API.streaming.eventRegExp["pause"].test(label);});delete this._base.events[a_event];};