/*
 * Embedly JQuery v2.1.4
 */
(function(a){window.embedlyURLre=/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;a.embedly=a.embedly||{};if(a.embedly.version){return}a.embedly.version="2.1.1";a.extend({embedly:function(k,q,o){var b=[];var p="http://api.embed.ly/";var d={endpoint:"oembed",maxWidth:null,maxHeight:null,wmode:"opaque",autoplay:null,width:null,method:"replace",addImageStyles:true,wrapElement:"div",className:"embed",urlRe:null,key:null,elems:[],success:null,error:null};var c;if(typeof q!="undefined"){c=a.extend(d,q)}else{c=d}if(!c.urlRe){c.urlRe=window.embedlyURLre}if(typeof k=="string"){k=new Array(k)}if(typeof o!="undefined"){c.success=o}if(c.success==null){c.success=function(i,t){var r,s=a(t.node);if(!(i)){return null}if((r=c.method)==="replace"){return s.replaceWith(i.code)}else{if(r==="after"){return s.after(i.code)}else{if(r==="afterParent"){return s.parent().after(i.code)}else{if(r==="replaceParent"){return s.parent().replaceWith(i.code)}}}}}}if(c.error==null){c.error=function(i,r){}}var m=function(i){return c.urlRe.test(i)};var n=function(r){var i="urls="+r;if(c.maxWidth!=null){i+="&maxwidth="+c.maxWidth}else{if(typeof dimensions!="undefined"){i+="&maxwidth="+dimensions.width}}if(c.maxHeight!=null){i+="&maxheight="+c.maxHeight}i+="&wmode="+c.wmode;if(typeof c.key=="string"){i+="&key="+c.key}if(typeof c.autoplay=="string"){i+="&autoplay="+c.autoplay}if(c.width){i+="&width="+c.width}return i};var j=function(){if(typeof c.key=="string"){if(c.endpoint.search(/objectify/i)>=0){return p+"2/objectify"}else{if(c.endpoint.search(/preview/i)>=0){return p+"1/preview"}}}return p+"1/oembed"};var g=function(i,v){if(c.endpoint!="oembed"){return c.success(i,v)}var r,t,s,u;if((r=i.type)==="photo"){u=i.title||"";s=[];if(c.addImageStyles){if(c.maxWidth){units=isNaN(parseInt(c.maxWidth))?"":"px";s.push("max-width: "+(c.maxWidth)+units)}if(c.maxHeight){units=isNaN(parseInt(c.maxHeight))?"":"px";s.push("max-height: "+(c.maxHeight)+units)}}s=s.join(";");t="<a href='"+v.url+"' target='_blank'><img style='"+s+"' src='"+i.url+"' alt='"+u+"' /></a>"}else{if(r==="video"){t=i.html}else{if(r==="rich"){t=i.html}else{u=i.title||v.url;thumb=i.thumbnail_url?'<img src="'+i.thumbnail_url+'" class="thumb" />':"";description=i.description;provider=i.provider_name?'<a href="'+i.provider_url+'" class="provider">'+i.provider_name+"</a> - ":"";t=thumb+"<a href='"+v.url+"'>"+u+"</a>";t+=provider;t+=description}}}if(c.wrapElement&&c.wrapElement=="div"&&a.browser.msie&&a.browser.version<9){c.wrapElement="span"}if(c.wrapElement){t="<"+c.wrapElement+' class="'+c.className+'">'+t+"</"+c.wrapElement+">"}i.code=t;if(typeof v.node!="undefined"){a(v.node).data("oembed",i).trigger("embedly-oembed",[i])}return c.success(i,v)};var e=function(i){var s,u,t,r;t=a.map(i,function(w,v){if(v==0){if(w.node!==null){node=a(w.node);r={width:node.parent().width(),height:node.parent().height()}}}return encodeURIComponent(w.url)}).join(",");a.ajax({url:j(),dataType:"jsonp",data:n(t),success:function(v){return a.each(v,function(w,x){return x.type!="error"?g(x,i[w]):c.error(i[w].node,x)})}})};a.each(k,function(s,r){node=typeof c.elems!=="undefined"?c.elems[s]:null;if(typeof node!="undefined"&&!m(r)){a(node).data("oembed",false)}var t={url:r,error_code:400,error_message:"HTTP 400: Bad Request",type:"error"};return(r&&m(r))?b.push({url:r,node:node}):c.error(node,t)});var l=[];var h=b.length;for(var f=0;(0<=h?f<h:f>h);f+=20){l=l.concat(e(b.slice(f,f+20)))}if(c.elems){return c.elems}else{return this}}});a.fn.embedly=function(d,g){var e=typeof d!="undefined"?d:{};if(typeof g!="undefined"){d.success=g}var f=new Array();var c=new Array();this.each(function(){if(typeof a(this).attr("href")!="undefined"){f.push(a(this).attr("href"));c.push(a(this))}else{a(this).find("a").each(function(){f.push(a(this).attr("href"));c.push(a(this))})}e.elems=c});var b=a.embedly(f,e);return this}})(jQuery);
