function valide_add_user() {
/*
é : \351
è : \350
ê : \352
à : \340
*/

var regex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;

	if ($('#txtEmail').val() == '') {
		alert("Please enter your email adress");
		return false;
	}
	if (!regex.test($('#txtEmail').val())) {
		alert("Please enter a valid email adress");
		return false;
	}
	if ($('#txtConfirmEmail').val() == 0) {
		alert("Please confirm your email adress");
		return false;
	}
	if ($('#txtEmail').val() != $('#txtConfirmEmail').val()) {
		alert("Please enter the same email adress");
		return false;
	}
	if ($('#txtPassword').val() == '') {
		alert("Please enter a password");
		return false;
	}
	if ($('#txtConfirmPassword').val() == 0) {
		alert("Please confirm your password");
		return false;
	}
	if ($('#txtPassword').val() != $('#txtConfirmPassword').val()) {
		alert("Please enter the same password");
		return false;
	}
	if ($('#sltVousEtes').val() == 0) {
		alert("Please enter your civility");
		return false;
	}
	if ($('#sltCivilite').val() == 0) {
		alert("Please enter your civility");
		return false;
	}
	if ($('#txtName').val() == '') {
		alert("Please enter your name");
		return false;
	}
	if ($('#txtAdresse').val() == '') {
		alert("Please enter your adress");
		return false;
	}
	if ($('#txtVille').val() == '') {
		alert("Please enter your city");
		return false;
	}
	if ($('#txtCodePostal').val() == '') {
		alert("Please enter your post code");
		return false;
	}
	if ($('#txtPays').val() == '') {
		alert("Please enter your country");
		return false;
	}
	$('#mon_formulaire').submit();
}

/*
	if ($('#txtTel').val() == '') {
		alert("Please enter your telephone number");
		return false;
	}		
*/

function valide_modify_user() {
/*
é : \351
è : \350
ê : \352
à : \340
*/

var regex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;

	if ($('#txtEmail').val() == '') {
		alert("Please enter your email adress");
		return false;
	}
	if (!regex.test($('#txtEmail').val())) {
		alert("Please enter a valid email adress");
		return false;
	}
	if ($('#txtPassword').val() != '') {
		if ($('#txtPassword').val() != $('#txtConfirmPassword').val()) {
			alert("Please enter the same password");
			return false;
		}	
	}
	if ($('#sltVousEtes').val() == 0) {
		alert("Please enter your civility");
		return false;
	}
	if ($('#sltCivilite').val() == 0) {
		alert("Please enter your civility");
		return false;
	}
	if ($('#txtName').val() == '') {
		alert("Please enter your family name");
		return false;
	}
	if ($('#txtFirstName').val() == '') {
		alert("Please enter your first name");
		return false;
	}
	if ($('#txtAdresse').val() == '') {
		alert("Please enter your adress");
		return false;
	}
	if ($('#txtCodePostal').val() == '') {
		alert("Please enter your post code");
		return false;
	}
	if ($('#txtVille').val() == '') {
		alert("Please enter your country");
		return false;
	}
	$('#mon_formulaire').submit();	
}

