(function($) {
    /*
jquery.twitter.js v1.5
Last updated: 08 July 2009
Created by Damien du Toit
http://coda.co.za/blog/2008/10/26/jquery-plugin-for-twitter
Licensed under a Creative Commons Attribution-Non-Commercial 3.0 Unported License
http://creativecommons.org/licenses/by-nc/3.0/
*/
    $.fn.getTwitter = function(options) {
        $.fn.getTwitter.defaults = {
            userName: "nakedpenguinboy",
            numTweets: 1,
            loaderText: "Loading...",
            slideIn: true,
            slideDuration: 750,
            showProfileLink: true,
            showTimestamp: true
        };
        var o = $.extend({}, $.fn.getTwitter.defaults, options);
        return this.each(function() {
            var c = $(this);
            // hide container element, remove alternative content, and add class
            c.hide().empty();
            // add twitter list to container element
            var twitterListHTML = "<p id=\"tweet\"></p>";
            c.append(twitterListHTML);
            var tl = $("#tweet");
            // hide twitter list
            tl.hide();
            // add preLoader to container element
            var preLoaderHTML = $("<p id=\"tweet\">"+o.loaderText+"</p>");
            c.append(preLoaderHTML);
            // show container element
            c.show();
            $.getScript("scripts/blogger.js");
            $.getScript("http://twitter.com/statuses/user_timeline/"+o.userName+".json?callback=twitterCallback2&count="+o.numTweets, function() {
                // remove preLoader from container element
                $(preLoaderHTML).remove();
                // remove timestamp and move to title of list item
                if (!o.showTimestamp) {
                    tl.find("p").each(function() {
                        var timestampHTML = $(this).children("a");
                        var timestamp = timestampHTML.html();
                        timestampHTML.remove();
                        $(this).attr("title", timestamp);
                    });
                }
                // show twitter list
                if (o.slideIn) {
                    // a fix for the jQuery slide effect
                    // Hat-tip: http://blog.pengoworks.com/index.cfm/2009/4/21/Fixing-jQuerys-slideDown-effect-ie-Jumpy-Animation
                    var tlHeight = tl.data("originalHeight");
                    // get the original height
                    if (!tlHeight) {
                        tlHeight = tl.show().height();
                        tl.data("originalHeight", tlHeight);
                        tl.hide().css({
                            height: 0
                        });
                    }
                    tl.show().animate({
                        height: tlHeight
                    }, o.slideDuration);
                }
                else {
                    tl.show();
                }
            });
        });
    };
})(jQuery);
