/*
 * Media Element
 * HTML5 <video> libary
 * http://mediaelementjs.com/
 *
 * Creates a JavaScript object that mimics HTML5 media objects
 * through a Flash->JavaScript|Silverlight bridge
 *
 * Copyright 2010, John Dyer
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 * Version: 1.0.5
 */
(function(){if(typeof window.console=="undefined"){window.console={log:function(){}}}var m=["audio","video","source"];for(var t=0;t<m.length;t++){document.createElement(m[t])}var g={},e=0,n={silverlight:[{version:"3.0",type:"video/mp4"},{version:"3.0",type:"video/m4v"},{version:"3.0",type:"video/mov"},{version:"3.0",type:"video/wmv"},{version:"3.0",type:"audio/wma"},{version:"3.0",type:"audio/mp4"},{version:"3.0",type:"audio/m4a"},{version:"3.0",type:"audio/mp3"}],flash:[{version:"9.0.124",type:"video/mp4"},{version:"9.0.124",type:"video/flv"},{version:"9.0.124",type:"video/mov"},{version:"9.0.124",type:"audio/mp3"},{version:"9.0.124",type:"audio/m4a"},{version:"9.0.124",type:"audio/mp4"},{version:"9.0.124",type:"audio/flv"}]};var q="undefined",h="object",a="Shockwave Flash",w="ShockwaveFlash.ShockwaveFlash",j="application/x-shockwave-flash",d=window,v=document,f=navigator,u=function(){var i=typeof v.getElementById!=q&&typeof v.getElementsByTagName!=q&&typeof v.createElement!=q,y=f.userAgent.toLowerCase(),A=f.platform.toLowerCase(),C=[0,0,0],B=null;if(typeof f.plugins!=q&&typeof f.plugins[a]==h){B=f.plugins[a].description;if(B&&!(typeof f.mimeTypes!=q&&f.mimeTypes[j]&&!f.mimeTypes[j].enabledPlugin)){plugin=true;ie=false;B=B.replace(/^.*\s+(\S+\s+\S+$)/,"$1");C[0]=parseInt(B.replace(/^(.*)\..*$/,"$1"),10);C[1]=parseInt(B.replace(/^.*\.(.*)\s.*$/,"$1"),10);C[2]=/[a-zA-Z]/.test(B)?parseInt(B.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof d.ActiveXObject!=q){try{var x=new ActiveXObject(w);if(x){B=x.GetVariable("$version");if(B){ie=true;B=B.split(" ")[1].split(",");C=[parseInt(B[0],10),parseInt(B[1],10),parseInt(B[2],10)]}}}catch(z){}}}return{pv:C}}();function c(y){var x=u.pv,i=y.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10)||0;i[2]=parseInt(i[2],10)||0;return(x[0]>i[0]||(x[0]==i[0]&&x[1]>i[1])||(x[0]==i[0]&&x[1]==i[1]&&x[2]>=i[2]))?true:false}var b={};b.isInstalled=function(I){if(I==undefined){I=null}var J=false,x=null;try{var B=null,A=false;if(window.ActiveXObject){try{B=new ActiveXObject("AgControl.AgControl");if(I===null){J=true}else{if(B.IsVersionSupported(I)){J=true}}B=null}catch(y){A=true}}else{A=true}if(A){var z=navigator.plugins["Silverlight Plug-In"];if(z){if(I===null){J=true}else{var C=z.description;if(C==="1.0.30226.2"){C="2.0.30226.2"}var H=C.split(".");while(H.length>3){H.pop()}while(H.length<4){H.push(0)}var F=I.split(".");while(F.length>4){F.pop()}var G,D,E=0;do{G=parseInt(F[E]);D=parseInt(H[E]);E++}while(E<F.length&&G===D);if(G<=D&&!isNaN(G)){J=true}}}}}catch(y){J=false}return J};function o(i,x){switch(i){case"flash":return c(x);case"silverlight":return b.isInstalled(x);default:return false}}function p(i){return i.split("&").join("&amp;").split("<").join("&lt;").split('"').join("&quot;")}function l(i){var x=document.createElement("div");x.innerHTML='<a href="'+p(i)+'">x</a>';return x.firstChild.href}function s(y){var D="";var x=document.getElementsByTagName("script");for(var C=0;C<x.length;C++){var z=x[C].src;for(var B=0;B<y.length;B++){var A=y[B];if(z.indexOf(A)>-1){D=z.substring(0,z.indexOf(A));break}}if(D!=""){break}}return D}var k=s(["mediaelement.js","mediaelement.min.js","mediaelement-and-player.js","mediaelement-and-player.min.js"]);var r={enablePluginDebug:false,plugins:["silverlight","flash"],type:"",flashUrl:k+"flashmediaelement.swf",silverlightUrl:k+"silverlightmediaelement.xap",defaultVideoWidth:480,defaultVideoHeight:270,pluginWidth:-1,pluginHeight:-1,success:function(){},error:function(){}};g.MediaElement=function(y,U){var D=y;if(typeof y=="string"){D=document.getElementById(y)}var ac=(D.tagName.toLowerCase()=="video");var B=r;for(var A in U){B[A]=U[A]}var M=(typeof(D.canPlayType)!="undefined");var aa=false;var ab="";var E="";var H="";function z(i,ah){if(navigator.userAgent.indexOf("Android")>-1&&(i=="video/mp4"||i=="video/m4v"||i=="video/mov")){aa=true;return}if(ah&&!i){var aj=ah.substring(ah.lastIndexOf(".")+1);i=((ac)?"video":"audio")+"/"+aj}if(M&&D.canPlayType(i).replace(/no/,"")!=""){aa=true}else{for(pi=0;pi<B.plugins.length;pi++){var ag=B.plugins[pi];var af=n[ag];for(var ai=0;ai<af.length;ai++){if(i==af[ai].type&&o(ag,af[ai].version)){ab=ah;E=ag}}}}}if(typeof(B.type)!="undefined"&&B.type!=""){z(B.type,null)}else{if(D.getAttribute("src")!="undefined"&&D.getAttribute("src")!=null){var I=D.getAttribute("src");var C=D.getAttribute("type");z(C,I);H=I}else{for(var Y=0;Y<D.childNodes.length;Y++){var y=D.childNodes[Y];if(y.nodeType==1&&y.tagName.toLowerCase()=="source"){var C=y.getAttribute("type");var I=y.getAttribute("src");z(C,I);if(H==""){H=I}}}}}if(!M&&navigator.userAgent.indexOf("Safari")>-1){D.innerHTML="You need to install Quicktime for Safari to operate properly. Weird, huh?";B.error(D);return}if(aa){for(var X in g.HtmlMediaElement){D[X]=g.HtmlMediaElement[X]}var G=false;var P=(D.getAttribute("autoplay")!=null);if(P){function F(){if(!G){D.play()}}var J="progress timeupdate".split(" ");function x(){for(var af in J){D.addEventListener(J[af],F,false)}}function Q(){for(var af in J){D.removeEventListener(J[af],F,false)}}x();D.addEventListener("playing",function(){G=true;Q()},true)}B.success(D,D);return D}else{if(E!=""){var V=1;var T=1;var ae="me_"+E+"_"+(e++);var K=(ab!=null)?l(ab):"";var ad=(D.getAttribute("poster")==null)?D.getAttribute("poster"):"";var P=(D.getAttribute("autoplay")!=null);if(ac){V=(B.videoWidth>0)?B.videoWidth:(D.getAttribute("width")!==null)?D.getAttribute("width"):B.defaultVideoWidth;T=(B.videoHeight>0)?B.videoHeight:(D.getAttribute("height")!==null)?D.getAttribute("height"):B.defaultVideoHeight}else{if(B.enablePluginDebug){V=320;T=240}}var W=g.PluginMediaElement(ae,E);W.success=B.success;g.MediaPluginBridge.registerPluginElement(ae,W,D);var O=document.createElement("div");D.parentNode.insertBefore(O,D);var S=["id="+ae,"poster="+ad,"autoplay="+P,"width="+V,"height="+T];if(K!=null){S.push("file="+K)}if(B.enablePluginDebug){S.push("debug=true")}var L="";switch(E){case"silverlight":O.innerHTML='<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"id="'+ae+'" width="'+V+'" height="'+T+'"><param name="initParams" value="'+S.join(",")+'" /><param name="windowless" value="true" /><param name="background" value="black" /><param name="minRuntimeVersion" value="3.0.0.0" /><param name="autoUpgrade" value="true" /><param name="source" value="'+B.silverlightUrl+'" /></object>';break;case"flash":if(navigator.appName.indexOf("Microsoft")!=-1){O.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"id="'+ae+'" width="'+V+'" height="'+T+'"> <param name="movie" value="'+B.flashUrl+"?x="+(new Date())+'" /> <param name="flashvars" value="'+S.join("&")+'" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <param name="wmode" value="transparent" /> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="true" /> </object>'}else{O.innerHTML='<embed name="'+ae+'" play="true" loop="false" quality="high" bgcolor="#000000" wmode="transparent" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+B.flashUrl+"?"+S.join("&")+'" width="'+V+'" height="'+T+'"></embed>'}break}D.style.display="none";return W}else{var R=document.createElement("div");R.className="me-cannotplay";try{R.style.width=D.width+"px";R.style.height=D.height+"px"}catch(Z){}var N=D.getAttribute("poster");if(N=="undefined"||N==""||N==null){R.innerHTML='<a href="'+H+'">Download file</a>'}else{R.innerHTML='<a href="'+H+'"><img src="'+D.getAttribute("poster")+'" /></a>'}D.parentNode.insertBefore(R,D);D.style.display="none";B.error(D)}}};g.HtmlMediaElement={pluginType:"native",setCurrentTime:function(i){this.currentTime=i},setMuted:function(i){this.muted=i},setVolume:function(i){this.volume=i},setSrc:function(i){this.src=i},setVideoSize:function(x,i){this.width=x;this.height=i}};g.PluginMediaElement=function(i,y){var x={};return{id:i,pluginType:y,pluginElement:null,playbackRate:-1,defaultPlaybackRate:-1,seekable:[],played:[],paused:true,ended:false,seeking:false,duration:0,muted:false,volume:1,currentTime:0,play:function(){this.pluginApi.playMedia();this.paused=false},load:function(){this.pluginApi.loadMedia();this.paused=false},pause:function(){this.pluginApi.pauseMedia();this.paused=true},setSrc:function(z){this.pluginApi.setSrc(l(z))},setCurrentTime:function(z){this.pluginApi.setCurrentTime(z);this.currentTime=z},setVolume:function(z){this.pluginApi.setVolume(z);this.volume=z},setMuted:function(z){this.pluginApi.setMuted(z);this.muted=z},setVideoSize:function(A,z){if(this.pluginElement.style){this.pluginElement.style.width=A+"px";this.pluginElement.style.height=z+"px"}this.pluginApi.setVideoSize(A,z)},setFullscreen:function(z){this.pluginApi.setFullscreen(z)},addEventListener:function(A,B,z){x[A]=x[A]||[];x[A].push(B)},dispatchEvent:function(z){var B,C=x[z],A;if(C){A=Array.prototype.slice.call(arguments,1);for(B=0;B<C.length;B++){C[B].apply(null,A)}}}}};g.MediaPluginBridge=(function(){var i=[],x=[];return{registerPluginElement:function(A,z,y){i[A]=z;x[A]=y},initPlugin:function(A){var z=i[A],y=x[A];switch(z.pluginType){case"flash":if(navigator.appName.indexOf("Microsoft")!=-1){z.pluginElement=z.pluginApi=window[A]}else{z.pluginElement=z.pluginApi=document[A]}break;case"silverlight":z.pluginElement=document.getElementById(z.id);z.pluginApi=z.pluginElement.Content.SilverlightApp;break}if(z.success){z.success(z,y)}},fireEvent:function(E,A,z){var C=i[E];C.ended=false;C.paused=false;var D={type:A,target:C};for(var B in z){C[B]=z[B];D[B]=z[B]}var y=z.bufferedTime||0;D.target.buffered=D.buffered={start:function(F){return 0},end:function(F){return y},length:1};C.dispatchEvent(D.type,D)}}}());window.html5=g;window.MediaElement=g.MediaElement})();
