function checkBlank(ele) {
	if (ele.val() == "") {
		ele.parents('fieldset').addClass('error');
		ele.parents('fieldset').find('span.msg').show();
		return true;
	}
	return false;
}

var error = 0;

$(function() {
	$('input, textarea').focusin(function() {
		$(this).parents('fieldset').find('span.msg').show();
	}).focusout(function() {
		$(this).parents('fieldset').find('span.msg').hide();
		$(this).parents('fieldset').removeClass('error');
		checkBlank($(this));
	});
	$('#contactform').submit(function() {
		error = 0;
		$('input, textarea').each(function() {
			if (checkBlank($(this))) {
				error = 1;
			}
		});
		if (error) return false;
	});
});
