
$(document).ready(function() {
	
	
	$('#tweetit').click(function (){
		tweet = $('#twit').val();
		$.ajax({
					type: "POST",
					async: "false",
					data: "tweet="+tweet,
					url: "/home/tweet",
					success: function(msg){
						$('#twit').val("");
						$('#tweeted').show().animate({"opacity": 0},2000);

					}
			});

	
	});		
			
 
	$('input:text').focus(function() { this.value="";});
   $('input:password').focus(function() { this.value="";});


	$('textarea').focus(function() { $(this).html("");});
	
	function limitChars(textid, limit, infodiv)
	{
   	var text = $('#'+textid).val();  
   	var textlength = text.length;
   	if(textlength > limit)
   		{
     		// $('#' + infodiv).html('You cannot write more then '+limit+' characters!');
      	$('#'+textid).val(text.substr(0,limit));
      	return false;
   	}
   else
   	{
      	$('#' + infodiv).html('<span class="chars">'+ (limit - textlength) +'</span>/<span class="max">'+ limit +'</span>');
      	return true;
   	}
	}

	$('#twit').keyup(function(){
      limitChars('twit', 140, 'charcount');
   })
     


	
   $("#flashMessage").slideDown("normal",
    function() {$("#flashMessage").animate({opacity: 1.0}, 2000).fadeOut(10000);}
    );
});		

	function getmore() {
			$.ajax({
				url: "/home/more",
				type: "POST",
				success: function (m) {
					$('a#more').hide();
					$('a#more').parent('li').after(m);
				} 					
 			});
 			return false;
		}