function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function init_js(){
	if(window.attachEvent){
		startList();
	}
}

function startList(){
	if(document.getElementById("nav")){
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
				this.style.zIndex=200;
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				this.style.zIndex=10;
			}
		}
	}
}

function checkform(theform) {
	var tags = new Array("input","textarea");
	for (var k = 0; k < tags.length; ) {
		var ar = theform.getElementsByTagName(tags[k++]);
		var cc = null;
		for (var i = 0; i < ar.length;) {
			cc = ar[i++];
			var nfos;
			if (cc.getAttribute('obg')) {
				nfos = cc.getAttribute('obg');
				if (nfos!=0) {
					if (cc.value=="") {
						alert(cc.getAttribute("err"));
						cc.focus();
						return false;
					}
					else {
						var isValid;
						var oComments = '';
						switch(cc.getAttribute("special")) {
							case null : 
								isValid = true;
								break;
							case "email" : 	
								isValid = validMail(cc.value);
								oComments = "\nEx.: nom@site.com";
								break;
							case "date" :  	
								isValid = validDate(cc.value);
								oComments = "\nEx.: 1982-03-25";
								break;
							case "nospecial" :  
								isValid = validSpecial(cc.value);
								oComments = "\nCaract&egrave;res autoris&eacute;s : <strong>a-z</strong>, <strong>A-Z</strong>, <strong>0-9</strong>";
								break;
							case "numeric" :  	
								isValid = validNumeric(cc.value);
								oComments = "\nEx.: 0-9";
								break;
							case "money" : 
								isValid = validCurrency(cc.value);
								oComments = "\nEx.: 159 ou 1979.23";
								break;
						}
						if(!isValid){
							alert(cc.getAttribute("err")+oComments);
							cc.focus();
							return false;
						}
					}
				}
			}
		}
	}
	return true;
} 

function validMail(email) {
	var result = false
	var theStr = new String(email)
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1)) result = true;
	}
	return result;
}

function validDate(dateaaaammjj) {
	var dt=dateaaaammjj.split("-"),date=new Date(dt[0],dt[1]-1,dt[2]);
	return date.getDate()==dt[2]&&date.getMonth()+1==dt[1]&&date.getFullYear()==dt[0]?date:false;
}

function validSpecial(fStr) {
	myReg = new RegExp("[A-Za-z0-9]+");
	if(myReg.exec(fStr)!=fStr) return false;
	return true;
}

function validNumeric(fStr) {
	myReg = new RegExp("[0-9]+");
	if(myReg.exec(fStr)!=fStr) return false;
	return true;
}

function validCurrency(fStr) {
	return RegExp(/^\$?\d+(\.\d{2})?$/).test(String(fStr).replace(/^\s+|\s+$/g, ""));
}

function buildPostData(form) {
	var returnData = "";
	var tags = new Array("input","textarea","select");
	for (var k = 0; k < tags.length; ) {
		var ar = form.getElementsByTagName(tags[k++]);
		var cc = null;
		for (var i = 0; i < ar.length;) {
			cc = ar[i++];
			if (cc.name != "" && cc.type != "file") {
				if (cc.getAttribute("type") == 'checkbox' || cc.getAttribute('type') == 'radio') {
					if (cc.checked != false) returnData += (returnData != "") ? "&" + cc.name + "=" + escape(cc.value) : cc.name + "=" + escape(cc.value);
				}
				else returnData += (returnData != "") ? "&" + cc.name + "=" + escape(cc.value) : cc.name + "=" + escape(cc.value);					
			}
		}
	}
	return returnData;
}

function callAjax(url,formToPost,fonct) {
	var postData = "";
	
		
		if (!('undefined' == typeof formToPost || formToPost == null)) {
			postData = buildPostData(formToPost);
		}
		if (window.XMLHttpRequest) {
			objAjax = new XMLHttpRequest();
			objAjax.onreadystatechange = fonct;
			if (postData != "") {
				objAjax.open("POST",url,true);
				objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
				objAjax.send(postData);
			}
			else {
				objAjax.open("GET",url,true);	
				objAjax.send(null);
			}
			
		}
		else if (window.ActiveXObject) {
			objAjax = new ActiveXObject("Microsoft.XMLHTTP");
			objAjax.onreadystatechange = fonct;
			if (postData != "") {
				objAjax.open("POST",url,true);
				objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
				objAjax.send(postData);
			}
			else {
				objAjax.open("GET",url,true);	
				objAjax.send();
			}
					
		}
		
		else {
			alert("Browser incompatible");
		}
		//alert('writing send');
	
	
}

