/*
 * Media Element jQuery plugin
 * http://mediaelementjs.com/
 *
 * Creates a controller bar for HTML5 <video> tags
 * and falls back to a Flash player or Silverlight player for browsers that
 * do not support <video> or cannot play the video type.
 * Mostly designed for H.264, but can also play Ogg, WebM, FLV, WMV, ACC and MP3
 *
 * Copyright 2010, John Dyer
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 * Version: 1.0.5
 */
(function(f){var b=document.createElement("video");var d=navigator.userAgent;var a=(typeof b.webkitEnterFullScreen!=="undefined");if(d.match("Chrome")){a=false}var e={defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,audioWidth:300,audioHeight:30,messages:{start:"Click to Start",loading:"Loading",paused:"Paused",error:"Error",ended:"Ended"}};function h(i){i=Math.round(i);minutes=Math.floor(i/60);minutes=(minutes>=10)?minutes:"0"+minutes;i=Math.floor(i%60);i=(i>=10)?i:"0"+i;return minutes+":"+i}var c=0;function g(v,O){v=f(v);var y=f.extend(true,{},e,O);var x=v[0].tagName.toLowerCase()=="video";var H="mep_"+c++;var N=navigator.userAgent;var Q=(N.match(/iPad/i)!=null);var J=(N.match(/iPhone/i)!=null);var W=(N.match(/Android/i)!=null);if(Q||J){v.attr("controls","controls");v.removeAttr("poster");if(Q&&v[0].getAttribute("autoplay")!==null){v[0].load();v[0].play()}return}else{if(W&&x){v.attr("controls","controls");return}else{v.removeAttr("controls")}}var D=f('<div id="'+H+'" class="mep-container">			<div class="mep-mediaelement">			</div>			<div class="mep-poster">				<img />			</div>			<div class="mep-overlay">				<div class="mep-overlay-message"></div>			</div>			<div class="mep-controls">				<div class="mep-playpause-button mep-play"><span></span></div>				<div class="mep-time-rail">					<span class="mep-time-total">						<span class="mep-time-loaded"></span>						<span class="mep-time-current"></span>						<span class="mep-time-handle"></span>					</span>				</div>				<div class="mep-time">					<span class="mep-currenttime"></span>					<span>|</span>					<span class="mep-duration"></span>				</div>				<div class="mep-volume-button mep-mute">					<span></span> 					<div class="mep-volume-slider">						<div class="mep-volume-rail">							<div class="mep-volume-handle"></div>						</div>					</div>				</div>				<div class="mep-fullscreen-button"><span></span></div>			</div>			<div class="mep-clear"></div>		</div>');v.before(D);var G=f("#"+H);G.find(".mep-mediaelement").append(v);G.addClass(v[0].className);var k=G.find(".mep-poster");var F=k.find("img");k.hide();var B=v.attr("poster");if(B!==""){F.attr("src",B);k.show()}var S=G.find(".mep-overlay");var s=G.find(".mep-overlay-message");if(v[0].getAttribute("autoplay")!==null){E(y.messages.loading)}else{E(y.messages.start)}function q(u,o){u=parseInt(u);o=parseInt(o);G.width(u).height(o);S.width(u).height(o);F.height(o).width(u)}var i=0;var l=0;if(x){i=(y.videoWidth>0)?y.videoWidth:(v[0].getAttribute("width")!==null)?v.attr("width"):y.defaultVideoWidth;l=(y.videoHeight>0)?y.videoHeight:(v[0].getAttribute("height")!==null)?v.attr("height"):y.defaultVideoHeight}else{i=y.audioWidth;l=y.audioHeight}q(i,l);var C=G.find(".mep-controls");var m=true;if(x){G.bind("mouseenter",function(){C.fadeIn(200);V();m=true}).bind("mouseleave",function(){C.fadeOut(200);m=false})}function E(o){if(x){s.html(o);S.css("visibility","visible")}}function R(){S.css("visibility","hidden")}var T=C.find(".mep-playpause-button");var j=C.find(".mep-fullscreen-button");if(!x){j.remove()}var P=C.find(".mep-time");var X=C.find(".mep-currenttime").html("00:00");var A=C.find(".mep-duration").html("00:00");var t=C.find(".mep-volume-button");var M=C.find(".mep-volume-slider");var r=C.find(".mep-volume-rail");var Y=C.find(".mep-volume-handle");var Z=C.find(".mep-time-rail");var p=Z.find(".mep-time-current").width(0);var I=Z.find(".mep-time-loaded").width(0);var w=Z.find(".mep-time-total");var z=C.find(".mep-time-handle");function V(){var o=T.outerWidth(true)+P.outerWidth(true)+t.outerWidth(true)+((x)?j.outerWidth(true):0);var u=C.width()-o-(Z.outerWidth(true)-Z.outerWidth(false));Z.width(u);w.width(u-(w.outerWidth(true)-w.width()))}function L(u,aa){C.show();V();T.bind("click",function(){if(T.hasClass("mep-play")){u.play();T.removeClass("mep-play").addClass("mep-pause")}else{u.pause();T.removeClass("mep-pause").addClass("mep-play")}});function ak(ap){var am=r.height();var ao=ap.pageY-r.offset().top;if(ao<0){ao=0}else{if(ao>am){ao=am}}Y.css("top",ao-(Y.height()/2));var an=(am-ao)/am;if(an==0){u.setMuted(true);t.removeClass("mep-mute").addClass("mep-unmute")}else{u.setMuted(false);t.removeClass("mep-unmute").addClass("mep-mute")}u.setVolume(an)}function aj(am){Y.css("top",r.height()-(r.height()*am)-(Y.height()/2))}function ai(){f(document).unbind("mousemove",ak).unbind("mouseup",ai)}M.bind("mousedown",function(am){ak(am);f(document).bind("mousemove",ak).bind("mouseup",ai)});t.find("span").bind("click",function(){if(u.muted){u.setMuted(false);t.removeClass("mep-unmute").addClass("mep-mute");aj(1)}else{u.setMuted(true);t.removeClass("mep-mute").addClass("mep-unmute");aj(0)}});var ad=false;var ac=0;var o=0;j.bind("click",function(){ae(!ad)});function ae(am){switch(u.pluginType){case"flash":u.setFullscreen(am);break;case"silverlight":u.setFullscreen(am);break;case"native":if(a){if(am){u.webkitEnterFullScreen()}else{u.webkitExitFullScreen()}}else{if(am){ac=v.height();o=v.width();G.addClass("mep-container-fullscreen").width("100%").height("100%").css("z-index",1000);v.width("100%").height("100%");S.width("100%").height("100%");F.width("100%").height("auto");j.removeClass("mep-fullscreen").addClass("mep-unfullscreen");V();f(document).bind("keydown",ah);f(window).bind("resize",al)}else{G.removeClass("mep-container-fullscreen").width(o).height(ac).css("z-index",1);v.width(o).height(ac);F.width(o).height(ac);j.removeClass("mep-unfullscreen").addClass("mep-fullscreen");V();f(document).unbind("keydown",ah);f(window).unbind("resize",al)}}}ad=am}function ah(am){if(am.keyCode==27){ae(false)}}function al(am){V()}Z.delegate("span","click",function(aq){var am=aq.pageX;var ar=w.offset();var ao=w.outerWidth();var an=((am-ar.left)/ao);var ap=an*u.duration;u.setCurrentTime(ap)});S.bind("click",function(am){if(u.paused){u.play()}},true);u.addEventListener("timeupdate",function(ao){if(!m){return}if(u.currentTime&&u.duration){X.html(h(u.currentTime));if(u.duration){A.html(h(u.duration))}var an=w.width()*u.currentTime/u.duration;p.width(an);var am=an-(z.width()/2);z.css("left",am)}ag(ao.target)},true);u.addEventListener("progress",function(am){ag(am.target)},true);function ag(an){if(an&&an.bytesTotal!=undefined&&an.bytesTotal>0&&an.bufferedBytes!=undefined){var am=an.bufferedBytes/an.bytesTotal;I.width(w.width()*am)}else{if(an&&an.buffered&&an.buffered.length>0&&an.buffered.end&&an.duration){var am=an.buffered.end(0)/an.duration;I.width(w.width()*am)}}}u.addEventListener("click",function(am){if(u.paused){u.play()}},true);u.addEventListener("playing",function(am){k.hide();T.removeClass("mep-play").addClass("mep-pause");R()},true);u.addEventListener("pause",function(am){T.removeClass("mep-pause").addClass("mep-play");E(y.messages.paused)},true);u.addEventListener("ended",function(am){k.show();T.removeClass("mep-pause").addClass("mep-play");E(y.messages.ended)},true);u.addEventListener("loadedmetadata",function(am){if(x&&y.videoHeight<=0&&v[0].getAttribute("height")===null&&!isNaN(am.target.videoHeight)){q(am.target.videoWidth,am.target.videoHeight);V();u.setVideoSize(am.target.videoWidth,am.target.videoHeight)}},true);var af="play playing played paused pausing".split(" ");for(var ab=0;ab<af.length;ab++){u.addEventListener(af[ab],function(am){console.log(am.type,am.target.paused)},true)}setTimeout(function(){V()},50);if(y.success){y.success(u,aa)}}function U(u){E(y.messages.error);var aa="";for(var o in u){aa+=o+" = "+u[o]+","}console.log("medialementplayer ERROR",aa)}var K=f.extend({},y,{pluginWidth:l,pluginHeight:i,success:L,error:U});var n=html5.MediaElement(v[0],K);return n}jQuery.fn.mediaelementplayer=function(i){return this.each(function(){return new g(f(this),i)})};window.html5.MediaElementPlayer=g;window.MediaElementPlayer=g})(jQuery);
