
(function($) {

    $.fn.listFader = $.fn.twitter_ticker = function(delay) {
        delay = delay || 6000;
        initTicker = function(el) {
            stopTicker(el);
            el.items = $("li", el);
            // hide all items (except first one)
            el.items.not(":eq(0)").hide().end();
            // current item
            el.currentitem = 0;
            startTicker(el);
        };
        startTicker = function(el) {
            el.tickfn = setInterval(function() { doTick(el) }, delay)
        };
        stopTicker = function(el) {
            clearInterval(el.tickfn);
        };
        pauseTicker = function(el) {
            el.pause = true;
        };
        resumeTicker = function(el) {
            el.pause = false;
        };
        doTick = function(el) {
            // don't run if paused
            if (el.pause) return;
            // pause until animation has finished
            el.pause = true;
            // hide current item
            $(el.items[el.currentitem]).fadeOut("slow",
		    function() {
		        $(this).hide();
		        // move to next item and show
		        el.currentitem = ++el.currentitem % (el.items.size());
		        $(el.items[el.currentitem]).fadeIn("slow",
				    function() {
				        el.pause = false;
				    }
			    );
		    }
	    );
        };
        this.each(
	    function() {
	        if (this.nodeName.toLowerCase() != "ul") return;
	        initTicker(this);
	    }
    )
    .addClass("twitter_ticker")
    .hover(
	    function() {
	        // pause if hovered over
	        pauseTicker(this);
	    },
	    function() {
	        // resume when not hovered over
	        resumeTicker(this);
	    }
    );
        return this;
    };

})(jQuery);


function twitterCallback2(C) {
    var A = [];
    for (var D = 0; D < C.length; D++) {
        var E = C[D].user.screen_name;
        var B = C[D].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(F) {
            return '<a href="' + F + '">' + F + "</a>"
        }).replace(/\B@([_a-z0-9]+)/ig, function(F) {
            return F.charAt(0) + '<a href="http://www.twitter.com/' + F.substring(1) + '">' + F.substring(1) + "</a>"
        });
        A.push("<li><a class='twitter_perma_link' target='_blank' href='http://twitter.com/pastorpaulabell/statuses/"
        //        + C[D].id + B + '</a> <a class="twitter_added"> | '
        + C[D].id + "'<span class='tweet'>" + B + '</a> <a class="twitter_added"> | '
        + relative_time(C[D].created_at) + "</a></li>")
    }
    document.getElementById("moostick").innerHTML = A.join("")
}
function relative_time(C) {
    var B = C.split(" ");
    C = B[1] + " " + B[2] + ", " + B[5] + " " + B[3];
    var A = Date.parse(C);
    var D = (arguments.length > 1) ? arguments[1] : new Date();
    var E = parseInt((D.getTime() - A) / 1000);
    E = E + (D.getTimezoneOffset() * 60);
    if (E < 60) {
        return "less than a minute ago"
    } else {
        if (E < 120) {
            return "about a minute ago"
        } else {
            if (E < (60 * 60)) {
                return (parseInt(E / 60)).toString() + " minutes ago"
            } else {
                if (E < (120 * 60)) {
                    return "about an hour ago"
                } else {
                    if (E < (24 * 60 * 60)) {
                        return "about " + (parseInt(E / 3600)).toString() + " hours ago"
                    } else {
                        if (E < (48 * 60 * 60)) {
                            return "1 day ago"
                        } else {
                            return (parseInt(E / 86400)).toString() + " days ago"
                        }
                    }
                }
            }
        }
    }
};
