/*jquery-oembed-youtube - v1.0.0
http://disshishkov.github.io/jquery-oembed-youtube
Copyright (c) 2014 Dis Shishkov; Licensed MIT
Original plugin: jquery-oembed(https://code.google.com/p/jquery-oembed/) by Richard Chamorro*/
var DS;!function(a){var b=function(){function a(a,b,c){this.MaxHeight=400,this.MaxWidth=500,this.ApiEndpoint=a,this.TemplateRegex=b,this.EmbedTag=c}return a}();a.OEmbedProvider=b}(DS||(DS={}));var DS;!function(a){var b=function(){function b(b,c){this._defaultOptions={MaxWidth:null,MaxHeight:null,IsIncludeHandle:!0,IsReplaceLink:!0,OnProviderNotFound:null,OnBeforeEmbed:null,OnAfterEmbed:null,OnEmbed:null},this._options=$.extend(!0,{},this._defaultOptions,c);var d=b.attr("href"),e=new RegExp("youtube\\.com/watch.+v=[\\w-]+&?","i");if(null!==d&&void 0!==d&&null!==d.match(e)){var f=new a.OEmbedProvider("https://www.youtube.com/embed/$1?wmode=transparent",/.*(?:v\=|be\/|embed\/)([\w\-]+)&?.*/,{Tag:"iframe",Height:349,Width:425});f.MaxWidth=this._options.MaxWidth,f.MaxHeight=this._options.MaxHeight;var g=$("<"+f.EmbedTag.Tag+"/>").attr("src",d.replace(f.TemplateRegex,f.ApiEndpoint)).attr("width",f.EmbedTag.Width?f.EmbedTag.Width.toString():"auto").attr("height",f.EmbedTag.Height?f.EmbedTag.Height.toString():"auto").attr("allowfullscreen","true").attr("allowscriptaccess","always").attr("scrolling","no").attr("frameborder","0").css("max-height",this._options.MaxHeight?this._options.MaxHeight.toString():"auto").css("max-width",this._options.MaxWidth?this._options.MaxWidth.toString():"auto");if(null!=this._options.OnBeforeEmbed&&this._options.OnBeforeEmbed.call(b,g),null!=this._options.OnEmbed)this._options.OnEmbed.call(b,g);else{if(!g)return;b.wrap("<div></div>");var h=b.parent();this._options.IsReplaceLink&&b.remove(),this._options.IsIncludeHandle&&!this._options.IsReplaceLink&&$("<span>&darr;</span>").insertBefore(b).click(function(a){var b=$(a.currentTarget);b.html("JnVhcnI7"==window.btoa(b.text())?"&darr;":"&uarr;"),b.parent().children().last().toggle()}),h.append("<br/>");try{g.clone().appendTo(h)}catch(i){h.append(g)}if(this._options.MaxWidth){var j=h.parent().width();if(j<this._options.MaxWidth){var k=$("iframe",h).width(),l=$("iframe",h).height(),m=k/j;$("iframe",h).width(k/m),$("iframe",h).height(l/m)}else this._options.MaxWidth&&$("iframe",h).width(this._options.MaxWidth),this._options.MaxHeight&&$("iframe",h).height(this._options.MaxHeight)}}null!=this._options.OnAfterEmbed&&this._options.OnAfterEmbed.call(b,g)}else null!==this._options.OnProviderNotFound&&this._options.OnProviderNotFound.call(b,d);return this}return b}();a.OEmbedYoutube=b}(DS||(DS={})),function(a){a.fn.OEmbedYoutube=function(b){return this.each(function(){var c=a(this);c.data("OEmbedYoutube")||c.data("OEmbedYoutube",new DS.OEmbedYoutube(c,b))})}}(jQuery);