(function(d,e){var a=function(g,h){this.$window=d(window);this.$document=d(document);this.element=g;this.$element=d(g);this.options=d.extend({},d.fn.strobemediaplaybackchrome.defaults,h)};var c={initialize:function(){if(!this.options.javascriptControls){this.$element.find(".strobeMediaPlaybackControlBar,.smp-error,.playoverlay").hide();return}this.$player=this.$element;this.player=this.element;this.sliding=false;this.$element=d("#strobemediaplayback");this.playOverlay=this.$element.find(".playoverlay");this.play=this.$element.find(".smp.play");this.mute=this.$element.find(".smp.volume");this.time=this.$element.find(".time");this.currentTimeLabel=this.$element.find(".currentTime");this.durationLabel=this.$element.find(".duration");this.errorOverlay=this.$element.find(".smp-error");this.fullscreen=this.$element.find(".fullscreen");this.play.bind("click",this,this.onPlayClick);this.playOverlay.bind("click",this,this.onPlayClick);this.mute.bind("click",this,this.onMuteClick);this.mute.bind("mouseover",this,this.onMuteOver);this.fullscreen.bind("click",this,this.onFullScreenClick);this.$player.bind("play",this,this.onPlay);this.$player.bind("pause",this,this.onPause);this.$player.bind("volumechange",this,this.onVolumeChange);this.$player.bind("durationchange",this,this.onDurationChange);this.$player.bind("timeupdate",this,this.onTimeUpdate);this.$player.bind("waiting",this,this.onWaiting);this.$player.bind("seeking",this,this.onSeeking);this.$player.bind("seeked",this,this.onSeeked);this.$player.bind("ended",this,this.onPause);this.$player.bind("error",this,this.onError);this.$player.bind("progress",this,this.onProgress);this.timeTrack=this.$element.find(".video-track");this.slider=this.$element.find(".slider");this.played=this.$element.find(".played");this.buffered=this.$element.find(".buffered");this.slider.bind("mousedown",this,this.onSliderMouseDown);this.slider.bind("touchstart",this,this.onSliderMouseDown);this.timeTrack.bind("mousedown",this,this.onTimeTrackClick);this.$window.bind("orientationchange",this,this.onOrinetationChangeOrResize);this.$window.bind("resize",this,this.onOrinetationChangeOrResize);if(options.disabledControls){this.$element.find(options.disabledControls).addClass("disabled")}this.isFullScreen=false;this.layoutControlBar(this.options.width,this.options.height);if("HTMLCanvasElement" in window){var g=d("#volumeSliderContainer").get(0);this.storedVolume=options.startingVolume;this.volumeSlider=new mc.VSlider(g,0,0,parseInt(getCookie("pegtv_Volume")*100),function(j){var i=document.getElementById("strobeMediaPlaybackId");var h=j.getValue()/100;i.volume=h;setCookie("pegtv_Volume",h,900)});d("#innerCanvas").css("border","0px none");d("#volumeSliderContainer").css("visibility","hidden");d("#innerCanvas").bind("mouseout",this,function(h){d("#volumeSliderContainer").css("visibility","hidden")})}},onSliderMouseDown:function(g){var l,j,p;if(!g.data.sliding){g.preventDefault();p=g.data.player;g.data.sliding=true;l=p.duration;g.data.onProgress(g);var n=g.data.timeTrack;var o=g.data.slider;var m=g.data.$document;m.bind("mousemove",g.data,h);m.bind("touchmove",g.data,h);m.bind("mouseup",g.data,i);m.bind("touchend",g.data,i);m.bind("touchcancel",g.data,k)}function h(w){w.preventDefault();var v=w.data.timeTrack.outerWidth();var s=w.data.timeTrack.offset().left;var r=w.clientX;var q=w.originalEvent;if(typeof r=="undefined"&&q&&q.touches&&q.touches.length>0){r=q.touches[0].pageX}var u=(r-s)/(v);j=l*u;if(j<l&&j>0){var t=(Math.max(0,j)/l*100);w.data.slider.css({left:t+"%"});w.data.played.css({width:t+"%"});w.data.seekTime=j;w.data.onProgress(w)}}function i(q){m.unbind("mousemove");m.unbind("touchmove");m.unbind("mouseup");m.unbind("touchend");if(j>0){q.data.seekTime=0;p.currentTime=j}q.data.sliding=false}function k(q){q.data.seekTime=0;q.data.sliding=false}},onOrinetationChangeOrResize:function(g){g.data.layoutControlBar(g.data.options.width,g.data.options.height)},onPlayClick:function(h){var g=h.data.player;if(g.paused){g.play()}else{g.pause()}},onMuteClick:function(h){var g=h.data.player;if(!g.muted){h.data.storedVolume=h.data.volumeSlider.getValue();h.data.volumeSlider.setValue(0)}else{h.data.volumeSlider.setValue(h.data.storedVolume)}g.muted=!g.muted},onMuteOver:function(h){d("#volumeSliderContainer").css("visibility","visible");var g=d("#volicon").css("right");g=parseFloat(g)+5;d("#volumeSliderContainer").css("right",g+"px")},onMuteOut:function(g){d("#volumeSliderContainer").css("visibility","hidden")},onFullScreenClick:function(g){g.data.$element.parent().toggleClass("fullscreen-mode")},onTimeTrackClick:function(j){var l=j.data.player.duration;var i=j.data.timeTrack.outerWidth();var g=j.data.timeTrack.offset().left;var h=(j.clientX-g)/(i);var k=l*h;if(k>0){j.data.player.currentTime=k}d("#seekDebug").html("clientX="+j.clientX+" width="+i+" duration="+l+" time="+k)},onPlay:function(g){g.data.errorOverlay.hide();g.data.play.removeClass("play").addClass("pause");if(g.data.options.hasOwnProperty("playButtonOverlay")&&g.data.options.playButtonOverlay){g.data.playOverlay.fadeOut(600)}},onPause:function(g){g.data.play.removeClass("pause").addClass("play");if(g.data.options.playButtonOverlay){g.data.playOverlay.fadeIn(600)}},onWaiting:function(g){g.data.buffered.css({width:0})},onError:function(h){if(h.data.useHTML5){var g;switch(h.target.error.code){case h.target.error.MEDIA_ERR_ABORTED:g="You aborted the video playback.";break;case h.target.error.MEDIA_ERR_NETWORK:g="A network error caused the video download to fail part-way.";break;case h.target.error.MEDIA_ERR_DECODE:g="The video playback was aborted due to a corruption problem or because the video used features your browser did not support.";break;case h.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:g="The video could not be loaded, either because the server or network failed or because the format is not supported.";break;default:g="An unknown error occurred.";break}h.data.errorOverlay.html(g);h.data.errorOverlay.show()}},onSeeking:function(g){},onSeeked:function(g){g.data.onProgress(g)},onVolumeChange:function(g){if(g.data.player.muted){g.data.mute.addClass("mute")}else{g.data.mute.removeClass("mute")}},onDurationChange:function(h){var j=h.data.player.duration;var g=h.data.player.currentTime;var i=b(g,j);h.data.currentTimeLabel.html(i[0]);if(i[1]=="Infinity:NaN:NaN"){h.data.durationLabel.html("LIVE");d(".video-progress2").css({visibility:"hidden"});d(".video-progress-live").css({visibility:"visible"})}else{d(".video-progress2").css({visibility:"visible"});d(".video-progress-live").css({visibility:"hidden"});h.data.durationLabel.html(i[1])}},onTimeUpdate:function(i){if(i.data.sliding){return}var k=i.data.player.duration;var h=i.data.player.currentTime;var j=b(h,k);i.data.currentTimeLabel.html(j[0]);if(j[1]=="Infinity:NaN:NaN"){i.data.durationLabel.html("LIVE")}else{i.data.durationLabel.html(j[1])}var g=(Math.max(0,h)/k*100);i.data.slider.css({left:g+"%"});i.data.played.css({width:g+"%"});i.data.onProgress(i)},onProgress:function(k){var j=0;if(!k.data.player.seeking){var h=k.data.player.buffered;var m=k.data.seekTime||Math.max(0,k.data.player.currentTime);var g=m/k.data.player.duration*100;if(h){if(h.length){if(h.end(h.length-1)>0){var l=h.end(h.length-1);j=(l/k.data.player.duration)*100;j-=g}else{j=0}}}if(g+j>100){j=100-g}}var i={left:g+"%",width:j+"%"};if(j+g>99){k.data.buffered.addClass("done")}else{k.data.buffered.removeClass("done")}k.data.buffered.css(i)},layoutControlBar:function(h,g){if(this.options.playButtonOverlay){this.playOverlay.fadeIn(600);this.playOverlay.css({left:(h/2-this.playOverlay.width()/2)+"px",top:(g/2-this.playOverlay.height()/2)+"px"})}d(".video-progress2").css({width:(h-200)+"px"});d(".video-progress-live").css({width:(h-200)+"px"});d(".strobeMediaPlaybackControlBar").css({width:h-2+"px",top:"279px"})}};a.prototype=c;d.fn.strobemediaplaybackchrome=function(h){var k=[],g;var j=this.each(function(){k.push(new a(this,h))});for(g=0;g<k.length;g++){k[g].initialize()}return j};d.fn.strobemediaplaybackchrome.defaults={javascriptControls:false};function f(g){showControlBar()}function b(i,n){var k;var g;var j;function l(q,h,m){q=Math.floor(isNaN(q)?0:Math.max(0,q));k=Math.floor(q/3600);g=Math.floor(q%3600/60);j=q%60;return((k>0||m)?(k+":"):"")+(((k>0||h)&&g<10)?"0":"")+g+":"+(j<10?"0":"")+j}var p=l(n);var o=l(i,k>0||g>9,k>0);return[o,p]}})(jQuery);
