(function(){eval(ustream.namespace);ustream.classes.Html5Video=$.klass({options:{autoplay:false,preload:false},videoCapability:!!document.createElement("video").canPlayType,supported:false,supportedAgents:[],supportedPages:[],video:null,agent:"",html:"",initialize:function(id,options){this.id=id;
this.options=merge(this.options,options||{});this.checkSupport()},checkSupport:function(){if(this.videoCapability&&this.checkAgent()&&$.inArray(ustream.vars.pageId,this.supportedPages)!==-1){this.supported=true
}else{this.supported=false}},checkAgent:function(){var supAgentsLength=this.supportedAgents.length,i;
for(i=0;i<supAgentsLength;i++){if(navigator.userAgent.toLowerCase().indexOf(this.supportedAgents[i])!==-1){this.agent=this.supportedAgents[i];
return true}}return false}})})();
(function(){eval(ustream.namespace);ustream.classes.Html5Viewer=$.klass({options:{autoplay:false,preload:false},supportedAgents:["iphone","ipad","ipod"],mediaTypes:{CHANNEL:"channel",VIDEO:"video",HIGHLIGHT:"highlight"},mediaId:0,videoCapability:!!document.createElement("video").canPlayType,supported:false,isReady:false,agent:"",html:'<iframe id="<%= id %>"src="/embed/<%= embedUrl %>?sitemode=1" width="<%= width %>" height="<%= height %>" scrolling="no" frameborder="0" style="border: 0px none transparent;"></iframe>',initialize:function(id,options){var o,fv;
this.id=id;this.options=$.klass.merge(this.options,options||{});ustream.vars.mteReferrer=document.referrer||"unknown";
o=this.options;this.checkSupport();if(this.supported){this.html=new ustream.classes.SimpleTpl(this.html);
fv=o.flashvars;o.autoplay=(fv.autoplay==="true");o.cid=fv.cid||false;o.vid=fv.vid||false;o.hid=fv.hid||false;
this.createHtml()}},createHtml:function(){var o=this.options;o.embedUrl="";if(o.cid){this.mediaId=o.embedUrl=o.cid;
this.type=this.mediaTypes.CHANNEL}if(o.vid){this.mediaId=o.embedUrl="recorded/"+o.vid;this.type=this.mediaTypes.VIDEO
}if(o.hid){o.embedUrl+="/highlight/"+o.hid;this.type=this.mediaTypes.HIGHLIGHT}o.embedUrl+=window.location.search;
$("#"+o.id).replaceWith(this.html.run(o));this.viewer=$("#"+o.id);this.viewer[0].contentWindow.addEventListener("MTEReady",$.proxy(this.ready,this))
},checkSupport:function(){if(this.videoCapability&&this.checkAgent()){this.supported=true}else{this.supported=false
}},checkAgent:function(){var supAgentsLength=this.supportedAgents.length,nav=navigator.userAgent.toLowerCase(),i;
for(i=0;i<supAgentsLength;i+=1){if(nav.indexOf(this.supportedAgents[i])!==-1){this.agent=this.supportedAgents[i];
return true}}return false},create:function(){$.console.log('DEPRECATED "html5viewer.create();" called');
$.console.trace()},ready:function(){this.viewer.exposed=this.viewer[0].contentWindow.MTEexposed;this.isReady=true;
this.executeQueuedFunctions()},pipe:function(method){if(!this.isReady){if(!this._pipeQueue){this._pipeQueue=[]
}this._pipeQueue.push(arguments);return}var args=($.makeArray(arguments)).slice(1),r;if(this.viewer.exposed[method]){r=this.viewer.exposed[method].apply(this.viewer.exposed,args)
}return r},executeQueuedFunctions:function(){if(this._pipeQueue){while(this._pipeQueue.length){this.pipe.apply(this,this._pipeQueue.shift())
}this._pipeQueue=null}},play:function(){this.pipe("play")},pause:function(){this.pipe("pause")},stop:function(){this.pipe("stop");
this.pipe("seek",0)},loadMedia:function(type,id){this.type=type;this.mediaId=+id;this.pipe("load",type,this.mediaId)
},createMediaItem:function(){this.loadMedia(this.type,this.mediaId)},createChannel:function(cid){this.loadMedia(this.mediaTypes.CHANNEL,cid)
},loadChannel:function(cid){this.loadMedia(this.mediaTypes.CHANNEL,cid)},changeToChannel:function(){this.createMediaItem()
},createRecord:function(vid){this.loadMedia(this.mediaTypes.VIDEO,vid)},changeToRecorded:function(vid){this.createRecord(vid)
},getChannelId:function(){return this.pipe("getCid")},getViewerCount:function(){return this.pipe("getViewers")
},getDuration:function(){return this.pipe("getDuration")}})}());

