// functie voor limiet op characters in tweet
function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength >= limit)
	{
		$('#' + infodiv).html("0");
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html((limit - textlength));
		return true;
	}
};

function getTweets() {
	$('#twitter_messages').load("./twitter/gettweets.php?c=0&randval="+Math.random());
}

function getAllTweets(limit) {
	url = "./twitter/gettweets.php?c=0&l=" + limit + "&randval="+Math.random();
	$('#twitter_messages').load(url);	
}

// stuur de tweet
function sendForm() {
	//laat 'bezig' animatie zien

	var proceed = true;

	if (!proceed) {
		hideAll();
	} else {
		// submit form!
		$.post("./twitter/tweet.php", { reactie: $("#reactie").val() } , function(data, textStatus) {
			if (textStatus == "success") {
				$("#bedankt").fadeIn(500).fadeTo(5000, 1).fadeOut(500);
				getTweets();
				$('#reactie').val("");
//	 			limitChars('reactie', 133, 'counter');			
			} else {
				$('#bezig').hide();
			}
		});		
	}
};	

