/*
	Fonctions de manipulation et de vérifications des formulaires de gestion de client
*/

function map(language,picture,picturetitle){
var winopts = "toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=yes,width=870,height=700,copyhistory=0"
smallwindow=window.open('map.asp?lang='+language+'&picture='+picture+'&picturetitle='+picturetitle,'maps',winopts);
smallwindow.focus();
}




$(document).ready(function(){
	if($("#contact_message").html() != null) {
		if($("#contact_message").html().length <= 15) {
			$("#contact_message").hide();
		} else {
			$("#contact_message").show("slow");
		};
	}

	$("input").change(function () {
		$("#contact_message").hide("slow");
	});

	$("textarea").change(function () {
		$("#contact_message").hide("slow");
	});

	// validation du formulaire
	$("#contact_us").submit(function () {
		var sErrorContact = "";

		if(!TestFieldString($("#contact_question").val(), 0, 50)) {
			sErrorContact += TradMes("Vous n'avez pas indiqué de question") + ".<br />";
		}
		if(!TestFieldString($("#contact_name").val(), 0, 50)) {
			sErrorContact += TradMes("Le nom n'est pas valide") + ".<br />";
		}
		if(!TestFieldString($("#contact_telephone").val(), 0, 20)) {
			sErrorContact += TradMes("Le numéro de téléphone n'est pas valide") + ".<br />";
		}
		if(!TestFieldString($("#contact_email").val(), 0, 100) || !TestEmailAddress($("#contact_email").val())) {
			sErrorContact += TradMes("L'adresse email n'est pas valide") + ".<br />";
		}

		var sError = "";
		if(sErrorContact.length > 0) {
			sError += sErrorContact + "<br />";
		}

		if(sError.length > 6) {
			sError = sError.substr(0, sError.length - 6);
			$("#contact_message").html(sError).show("slow");
			return false;
		} else {
			return true;
		}
	});	
});






