(function($) {
	$(document).ready(function () {

		$.fn.twitterpts = function(options){

			var options = jQuery.extend({
				username: 'alexpts',
				total:5
			},options);


			return this.each(function() {

				var _this = $(this);


				$.ajax({
					url:"http://twitter.com/status/user_timeline/" + options.username + ".json?count=" + options.total,
					dataType: 'jsonp',
					erorr:function() {
						_this.prepend("<div class='twitter'>Слишком много обращений к твиту, попробуйте немного подождать...</div>");
					},
					success:function(response) {
						var twitterLast = "<div id='twitterLast'>";
						$.each(response, function(i, tweets) {
							var text = tweets.text.replace( /(http:\/\/(?:[^\s]{4,}))/, '<a href="$1" target="_blank">$1</a>' ).replace( /^(?:@([^ ]+))/, '<a href="http://twitter.com/$1" target="_blank">@$1</a>' );
							twitterLast +="<div class='twitter'>" +text+ "</div>";
						});
						twitterLast +="</div>"
						_this.html(twitterLast);
						$(".twitter").css({'padding':'2px','border-bottom':'1px dotted #cccccc'});

					}

				});


			});

		};

	});
})(jQuery);