function valide_depot_annonce() {
	
var regex = /^[0-9]+$/;
var regex_email = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;

var month = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
var today = new Date()
var today = (month[today.getMonth()]+"/"+today.getDate()+"/"+today.getFullYear())
var today = Date.parse(today)

var date_calendar = $('#txtPreavisDate').val()
var date_calendar = date_calendar.split('/')
var date_calendar = Date.parse(date_calendar[1]+'/'+date_calendar[0]+'/'+date_calendar[2])

	if(document.getElementById("chkCertification")) {
		if (!$('#chkCertification').is(':checked')) {
			alert("Veuillez cocher la case locataires occupants");
			$('#sltDepartement').focus();
			return false;
		}
	}

	if ($('#sltDepartement').val() == 0) {
		alert("Veuillez saisir votre d\351partement");
		$('#sltDepartement').focus();
		return false;
	}
	if (($('#txtCodePostal').val().length != 5) || (!regex.test($('#txtCodePostal').val()))) {
		alert("Veuillez saisir un code postal \340 5 chiffres");
		$('#txtCodePostal').focus();
		return false;
	}
	if (($('#txtCodePostal').val().substr(0,2)) != ($('#sltDepartement').val().substr(0,2))) {
		alert("Veuillez saisir un code postal correspondant \340 votre d\351partement");
		$('#txtCodePostal').focus();
		return false;
	}
	if ($('#txtVille').val() == '') {
		alert("Veuillez saisir votre ville");
		$('#txtVille').focus();
		return false;
	}
	if ($('#txtAnnonceTitle2').val() == '') {
		alert("Veuillez saisir le champ concernant le quartier");
		$('#txtAnnonceTitle2').focus();
		return false;
	}
	if ($('#txtAnnonceTitle').val() == '') {
		alert("Veuillez saisir le titre de l'annonce");
		$('#txtAnnonceTitle').focus();
		return false;
	}
	if ($('#sltTypeBien').val() == 0) {
		alert("Veuillez saisir un type de bien");
		$('#sltTypeBien').focus();
		return false;
	}
	if ($('#sltPieceNb').val() == 0) {
		alert("Veuillez saisir le nombre de pi\350ces");
		$('#sltPieceNb').focus();
		return false;
	}
	if ($('#sltChambreNb').val() == 0) {
		alert("Veuillez saisir le nombre de chambres");
		$('#sltChambreNb').focus();
		return false;
	}
	if ($('#txtPreavisDate').val() == '') {
		alert("Veuillez saisir une date");
		$('#txtPreavisDate').focus();
		return false;
	}
	if (date_calendar < today ) {
		alert("La date d'\351ch\351ance de votre pr\351avis doit \352tre ult\351rieure \340 la date d'aujourd'hui. Veuillez modifier celle-ci.");
		$('#txtPreavisDate').focus();
		return false;
	}
	if ($('#txtSurface').val() == '') {
		alert("Veuillez saisir la surface");
		$('#txtSurface').focus();
		return false;
	}
	if (!regex.test($('#txtSurface').val())) {
			alert("La champ surface ne doit contenir que des des chiffres");
			return false;
	}
	if ($('#txtLoyer').val() == '') {
		alert("Veuillez saisir un montant pour le loyer");
		$('#txtLoyer').focus();
		return false;
	}
	if (!regex.test($('#txtLoyer').val())) {
			alert("La champ loyer ne doit contenir que des des chiffres");
			return false;
	}
	if ($('#sltChauffage').val() == 0) {
		alert("Veuillez saisir un type de chauffage");
		$('#sltChauffage').focus();
		return false;
	}
	if ($('#txtDescription').val() == '') {
		alert("Veuillez enter une description");
		$('#txtDescription').focus();
		return false;
	}
	//if (!$('#chkOpenCoordonnee').is(':checked')) {
		
		if ($('#txtcontactMail').val() == '') {
			alert("Veuillez saisir un email de la personne \340 contacter");
			return false;
		}
		if (!regex_email.test($('#txtcontactMail').val())) {
			alert("Veuillez saisir un email valide de la personne \340 contacter");
			return false;
		}
		/*if ($('#txtcontactMail').val() != $('#txtcontactConfirmMail').val()) {
			alert("Veuillez saisir deux fois le m\352me email de la personne \340 contacter");
			return false;
		}*/
		if ($('#sltContactCivilite').val() == 0) {
			alert("Veuillez saisir la civilit\351 de la personne \340 contacter");
			return false;
		}
		if ($('#TxtContactName').val() == '') {
			alert("Veuillez saisir le nom de la personne \340 contacter");
			return false;
		}
		if ($('#txtContactPhone').val() == '') {
			alert("Veuillez saisir le t\351l\351phone de la personne \340 contacter");
			return false;
		}
		if (!regex.test($('#txtContactPhone').val())) {
			alert("La champ telephone ne doit contenir que des des chiffres");
			return false;
	}
		if ($('#sltContactCivilite3').val() == 0) {
			alert("Veuillez remplir la mani\350re dont vous souhaitez \352tre contacter");
			return false;
		}
		
		if ($('#sltContactCivilite2').val() == 0) {
			alert("Veuillez indiquer la plage horaire de d\351lbut");
			return false;
		}
		
		if ($('#sltContactCivilite4').val() == 0) {
			alert("Veuillez indiquer la plage horaire de d\351lbut de fin");
			return false;
		}

//	}
	
	$('#form_insert_annonce').submit();
}

function valide_coordonnees_fact() {
	var regex_email = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
	if ($('#txtEmail').val() == '') {
		alert("Veuillez saisir un email");
		return false;
	}
	if (!regex_email.test($('#txtEmail').val())) {
		alert("Veuillez saisir un email valide");
		return false;
	}
	if ($('#txtEmail').val() != $('#txtConfirmEmail').val()) {
		alert("Veuillez saisir deux fois le m\352me mail");
		return false;
	}
	if ($('#sltCivilite').val() == 0) {
		alert("Veuillez saisir le champ cilivit\351");
		return false;
	}
	if ($('#txtName').val() == '') {
		alert("Veuillez saisir le champ Nom");
		return false;
	}
	if ($('#txtFirstName').val() == '') {
		alert("Veuillez saisir le champ Pr\351nom");
		return false;
	}
	if ($('#txtAdresse').val() == '') {
		alert("Veuillez saisir le champ Adresse");
		return false;
	}
	if ($('#txtCodePostal').val() == '') {
		alert("Veuillez saisir le champ Code postal");
		return false;
	}
	if ($('#txtVille').val() == '') {
		alert("Veuillez saisir le champ Ville");
		return false;
	}
	$('#confirmer_paiement').submit();
}

function ChargesComprises() {
	if ($('#txtChargescomprises').is(':checked')) {
		$('#txtCharge').attr("disabled", true);
	}
	else {
		$('#txtCharge').attr("disabled", false);
	}
}

function toggle_search() {
	$("#p_search").toggle("normal");
}

function change_img(param) {
	var chaine = $("#"+param).attr("src");
	var reg = new RegExp("small");
	var source_img = chaine.replace(reg, "large");
	document.getElementById('img_target').src = source_img;
}

function remove_display() {
	$("#ss_liens_menu a").css("display","block");
}