(function(a){var b=function(a,b,c){this.target=a;this.url=b;this.html=[];this.options=jQuery.extend({ssl:false,limit:null,key:null,template:"",tokens:{}},c||{})};b.prototype.load=function(b){var c="http"+(this.options.ssl?"s":""),d=c+"://ajax.googleapis.com/ajax/services/feed/load",e=d+"?v=1.0&output=json_xml&callback=?&q="+encodeURIComponent(this.url),f=this;if(this.options.limit!=null)e+="&num="+this.options.limit;if(this.options.key!=null)e+="&key="+this.options.key;a.getJSON(e,b)};b.prototype.render=function(){var a=this,b=a.options.template.match(/\{entry\}(.*)\{\/entry\}/),c=!!b,d=c?b[1]:this.options.template;this.load(function(e){a.entries=e.responseData.feed.entries;jQuery(a.entries).each(function(){var b=this,c=d;if(a.isRelevant(b)){jQuery(d.match(/(\{.*?\})/g)).each(function(){var d=this.toString();c=c.replace(d,a.getValueForToken(d,b))});a.html.push(c)}});var f=a.html.join("\n");if(c)f=a.options.template.replace(b[0],f);else f=jQuery(f).length==0?jQuery("
"+f+"
"):jQuery(f);a.target.append(f)})};b.prototype.isRelevant=function(a){var b=this.getTokenMap(a);if(this.options.filter){if(this.options.filterLimit&&this.options.filterLimit==this.html.length){return false}else{return this.options.filter(a,b)}}else{return true}};b.prototype.getTokenMap=function(a){return jQuery.extend({url:a.link,author:a.author,date:a.publishedDate,title:a.title,body:a.content,shortBody:a.contentSnippet,bodyPlain:a.content.replace(/<\/?[^>]+>/gi,""),shortBodyPlain:a.contentSnippet.replace(/<\/?[^>]+>/gi,""),teaserImage:function(a){try{return a.content.match(/()/gi)[0]}catch(b){return""}},teaserImageUrl:function(a){try{return a.content.match(/()/gi)[0].match(/src="(.*?)"/)[1]}catch(b){return""}},index:jQuery.inArray(a,this.entries),totalEntries:this.entries.length},this.options.tokens)};b.prototype.getValueForToken=function(a,b){var c=this.getTokenMap(b),d=a.replace(/[\{\}]/g,""),e=c[d];if(typeof e!="undefined")return typeof e=="function"?e(b,c):e;else throw new Error("Unknown token: "+a)};a.fn.rss=function(a,c){(new b(this,a,c)).render()}})(jQuery)