(function($){$.fn.videoBG=function(selector,options){if(options===undefined){options={};} if(typeof selector==="object"){options=$.extend({},$.fn.videoBG.defaults,selector);} else if(!selector){options=$.fn.videoBG.defaults;} else{return $(selector).videoBG(options);} var container=$(this);if(!container.length){return;} if(container.css('position')=='static'||!container.css('position')){container.css('position','relative');} if(options.width===0){options.width=container.width();} if(options.height===0){options.height=container.height();} var wrap=$.fn.videoBG.wrapper();wrap.height(options.height).width(options.width);if(options.textReplacement){options.scale=true;container.width(options.width).height(options.height).css('text-indent','-9999px');} else{wrap.css('z-index',options.zIndex+1);} wrap.html(container.clone(true));var video=$.fn.videoBG.video(options);if(options.scale){wrap.height(options.height).width(options.width);video.height(options.height).width(options.width);} container.html(wrap);container.append(video);return video.find("video")[0];};$.fn.videoBG.setFullscreen=function($el){var windowWidth=$(window).width(),windowHeight=$(window).height();$el.css('min-height',0).css('min-width',0);$el.parent().width(windowWidth).height(windowHeight);var shift=0;if(windowWidth/windowHeight>$el.aspectRatio){$el.width(windowWidth).height('auto');var height=$el.height();shift=(height-windowHeight)/2;if(shift<0){shift=0;} $el.css("top",-shift);}else{$el.width('auto').height(windowHeight);var width=$el.width();shift=(width-windowWidth)/2;if(shift<0){shift=0;} $el.css("left",-shift);if(shift===0){var t=setTimeout(function(){$.fn.videoBG.setFullscreen($el);},500);}} $('body > .videoBG_wrapper').width(windowWidth).height(windowHeight);};$.fn.videoBG.video=function(options){$('html, body').scrollTop(-1);var $div=$('
');$div.addClass('videoBG').css('position',options.position).css('z-index',options.zIndex).css('top',0).css('left',0).css('height',options.height).css('width',options.width).css('opacity',options.opacity).css('overflow','hidden');var $video=$('