/*
 * 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(b){b.getScript("http://github.com/cowboy/javascript-linkify/raw/master/ba-linkify.min.js");var j=function(a){return a.replace(/[@]+[A-Za-z0-9-_]+/ig,function(d){return d.link("http://twitter.com/"+d.replace("@",""))})},k=function(a){return a.replace(/[#]+[A-Za-z0-9-_]+/ig,function(d){return d.link("http://search.twitter.com/search?q="+d.replace("#","%23"))})};b.twitter=function(a,d){if(!a)return false;var c,f=RegExp(false);if(typeof a=="string")c=b.extend({},b.twitter.opts,{q:a});else{a.rpp=a.limit?a.limit:a.rpp;a.limit=a.limit?a.limit:a.rpp;f=(exclusionsStr=a.exclusions?a.exclusions.replace(" ","|"):false)?RegExp(exclusionsStr):false;c=b.extend({},b.twitter.opts,a);c.rpp=c.exclusions||!c.replies||!c.retweets?c.rpp*10:c.rpp}b.getJSON("http://search.twitter.com/search.json?callback=?",c,function(g){d(g,c,f)})};b.fn.twitter=function(a){if(!a)return this;return this.each(function(){var d=b(this);b.twitter(a,function(c,f,g){var h=b("<ul>"),i=0;if(c.results&&c.results.length){for(var l in c.results){var e=c.results[l],m=!f.replies&&e.to_user_id?false:true,n=!f.retweets&&e.text.slice(0,2)=="RT"?false:true;if(m)if(n)if(!(g&&g.test(e.text))){b("<li/>",{className:"tweet"}).append(b("<a/>",{href:"http://twitter.com/"+e.from_user,html:'<img src="'+e.profile_image_url+'"/>'})).append(b("<span>",{className:"content",html:'<a href="http://twitter.com/'+e.from_user+'">@'+e.from_user+"</a>: "+j(k(linkify(e.text)))})).appendTo(h);i++;if(i===f.limit)break}}d.html(h)}else d.html(b("<h3/>",{className:"twitter-notFound",text:f.notFoundText}))})})};b.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:""}})(jQuery);
