function jq_form_validate(el) {
	f = this;	
	var valid = true;	
	$(f).find(".required").each(function(){	
		if (isEmpty($(this).val()) ) {
			valid= false;
			$(this).addClass("notvalid");
		}
	});
	if (!valid) {
		alert("Formulaire incomplet !");
	}
	return valid;
}

$(function() {
	$(":input.required").change(function() {
		$(this).removeClass("notvalid");
	});
	
	$("form").bind("submit", jq_form_validate);
	
	$("#send_this_page").click(function(){
		window.open(
			"envoyer_cette_page.php?url=" + $(this).attr("title")
			,"sendthispage"
			,"resizable=no,width=600,height=550"
		);		
		return false;
	});
	
	$("#print_this_page").click(function(){
		self.print();
		return false;
	});
});


/**
 * Determine whether a value is empty. This is true when all characters in the
 * value are one of "\n, \t, ' '".
 */
function isEmpty(value) {

    for (var i= 0; i < value.length; i++) {
	var c = value.charAt(i);

	if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }

    return true;
}