function new_captcha()
{
    // loads new freeCap image
    if(document.getElementById)
    {
        // extract image name from image source (i.e. cut off ?randomness)
        thesrc = document.getElementById("captcha").src;
        thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
        // add ?(random) to prevent browser/isp caching
        document.getElementById("captcha").src = thesrc+"?"+Math.round(Math.random()*100000);
    } else {
        alert("Sorry, cannot autoreload captcha image\nSubmit the form and a new captcha will be loaded");
    }
}

function new_captcha_request()
{
    // loads new freeCap image
    if(document.getElementById)
    {
        // extract image name from image source (i.e. cut off ?randomness)
        thesrc = document.getElementById("captcha_request").src;
        thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
        // add ?(random) to prevent browser/isp caching
        document.getElementById("captcha_request").src = thesrc+"?"+Math.round(Math.random()*100000);
    } else {
        alert("Sorry, cannot autoreload captcha image\nSubmit the form and a new captcha will be loaded");
    }
}

//vérifie la validiter du mail
function verifMail(email) { // Email valide ?
	var arobase = email.indexOf("@");
	var point = email.lastIndexOf(".");
	
	if((arobase < 1)||(point + 3 > email.length)||(point < arobase)){
		return false;
	}else{
		return true;
	}
}

function verifContactForm(){

	/* validation type de produit */
	/*
	if(document.form_contact_demand.Id_type.value == 0){
		alert('Please select a kind of product');
		document.form_contact_demand.Id_type.focus();
		return false;
	}
	*/
	
	/* validation sector */
	if(document.form_contact_demand.Id_sector.value == 0){
		alert('Please select a area');
		document.form_contact_demand.Id_sector.focus();
		return false;
	}
	
	/* validation Price by week */
	if(document.form_contact_demand.Price.value == 0){
		alert('Please choose a Price');
		document.form_contact_demand.Price.focus();
		return false;
	}
	
	/* validation date debut  */
	if(document.form_contact_demand.DateStart.value == ""){
		alert('Periode from');
		document.form_contact_demand.DateStart.focus();
		return false;
	}
	
	/* validation date fin */
	if(document.form_contact_demand.DateEnd.value == ""){
		alert('Periode to');
		document.form_contact_demand.DateEnd.focus();
		return false;
	}
	
	/* validation Nombre de chambre de la demande */
	/*if(document.form_contact_demand.Nb_room.value == ""){
		alert('Number of bedroom is required');
		document.form_contact_demand.Nb_room.focus();
		return false;
	}*/
	
	/* validation Nom du tiers */
	if(document.form_contact_demand.LName.value == ""){
		alert('Last Name is required');
		document.form_contact_demand.LName.focus();
		return false;
	}
	
	/* validation Prenom du tiers */
	if(document.form_contact_demand.FName.value == ""){
		alert('First Name is required');
		document.form_contact_demand.FName.focus();
		return false;
	}
	
	/* validation Pays du tiers */
	/*if(document.form_contact_demand.Country.value == ""){
		alert('Country is required');
		document.form_contact_demand.Country.focus();
		return false;
	}*/
	
	/* validation tel du tiers */
	/*if(document.form_contact_demand.Tel.value == ""){
		alert('Tel is required');
		document.form_contact_demand.Tel.focus();
		return false;
	}*/
	
	/* Validation mail */
	if(document.form_contact_demand.Email.value == ""){
		alert('Email is required');
		document.form_contact_demand.Email.focus();
		return false;
	}else{
		if(!verifMail(document.form_contact_demand.Email.value)) {
			alert("Invalid Email (xxxxxxx@xxxxxx.xxx)");
			document.form_contact_demand.Email.focus();
			return false;
		}
	}
	/* Validation code anti spam */
	if (document.form_contact_demand.form_code02)
	{
		if(document.form_contact_demand.form_code02.value == ""){
			alert('Copy the word in the image to the field');
			document.form_contact_demand.form_code02.focus();
			return false;
		}
	}
	
}