/*
 * Twitter Search Plugin jquery.twitter.js
 * http://code.bocoup.com/jquery-twitter-plugin/
 *
 * Copyright (c) 2010 Bocoup, LLC
 * Authors: Boaz Sender, Rick Waldron, Nick Cammarata
 * Dual licensed under the MIT and GPL licenses.
 * http://code.bocoup.com/license/
 *
 */
;(function(c){if(!window.linkify){c.getScript("/includes/js/ba-linkify.min.js")}var b=function(d){return d.replace(/[@]+[A-Za-z0-9-_]+/ig,function(e){return e.link("http://twitter.com/"+e.replace("@",""))})},a=function(d){return d.replace(/[#]+[A-Za-z0-9-_]+/ig,function(e){return e.link("http://search.twitter.com/search?q="+e.replace("#","%23"))})};c.twitter=function(d,g){if(!d){return false}var f,e=new RegExp(false);if(typeof d=="string"){f=c.extend({},c.twitter.opts,{q:d})}else{d.rpp=d.limit?d.limit:d.rpp;d.limit=d.limit?d.limit:d.rpp;exclusionsStr=d.exclusions?d.exclusions.replace(" ","|"):false;e=exclusionsStr?new RegExp(exclusionsStr):false;f=c.extend({},c.twitter.opts,d);f.rpp=f.exclusions||!f.replies||!f.retweets?(f.rpp*10):f.rpp}c.getJSON("http://search.twitter.com/search.json?callback=?",f,function(h){g(h,f,e)})};c.fn.twitter=function(d){if(!d){return this}return this.each(function(){var e=c(this);c.twitter(d,function(k,n,h){var f=c("<ul>"),g=0;if(k.results&&k.results.length){for(var j in k.results){var m=k.results[j],p=!n.replies&&m.to_user_id?false:true,o=!n.retweets&&m.text.slice(0,2)=="RT"?false:true;if(!p){continue}if(!o){continue}if(h&&h.test(m.text)){continue}var l=c("<li/>",{className:"tweet"});if(n.avatar==true){l.append(c("<a/>",{href:"http://twitter.com/"+m.from_user,html:'<img src="'+m.profile_image_url+'"/>'}))}l.append(c("<span>",{className:"content",html: b(a(linkify(m.text)))})).appendTo(f);g++;if(g===n.limit){break}}e.html(f)}else{e.html(c("<h3/>",{className:"twitter-notFound",text:n.notFoundText}))}})})};c.twitter.opts={limit:7,exclusions:"",notFoundText:"No results found on twitter",replies:true,retweets:true,ands:"",phrase:"",ors:"",nots:"",tag:"",lang:"",from:"",to:"",ref:"",near:"",within:"",units:"",since:"",until:"",tude:"",filter:"",include:"",rpp:5,q:"",avatar:true}})(jQuery);