function ajaxOk() {
	if (objAjax.readyState == 4) {
		//alert(objAjax.status);
		if (objAjax.status == 200) {
			
			return true;
		}
		else if (objAjax.status == 401) {
			//document.location.href = 'login.php';
			return false;
		}
		else if (objAjax.status == 403) {
			var err = objAjax.responseXML;
			objAjax = null;
			alert(err);
			return false;
		}
		else if (objAjax.status == 404) {
			//bypass le probleme d'enregistrement inexistant
			var err = objAjax.responseXML;
			objAjax = null;
			alert(err);
			return false;
		}
		else {
			var err = objAjax.responseXML;
			alert('erreur : '+objAjax.status);
			objAjax = null;
			alert(err);
			return false;
		}
 	}
	else return false;
}

function addEmail(email){
	lafonct = function() {
		if(ajaxOk()){
			document.getElementById('emailform').innerHTML='Merci.<br />Nous vous contacterons lors du lancement.';
			objAjax = null;

		}
	}
	if(validMail(email)){
		callAjax(url+'_addemail.php?email='+email,null,lafonct);
	}else{
		alert("Veuillez entrer une adresse courriel valide.");
	}
}

function _doSubmitNewAgent(hndl){
	lafonct = function() {
		if(ajaxOk()){
			if(objAjax.responseText==0){hndl.submit();}else{alert('Ce nom d\'utilisateur est déjà utilisé.\nVeuillez en choisir un autre');}
			objAjax = null;
		}
	}
	if(checkform(hndl)){
		callAjax(url+'_validateUsername.php?username='+hndl.username.value,null,lafonct);
	}
}

function _doSubmitNewClient(hndl){
	lafonct = function() {
		if(ajaxOk()){
			if(objAjax.responseText==0){hndl.submit();}else{alert('Ce nom d\'utilisateur est déjà utilisé.\nVeuillez en choisir un autre');}
			objAjax = null;
		}
	}
	if(checkform(hndl)){
		callAjax(url+'_validateUsername.php?username='+hndl.username.value,null,lafonct);
	}
}

function _delTestament(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier ('+nom+')?')){
		Element.remove($('testament'+id));
		callAjax(url+'_delfile.php?module=testament&id='+id,null,lafonct);
	}
}

function _delTestamentP(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier ('+nom+')?')){
		Element.remove(parent.document.getElementById('testament'+id));
		callAjax(url+'_delfile.php?module=testament&id='+id,null,lafonct);
	}
}

function _delProprieteFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier ?')){
		Element.remove(parent.document.getElementById('proprietefile'+id));
		callAjax(url+'_delfile.php?module=proprieteFile&id='+id,null,lafonct);
	}
}

function _delAssuranceFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('assurancefile'+id));
		callAjax(url+'_delfile.php?module=assuranceFile&id='+id,null,lafonct);
	}
}

function _delInstitutionFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('institutionfile'+id));
		callAjax(url+'_delfile.php?module=institutionFile&id='+id,null,lafonct);
	}
}

function _delPlacementFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('placementfile'+id));
		callAjax(url+'_delfile.php?module=placementFile&id='+id,null,lafonct);
	}
}

function _delCoffretFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('coffretfile'+id));
		callAjax(url+'_delfile.php?module=coffretFile&id='+id,null,lafonct);
	}
}

function _delVehiculeFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('vehiculefile'+id));
		callAjax(url+'_delfile.php?module=vehiculeFile&id='+id,null,lafonct);
	}
}

function _delPretFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('pretfile'+id));
		callAjax(url+'_delfile.php?module=pretFile&id='+id,null,lafonct);
	}
}

function _delLienFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('lienfile'+id));
		callAjax(url+'_delfile.php?module=lienFile&id='+id,null,lafonct);
	}
}

function _delLitigeFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('litigefile'+id));
		callAjax(url+'_delfile.php?module=litigeFile&id='+id,null,lafonct);
	}
}

function _delSeingFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('seingfile'+id));
		callAjax(url+'_delfile.php?module=seingFile&id='+id,null,lafonct);
	}
}

function _delBienFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('bienfile'+id));
		callAjax(url+'_delfile.php?module=bienFile&id='+id,null,lafonct);
	}
}

function _delPretPersoFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('pretpersofile'+id));
		callAjax(url+'_delfile.php?module=pretPersoFile&id='+id,null,lafonct);
	}
}

function _delPretHypoFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('prethypofile'+id));
		callAjax(url+'_delfile.php?module=pretHypoFile&id='+id,null,lafonct);
	}
}

