(function($) {
  /*
  $.fn.latestTweet = function (customOptions) {
    var options = {
      username:'websitebiz'
    };
    if (customOptions) {
      $.extend(options, customOptions);
    }
    return this.each(function () {
      var e = $(this);
      $.getJSON('http://twitter.com/statuses/user_timeline/' + options.username + '.json?callback=?&count=3', function (response) {
        if (response.length) {
          var tweet = twttr.txt.autoLink(response[0].text);
          e.find('.tweet').html(tweet);
          e.find('.tweet a').attr({ target:'_blank' });
          e.find('.time-ago').text(' ' + prettyDate(response[0].created_at));
        }
      });
    });
  };
  */
  
  $.fn.latestTweet = function (customOptions) {
    var options = {
      username:'websitebiz',
      number:1
    };
    if (customOptions) {
      $.extend(options, customOptions);
    }
    return this.each(function () {
      var e = $(this);
      var l, p, s, limit, tweet;
      $.getJSON('/twitter_wrapper.php?wrapthis=http://twitter.com/statuses/user_timeline/' + options.username + '.json?callback=?&include_rts=1&count=' + 15, function (response) {
        if (response.length) {
          var limit = (response.length < options.number) ? response.length : options.number;
          for (var i = 0; i < limit; i++) {
            l = $('<li></li>');
            var tweet = twttr.txt.autoLink(response[i].text);
            p = $('<p class="tweet"></p>').html(tweet);
            p.find('a').attr({ target:'_blank' });
            //s = $('<br/><span></span>').text(' ' + prettyDate(response[i].created_at));
            
            p.append(s);
            l.append(p);
            e.append(l);
          }
        }
      });
    });
  };
  
  $.fn.recentTweets = function (customOptions) {
    var options = {
      username:'SeedsScholars',
      number:3
    };
    if (customOptions) {
      $.extend(options, customOptions);
    }
    return this.each(function () {
      var e = $(this);
      var l, p, s, limit, tweet;
      $.getJSON('http://twitter.com/statuses/user_timeline/' + options.username + '.json?callback=?&include_rts=1&count=' + 15, function (response) {
        if (response.length) {
          var limit = (response.length < options.number) ? response.length : options.number;
          for (var i = 0; i < limit; i++) {
            l = $('<li></li>');
            var tweet = twttr.txt.autoLink(response[i].text);
            p = $('<p class="tweet"></p>').html(tweet);
            p.find('a').attr({ target:'_blank' });
            //s = $('<span class="time-ago"></span>').text(' ' + prettyDate(response[i].created_at));
            
            p.append(s);
            l.append(p);
            e.append(l);
          }
        }
      });
    });
  };
  
})(jQuery);


/*
 * JavaScript Pretty Date
 * Copyright (c) 2008 John Resig (jquery.com)
 * Licensed under the MIT license.
 */

// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(time){
	var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
		diff = (((new Date()).getTime() - date.getTime()) / 1000),
		day_diff = Math.floor(diff / 86400);
			
	if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
		return;
			
	return day_diff == 0 && (
			diff < 60 && "just now" ||
			diff < 120 && "1 minute ago" ||
			diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
			diff < 7200 && "1 hour ago" ||
			diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
		day_diff == 1 && "Yesterday" ||
		day_diff < 7 && day_diff + " days ago" ||
		day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";
}

// If jQuery is included in the page, adds a jQuery plugin to handle it as well
if ( typeof jQuery != "undefined" ) {
	jQuery.fn.prettyDate = function(){
		return this.each(function(){
			var date = prettyDate(this.title);
			if ( date )
				jQuery(this).text( date );
		});
	};
}

