function Delete(url) {
	if (confirm("Voulez-vous vraiment effacer cet élément ?")) {
		document.location.href = url;
	}
}

function checkList(el) {
	for(i=0;i<el.options.length;i++) {
		if(el.options[i].selected==true && el.options[i].value!='0')
			return true
	}
	return false
}

function checkEmail(email){
	if(!email) return false ;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if(filter.test(email))
	var a = true;
	else
	{
		return false
	}
	return true
}

function checkString(strng, ln) {
	if(!ln) ln = 0;
	if(!strng) strng = "";
	if(strng.length < ln || strng=="")
		return false;	
	return true;
}

function co() {
	if ($F('objet') == 'Recrutement') {
		$('mes').update('Votre lettre :');
		$('cv').show();
	} else {
		$('mes').update('Votre message :');
		$('cv').hide();
	}
}

function check_form() {
	if(!($("civilite1").checked || $("civilite2").checked || $("civilite3").checked)) {
		$("err").show();
		$("err").update("Veuillez choisir votre civilit&eacute;");
		new Effect.Highlight("trcivilite", { startcolor: '#ffff99',
endcolor: '#EFEFEF' }); 
		new Effect.Highlight("err", { startcolor: '#ffff99',
endcolor: '#996666' });
		return false;
	} else if (!checkString($F("nom"))) {
		$("err").show();
		$("err").update("Veuillez saisir votre nom");
		new Effect.Highlight("trnom", { startcolor: '#ffff99',
endcolor: '#EFEFEF' }); 
		new Effect.Highlight("err", { startcolor: '#ffff99',
endcolor: '#996666' });
		return false;
	} else if (!checkString($F("prenom"))) {
		$("err").show();
		$("err").update("Veuillez saisir votre pr&eacute;nom");
		new Effect.Highlight("trprenom", { startcolor: '#ffff99',
endcolor: '#EFEFEF' }); 
		new Effect.Highlight("err", { startcolor: '#ffff99',
endcolor: '#996666' });
		return false;
	} else if (!checkString($F("adresse"))) {
		$("err").show();
		$("err").update("Veuillez saisir votre adresse");
		new Effect.Highlight("tradresse", { startcolor: '#ffff99',
endcolor: '#EFEFEF' }); 
		new Effect.Highlight("err", { startcolor: '#ffff99',
endcolor: '#996666' });
		return false;
	} else if (!checkList($("pays"))) {
		$("err").show();
		$("err").update("Veuillez s&eacute;l&eacute;ctionner votre pays");
		new Effect.Highlight("trpays", { startcolor: '#ffff99',
endcolor: '#EFEFEF' }); 
		new Effect.Highlight("err", { startcolor: '#ffff99',
endcolor: '#996666' });
		return false;
	} else {
		
		if (($("contact1").checked) && (!checkEmail($F("email")))) {
			$("err").show();
			$("err").update("Veuillez saisir un adresse email valide");
			new Effect.Highlight("tremail", { startcolor: '#ffff99', endcolor: '#EFEFEF' });
			new Effect.Highlight("err", { startcolor: '#ffff99', endcolor: '#996666' });
			return false;
		} else if (($("contact2").checked) && (!checkString($F("tel")))) {
			$("err").show();
			$("err").update("Veuillez saisir votre num&eacute;ro de t&eacute;l&eacute;phone");
			new Effect.Highlight("trtel", { startcolor: '#ffff99', endcolor: '#EFEFEF' });
			new Effect.Highlight("err", { startcolor: '#ffff99', endcolor: '#996666' });
			return false;
		} else if (($F("objet") == "Recrutement") && ($("cvfile").value == "")) {
			$("err").show();
			$("err").update("Veuillez attacher votre CV");
			new Effect.Highlight("cv", { startcolor: '#ffff99', endcolor: '#EFEFEF' });
			new Effect.Highlight("err", { startcolor: '#ffff99', endcolor: '#996666' });
			return false;			
		} else {		
			if ($F("objet") == "Recrutement") {				
				$("myform").submit();
			} else {
				Modalbox.show('index.php?mod=contact&act=send&xhr=1', {title: 'Nous contacter', width: 300, params:Form.serialize('myform') }); 
				return false;			
			}
		}
	}
}

function submit_rp() {
	var u = document.location;
	var filter = /nos-programmes-immobiliers.htm/;
	if (filter.test(u))  {
		new Effect.BlindUp('license');
		Modalbox.show("<div align='center' style='height:70px;'><img src='images/loading.gif' /></div>", {title:'Chargement en cours'});
		Modalbox.deactivate();		
		var url = 'index.php?mod=prog_immo';
		new Ajax.Request(url, {
			method: 'get',
			encoding: 'iso-8859-1',
			parameters: { id_loi: $F('filtre_loi'), xhr:1 },
			onSuccess: function(transport) {
				var notice = $('main_content');
				notice.update(transport.responseText);
				Modalbox.activate();
				Modalbox.hide();
			}
		});
		
		
	} else {
		document.location.href = "index.php?mod=prog_immo&act=lists&id_loi=" + $F('filtre_loi');	
	}
}