(function (d) {
    var e = {
        username: false,
        cache: true,
        count: 4
    };
    var a = (function () {
        var f = [
            [/(^|[\n ])([\w]+?:\/\/[\w]+[^ \"\n\r\t< ]*)/g, '$1<a href="$2">$2</a>'],
            [/(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)/g, '$1<a href="http://$2">$2</a>'],
            [/@(\w+)/g, '<a class="tweet-mention" href="http://twitter.com/$1">@$1</a>'],
            [/#(\w+)/g, '<a class="tweet-hash" href="http://search.twitter.com/search?q=$1">#$1</a>']];
        return function (h) {
            var g;
            for (g = 0; g < f.length; g++) {
                h = h.replace(f[g][0], f[g][1])
            }
            return h
        }
    })();
    var c = function (f) {
        if (f < 60) {
            return "just now"
        } else {
            if (f < 60 * 60) {
                minutes = Math.round(f / 60);
                return (minutes > 1) ? minutes + " minutes ago" : " 1 minute ago"
            } else {
                if

                    (f < 60 * 60 * 24) {
                    hours = Math.round(f / (60 * 60));
                    return (hours > 1) ? hours + " hours ago" : " 1 hour ago"
                } else {
                    if (f < 60 * 60 * 24 * 7) {
                        days = Math.round(f /(60 * 60 * 24));
                        return (days > 1) ? days + " days ago" : " yesterday"
                    } else {
                        if (f < 60 * 60 * 24 * 7 * 4) {
                            weeks = Math.round(f / (60 * 60 * 24 * 7));
                            return (weeks > 1) ?

                                weeks + " weeks ago" : " last week"
                        } else {
                            months = Math.round(f / (60 * 60 * 24 * 30));
                            return (months > 1) ? months + " months ago" : " last month"
                        }
                    }
                }
            }
        }
    };
    var b = function (k, l, m) {
        var h, g = new Date(),
                j, f = "";
        f += '<ul>';
        for (h = 0; h < l.length; h++) {
            j = c((g - new Date(l[h].created_at)) / 1000);
            f += '<li><div style="width=400px;">' + a(l[h].text) + '</div></li>'
        }
        f += '</ul>';
        k.append(f)
    };
    d.fn.fetchTweets = function (g) {
        var f = "http://search.twitter.com/search.json?callback=?&";
        var h = d.extend

        (e, g || {});
        var i = d(this);
        f += "rpp=" + h.count + "&q=from:" + h.username;
        d.ajaxSetup({
            cache: h.cache
        });
        i.html('<ul><li><div>Loading tweets...</div><li><ul>');
        d.getJSON(f, function (j) {
            if (!j || !j.results) {
                i.html('<div class="error">Error fetching tweets!</div>');
                return false
            }
            i.html("");
            b(i, j.results, h.username)
        })
    }
})(jQuery);
