/*
 * jTwitter 1.1.1 - Twitter API abstraction plugin for jQuery
 *
 * Copyright (c) 2009 jQuery Howto
 *
 * Licensed under the GPL license:
 *   http://www.gnu.org/licenses/gpl.html
 *
 * URL:
 *   http://jquery-howto.blogspot.com
 *
 * Author URL:
 *   http://jquery-howto.blogspot.com
 *
 * Starting from version 1.1 plugin gets user posts
 * the returned object has changed. See update.
 * {
        "screen_name":"jqueryHowto",
        "name":"jQuery HowTo",
        "description":"jQuery and javascript howtos, tutorials, hacks, tips and performanace tests. Ask your jQuery questions here...",
        "url":"http://jquery-howto.blogspot.com",
        "followers_count":294,
        "friends_count":120,
        "favourites_count":0,
        "statuses_count":154,
        "location":"",
        "id":26767000,
        "time_zone":"Central Time (US & Canada)",
        "profile_image_url":"http://s3.amazonaws.com/twitter_production/profile_images/110763033/jquery_normal.gif",
        "notifications":false,
        "utc_offset":-21600,
        "following":false,
        "protected":false,
        "created_at":"Thu Mar 26 14:58:19 +0000 2009",
        "profile_link_color":"0000ff",
        "profile_sidebar_fill_color":"e0ff92",
        "profile_background_tile":false,
        "profile_sidebar_border_color":"87bc44",
        "profile_background_color":"9ae4e8",
        "profile_text_color":"000000"
        "profile_background_image_url":"http://static.twitter.com/images/themes/theme1/bg.gif",
} */
(function( $ ){
	$.extend( {
		jTwitter: function( username, numPosts, fnk ) {
			var info = {};
			
			// If no arguments are sent or only username is set
			if( username == 'undefined' || numPosts == 'undefined' ) {
				return;
			} else if( $.isFunction( numPosts ) ) {
				// If only username and callback function is set
				fnk = numPosts;
				numPosts = 5;
			}
			
			var url = "http://twitter.com/status/user_timeline/"
				+ username + ".json?count="+numPosts+"&callback=?";

			$.getJSON( url, function( data ){
				if( $.isFunction( fnk ) ) {
					fnk.call( this, data );
				}
			});
		}
	});
})( jQuery );
