!function(U,j,e,S){"use strict";j=void 0!==j&&j.Math==Math?j:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),U.fn.embed=function(h){var b,g=U(this),v=g.selector||"",y=(new Date).getTime(),w=[],P=h,C="string"==typeof P,E=[].slice.call(arguments,1);return g.each(function(){var c,t=U.isPlainObject(h)?U.extend(!0,{},U.fn.embed.settings,h):U.extend({},U.fn.embed.settings),e=t.selector,n=t.className,r=t.sources,l=t.error,a=t.metadata,o=t.namespace,i=t.templates,d="."+o,u="module-"+o,s=(U(j),U(this)),m=(s.find(e.placeholder),s.find(e.icon),s.find(e.embed)),p=this,f=s.data(u);c={initialize:function(){c.debug("Initializing embed"),c.determine.autoplay(),c.create(),c.bind.events(),c.instantiate()},instantiate:function(){c.verbose("Storing instance of module",c),f=c,s.data(u,c)},destroy:function(){c.verbose("Destroying previous instance of embed"),c.reset(),s.removeData(u).off(d)},refresh:function(){c.verbose("Refreshing selector cache"),s.find(e.placeholder),s.find(e.icon),m=s.find(e.embed)},bind:{events:function(){c.has.placeholder()&&(c.debug("Adding placeholder events"),s.on("click"+d,e.placeholder,c.createAndShow).on("click"+d,e.icon,c.createAndShow))}},create:function(){c.get.placeholder()?c.createPlaceholder():c.createAndShow()},createPlaceholder:function(e){var n=c.get.icon(),o=c.get.url();c.generate.embed(o);e=e||c.get.placeholder(),s.html(i.placeholder(e,n)),c.debug("Creating placeholder for embed",e,n)},createEmbed:function(e){c.refresh(),e=e||c.get.url(),m=U("<div/>").addClass(n.embed).html(c.generate.embed(e)).appendTo(s),t.onCreate.call(p,e),c.debug("Creating embed object",m)},changeEmbed:function(e){m.html(c.generate.embed(e))},createAndShow:function(){c.createEmbed(),c.show()},change:function(e,n,o){c.debug("Changing video to ",e,n,o),s.data(a.source,e).data(a.id,n),o?s.data(a.url,o):s.removeData(a.url),c.has.embed()?c.changeEmbed():c.create()},reset:function(){c.debug("Clearing embed and showing placeholder"),c.remove.active(),c.remove.embed(),c.showPlaceholder(),t.onReset.call(p)},show:function(){c.debug("Showing embed"),c.set.active(),t.onDisplay.call(p)},hide:function(){c.debug("Hiding embed"),c.showPlaceholder()},showPlaceholder:function(){c.debug("Showing placeholder image"),c.remove.active(),t.onPlaceholderDisplay.call(p)},get:{id:function(){return t.id||s.data(a.id)},placeholder:function(){return t.placeholder||s.data(a.placeholder)},icon:function(){return t.icon?t.icon:s.data(a.icon)!==S?s.data(a.icon):c.determine.icon()},source:function(e){return t.source?t.source:s.data(a.source)!==S?s.data(a.source):c.determine.source()},type:function(){var e=c.get.source();return r[e]!==S&&r[e].type},url:function(){return t.url?t.url:s.data(a.url)!==S?s.data(a.url):c.determine.url()}},determine:{autoplay:function(){c.should.autoplay()&&(t.autoplay=!0)},source:function(o){var t=!1;return(o=o||c.get.url())&&U.each(r,function(e,n){if(-1!==o.search(n.domain))return t=e,!1}),t},icon:function(){var e=c.get.source();return r[e]!==S&&r[e].icon},url:function(){var e,n=t.id||s.data(a.id),o=t.source||s.data(a.source);return(e=r[o]!==S&&r[o].url.replace("{id}",n))&&s.data(a.url,e),e}},set:{active:function(){s.addClass(n.active)}},remove:{active:function(){s.removeClass(n.active)},embed:function(){m.empty()}},encode:{parameters:function(e){var n,o=[];for(n in e)o.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return o.join("&amp;")}},generate:{embed:function(e){c.debug("Generating embed html");var n,o,t=c.get.source();return(e=c.get.url(e))?(o=c.generate.parameters(t),n=i.iframe(e,o)):c.error(l.noURL,s),n},parameters:function(e,n){var o=r[e]&&r[e].parameters!==S?r[e].parameters(t):{};return(n=n||t.parameters)&&(o=U.extend({},o,n)),o=t.onEmbed(o),c.encode.parameters(o)}},has:{embed:function(){return 0<m.length},placeholder:function(){return t.placeholder||s.data(a.placeholder)}},should:{autoplay:function(){return"auto"===t.autoplay?t.placeholder||s.data(a.placeholder)!==S:t.autoplay}},is:{video:function(){return"video"==c.get.type()}},setting:function(e,n){if(c.debug("Changing setting",e,n),U.isPlainObject(e))U.extend(!0,t,e);else{if(n===S)return t[e];U.isPlainObject(t[e])?U.extend(!0,t[e],n):t[e]=n}},internal:function(e,n){if(U.isPlainObject(e))U.extend(!0,c,e);else{if(n===S)return c[e];c[e]=n}},debug:function(){!t.silent&&t.debug&&(t.performance?c.performance.log(arguments):(c.debug=Function.prototype.bind.call(console.info,console,t.name+":"),c.debug.apply(console,arguments)))},verbose:function(){!t.silent&&t.verbose&&t.debug&&(t.performance?c.performance.log(arguments):(c.verbose=Function.prototype.bind.call(console.info,console,t.name+":"),c.verbose.apply(console,arguments)))},error:function(){t.silent||(c.error=Function.prototype.bind.call(console.error,console,t.name+":"),c.error.apply(console,arguments))},performance:{log:function(e){var n,o;t.performance&&(o=(n=(new Date).getTime())-(y||n),y=n,w.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:p,"Execution Time":o})),clearTimeout(c.performance.timer),c.performance.timer=setTimeout(c.performance.display,500)},display:function(){var e=t.name+":",o=0;y=!1,clearTimeout(c.performance.timer),U.each(w,function(e,n){o+=n["Execution Time"]}),e+=" "+o+"ms",v&&(e+=" '"+v+"'"),1<g.length&&(e+=" ("+g.length+")"),(console.group!==S||console.table!==S)&&0<w.length&&(console.groupCollapsed(e),console.table?console.table(w):U.each(w,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),w=[]}},invoke:function(t,e,n){var r,a,o,i=f;return e=e||E,n=p||n,"string"==typeof t&&i!==S&&(t=t.split(/[\. ]/),r=t.length-1,U.each(t,function(e,n){var o=e!=r?n+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(U.isPlainObject(i[o])&&e!=r)i=i[o];else{if(i[o]!==S)return a=i[o],!1;if(!U.isPlainObject(i[n])||e==r)return i[n]!==S?a=i[n]:c.error(l.method,t),!1;i=i[n]}})),U.isFunction(a)?o=a.apply(n,e):a!==S&&(o=a),U.isArray(b)?b.push(o):b!==S?b=[b,o]:o!==S&&(b=o),a}},C?(f===S&&c.initialize(),c.invoke(P)):(f!==S&&f.invoke("destroy"),c.initialize())}),b!==S?b:this},U.fn.embed.settings={name:"Embed",namespace:"embed",silent:!1,debug:!1,verbose:!1,performance:!0,icon:!1,source:!1,url:!1,id:!1,autoplay:"auto",color:"#444444",hd:!0,brandedUI:!1,parameters:!1,onDisplay:function(){},onPlaceholderDisplay:function(){},onReset:function(){},onCreate:function(e){},onEmbed:function(e){return e},metadata:{id:"id",icon:"icon",placeholder:"placeholder",source:"source",url:"url"},error:{noURL:"No URL specified",method:"The method you called is not defined"},className:{active:"active",embed:"embed"},selector:{embed:".embed",placeholder:".placeholder",icon:".icon"},sources:{youtube:{name:"youtube",type:"video",icon:"video play",domain:"youtube.com",url:"//www.youtube.com/embed/{id}",parameters:function(e){return{autohide:!e.brandedUI,autoplay:e.autoplay,color:e.color||S,hq:e.hd,jsapi:e.api,modestbranding:!e.brandedUI}}},vimeo:{name:"vimeo",type:"video",icon:"video play",domain:"vimeo.com",url:"//player.vimeo.com/video/{id}",parameters:function(e){return{api:e.api,autoplay:e.autoplay,byline:e.brandedUI,color:e.color||S,portrait:e.brandedUI,title:e.brandedUI}}}},templates:{iframe:function(e,n){var o=e;return n&&(o+="?"+n),'<iframe src="'+o+'" width="100%" height="100%" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'},placeholder:function(e,n){var o="";return n&&(o+='<i class="'+n+' icon"></i>'),e&&(o+='<img class="placeholder" src="'+e+'">'),o}},api:!1,onPause:function(){},onPlay:function(){},onStop:function(){}}}(jQuery,window,document);