
document.observe("dom:loaded", function() {

	$$("#menu a").each(function( _elt) {

		if( _elt.href == document.location.href ) {
			_elt.addClassName("current");
		} else {
			_elt.removeClassName("current");
		}
	});

	if( $("comment-form") ) {
		$("comment-form").observe("submit", checkForm );
	}

	if( $("contact-form") ) {
		$("contact-form").observe("submit", checkFormContact );
	}

});


function checkForm( evt ) {

	var errors = new Array();

	if( $F("c_name").trim().empty() ) {
		errors.push("- Votre nom");
	}

	if( ! $F("c_mail").isEmail() ) {
		errors.push("- Votre email");
	}

	if( $F("c_content").trim().empty() ) {
		errors.push("- Votre message");
	}

	if( ! errors.empty() ) {
		alert("Veuillez renseigner les champs suivants :\n"+errors.join("\n"));

		evt.stop();
		return false;
	}

}

function checkFormContact( evt ) {

	var errors = new Array();

	if( $F("Contact_name").trim().empty() ) {
		errors.push("- Votre nom");
	}

	if( ! $F("Contact_email").isEmail() ) {
		errors.push("- Votre email");
	}

	if( $F("Contact_body").trim().empty() ) {
		errors.push("- Votre message");
	}

	if( $F("Contact_antispam").trim().empty() ) {
		errors.push("- Le code anti-spam");
	}

	if( ! errors.empty() ) {
		alert("Veuillez renseigner les champs suivants :\n"+errors.join("\n"));

		evt.stop();
		return false;
	}

}