function _delCarteCreditFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('cartecreditfile'+id));
		callAjax(url+'_delfile.php?module=carteCreditFile&id='+id,null,lafonct);
	}
}

function _delCautionnementFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('cautionnementfile'+id));
		callAjax(url+'_delfile.php?module=cautionnementFile&id='+id,null,lafonct);
	}
}

function _delProcesFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('procesfile'+id));
		callAjax(url+'_delfile.php?module=procesFile&id='+id,null,lafonct);
	}
}

function _delBauxFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('bauxfile'+id));
		callAjax(url+'_delfile.php?module=bauxFile&id='+id,null,lafonct);
	}
}

function _delautresDettesFile(id){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce fichier?')){
		Element.remove(parent.document.getElementById('autresDettesfile'+id));
		callAjax(url+'_delfile.php?module=autresDettesFile&id='+id,null,lafonct);
	}
}

function _startUploadTestament(){
	$('loadingTestament').style.display='';
	document.uploadTestament.submit();
}

function _startUploadpropriete(id){
	$('loadingProprieteMod'+id).style.display='';
	$('uploadPropriete'+id).submit();
}

function _startUploadAssurance(id){
	$('loadingAssuranceMod'+id).style.display='';
	$('uploadAssurance'+id).submit();
}

function _startUploadInstitution(id){
	$('loadingInstitutionMod'+id).style.display='';
	$('uploadInstitution'+id).submit();
}

function _startUploadPlacement(id){
	$('loadingPlacementMod'+id).style.display='';
	$('uploadPlacement'+id).submit();
}

function _startUploadCoffret(id){
	$('loadingCoffretMod'+id).style.display='';
	$('uploadCoffret'+id).submit();
}

function _startUploadVehicule(id){
	$('loadingVehiculeMod'+id).style.display='';
	$('uploadVehicule'+id).submit();
}

function _startUploadPret(id){
	$('loadingPretMod'+id).style.display='';
	$('uploadPret'+id).submit();
}

function _startUploadLien(id){
	$('loadingLienMod'+id).style.display='';
	$('uploadLien'+id).submit();
}

function _startUploadLitige(id){
	$('loadingLitigeMod'+id).style.display='';
	$('uploadLitige'+id).submit();
}

function _startUploadSeing(id){
	$('loadingSeingMod'+id).style.display='';
	$('uploadSeing'+id).submit();
}

function _startUploadBien(id){
	$('loadingBienMod'+id).style.display='';
	$('uploadBien'+id).submit();
}

function _startUploadPretPerso(id){
	$('loadingPretPerso'+id).style.display='';
	$('uploadPretPerso'+id).submit();
}

function _startUploadPretHypo(id){
	$('loadingPretHypo'+id).style.display='';
	$('uploadPretHypo'+id).submit();
}

function _startUploadCarteCredit(id){
	$('loadingCarteCredit'+id).style.display='';
	$('uploadCarteCredit'+id).submit();
}

function _startUploadCautionnement(id){
	$('loadingCautionnement'+id).style.display='';
	$('uploadCautionnement'+id).submit();
}

function _startUploadProces(id){
	$('loadingProces'+id).style.display='';
	$('uploadProces'+id).submit();
}

function _startUploadBaux(id){
	$('loadingBaux'+id).style.display='';
	$('uploadBaux'+id).submit();
}

function _startUploadautresDettes(id){
	$('loadingautresDettes'+id).style.display='';
	$('uploadautresDettes'+id).submit();
}

function _addLiquidateur(){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			eval(objAjax.responseText);
			objAjax = null;
		}
	}
	if(checkform($('addLiquidateur'))){
		callAjax(url+'_addLiquidateur.php',$('addLiquidateur'),lafonct);
	}
}

function _delLiquidateur(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce liquidateur ('+nom+')?')){
		Element.remove(document.getElementById('liquidaNom'+id));
		Element.remove(document.getElementById('trModEx'+id));
		callAjax(url+'_delfile.php?module=liquidateur&id='+id,null,lafonct);
	}
}

function _delPropriete(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cette propriété ('+nom+')?')){
		Element.remove(document.getElementById('trNomPr'+id));
		Element.remove(document.getElementById('trModPr'+id));
		callAjax(url+'_delfile.php?module=propriete&id='+id,null,lafonct);
	}
}

function _delAss(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cette assurance ('+nom+')?')){
		Element.remove(document.getElementById('trNomAs'+id));
		Element.remove(document.getElementById('trModAs'+id));
		callAjax(url+'_delfile.php?module=assurance&id='+id,null,lafonct);
	}
}

