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){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(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:"1.0.0",DEBUG: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;events[ev]=labels;
return true;},clearCustomEvent:function(ev){if(events[ev])delete events[ev];},getScriptVersion:function(){
return version},init:function(){try{if(url=="")url=window.ns_pixelUrl.match(ns_API.regCounter)[0];for(var i=0,player;(player=players[i]);i++){if(player.onInit instanceof Function){try{player.onInit.call(player);}catch(e){throwException(e)}}}}catch(e){throwException(e);}},throwException:function(e){if(DEBUG)alert("Streaming API\n"+(e.message||e));},uniqueID:function(){var time=new Date().getTime();if(!uniqueIds[time])uniqueIds[time]=0;uniqueIds[time]++;
return String(time+"#"+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,keepAliveInterval*6e4);else log("keep-alive",{});},enableKeepAlive:function(player){if(!player.keepalive)setKeepAlive(player);},clearKeepAlive:function(player){if(player&&player.keepalive)clearInterval(player.keepalive);},log:function(ev,labels,callback){if(!labels)
return;try{if(url=="")throw "Please specify a valid sitestat url";var qs=["&"+label_prefix+"ev="+ev,"ns_type=hidden","ns_ts="+new Date().getTime()];if(!events[ev])
return;var regex=new RegExp();for(var label in labels){if(ns_API.reservedLabels.test(label))continue;regex.compile(label,"i");if(((labels[label]!=""&&labels[label]!="null")||labels[label]==0)&&labels[label]!=null&&typeof labels[label]!="undefined"&&(regex.test(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().compile(label+"[\||$]","i").test(events[ev].join("|")))?"":label_prefix)+label+"="+String(escape(labels[label]).substring(0,200)));}}window["ns_img"+incLogs]=new Image();window["ns_img"+incLogs].src=url+qs.join("&");if(DEVELOPER){if(debugLabels){var arr=[];for(var j=0;j<qs.length;j++){if(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;}incLogs++;}catch(e){throwException(e)}},getLabels:function(ev){
return(events[ev])?events[ev]:null},getURL:function(){
return url;},setURL:function(_url){url=_url;},register:function(player){players.push(player);},_construct:ns_API.addLoadEvent(function(){ns_API.streaming.init.apply(ns_API.streaming)})}}();};ns_API.streaming.playlist=function(){entries=[];uid=ns_API.streaming.uniqueID();sequence=1;};ns_API.streaming.playlist.prototype.addEntry=function(entry){entries.push(entry);entry.uid=uid;entry.clip=entries.length;};ns_API.streaming.playlist.prototype.getTotalValues=function(key){var total=0,value;for(var i=0,entry;(entry=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 getTotalValues("totalPlayed");};ns_API.streaming.playlist.prototype.getTotalEvents=function(){
return getTotalValues("events");};ns_API.streaming.playlist.prototype.getPlayListLength=function(){
return getTotalValues("duration");};ns_API.streaming.playlist.prototype.getTotalBufferTime=function(){var total=0;for(var i=0,entry;(entry=entries[i]);i++)total+=entry.getBufferTime();
return total;};ns_API.streaming.playlistItem=function(options){options=options||{};uid=0;sequence=0;buffer=[];__bufferstart=0;currentPosition=0;events=0;playStart=0;totalPlayed=0;playTime=0;episodeLength=options.episodeLength||0;clip=options.clip||1;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||""};playing=false;paused=false;buffering=false;timer=null;onPlayingCallback=options.onPlayingCallback;};ns_API.streaming.playlistItem.prototype.clear=function(){buffer=[];events=0;playStart=0;playTime=0;totalPlayed=0;};ns_API.streaming.playlistItem.prototype.play=function(player){if(buffering)bufferEnd();if(playing)
return;playStart=new Date().getTime();var scope=this;timer=window.setInterval(function(){try{scope.onPlaying.call(scope)}catch(e){}},100);playing=true;paused=false;ns_API.streaming.enableKeepAlive(this);};ns_API.streaming.playlistItem.prototype.pause=function(player){events++;paused=true;if(timer)window.clearInterval(timer);playing=false;};ns_API.streaming.playlistItem.prototype.end=function(player){if(!playing&&playing!=null)
return;ns_API.streaming.clearKeepAlive(this);if(timer)window.clearInterval(timer);playing=false;paused=false;};ns_API.streaming.playlistItem.prototype.onPlaying=function(){if(onPlayingCallback instanceof Function)currentPosition=onPlayingCallback();};ns_API.streaming.playlistItem.prototype.addPlayingTime=function(){totalPlayed+=(new Date().getTime()-playStart);playStart=new Date().getTime();};ns_API.streaming.playlistItem.prototype.bufferStart=function(player){if(playing){addPlayingTime();player.dispatchState("end",this);playing=false;buffering=true;}__bufferstart=new Date().getTime()};ns_API.streaming.playlistItem.prototype.bufferEnd=function(player){buffering=false;if(__bufferstart&&parseInt(__bufferstart)>0)buffer.push(new Date().getTime()-__bufferstart);};ns_API.streaming.playlistItem.prototype.getBufferTime=function(){var buffer=0;for(var i=0;i<buffer.length;i++)buffer+=parseInt(buffer[i]);
return buffer;};ns_API.streaming.playlistItem.prototype.getItemInfo=function(_key){if(info[_key])
return info[_key];};ns_API.streaming.playlistItem.prototype.setItemInfo=function(_key,_value){if(typeof _value!="undefined"&&_value!="")info[_key]=_value;};ns_API.streaming.player=function(ref){_base=ns_API.streaming;ref=ref;keepalive=null;player=null;playerVersion="x.x";userPlaylist={title:"",clips:[]};playLists={};playList=null;classId=null;hasPlaylist=false;embedType=null;currentItem=null;doPlaylistEndEvent=false;doPlaylistStartEvent=true;if(arguments.callee.caller)construct();};ns_API.streaming.player.prototype.construct=function(){_base.register(this);};ns_API.streaming.player.prototype.onInit=function(){player=(typeof ref=="string")?((document.getElementById(ref)!=null)?document.getElementById(ref):(window[ref])?window[ref]:document[ref]):ref;if(!ns_API.isIE&&player&&!/embed/i.test(player.tagName))player=document[player.getElementsByTagName("embed")[0].name];if(!player||!player.tagName)throw("DomElement not found");};ns_API.streaming.player.prototype.clearPlaylist=function(){playList=null;userPlaylist={title:"",clips:[]};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)obj[label]=this["getLabelValue_"+label.toUpperCase()]();}
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")_base.log(state,getLabelValues(state));entry[state].call(entry,this);doPlaylistStartEvent=false;};ns_API.streaming.player.prototype.onOpenStateChange=function(state){if(this["onOpenState_"+openStates[state]] instanceof Function)this["onOpenState_"+openStates[state]].apply(this,arguments);};ns_API.streaming.player.prototype.onPlayStateChange=function(state){if(this["onPlayState_"+playStates[state]] instanceof Function)this["onPlayState_"+playStates[state]].apply(this,arguments);};ns_API.streaming.player.prototype.onBuffering=function(start){var entry=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){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(!userPlaylist.clips)userPlaylist.clips=[];if(userPlaylist.clips.length<a_clip_nr)userPlaylist.clips.length=a_clip_nr;userPlaylist.clips[a_clip_nr-1]=new _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(userPlaylist&&userPlaylist.clips&&userPlaylist.clips[clip_nr])
return(callback instanceof Function)?callback(userPlaylist.clips[clip_nr].getItemInfo(key)):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(userPlaylist&&userPlaylist.clips&&userPlaylist.clips[clip_nr])
return 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=getCurrentPlaylist();clearClipIncrements(playlist);playlist.sequence++;};ns_API.streaming.player.prototype.getCurrentPlaylist=function(){};ns_API.streaming.player.prototype.getLabelValue_PB=function(){
return(doPlaylistStartEvent)?1:null};ns_API.streaming.player.prototype.getLabelValue_PE=function(){
return(doPlaylistEndEvent)?1:null};ns_API.streaming.player.prototype.getLabelValue_MP=function(){
return type};ns_API.streaming.player.prototype.getLabelValue_MV=function(){
return playerVersion};ns_API.streaming.player.prototype.getLabelValue_SV=function(){
return _base.version};ns_API.streaming.player.prototype.getLabelValue_EL=function(){
return getSelectedItem().episodeLength};ns_API.streaming.player.prototype.getLabelValue_CN=function(){
return getSelectedItem().clip};ns_API.streaming.player.prototype.getLabelValue_PT=function(){
return getSelectedItem().totalPlayed};ns_API.streaming.player.prototype.getLabelValue_PC=function(){
return getSelectedItem().events};ns_API.streaming.player.prototype.getLabelValue_SQ=function(){var entry=getSelectedItem();entry.sequence=Math.max(1,entry.sequence);
return entry.sequence};ns_API.streaming.player.prototype.getLabelValue_PO=function(){
return getSelectedItem().currentPosition};ns_API.streaming.player.prototype.getLabelValue_CL=function(){
return getClipInfo("duration",getIndex(),getSelectedItem(),getDurationFromString)};ns_API.streaming.player.prototype.getLabelValue_BT=function(){
return getSelectedItem().getBufferTime()};ns_API.streaming.player.prototype.getLabelValue_PR=function(){
return getClipInfo("program",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_EP=function(){
return getClipInfo("episode",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_PN=function(){
return getClipInfo("part",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_DT=function(){
return getClipInfo("date",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_FEE=function(){
return getClipInfo("fee",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_TY=function(){
return getClipInfo("streamtype",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_ST=function(){
return getClipInfo("station",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_TP=function(){
return getClipInfo("totalparts",getIndex(),getSelectedItem())};ns_API.streaming.player.prototype.getLabelValue_ID=function(){
return getSelectedItem().uid};ns_API.streaming.player.prototype.getLabelValue_SP=function(){
return getCurrentPlaylist().sequence};ns_API.streaming.player.prototype.getLabelValue_CA=function(){
return(doPlaylistEndEvent)?getCurrentPlaylist().getPlayListLength():null};ns_API.streaming.player.prototype.getLabelValue_BP=function(){
return(doPlaylistEndEvent)?getCurrentPlaylist().getTotalBufferTime():null};ns_API.streaming.player.prototype.getLabelValue_PA=function(){
return(doPlaylistEndEvent)?getCurrentPlaylist().getTotalPlayingTime():null};ns_API.streaming.player.prototype.getLabelValue_PP=function(){
return(doPlaylistEndEvent)?getCurrentPlaylist().getTotalEvents():null};ns_API.streaming.player.prototype.getLabelValue_CP=function(){
return getCurrentPlaylist().entries.length};ns_API.streaming.player.prototype.getLabelValue_PL=function(){
return(userPlaylist.title.replace(/\s/g,"")!="")?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(){_super.apply(this,arguments);type="MediaPlayer";classId=new RegExp(/6BF52A52-394A-11D3-B153-00C04F79FAA6/i);embedType="";openStates=["undefined","PlaylistChanging","PlaylistLocating","PlaylistConnecting","PlaylistLoading","PlaylistOpening","PlaylistOpenNoMedia","PlaylistChanged","MediaChanging","MediaLocating","MediaConnecting","MediaLoading","MediaOpening","MediaOpen","BeginCodecAcquisition","EndCodecAcquisition","BeginLicenseAcquisition","EndLicenseAcquisition","BeginIndividualization","EndIndividualization","MediaWaiting","OpeningUnknownUrl"];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(){_super.prototype.onInit.call(this);if(!ns_API.isIE)throw "Internet Explorer needed";if(!classId.test(player.classid))throw "Invalid classid for element\nrequired:"+classId.toString();if(_base.DEBUG)player.settings.mute=true;playerVersion=player.versionInfo;setEventHandlers();};ns_API.streaming.mediaPlayer.prototype.setEventHandlers=function(){var scope=this;player.SendPlayStateChangeEvents=1;player.SendOpenStateChangeEvents=1;player.attachEvent("PositionChange",function(){try{scope.onPositionChange.apply(scope,arguments)}catch(e){}});player.attachEvent("PlayStateChange",function(){try{scope.onPlayStateChange.apply(scope,arguments)}catch(e){}});player.attachEvent("OpenStateChange",function(){try{scope.onOpenStateChange.apply(scope,arguments)}catch(e){}});player.attachEvent("buffering",function(){try{scope.onBuffering.apply(scope,arguments)}catch(e){}});};ns_API.streaming.mediaPlayer.prototype.initPlaylist=function(){var playlist=player.currentPlaylist,scope=this;if(!playLists[playlist.name])playLists[playlist.name]=new _base.playlist();for(var i=0,entry,playlistitem;i<playlist.count&&(entry=playlist.item(i));i++){if(playLists[player.currentPlaylist.name].entries[i]){playLists[player.currentPlaylist.name].entries[i].setItemInfo("duration",calculateDuration(entry));}else{playlistitem=new ns_API.streaming.playlistItem({onPlayingCallback:function(){
return Math.floor(scope.player.controls.currentPosition)*1000},episodeLength:getEpisodeLength(entry),clip:i+1,duration: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=playLists[player.currentPlaylist.name].uid;playLists[playlist.name].addEntry(playlistitem);}}};ns_API.streaming.mediaPlayer.prototype.getEpisodeLength=function(_entry){var episode=_entry.getItemInfo("episode");if(episode=="")
return calculateDuration(_entry);var total=0;for(var i=0,entry;i<player.currentPlaylist.count&&(entry=player.currentPlaylist.item(i));i++)if(entry.getItemInfo("episode")==episode)total+=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 player.network.bandWidth;};ns_API.streaming.mediaPlayer.prototype.getLabelValue_PL=function(){if(userPlaylist.title.replace(/\s/g,"")!=""){
return userPlaylist.title;}else{var title=player.currentPlaylist.getItemInfo("playlist");try{
return(/^\s*$/.test(title))?null:title;}catch(e){}}};ns_API.streaming.mediaPlayer.prototype.getLabelValue_CS=function(){try{
return String(player.currentMedia.imageSourceWidth+"x"+String(player.currentMedia.imageSourceHeight));}catch(e){}};ns_API.streaming.mediaPlayer.prototype.getLabelValue_BR=function(){try{
return player.currentMedia.getItemInfo("Bitrate");}catch(e){}};ns_API.streaming.mediaPlayer.prototype.getLabelValue_ER=function(){
return(player&&player.currentMedia&&player.currentMedia.error)?player.currentMedia.error.errorDescription:null;};ns_API.streaming.mediaPlayer.prototype.onPositionChange=function(){getSelectedItem().currentPosition=Math.floor(player.controls.currentPosition*1000);};ns_API.streaming.mediaPlayer.prototype.onPlayStateChange=function(state){if(state==1)doPlaylistEndEvent=true;_base.player.prototype.onPlayStateChange.apply(this,arguments);};ns_API.streaming.mediaPlayer.prototype.getSelectedItem=function(){try{var currentPlaylist=player.currentPlaylist;var playlist=playLists[currentPlaylist.name];if(!playlist)initPlaylist();playlist=playLists[currentPlaylist.name];for(var i=0,entry;i<currentPlaylist.count&&(entry=currentPlaylist.item(i));i++)if(player.currentMedia.isIdentical(entry))
return playlist.entries[i];}catch(e){
return currentItem}};ns_API.streaming.mediaPlayer.prototype.getIndex=function(){try{var currentPlaylist=player.currentPlaylist,playlist=playLists[currentPlaylist.name];if(!playlist)initPlaylist();playlist=playLists[currentPlaylist.name];for(var i=0,entry;i<currentPlaylist.count&&(entry=currentPlaylist.item(i));i++)if(player.currentMedia.isIdentical(entry))
return i;}catch(e){
return 0;}};ns_API.streaming.mediaPlayer.prototype.getCurrentPlaylist=function(){try{
return playLists[player.currentPlaylist.name];}catch(e){}};ns_API.streaming.mediaPlayer.prototype.onPlayState_Playing=function(){getSelectedItem().currentPosition=Math.floor(player.controls.currentPosition*1000);dispatchState("play",getSelectedItem());};ns_API.streaming.mediaPlayer.prototype.onPlayState_Paused=function(){dispatchState("pause",getSelectedItem());};ns_API.streaming.mediaPlayer.prototype.onPlayState_Stopped=function(){var entry=getSelectedItem();doPlaylistEndEvent=true;dispatchState("end",entry);incrementPlaylist();doPlaylistEndEvent=false;doPlaylistStartEvent=true;};ns_API.streaming.mediaPlayer.prototype.onOpenState_MediaChanging=function(){setEndEventState(currentItem);dispatchState("end",currentItem);};ns_API.streaming.mediaPlayer.prototype.setEndEventState=function(entry){if(entry.clip==getCurrentPlaylist().entries.length)doPlaylistEndEvent=true;};ns_API.streaming.mediaPlayer.prototype.onPlayState_MediaEnded=function(){var entry=getSelectedItem();setEndEventState(entry);dispatchState("end",entry);if(doPlaylistEndEvent)incrementPlaylist();};ns_API.streaming.mediaPlayer.prototype.onOpenState_MediaOpen=function(){initPlaylist();var entry=getSelectedItem();entry.sequence++;currentItem=entry;doPlaylistEndEvent=false;entry.events=0;entry.totalPlayed=0;entry.playing=null;entry.buffering=false;if(entry.clip==1)doPlaylistStartEvent=true;};ns_API.streaming.realPlayer=function(){version="1.0.0";_super.apply(this,arguments);type="RealPlayer";playStates=["Stopped","Contacting","Buffering","Playing","Paused","Seeking"];classId=new RegExp(/CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA/i);embedType="";realTag="object";bufferState=-1;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(){_super.prototype.onInit.call(this);try{if(!classId.test(player.classid))throw "Invalid classid for element\nrequired:"+classId.toString();realTag="object";}catch(e){realTag="embed";}setEventHandlers();};ns_API.streaming.realPlayer.prototype.setEventHandlers=function(){try{var scope=this;if(/object/i.test(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{player.attachEvent("onPostSeek",function(){try{scope.onPostSeek.apply(scope,arguments)}catch(e){}});player.attachEvent("onClipOpened",function(){try{scope.onClipOpened.apply(scope,arguments)}catch(e){}});player.attachEvent("onBuffering",function(){try{scope.onBuffering.apply(scope,arguments)}catch(e){}});player.attachEvent("onPlayStateChange",function(){try{scope.onPlayStateChange.apply(scope,arguments)}catch(e){}});player.attachEvent("onClipClosed",function(){try{scope.onClipClosed.apply(scope,arguments)}catch(e){}});}}else{var name=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(!playList){playList=new _base.playlist();doPlaylistStartEvent=true;}else if(playList&&playList.entries>0&&playList.entries.length==player.GetNumEntries()){
return;}var scope=this;for(var i=0;i<player.GetNumEntries();i++){if(!playList.entries[i]){var playlistitem=new ns_API.streaming.playlistItem({onPlayingCallback:function(){
return function(){
return(getSelectedItem()==currentItem)?player.GetPosition():currentItem.currentPosition;}.apply(scope)},episodeLength:0,clip:i+1,duration:0});playlistitem.uid=playList.uid;playlistitem.sequence=0;playList.addEntry(playlistitem);}}};ns_API.streaming.realPlayer.prototype.getSelectedItem=function(){initPlayList();try{try{if(/stopped/i.test(playStates[player.GetPlayState()])||doClipEndEvent)
return(currentItem)?currentItem:playList.entries[player.GetCurrentEntry()];}catch(e){}
return playList.entries[player.GetCurrentEntry()];}catch(e){
return null}};ns_API.streaming.realPlayer.prototype.getIndex=function(){try{
return currentItem.clip-1;}catch(e){
return 0;}};ns_API.streaming.realPlayer.prototype.getCurrentPlaylist=function(){
return playList;};ns_API.streaming.realPlayer.prototype.onPostSeek=function(){if(player.GetPosition()==player.GetLength())dispatchState("end",getSelectedItem());getSelectedItem().currentPosition=player.GetPosition();};ns_API.streaming.realPlayer.prototype.onPlayStateChange=function(state){var entry=getSelectedItem();if(playStates[state]&&/stopped/i.test(playStates[state])){var entry=getSelectedItem();doPlaylistEndEvent=true;if(entry)entry.sequence++;};_base.player.prototype.onPlayStateChange.apply(this,arguments);if(playStates[state]&&/playing/i.test(playStates[state]))doPlaylistStartEvent=false;};ns_API.streaming.realPlayer.prototype.onPlayState_Playing=function(){var entry=getSelectedItem();if(!entry)
return;if(!entry.isOpened)onClipOpened();doClipEndEvent=false;if(currentItem!=entry&&currentItem&&currentItem.playing){doClipEndEvent=true;dispatchState("end",currentItem);}else{doClipEvent=false;}currentItem=entry;if(player.GetPosition()==player.GetLength()&&!player.GetLiveState())
return;playerVersion=(player.GetVersionInfo().replace(/\s/g,"")!="")?player.GetVersionInfo():playerVersion;dispatchState("play",entry);};ns_API.streaming.realPlayer.prototype.onPlayState_Stopped=function(){var entry=getSelectedItem();if(!entry)
return;doPlaylistEndEvent=true;doPlaylistStartEvent=true;doClipEndEvent=true;dispatchState("end",entry);entry.isOpened=false;incrementPlaylist();doPlaylistEndEvent=false;};ns_API.streaming.realPlayer.prototype.onPlayState_Paused=function(){dispatchState("pause",getSelectedItem());};ns_API.streaming.realPlayer.prototype.onClipOpened=function(){if(_base.DEBUG)player.SetMute(true);var entry=getSelectedItem();if(!entry)
return;entry.isOpened=true;doPlaylistStartEvent=(doClipEndEvent||doPlayListStartEvent||(!currentItem||(currentItem.clip!=entry.clip&&entry.clip==1)))?true:false;if(entry!=currentItem)entry.sequence++;doClipEndEvent=false;entry.currentPosition=0;entry.playing=false;entry.events=0;entry.bufferState=-1;entry.buffering=false;};ns_API.streaming.realPlayer.prototype.onClipClosed=function(){doClipEndEvent=true;currentItem.isOpened=false;dispatchState("end",currentItem);};ns_API.streaming.realPlayer.prototype.onPlayState_Buffering=function(){var entry=getSelectedItem();_base.player.prototype.onBuffering.call(this,true);};ns_API.streaming.realPlayer.prototype.onBuffering=function(state){var entry=getSelectedItem();if(!entry)
return;if(state!=bufferState){bufferState=state;_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(userPlaylist&&userPlaylist.clips[a_clip_nr-1])userPlaylist.clips[a_clip_nr-1].setItemInfo("bitrate",a_bitrate);};ns_API.streaming.realPlayer.prototype.getLabelValue_CA=function(){var playlist=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=getClipInfo("duration",i,null,getDurationFromString);total+=(value=="undefined"||isNaN(parseInt(value))?0:parseInt(value));}}
return total};ns_API.streaming.realPlayer.prototype.getLabelValue_LI=function(){
return player.GetLiveState()};ns_API.streaming.realPlayer.prototype.getLabelValue_UB=function(){
return player.GetBandwidthAverage();};ns_API.streaming.realPlayer.prototype.getLabelValue_CS=function(){
return String(player.GetClipWidth()+"x"+String(player.GetClipHeight()));};ns_API.streaming.realPlayer.prototype.getLabelValue_BR=function(){
return getClipInfo("bitrate",getIndex(),getSelectedItem())};ns_API.streaming.realPlayer.prototype.getLabelValue_ER=function(){
return(player.GetLastErrorUserString()!="")?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=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(_base.eventRegExp["end"].test(a_label))if(_base.DEBUG)throw new _base.exceptions["ReservedLabelException"];else return;if(!/^[a-z]{1,50}$/i.test(a_label))if(_base.DEBUG)throw new _base.exceptions["InvalidLabelException"];else return;var reg=new RegExp(_base.events.end.join("|"),"i");if(!reg.test(a_label))_base.events.end.push(a_label);var callback=a_callback;this["getLabelValue_"+a_label.toUpperCase()]=function(){
return(doPlaylistEndEvent)?(callback instanceof Function)?callback():callback:null}};ns_API.streaming.player.prototype.resetEndEventLabels=function(){_base.events.end=_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(_base.DEBUG)throw new _base.exceptions["ReservedEventException"];else return;_base.events[a_event]=_base.eventRegExp["pause"].source.split("|");var labels=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(_base.DEBUG)throw new _base.exceptions["InvalidLabelException"];else continue;_base.events[a_event].push(pair[1]);labels[pair[1]]=pair[2];}_base.log(a_event,labels,function(label){
return!ns_API.streaming.eventRegExp["pause"].test(label);});delete _base.events[a_event];};
