"));this.setActive();if(this.config.spriteUrl!=""){this.buffIcnSprite=a("
").appendTo(this.buffIcn).css({width:this.config.spriteWidth,height:this.config.spriteHeight,marginLeft:((this.buffIcn.width()-this.config.spriteWidth)/2)+"px",marginTop:((this.buffIcn.height()-this.config.spriteHeight)/2)+"px",backgroundColor:"transparent",backgroundImage:"url("+this.config.spriteUrl+")",backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}).addClass("inactive")}this.pp.getMediaContainer();this.display.append(this.startButton).append(this.buffIcn);this.pluginReady=true},displayReadyHandler:function(){var b=this;this.startButton.unbind().click(function(){b.pp.setPlay()});this.hideStartButton();if(this.getConfig("designMode")){this.shofBufferIcon()}},syncingHandler:function(){this.showBufferIcon();if(this.pp.getState("IDLE")){this.hideStartButton()}},readyHandler:function(){this.hideBufferIcon();if(this.pp.getState("IDLE")){this.showStartButton()}},bufferHandler:function(b){if(!this.pp.getState("PLAYING")&&!this.pp.getState("AWAKENING")){return}if(b=="EMPTY"){this.showBufferIcon()}else{this.hideBufferIcon()}},stateHandler:function(b){switch(b){case"STARTING":this.showBufferIcon();this.hideStartButton();break;case"PLAYING":this.hideBufferIcon();this.hideStartButton();break;case"IDLE":this.showStartButton();break;case"AWAKENING":this.hideStartButton();break;case"ERROR":this.hideBufferIcon();this.hideStartButton();break;case"COMPLETED":this.hideBufferIcon();break;default:this.hideStartButton()}},stoppedHandler:function(){this.hideBufferIcon()},scheduleLoadingHandler:function(){this.hideStartButton();this.showBufferIcon()},scheduledHandler:function(){if(!this.getConfig("autoplay")){tthis.showStartButton()}this.hideBufferIcon()},plugineventHandler:function(c){if(c.PLUGIN=="controlbar"&&c.EVENT=="show"&&this.getConfig("staticControls")){var b=c.height*100/this.pp.getDC().height();this.display.height((100-b)+"%").data("sc",true)}},mousedownHandler:function(b){var c=this;if(a(b.target).attr("id").indexOf("_media")==-1){return}if(b.which!=1){return}switch(this.pp.getState()){case"ERROR":this.pp.setActiveItem("next");return;case"IDLE":this.pp.setPlay();return}if(this.pp.getHasGUI()==true){return}this.displayClicks++;if(this.displayClicks>0){setTimeout(function(){if(c.displayClicks==1){if(c.pp.getState()=="PLAYING"){c.clickHandler("displayPlaying")}else{c.clickHandler("display")}}else{if(c.displayClicks==2){c.clickHandler("displayDbl")}}c.displayClicks=0},250)}return},showStartButton:function(){this.startButton.addClass("active").removeClass("inactive")},hideStartButton:function(){this.startButton.addClass("inactive").removeClass("active")},hideBufferIcon:function(){var b=this;if(this.getConfig("designMode")){return}clearTimeout(this.bufferDelayTimer);this.buffIcn.stop(true,true);this.buffIcn.fadeOut("fast",function(){a(this).addClass("inactive").removeClass("active").css("display","")})},showBufferIcon:function(b){var c=this;clearTimeout(this.bufferDelayTimer);if(this.pp.getHasGUI()){return}if((this.pp.getModel()==="YTAUDIO"||this.pp.getModel()==="YTVIDEO")&&!this.pp.getState("IDLE")){b=true}if(b!=true&&this.getConfig("bufferIconDelay")>0){this.bufferDelayTimer=setTimeout(function(){c.showBufferIcon(true)},this.getConfig("bufferIconDelay"));return}this.buffIcn.stop(true,true);if(this.buffIcn.hasClass("active")){return}this.buffIcn.fadeIn("fast",function(){if(c.buffIcnSprite==null){return}var d=(c.config.spriteCountUp==true)?0:(c.config.spriteHeight+c.config.spriteOffset)*(c.config.spriteTiles-1),e=d;c.buffIcnSprite.addClass("active").removeClass("inactive").css("display","");(function(){if(!c.buffIcn.is(":visible")){return}c.buffIcnSprite.css("backgroundPosition","0px -"+e+"px");if(c.config.spriteCountUp==true){e+=c.config.spriteHeight+c.config.spriteOffset}else{e-=c.config.spriteHeight+c.config.spriteOffset}if(e>(d+c.config.spriteHeight)*c.config.spriteTiles||e
'},initialize:function(){var f=this,e=this.playerDom.html(),c=true,b=this.pp.getNS();for(var d in this.controlElementsConfig){if(e.match(new RegExp(b+d,"gi"))){c=false;break}}if(c){this.cb=this.applyToPlayer(a(document.createElement("div")).addClass("controls"));this.applyTemplate(this.cb,this.getConfig("controlsTemplate"))}else{this.cb=this.playerDom.find("."+b+"controls")}for(var d in this.controlElementsConfig){this.controlElements[d]=a(this.playerDom).find("."+b+d);$p.utils.blockSelection(this.controlElements[d])}this.addGuiListeners();this._storeVol=this.getConfig("volume");this.updateDisplay();this.hidecb(true);this.pluginReady=true},applyTemplate:function(c,f){var d=this,b=this.pp.getNS();if(f){var e=f.match(/\%{[a-zA-Z_]*\}/gi);if(e!=null){a.each(e,function(g,h){var i=h.replace(/\%{|}/gi,"");if(h.match(/\_/gi)){f=f.replace(h,'')}else{f=f.replace(h,'class="'+b+i+'"')}})}c.html(f)}},itemHandler:function(b){a(this.cb).find("."+this.pp.getNS()+"cuepoint").remove();this.pluginReady=true;this.hidecb(true);this.drawTitle();this.displayQualityToggle()},startHandler:function(){if(this.getConfig("showOnStart")==true){this.showcb(true)}else{this.hidecb(true)}},readyHandler:function(b){clearTimeout(this._cTimer);this.cb.removeClass("fade");if(this.getConfig("showOnIdle")){this.showcb(true)}if(!this.getConfig("disableFade")){this.cb.addClass("fade")}else{this.sendEvent("show",{width:this.cb.width(),height:this.cb.height()})}this.pluginReady=true},durationChangeHandler:function(b){this.sendEvent("show",{width:this.cb.width(),height:this.cb.height()});this.displayCuePoints(b)},updateDisplay:function(){var b=this,c=this.pp.getState();if(this.pp.getHasGUI()){return}if(this.getConfig("controls")==false){this.hidecb(true);return}if(this.pp.getItemCount()<2||this.getConfig("disallowSkip")){this._active("prev",false);this._active("next",false)}else{this._active("prev",true);this._active("next",true)}if(this.pp.getItemIdx()<1){this._active("prev",false)}if(this.pp.getItemIdx()>=this.pp.getItemCount()-1){this._active("next",false)}if(this.getConfig("disablePause")){this._active("play",false);this._active("pause",false)}else{if(c==="PLAYING"){this.drawPauseButton()}if(c==="PAUSED"){this.drawPlayButton()}if(c==="IDLE"){this.drawPlayButton()}}this._active("stop",c!=="IDLE");this._active("forward",c!=="IDLE");this._active("rewind",c!=="IDLE");if(this.pp.getInFullscreen()===true){this.drawExitFullscreenButton()}else{this.drawEnterFullscreenButton()}if(!this.getConfig("enableFullscreen")||this.getConfig("isCrossDomain")){this._active("fsexit",false);this._active("fsenter",false)}this._active("loop",this.pp.getConfig("loop"));
this.displayQualityToggle();this.displayTime();this.displayVolume(this.pp.getVolume()||this._storeVol)},stateHandler:function(b){this.updateDisplay();if("STOPPED|DONE|IDLE".indexOf(b)>-1){this._noCHide=false;this.hidecb(true);return}if("STOPPED|AWAKENING|IDLE|DONE".indexOf(b)>-1){this.displayTime(0,0,0);this.displayProgress(0)}else{this.displayProgress()}},scheduleModifiedHandler:function(){if(this.pp.getState()==="IDLE"){return}this.updateDisplay();this.displayTime();this.displayProgress()},volumeHandler:function(b){this.displayVolume(b)},progressHandler:function(b){this.displayProgress()},timeHandler:function(b){this.displayTime();this.displayProgress()},qualityChangeHandler:function(b){this.displayQualityToggle(b)},fullscreenHandler:function(d){var c=this,b=this.pp.getNS();clearTimeout(this._cTimer);this._noCHide=false;this._cFading=false;this._vSliderAct=false;if(!this.getConfig("controls")){return}if(!this.getConfig("enableFullscreen")||this.getConfig("isCrossDomain")){return}if(d){this.cb.addClass("fullscreen");this.drawExitFullscreenButton()}else{this.cb.removeClass("fullscreen");this.drawEnterFullscreenButton()}if(this.pp.getState()=="IDLE"&&!this.getConfig("showOnIdle")){this.hidecb(true)}else{this._cTimer=setTimeout(function(){c.hidecb()},this.getConfig("fadeDelay"))}if(this.getConfig("disableFade")){this.sendEvent("show",{width:this.cb.width(),height:this.cb.height()})}},scaledHandler:function(){if(this.getConfig("disableFade")){this.sendEvent("show",{width:this.cb.width(),height:this.cb.height()})}},addGuiListeners:function(){var b=this;a.each(this.controlElementsConfig,function(c,d){if(!d){return true}if(d.on==null){return true}a.each(d.on,function(h,e){var f=("on"+e in window.document);if(!f){var g=document.createElement("div");g.setAttribute("on"+e,"return;");f=(typeof g["on"+e]=="function")}if(f){b.controlElements[c].bind(e,function(i){b.clickCatcher(i,d.call,b.controlElements[c])});return false}})});this.cb.mouseenter(function(c){b.controlsMouseEnterListener(c)});this.cb.mouseleave(function(c){b.controlsMouseLeaveListener(c)})},clickCatcher:function(b,d,c){b.stopPropagation();b.preventDefault();this[d](b,c);return false},drawTitle:function(){var b=this;this.controlElements.title.html(this.getConfig("title",""))},hidecb:function(c){clearTimeout(this._cTimer);var b=this.pp.getNS(),d=this;if(this.cb==null){return}this.cb.stop(true,true);if(this.getConfig("disableFade")||this._noCHide||!this.cb.is(":visible")){return}if(c===true){this._cFading=false;this.cb.removeClass("active").addClass("inactive").css("display","");return}if(this.getConfig("controls")==false||!this.cb.hasClass("fade")){this.cb.removeClass("active").addClass("inactive");return}this.cb.fadeOut("slow",function(){a(this).removeClass("active").addClass("inactive").css("display","");d._cFading=false})},showcb:function(c){clearTimeout(this._cTimer);if(this.pp.getHasGUI()||this.getConfig("controls")==false){this.cb.removeClass("active").addClass("inactive").css("display","");return}var d=this,b=this.pp.getNS();if(this.cb==null){return}if("IDLE|AWAKENING|ERROR".indexOf(this.pp.getState())>-1&&c!=true){return}this.cb.stop(true,true);if((!this.cb.hasClass("fade")||c==true)){this.cb.removeClass("inactive").addClass("active").css("display","");return}if(this.cb.is(":visible")||this._cFading==true){this._cTimer=setTimeout(function(){d.hidecb()},this.getConfig("fadeDelay"));return}this._cFading=true;this.cb.fadeIn("slow",function(){d._cFading=false;a(this).removeClass("inactive").addClass("active").css("display","")})},displayTime:function(f,c,j){if(this.pp.getHasGUI()){return}try{var d=(f!=undefined)?f:this.pp.getLoadPlaybackProgress(),h=(c!=undefined)?c:this.pp.getDuration(),b=(j!=undefined)?j:this.pp.getPosition()}catch(g){var d=f||0,h=c||0,b=j||0}this.controlElements.playhead.data("pct",d).css({width:d+"%"});var i=a.extend({},this._clockDigits(h,"dur"),this._clockDigits(b,"elp"),this._clockDigits(h-b,"rem"));a.each(this.controlElements,function(e,k){if(i[e]){a.each(k,function(){a(this).html(i[e])})}})},displayProgress:function(){this.controlElements.loaded.css("width",this.pp.getLoadProgress()+"%")},displayVolume:function(f){if(this._vSliderAct==true){return}if(f==null){return}var b=this.cb.is(":visible"),e=this,d=this.getConfig("fixedVolume"),c=(this.controlElements.mute.hasClass("toggle")||this.controlElements.unmute.hasClass("toggle")||this.getConfig("toggleMute"));this._active("mute",!d);this._active("unmute",!d);this._active("vmax",!d);this._active("vknob",!d);this._active("vmarker",!d);this._active("vslider",!d);this.controlElements.vmarker.css("width",f*100+"%");this.controlElements.vknob.css("left",f*100+"%");if(c){switch(parseFloat(f)){case 0:this._active("mute",false);this._active("unmute",true);this._active("vmax",true);break;default:this._active("mute",true);this._active("unmute",false);this._active("vmax",false);break}}if(b){this.cb.fadeTo(1,0.99).fadeTo(1,1)}},displayCuePoints:function(d){var b=this,c=this.pp.getNS();if(!this.getConfig("showCuePoints")){return
}b.controlElements.scrubber.remove("."+c+"cuepoint");a.each(this.pp.getCuePoints()||[],function(){var e=Math.max(100/d,Math.round(d/100),1),h=(this.on*100/d)-((e/2)*100/d),g=this,f=b.pp,i=a(document.createElement("div")).addClass(c+"cuepoint").addClass("inactive").css("left",h+"%").css("width",e+"%").data("on",this.on);if(this.title!=""){i.attr("title",this.title)}this.addListener("unlock",function(){a(i).removeClass("inactive").addClass("active");i.click(function(){b.pp.setPlayhead(i.data("on"))})});b.controlElements.scrubber.append(i)})},drawPauseButton:function(b){this._active("pause",true);this._active("play",false)},drawPlayButton:function(b){this._active("pause",false);this._active("play",true)},drawEnterFullscreenButton:function(b){this._active("fsexit",false);this._active("fsenter",true)},drawExitFullscreenButton:function(b){this._active("fsexit",true);this._active("fsenter",false)},displayQualityToggle:function(d){var f=this.getConfig("playbackQualities"),e=this.pp.getPlaybackQualities(),b=this.pp.getNS();best=[];if(e.length<2||f.length<2){this._active("loquality",false).removeClass().addClass(b+"loquality").data("qual","");this._active("hiquality",false).removeClass().addClass(b+"hiquality").data("qual","");return}f.sort(function(h,g){return h.minHeight-g.minHeight});for(var c=f.length;c--;c>0){if(a.inArray(f[c].key,e)>-1){best.push(f[c].key)}if(best.length>1){break}}if(best[0]==this.pp.getPlaybackQuality()){this._active("loquality",true).addClass("qual"+best[1]).data("qual",best[1]);this._active("hiquality",false).addClass("qual"+best[0]).data("qual",best[0])}else{this._active("loquality",false).addClass("qual"+best[1]).data("qual",best[1]);this._active("hiquality",true).addClass("qual"+best[0]).data("qual",best[0])}},setQualityClk:function(b){this.pp.setPlaybackQuality(a(b.target).data("qual"))},playClk:function(b){this.pp.setPlay()},pauseClk:function(b){this.pp.setPause()},stopClk:function(b){this.pp.setStop()},controlsMouseEnterListener:function(b){this._noCHide=true},controlsMouseLeaveListener:function(b){this._noCHide=false},controlsClk:function(b){},leftclickHandler:function(){this.mouseleaveHandler()},mousemoveHandler:function(b){if(this.pp.getState("STARTING")){return}clearTimeout(this._cTimer);this.showcb()},mouseleaveHandler:function(b){var c=this;clearTimeout(this._cTimer);this._noCHide=false;this._cTimer=setTimeout(function(){c.hidecb()},this.getConfig("fadeDelay"))},prevClk:function(b){this.pp.setActiveItem("previous")},nextClk:function(b){this.pp.setActiveItem("next")},forwardClk:function(b){this.pp.setPlayhead("+10")},rewindClk:function(b){this.pp.setPlayhead("-10")},muteClk:function(b){this._storeVol=(this.pp.getVolume()==0)?this.getConfig("volume"):this.pp.getVolume();this.pp.setVolume(0)},unmuteClk:function(b){if(this._storeVol<=0){this._storeVol=1}this.pp.setVolume(this._storeVol)},vmaxClk:function(b){this.pp.setVolume(1)},enterFullscreenClk:function(b){this.pp.setFullscreen(true)},exitFullscreenClk:function(b){this.pp.setFullscreen(false)},openCloseClk:function(b){var c=this;a(a(b.currentTarget).attr("class").split(/\s+/)).each(function(d,e){if(e.indexOf("toggle")==-1){return}c.playerDom.find("."+e.substring(6)).slideToggle("slow",function(){c.pp.setResize()});c.controlElements.open.toggle();c.controlElements.close.toggle()})},loopClk:function(b){this.pp.setLoop(a(b.currentTarget).hasClass("inactive")||false);this.updateDisplay()},startClk:function(b){this.pp.setPlay()},vmarkerClk:function(b){vsliderClk(b)},vsliderClk:function(c){if(this._vSliderAct==true){return}var g=(this.pp.getInFullscreen()===true&&this.controlElements.vslider.length>1)?1:0,e=a(this.controlElements.vslider[g]),b=e.width(),d=(c.originalEvent.touches)?c.originalEvent.touches[0].pageX:c.originalEvent.pageX,f=d-e.offset().left;if(f<0||f=="NaN"||f==undefined){result=0}else{result=(f/b)}this.pp.setVolume(result);this._storeVol=result},scrubberdragStartDragListener:function(b){if(this.getConfig("disallowSkip")==true){return}this._sSliderAct=true;var e=this,f=(this.pp.getInFullscreen()===true&&this.controlElements.scrubber.length>1)?1:0,c=a(this.controlElements.scrubberdrag[f]),g=a(this.controlElements.loaded[f]),d=0,k=Math.abs(parseInt(c.offset().left)-b.clientX),i=function(m){var l=Math.abs(c.offset().left-m.clientX);l=(l>c.width())?c.width():l;l=(l>g.width())?g.width():l;l=(l<0)?0:l;l=Math.abs(l/c.width())*e.pp.getDuration();if(l>0&&l!=d){d=l;e.pp.setPlayhead(d)}},h=function(l){l.stopPropagation();l.preventDefault();e.playerDom.unbind("mouseup.slider");c.unbind("mousemove",j);c.unbind("mouseup",h);e._sSliderAct=false;return false},j=function(l){clearTimeout(e._cTimer);l.stopPropagation();l.preventDefault();i(l);return false};this.playerDom.bind("mouseup.slider",h);c.mouseup(h);c.mousemove(j);i(b)},vknobStartDragListener:function(b,c){this._vSliderAct=true;var f=this,g=(this.pp.getInFullscreen()===true&&this.controlElements.vslider.length>1)?1:0,e=a(c[g]),d=a(this.controlElements.vslider[g]),d=a(this.controlElements.vslider[g]),k=Math.abs(parseInt(e.position().left)-b.clientX),h=0,i=function(l){f.playerDom.unbind("mouseup",i);
d.unbind("mousemove",j);d.unbind("mouseup",i);e.unbind("mousemove",j);e.unbind("mouseup",i);f._vSliderAct=false;return false},j=function(l){clearTimeout(f._cTimer);var m=(l.clientX-k);m=(m>d.width()-e.width()/2)?d.width()-(e.width()/2):m;m=(m<0)?0:m;e.css("left",m+"px");h=Math.abs(m/(d.width()-(e.width()/2)));f.pp.setVolume(h);f._storeVol=h;a(f.controlElements.vmarker[g]).css("width",h*100+"%");return false};this.playerDom.mouseup(i);d.mousemove(j);d.mouseup(i);e.mousemove(j);e.mouseup(i)},handleStartDragListener:function(d,g){var h=this;var f=Math.abs(parseInt(this.cb.position().left)-d.clientX);var c=Math.abs(parseInt(this.cb.position().top)-d.clientY);var b=function(i){i.stopPropagation();i.preventDefault();h.playerDom.unbind("mouseup",b);h.playerDom.unbind("mouseout",b);h.playerDom.unbind("mousemove",e);return false};var e=function(i){i.stopPropagation();i.preventDefault();clearTimeout(h._cTimer);var k=(i.clientX-f);k=(k>h.playerDom.width()-h.cb.width())?h.playerDom.width()-h.cb.width():k;k=(k<0)?0:k;h.cb.css("left",k+"px");var j=(i.clientY-c);j=(j>h.playerDom.height()-h.cb.height())?h.playerDom.height()-h.cb.height():j;j=(j<0)?0:j;h.cb.css("top",j+"px");return false};this.playerDom.mousemove(e);this.playerDom.mouseup(b)},errorHandler:function(b){this.hidecb(true)},_active:function(d,b){var c=this.controlElements[d];if(b==true){c.addClass("active").removeClass("inactive")}else{c.addClass("inactive").removeClass("active")}return c},_clockDigits:function(e,i){if(e<0||isNaN(e)||e==undefined){e=0}var g=Math.floor(e/(60*60));var h=e%(60*60);var d=Math.floor(h/60);var c=h%60;var f=Math.floor(c);var b={};b["min_"+i]=(d<10)?"0"+d:d;b["sec_"+i]=(f<10)?"0"+f:f;b["hr_"+i]=(g<10)?"0"+g:g;return b}}});