;(function($,window,document,navigator){"use strict";var pluginName="vide",defaults={volume:1,playbackRate:1,muted:true,loop:true,autoplay:true,position:"50% 50%",posterType:"detect"};var iOS=/iPad|iPhone|iPod/i.test(navigator.userAgent),android=/Android/i.test(navigator.userAgent);$[pluginName]={lookup:[]};var parseOptions=function(str){var obj={},clearedStr,arr;clearedStr=str.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,",");arr=clearedStr.split(",");var i,len,val;for(i=0,len=arr.length;i").load(onLoad);$("").load(onLoad);$("").load(onLoad);$("").load(onLoad);};function Vide(element,path,options){this.element=$(element);this._defaults=defaults;this._name=pluginName;if(typeof path==="string"){path=path.replace(/\.\w*$/,"");}else if(typeof path==="object"){for(var i in path){path[i]=path[i].replace(/\.\w*$/,"");}}this.settings=$.extend({},defaults,options);this.path=path;this.init();}Vide.prototype.init=function(){var that=this;this.wrapper=$("
");var position=parsePosition(this.settings.position);this.wrapper.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-repeat":"no-repeat","background-position":position.x+" "+position.y});var poster=this.path;if(typeof this.path==="object"){if(this.path.poster){poster=this.path.poster;}else{if(this.path.mp4){poster=this.path.mp4;}else if(this.path.webm){poster=this.path.webm;}else if(this.path.ogv){poster=this.path.webm;}}}if(this.settings.posterType==="detect"){findPoster(poster,$.proxy(this.setPoster,this));}else{this.setPoster(poster+"."+this.settings.posterType);}if(this.element.css("position")==="static"){this.element.css("position","relative");}this.element.prepend(this.wrapper);if(!iOS&&!android){if(typeof this.path==="object"){var sources="";if(this.path.mp4){sources+="";}if(this.path.webm){sources+="";}if(this.path.ogv){sources+="";}this.video=$("");}else{this.video=$("");}this.video.css("visibility","hidden");this.video.prop({autoplay:this.settings.autoplay,loop:this.settings.loop,volume:this.settings.volume,muted:this.settings.muted,playbackRate:this.settings.playbackRate});this.wrapper.append(this.video);this.video.css({"margin":"auto","position":"absolute","z-index":-1,"top":position.y,"left":position.x,"-webkit-transform":"translate(-"+position.x+", -"+position.y+")","-ms-transform":"translate(-"+position.x+", -"+position.y+")","transform":"translate(-"+position.x+", -"+position.y+")"});this.video.bind("loadedmetadata."+pluginName,function(){that.video.css("visibility","visible");that.resize();});$(this.element).bind("resize."+pluginName,function(){that.resize();});}};Vide.prototype.setPoster=function(url){this.wrapper.css("background-image","url("+url+")");};Vide.prototype.getVideoObject=function(){return this.video?this.video[0]:null;};Vide.prototype.resize=function(){if(!this.video){return;}var videoHeight=this.video[0].videoHeight,videoWidth=this.video[0].videoWidth;var wrapperHeight=this.wrapper.height(),wrapperWidth=this.wrapper.width();if(wrapperWidth/videoWidth>wrapperHeight/videoHeight){this.video.css({"width":wrapperWidth+2,"height":"auto"});}else{this.video.css({"width":"auto","height":wrapperHeight+2});}};Vide.prototype.destroy=function(){this.element.unbind(pluginName);if(this.video){this.video.unbind(pluginName);}delete $[pluginName].lookup[this.index];this.element.removeData(pluginName);this.wrapper.remove();};$.fn[pluginName]=function(path,options){var instance;this.each(function(){instance=$.data(this,pluginName);if(instance){instance.destroy();}instance=new Vide(this,path,options);instance.index=$[pluginName].lookup.push(instance)-1;$.data(this,pluginName,instance);});return this;};$(document).ready(function(){$(window).bind("resize."+pluginName,function(){for(var len=$[pluginName].lookup.length,instance,i=0;i