!function(e,t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):e.jQuery)}(this,function(e){"use strict";function t(e){var t,o,i,r,n,s,a,d={};for(a=0,s=(n=e.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,",").split(",")).length;a<s&&(-1===(o=n[a]).search(/^(http|https|ftp):\/\//)&&-1!==o.search(":"));a++)t=o.indexOf(":"),i=o.substring(0,t),(r=o.substring(t+1))||(r=void 0),"string"==typeof r&&(r="true"===r||"false"!==r&&r),"string"==typeof r&&(r=isNaN(r)?r:+r),d[i]=r;return null==i&&null==r?e:d}function o(o,n,s){if(this.$element=e(o),"string"==typeof n&&(n=t(n)),s?"string"==typeof s&&(s=t(s)):s={},"string"==typeof n)n=n.replace(/\.\w*$/,"");else if("object"==typeof n)for(var a in n)n.hasOwnProperty(a)&&(n[a]=n[a].replace(/\.\w*$/,""));this.settings=e.extend({},i,s),this.path=n;try{this.init()}catch(e){if(e.message!==r)throw e}}var i={volume:1,playbackRate:1,muted:!0,loop:!0,autoplay:!0,position:"50% 50%",posterType:"detect",resizing:!0,bgColor:"transparent",className:""},r="Not implemented";o.prototype.init=function(){var t,o,i=this,n=i.path,s=n,a="",d=i.$element,p=i.settings,c=function(e){var t,o,i,r=(e=""+e).split(/\s+/),n="50%",s="50%";for(i=0,t=r.length;i<t;i++)"left"===(o=r[i])?n="0%":"right"===o?n="100%":"top"===o?s="0%":"bottom"===o?s="100%":"center"===o?0===i?n="50%":s="50%":0===i?n=o:s=o;return{x:n,y:s}}(p.position),u=p.posterType;o=i.$wrapper=e("<div>").addClass(p.className).css({position:"absolute","z-index":-1,top:0,left:0,bottom:0,right:0,overflow:"hidden","-webkit-background-size":"cover","-moz-background-size":"cover","-o-background-size":"cover","background-size":"cover","background-color":p.bgColor,"background-repeat":"no-repeat","background-position":c.x+" "+c.y}),"object"==typeof n&&(n.poster?s=n.poster:n.mp4?s=n.mp4:n.webm?s=n.webm:n.ogv&&(s=n.ogv)),"detect"===u?function(t,o){var i=function(){o(this.src)};e('<img src="'+t+'.gif">').on("load",i),e('<img src="'+t+'.jpg">').on("load",i),e('<img src="'+t+'.jpeg">').on("load",i),e('<img src="'+t+'.png">').on("load",i)}(s,function(e){o.css("background-image","url("+e+")")}):"none"!==u&&o.css("background-image","url("+s+"."+u+")"),"static"===d.css("position")&&d.css("position","relative"),d.prepend(o),"object"==typeof n?(n.mp4&&(a+='<source src="'+n.mp4+'.mp4" type="video/mp4">'),n.webm&&(a+='<source src="'+n.webm+'.webm" type="video/webm">'),n.ogv&&(a+='<source src="'+n.ogv+'.ogv" type="video/ogg">'),t=i.$video=e("<video>"+a+"</video>")):t=i.$video=e('<video><source src="'+n+'.mp4" type="video/mp4"><source src="'+n+'.webm" type="video/webm"><source src="'+n+'.ogv" type="video/ogg"></video>');try{t.prop({autoplay:p.autoplay,loop:p.loop,volume:p.volume,muted:p.muted,defaultMuted:p.muted,playbackRate:p.playbackRate,defaultPlaybackRate:p.playbackRate})}catch(e){throw new Error(r)}t.css({margin:"auto",position:"absolute","z-index":-1,top:c.y,left:c.x,"-webkit-transform":"translate(-"+c.x+", -"+c.y+")","-ms-transform":"translate(-"+c.x+", -"+c.y+")","-moz-transform":"translate(-"+c.x+", -"+c.y+")",transform:"translate(-"+c.x+", -"+c.y+")",visibility:"hidden",opacity:0}).one("canplaythrough.vide",function(){i.resize()}).one("playing.vide",function(){t.css({visibility:"visible",opacity:1}),o.css("background-image","none")}),d.on("resize.vide",function(){p.resizing&&i.resize()}),o.append(t)},o.prototype.getVideoObject=function(){return this.$video[0]},o.prototype.resize=function(){if(this.$video){var e=this.$wrapper,t=this.$video,o=t[0],i=o.videoHeight,r=o.videoWidth,n=e.height(),s=e.width();s/r>n/i?t.css({width:s+2,height:"auto"}):t.css({width:"auto",height:n+2})}},o.prototype.destroy=function(){delete e.vide.lookup[this.index],this.$video&&this.$video.off("vide"),this.$element.off("vide").removeData("vide"),this.$wrapper.remove()},e.vide={lookup:[]},e.fn.vide=function(t,i){var r;return this.each(function(){(r=e.data(this,"vide"))&&r.destroy(),(r=new o(this,t,i)).index=e.vide.lookup.push(r)-1,e.data(this,"vide",r)}),this},e(document).ready(function(){var t=e(window);t.on("resize.vide",function(){for(var t,o=e.vide.lookup.length,i=0;i<o;i++)(t=e.vide.lookup[i])&&t.settings.resizing&&t.resize()}),t.on("unload.vide",function(){return!1}),e(document).find("[data-vide-bg]").each(function(t,o){var i=e(o),r=i.data("vide-options"),n=i.data("vide-bg");i.vide(n,r)})})});