function twitter(p_sUsername,p_nCount,p_bAvatar){
	$.ajax({
		url: 'http://api.twitter.com/1/statuses/user_timeline/'+p_sUsername+'.json?include_rts=true&include_entities=true&count='+p_nCount+'&callback=?',
		dataType: 'json',
		success: function(result){
			var sHtml = '';
			$.each(result, function(i,oTweet){
				
				var sTweet = '';
				
				sTweet += '<div class="tweet">';
				sTweet += '<span class="date">'+formatTime(oTweet.created_at)+'</span>';
				if(p_bAvatar){
					sTweet += '<div class="image">';
					sTweet += '<a href="http://www.twitter.com/'+oTweet.user.screen_name+'" target="_blank">';
					sTweet += '<img src="'+oTweet.user.profile_image_url+'" alt="'+oTweet.user.name+'" />';
					sTweet += '</a>';
					sTweet += '</div>';
				}
				sTweet += '<div class="content">'+formatTweet(oTweet.text)+'</div>';
				sTweet += '</div>';
				
				sHtml += sTweet;
			});
			$('#twitter').html(sHtml);
		}
	});
}

function clearInput() {
	$('.fade').focus(function() {
		$(this).select();
		$(this).prev().fadeTo(150, 0.33);
		$(this).keydown(function() {
			$(this).css('background-repeat', 'repeat');			 
		});
	});
	$('.fade').blur(function() {
		if ( $(this).val() == '' ) {
			$(this).css('background-repeat', 'no-repeat');
			$(this).prev().fadeTo(150, 1);
		}
	});
	$('.fade').each(function(){
		if ( $(this).val() != '') {
			$(this).css('background-repeat', 'repeat');
		};
	});
}

function validateForm(p_sForm) {
	
	var rules = {};
	rules[aFields[1]] = {
		required: true
	};
	rules[aFields[2]] = {
		required: true,
		email: true
	};
	rules[aFields[3]] = {
		telephone: true
	};
	rules[aFields[4]] = {
		required: true,
		minlength: true
	};
	
	var messages = {};
	messages[aFields[1]] = {
		required: 'Vul uw naam in.'
	};
	messages[aFields[2]] = {
		required: 'Vul uw e-mailadres in.',
		email: 'Vul een geldig e-mailadres in.'
	};
	messages[aFields[3]] = {
		telephone: 'Vul een geldig telefoonnummer in.'
	};
	messages[aFields[4]] = {
		required: 'Vul uw Bericht in.',
		minlength: 'Vul minimaal 2 tekens in.'
	};
	
	$('#'+p_sForm).validate({
		rules: rules,
		messages: messages,
		errorPlacement: function(error, element) {
			var obj = element.parent().parent().next('div.icon');
			error.insertAfter(obj);
			obj.attr('class','icon invalid');
		},
		success: function(label) {
			label.prev('div.icon').attr('class','icon valid');
			label.remove();
		},
		submitHandler: function(form) {
			form.trigger('submit');
		}
	});	
}
function showForm() {
	$("#message").click(function () {
	  $("#overlay").show("slow", function () {
		/* use callee so don't have to name the function */
		$(this).next("div").show("slow", arguments.callee);
	  });
	});
	$("#close").click(function () {
	  $("#overlay").hide("fast");
	});
}