function _delInstitution(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cette institution financière ('+nom+')?')){
		Element.remove(document.getElementById('trNomIn'+id));
		Element.remove(document.getElementById('trModIn'+id));
		callAjax(url+'_delfile.php?module=institution&id='+id,null,lafonct);
	}
}

function _delPlacement(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce placement ('+nom+')?')){
		Element.remove(document.getElementById('trNomPl'+id));
		Element.remove(document.getElementById('trModPl'+id));
		callAjax(url+'_delfile.php?module=placements&id='+id,null,lafonct);
	}
}

function _delCoffret(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce coffret de sécurité ('+nom+')?')){
		Element.remove(document.getElementById('trNomCo'+id));
		Element.remove(document.getElementById('trModCo'+id));
		callAjax(url+'_delfile.php?module=coffret&id='+id,null,lafonct);
	}
}

function _delVehicule(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce véhicule ('+nom+')?')){
		Element.remove(document.getElementById('trNomVe'+id));
		Element.remove(document.getElementById('trModVe'+id));
		callAjax(url+'_delfile.php?module=vehicule&id='+id,null,lafonct);
	}
}
function _delPret(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce prêt ('+nom+')?')){
		Element.remove(document.getElementById('trNomCp'+id));
		Element.remove(document.getElementById('trModCp'+id));
		callAjax(url+'_delfile.php?module=pret&id='+id,null,lafonct);
	}
}

function _delLien(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce lien financier ('+nom+')?')){
		Element.remove(document.getElementById('trNomLf'+id));
		Element.remove(document.getElementById('trModLf'+id));
		callAjax(url+'_delfile.php?module=lien&id='+id,null,lafonct);
	}
}

function _delLitige(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer ce litige ('+nom+')?')){
		Element.remove(document.getElementById('trNomLi'+id));
		Element.remove(document.getElementById('trModLi'+id));
		callAjax(url+'_delfile.php?module=litige&id='+id,null,lafonct);
	}
}

function _delSeing(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomAu'+id));
		Element.remove(document.getElementById('trModAu'+id));
		callAjax(url+'_delfile.php?module=seing&id='+id,null,lafonct);
	}
}

function _delArrangement(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomAr'+id));
		Element.remove(document.getElementById('trModAr'+id));
		callAjax(url+'_delfile.php?module=arrangement&id='+id,null,lafonct);
	}
}

function _delPretPerso(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomPretPerso'+id));
		Element.remove(document.getElementById('trModPretPerso'+id));
		callAjax(url+'_delfile.php?module=pretperso&id='+id,null,lafonct);
	}
}

function _delPretHypo(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomPretHypo'+id));
		Element.remove(document.getElementById('trModPretHypo'+id));
		callAjax(url+'_delfile.php?module=prethypo&id='+id,null,lafonct);
	}
}

function _delCarteCredit(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomCarteCredit'+id));
		Element.remove(document.getElementById('trModCarteCredit'+id));
		callAjax(url+'_delfile.php?module=carteCredit&id='+id,null,lafonct);
	}
}

function _delCautionnement(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomCautionnement'+id));
		Element.remove(document.getElementById('trModCautionnement'+id));
		callAjax(url+'_delfile.php?module=cautionnement&id='+id,null,lafonct);
	}
}

function _delProces(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomProces'+id));
		Element.remove(document.getElementById('trModProces'+id));
		callAjax(url+'_delfile.php?module=proces&id='+id,null,lafonct);
	}
}

function _delBaux(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomBaux'+id));
		Element.remove(document.getElementById('trModBaux'+id));
		callAjax(url+'_delfile.php?module=baux&id='+id,null,lafonct);
	}
}

function _delautresDettes(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomautresDettes'+id));
		Element.remove(document.getElementById('trModautresDettes'+id));
		callAjax(url+'_delfile.php?module=autresDettes&id='+id,null,lafonct);
	}
}

function _delBien(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//window.location.reload();
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet item ('+nom+')?')){
		Element.remove(document.getElementById('trNomSa'+id));
		Element.remove(document.getElementById('trModSa'+id));
		callAjax(url+'_delfile.php?module=bien&id='+id,null,lafonct);
	}
}

function _saveLiquidateur(id){
	lafonct = function() {
		if(ajaxOk()){
			Element.remove(document.getElementById('liquidaNom'+id));
			Element.remove(document.getElementById('trModEx'+id));
			eval(objAjax.responseText);
			objAjax = null;
		}
	}
	if(checkform($('formModLiquid'+id))){
		callAjax(url+'_modLiquidateur.php?id='+id,$('formModLiquid'+id),lafonct);
	}
}

