/*
 * 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
 *
 */
(function( $ ){
  $.extend( {
    jTwitter: function( userId, numPosts, options ) {
      var info = {};

      // If no arguments are sent or only userId is set
      if( userId == 'undefined' || numPosts == 'undefined' ) {
        return;
      }

      var url = 'https://api.twitter.com/1/statuses/user_timeline.json?' +
        'count=' + numPosts +
        '&user_id=' + userId +
        '&include_rts=t&exclude_replies=t&include_entities=t&callback=?';

      $.getJSON( url, function( data ){
        if( $.isFunction( options.callback ) ) {
          options.callback.apply( this, [data, options] );
        }
      });
    }
  });
})( jQuery );