/*!
 * twitter-text-js 1.4.2
 *
 * Copyright 2010 Twitter, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
if(!window.twttr)window.twttr={};
(function(){function c(b,a){a=a||"";if(typeof b!=="string")b.global&&a.indexOf("g")<0&&(a+="g"),b.ignoreCase&&a.indexOf("i")<0&&(a+="i"),b.multiline&&a.indexOf("m")<0&&(a+="m"),b=b.source;return RegExp(b.replace(/#\{(\w+)\}/g,function(a,b){var c=twttr.txt.regexen[b]||"";if(typeof c!=="string")c=c.source;return c}),a)}function j(b,a){return b.replace(/#\{(\w+)\}/g,function(b,c){return a[c]||""})}function l(b){var a={},k;for(k in b)b.hasOwnProperty(k)&&(a[k]=b[k]);return a}function i(b,a,k){if(!k)return typeof b===
"string"&&b.match(a)&&RegExp["$&"]===b;return!b||b.match(a)&&RegExp["$&"]===b}twttr.txt={};twttr.txt.regexen={};var s={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#32;"};twttr.txt.htmlEscape=function(b){return b&&b.replace(/[&"'><]/g,function(a){return s[a]})};for(var d=String.fromCharCode,p=[d(32),d(133),d(160),d(5760),d(6158),d(8232),d(8233),d(8239),d(8287),d(12288)],h=9;h<=13;h++)p.push(String.fromCharCode(h));for(h=8192;h<=8202;h++)p.push(String.fromCharCode(h));twttr.txt.regexen.spaces=
c("["+p.join("")+"]");twttr.txt.regexen.punct=/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~/;twttr.txt.regexen.atSigns=/[@\uff20]/;twttr.txt.regexen.extractMentions=c(/(^|[^a-zA-Z0-9_])(#{atSigns})([a-zA-Z0-9_]{1,20})(?=(.|$))/g);twttr.txt.regexen.extractReply=c(/^(?:#{spaces})*#{atSigns}([a-zA-Z0-9_]{1,20})/);twttr.txt.regexen.listName=/[a-zA-Z][a-zA-Z0-9_\-\u0080-\u00ff]{0,24}/;twttr.txt.regexen.latinAccentChars=c("\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u00c6\u00c7\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf\u00d0\u00d1\u00d2\u00d3\u00d4\u00d5\u00d6\u00d8\u00d9\u00da\u00db\u00dc\u00dd\u00de\u00df\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u00e6\u00e7\u00e8\u00e9\u00ea\u00eb\u00ec\u00ed\u00ee\u00ef\u00f0\u00f1\u00f2\u00f3\u00f4\u00f5\u00f6\u00f8\u00f9\u00fa\u00fb\u00fc\u00fd\u00fe\\303\\277");
twttr.txt.regexen.latenAccents=c(/[#{latinAccentChars}]+/);twttr.txt.regexen.endScreenNameMatch=c(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/\/)/);twttr.txt.regexen.hashtagAlpha=c(/[a-z_#{latinAccentChars}]/i);twttr.txt.regexen.hashtagAlphaNumeric=c(/[a-z0-9_#{latinAccentChars}]/i);twttr.txt.regexen.autoLinkHashtags=c(/(^|[^0-9A-Z&\/\?]+)(#|\uff03)(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi);twttr.txt.regexen.autoLinkUsernamesOrLists=/(^|[^a-zA-Z0-9_]|RT:?)([@\uff20]+)([a-zA-Z0-9_]{1,20})(\/[a-zA-Z][a-zA-Z0-9_\-]{0,24})?/g;
twttr.txt.regexen.autoLinkEmoticon=/(8\-\#|8\-E|\+\-\(|\`\@|\`O|\&lt;\|:~\(|\}:o\{|:\-\[|\&gt;o\&lt;|X\-\/|\[:-\]\-I\-|\/\/\/\/\u00d6\\\\\\\\|\(\|:\|\/\)|\u2211:\*\)|\( \| \))/g;twttr.txt.regexen.validPrecedingChars=c(/(?:[^-\/"':!=A-Za-z0-9_@\uff20]|^|\:)/);twttr.txt.regexen.validSubdomain=c(/([^#{punct}\s]([_-]|[^#{punct}\s])*)?[^#{punct}\s]\./);twttr.txt.regexen.validDomainName=c(/([^#{punct}\s]([-]|[^#{punct}\s])*)?[^#{punct}\s]/);twttr.txt.regexen.validDomain=c(/(#{validSubdomain})*#{validDomainName}\.[a-z]{2,}(?::[0-9]+)?/i);
twttr.txt.regexen.validGeneralUrlPathChars=/[a-z0-9!\*';:=\+\$\/%#\[\]\-_,~|]/i;twttr.txt.regexen.wikipediaDisambiguation=c(/(?:\(#{validGeneralUrlPathChars}+\))/i);twttr.txt.regexen.validUrlPathChars=c(/(?:#{wikipediaDisambiguation}|@#{validGeneralUrlPathChars}+\/|[\.,]?#{validGeneralUrlPathChars})/i);twttr.txt.regexen.validUrlPathEndingChars=c(/(?:[\+\-a-z0-9=_#\/]|#{wikipediaDisambiguation})/i);twttr.txt.regexen.validUrlQueryChars=/[a-z0-9!\*'\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i;twttr.txt.regexen.validUrlQueryEndingChars=
/[a-z0-9_&=#\/]/i;twttr.txt.regexen.extractUrl=c("((#{validPrecedingChars})((https?:\\/\\/)(#{validDomain})(\\/(?:#{validUrlPathChars}+#{validUrlPathEndingChars}|#{validUrlPathChars}+#{validUrlPathEndingChars}?|#{validUrlPathEndingChars})?)?(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?))","gi");twttr.txt.regexen.validateUrlUnreserved=/[a-z0-9\-._~]/i;twttr.txt.regexen.validateUrlPctEncoded=/(?:%[0-9a-f]{2})/i;twttr.txt.regexen.validateUrlSubDelims=/[!$&'()*+,;=]/i;twttr.txt.regexen.validateUrlPchar=
c("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|:|@)","i");twttr.txt.regexen.validateUrlScheme=/(?:[a-z][a-z0-9+\-.]*)/i;twttr.txt.regexen.validateUrlUserinfo=c("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|:)*","i");twttr.txt.regexen.validateUrlDecOctet=/(?:[0-9]|(?:[1-9][0-9])|(?:1[0-9]{2})|(?:2[0-4][0-9])|(?:25[0-5]))/i;twttr.txt.regexen.validateUrlIpv4=c(/(?:#{validateUrlDecOctet}(?:\.#{validateUrlDecOctet}){3})/i);twttr.txt.regexen.validateUrlIpv6=
/(?:\[[a-f0-9:\.]+\])/i;twttr.txt.regexen.validateUrlIp=c("(?:#{validateUrlIpv4}|#{validateUrlIpv6})","i");twttr.txt.regexen.validateUrlSubDomainSegment=/(?:[a-z0-9](?:[a-z0-9_\-]*[a-z0-9])?)/i;twttr.txt.regexen.validateUrlDomainSegment=/(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)/i;twttr.txt.regexen.validateUrlDomainTld=/(?:[a-z](?:[a-z0-9\-]*[a-z0-9])?)/i;twttr.txt.regexen.validateUrlDomain=c(/(?:(?:#{validateUrlSubDomainSegment]}\.)*(?:#{validateUrlDomainSegment]}\.)#{validateUrlDomainTld})/i);twttr.txt.regexen.validateUrlHost=
c("(?:#{validateUrlIp}|#{validateUrlDomain})","i");twttr.txt.regexen.validateUrlUnicodeSubDomainSegment=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9_\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i;twttr.txt.regexen.validateUrlUnicodeDomainSegment=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i;twttr.txt.regexen.validateUrlUnicodeDomainTld=/(?:(?:[a-z]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i;
twttr.txt.regexen.validateUrlUnicodeDomain=c(/(?:(?:#{validateUrlUnicodeSubDomainSegment}\.)*(?:#{validateUrlUnicodeDomainSegment}\.)#{validateUrlUnicodeDomainTld})/i);twttr.txt.regexen.validateUrlUnicodeHost=c("(?:#{validateUrlIp}|#{validateUrlUnicodeDomain})","i");twttr.txt.regexen.validateUrlPort=/[0-9]{1,5}/;twttr.txt.regexen.validateUrlUnicodeAuthority=c("(?:(#{validateUrlUserinfo})@)?(#{validateUrlUnicodeHost})(?::(#{validateUrlPort}))?","i");twttr.txt.regexen.validateUrlAuthority=c("(?:(#{validateUrlUserinfo})@)?(#{validateUrlHost})(?::(#{validateUrlPort}))?",
"i");twttr.txt.regexen.validateUrlPath=c(/(\/#{validateUrlPchar}*)*/i);twttr.txt.regexen.validateUrlQuery=c(/(#{validateUrlPchar}|\/|\?)*/i);twttr.txt.regexen.validateUrlFragment=c(/(#{validateUrlPchar}|\/|\?)*/i);twttr.txt.regexen.validateUrlUnencoded=c("^(?:([^:/?#]+):)(?://([^/?#]*))([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$","i");twttr.txt.autoLink=function(b,a){a=l(a||{});return twttr.txt.autoLinkUsernamesOrLists(twttr.txt.autoLinkUrlsCustom(twttr.txt.autoLinkHashtags(b,a),a),a)};twttr.txt.autoLinkUsernamesOrLists=
function(b,a){a=l(a||{});a.urlClass=a.urlClass||"tweet-url";a.listClass=a.listClass||"list-slug";a.usernameClass=a.usernameClass||"username";a.usernameUrlBase=a.usernameUrlBase||"http://twitter.com/";a.listUrlBase=a.listUrlBase||"http://twitter.com/";if(!a.suppressNoFollow)var k=' rel="nofollow"';for(var c="",g=twttr.txt.splitTags(b),e=0;e<g.length;e++){var f=g[e];e!==0&&(c+=e%2===0?">":"<");c+=e%4!==0?f:f.replace(twttr.txt.regexen.autoLinkUsernamesOrLists,function(b,c,r,e,g,f,d){var f=d.slice(f+
b.length),c={before:c,at:r,user:twttr.txt.htmlEscape(e),slashListname:twttr.txt.htmlEscape(g),extraHtml:k,preChunk:"",chunk:twttr.txt.htmlEscape(d),postChunk:""},h;for(h in a)a.hasOwnProperty(h)&&(c[h]=a[h]);return g&&!a.suppressLists?(b=c.chunk=j("#{user}#{slashListname}",c),c.list=twttr.txt.htmlEscape(b.toLowerCase()),j('#{before}#{at}<a class="#{urlClass} #{listClass}" href="#{listUrlBase}#{list}"#{extraHtml}>#{chunk}</a>',c)):f&&f.match(twttr.txt.regexen.endScreenNameMatch)?b:(c.chunk=twttr.txt.htmlEscape(e),
c.dataScreenName=!a.suppressDataScreenName?j('data-screen-name="#{chunk}" ',c):"",j('#{before}#{at}<a class="#{urlClass} #{usernameClass}" #{dataScreenName}href="#{usernameUrlBase}#{chunk}"#{extraHtml}>#{preChunk}#{chunk}#{postChunk}</a>',c))})}return c};twttr.txt.autoLinkHashtags=function(b,a){a=l(a||{});a.urlClass=a.urlClass||"tweet-url";a.hashtagClass=a.hashtagClass||"hashtag";a.hashtagUrlBase=a.hashtagUrlBase||"http://twitter.com/search?q=%23";if(!a.suppressNoFollow)var k=' rel="nofollow"';return b.replace(twttr.txt.regexen.autoLinkHashtags,
function(b,c,e,f){var b={before:c,hash:twttr.txt.htmlEscape(e),preText:"",text:twttr.txt.htmlEscape(f),postText:"",extraHtml:k},d;for(d in a)a.hasOwnProperty(d)&&(b[d]=a[d]);return j('#{before}<a href="#{hashtagUrlBase}#{text}" title="##{text}" class="#{urlClass} #{hashtagClass}"#{extraHtml}>#{hash}#{preText}#{text}#{postText}</a>',b)})};twttr.txt.autoLinkUrlsCustom=function(b,a){a=l(a||{});if(!a.suppressNoFollow)a.rel="nofollow";if(a.urlClass)a["class"]=a.urlClass,delete a.urlClass;delete a.suppressNoFollow;
delete a.suppressDataScreenName;return b.replace(twttr.txt.regexen.extractUrl,function(b,c,g,e,f){if(f){var b="",d;for(d in a)b+=j(' #{k}="#{v}" ',{k:d,v:a[d].toString().replace(/"/,"&quot;").replace(/</,"&lt;").replace(/>/,"&gt;")});g={before:g,htmlAttrs:b,url:twttr.txt.htmlEscape(e)};return j('#{before}<a href="#{url}"#{htmlAttrs}>#{url}</a>',g)}else return c})};twttr.txt.extractMentions=function(b){for(var a=[],b=twttr.txt.extractMentionsWithIndices(b),c=0;c<b.length;c++)a.push(b[c].screenName);
return a};twttr.txt.extractMentionsWithIndices=function(b){if(!b)return[];var a=[],c=0;b.replace(twttr.txt.regexen.extractMentions,function(d,g,e,f,h){h.match(twttr.txt.regexen.endScreenNameMatch)||(d=b.indexOf(e+f,c),c=d+f.length+1,a.push({screenName:f,indices:[d,c]}))});return a};twttr.txt.extractReplies=function(b){if(!b)return null;b=b.match(twttr.txt.regexen.extractReply);if(!b)return null;return b[1]};twttr.txt.extractUrls=function(b){for(var a=[],b=twttr.txt.extractUrlsWithIndices(b),c=0;c<
b.length;c++)a.push(b[c].url);return a};twttr.txt.extractUrlsWithIndices=function(b){if(!b)return[];var a=[];b.replace(twttr.txt.regexen.extractUrl,function(c,d,g,e,f){if(f){var c=b.indexOf(e,h),h=c+e.length;a.push({url:e,indices:[c,h]})}});return a};twttr.txt.extractHashtags=function(b){for(var a=[],b=twttr.txt.extractHashtagsWithIndices(b),c=0;c<b.length;c++)a.push(b[c].hashtag);return a};twttr.txt.extractHashtagsWithIndices=function(b){if(!b)return[];var a=[],c=0;b.replace(twttr.txt.regexen.autoLinkHashtags,
function(d,g,e,f){d=b.indexOf(e+f,c);c=d+f.length+1;a.push({hashtag:f,indices:[d,c]})});return a};twttr.txt.splitTags=function(b){for(var b=b.split("<"),a,c=[],d=0;d<b.length;d+=1)if(a=b[d]){a=a.split(">");for(var g=0;g<a.length;g+=1)c.push(a[g])}else c.push("");return c};twttr.txt.hitHighlight=function(b,a,c){a=a||[];c=c||{};if(a.length===0)return b;var c=c.tag||"em",c=["<"+c+">","</"+c+">"],b=twttr.txt.splitTags(b),d,g,e="",f=0,h=b[0],j=0,i=0,n=!1,m=h,l=[],o;for(d=0;d<a.length;d+=1)for(g=0;g<a[d].length;g+=
1)l.push(a[d][g]);for(a=0;a<l.length;a+=1){g=l[a];d=c[a%2];for(o=!1;h!=null&&g>=j+h.length;)e+=m.slice(i),n&&g===j+m.length&&(e+=d,o=!0),b[f+1]&&(e+="<"+b[f+1]+">"),j+=m.length,i=0,f+=2,m=h=b[f],n=!1;!o&&h!=null?(n=g-j,e+=m.slice(i,n)+d,i=n,n=a%2===0?!0:!1):o||(e+=d)}if(h!=null){i<m.length&&(e+=m.slice(i));for(a=f+1;a<b.length;a+=1)e+=a%2===0?b[a]:"<"+b[a]+">"}return e};var q=[d(65534),d(65279),d(65535),d(8234),d(8235),d(8236),d(8237),d(8238)];twttr.txt.isInvalidTweet=function(b){if(!b)return"empty";
if(b.length>140)return"too_long";for(var a=0;a<q.length;a++)if(b.indexOf(q[a])>=0)return"invalid_characters";return!1};twttr.txt.isValidTweetText=function(b){return!twttr.txt.isInvalidTweet(b)};twttr.txt.isValidUsername=function(b){if(!b)return!1;var a=twttr.txt.extractMentions(b);return a.length===1&&a[0]===b.slice(1)};var t=c(/^#{autoLinkUsernamesOrLists}$/);twttr.txt.isValidList=function(b){b=b.match(t);return!(!b||!(b[1]==""&&b[4]))};twttr.txt.isValidHashtag=function(b){if(!b)return!1;var a=twttr.txt.extractHashtags(b);
return a.length===1&&a[0]===b.slice(1)};twttr.txt.isValidUrl=function(b,a){a==null&&(a=!0);if(!b)return!1;var c=b.match(twttr.txt.regexen.validateUrlUnencoded);if(!c||c[0]!==b)return!1;var d=c[1],g=c[2],e=c[3],f=c[4],c=c[5];if(!i(d,twttr.txt.regexen.validateUrlScheme)||!d.match(/^https?$/i)||!i(e,twttr.txt.regexen.validateUrlPath)||!i(f,twttr.txt.regexen.validateUrlQuery,!0)||!i(c,twttr.txt.regexen.validateUrlFragment,!0))return!1;return a&&i(g,twttr.txt.regexen.validateUrlUnicodeAuthority)||!a&&
i(g,twttr.txt.regexen.validateUrlAuthority)}})();