function _updatePropriete(id){
	if(checkform($('editPrform'+id))){
		$('editPrform'+id).submit();
	}
}

function _addEnfant(){
	lafonct = function() {
		if(ajaxOk()){
			eval(objAjax.responseText);
			objAjax = null;
		}
	}
	if(checkform($('addEnfant'))){
		callAjax(url+'_addEnfant.php',$('addEnfant'),lafonct);
	}
}

function _saveEnfant(id){
	lafonct = function() {
		if(ajaxOk()){
			Element.remove(document.getElementById('enfantNom'+id));
			Element.remove(document.getElementById('trModEn'+id));
			eval(objAjax.responseText);
			objAjax = null;
		}
	}
	if(checkform($('modEnfant'+id))){
		callAjax(url+'_modEnfant.php?id='+id,$('modEnfant'+id),lafonct);
	}
}

function _delEnfant(id,nom){
	lafonct = function() {
		if(ajaxOk()){
			//alert(objAjax.responseText);
			objAjax = null;
		}
	}
	if(confirm('Voulez-vous supprimer cet enfant ('+nom+')?')){
		Element.remove(document.getElementById('enfantNom'+id));
		Element.remove(document.getElementById('trModEn'+id));
		callAjax(url+'_delfile.php?module=enfant&id='+id,null,lafonct);
	}
}

function _saveRenseignement(){
	$('nomNotaire').value = $('nomN').value;
	$('villeNotaire').value = $('villeN').value;
	if($('OuiNota').checked){
		$('isNotarie').value = 1;
	}else{
		$('isNotarie').value = 0;
	}
	if(document.fMain.etatc.options[document.fMain.etatc.selectedIndex].value==4 ||document.fMain.etatc.options[document.fMain.etatc.selectedIndex].value==6 ){
		if($('nom').value==''){alert('Veuillez entrer le nom de votre conjoint(e)');return(false);}
		if($('adresse').value==''){alert('Veuillez entrer l\'adresse de votre conjoint(e)');return(false);}
		if($('ville').value==''){alert('Veuillez entrer la ville de votre conjoint(e)');return(false);}
		if($('pays').value==''){alert('Veuillez entrer le pays de votre conjoint(e)');return(false);}
		if($('province').value==''){alert('Veuillez entrer la province de votre conjoint(e)');return(false);}
		if($('codepostal').value==''){alert('Veuillez entrer le code postal de votre conjoint(e)');return(false);}
	}
	if($('OuiTest').checked==true && $('OuiNota').checked==true){
		if($('nomN').value==''){alert('Veuillez entrer le nom de votre notaire');return(false);}
		if($('villeN').value==''){alert('Veuillez entrer l\'adresse de votre notaire');return(false);}
	}
	document.fMain.submit();
}

function validRegisterAndSubmit(hndl){
	lafonct = function() {
		if(ajaxOk()){
			if(objAjax.responseText==0){hndl.submit();}else{alert('Ce nom d\'utilisateur est déjà utilisé.\nVeuillez en choisir un autre');}
			objAjax = null;
		}
	}
	if(checkform(hndl)){
		callAjax(url+'_validateUsername.php?username='+hndl.username.value,null,lafonct);
	}
}

function validMembreAndSubmit(hndl){
	lafonct = function() {
		if(ajaxOk()){
			if(objAjax.responseText==0){hndl.submit();}else{alert('Ce nom d\'utilisateur est déjà utilisé.\nVeuillez en choisir un autre');}
			objAjax = null;
		}
	}
	if(checkform(hndl)){
		callAjax(url+'_validateUsernameLogged.php?username='+hndl.username.value,null,lafonct);
	}
}

function updateTaxesEtTotal(){
	$('tps').innerHTML = (document.registerform.achat.options[document.registerform.achat.selectedIndex].getAttribute('tps'))+' $';
	$('tvq').innerHTML = (document.registerform.achat.options[document.registerform.achat.selectedIndex].getAttribute('tvq'))+' $';
	$('total').innerHTML = (document.registerform.achat.options[document.registerform.achat.selectedIndex].getAttribute('taxes'))+' $';
}

function popupinfowindow(theURL,winName,features) {
		  window.open(theURL,winName,features);
		}

function toggleProv(hndl){
	if(hndl.options[hndl.selectedIndex].value=="CA"){
		document.registerform.province.style.display='none';
		document.registerform.province_ca.style.display='';
	}else{
		document.registerform.province.style.display='';
		document.registerform.province_ca.style.display='none';
	}
}

