/*
 * jQuery Tasty Tweet v1.1
 * http://tastycms.com/tastytweet
 *
 * Copyright 2010, Ed Knittel
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 */

(function(a){a.fn.tastyTweet=function(b){var d=a.extend({},a.fn.tastyTweet.defaults,b);return this.each(function(){var e=a(this);e.addClass("tastyTweet");a.ajaxSetup({cache:true});a.getJSON("http://search.twitter.com/search.json?callback=?&rpp="+d.count+"&q=from:"+d.user,function(f){if(d.showTitle){e.append('<h3><a href="http://twitter.com/'+d.user+'">Follow <strong>'+d.user+"</strong> <span>on <em>Twitter</em></span></a></h3>")}e.append("<ul/>");a.each(f.results,function(j,m){if(m.text!==undefined){var l=new RegExp("^"+d.user+": ","g");var h=m.text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g,function(i){return'<a href="'+i+'">'+i+"</a>"}).replace(/\B@([_a-z0-9]+)/ig,function(i){return i.charAt(0)+'<a href="http://twitter.com/'+i.substring(1)+'">'+i.substring(1)+"</a>"}).replace(l,"");var k="http://twitter.com/"+d.user+"/statuses/"+m.id;var g='<a href="'+k+'">'+c(m.created_at)+"</a>";var m=e.find("ul").append(a("<li>"+h+" - "+g+"</li>"));if(d.effect.length>0){if(d.effect=="fadeIn"){m.hide().fadeIn(d.animSpeed)}else{if(d.effect=="slideDown"){m.hide().slideDown(d.animSpeed)}}}}})})});function c(h){var e=h.split(" ");h=e[2]+" "+e[1]+", "+e[3]+" "+e[4];var g=Date.parse(h);var f=(arguments.length>1)?arguments[1]:new Date();var i=parseInt((f.getTime()-g)/1000);i=i+(f.getTimezoneOffset()*60);if(i<60){return"less than a minute ago"}else{if(i<120){return"about a minute ago"}else{if(i<(60*60)){return(parseInt(i/60)).toString()+" minutes ago"}else{if(i<(120*60)){return"about an hour ago"}else{if(i<(24*60*60)){return"about "+(parseInt(i/3600)).toString()+" hours ago"}else{if(i<(48*60*60)){return"1 day ago"}else{return(parseInt(i/86400)).toString()+" days ago"}}}}}}}};a.fn.tastyTweet.defaults={user:"tastycms",count:5,effect:"fadeIn",animSpeed:750,showTitle:true}})(jQuery);
