/* VERIF FORM FUNCTION */
function validateEmail(field) {

	frm=document.forms["mailform"];
	mail=frm.elements["email"].value;


	
	//mail = field;
	
	at=mail.indexOf("@",1);
	dot=mail.indexOf(".",at+1);
	
	if (mail != 0) {
	//	alert ('inside');
		if ((mail.length<3)||(at<0)||(dot<2)){		
			document.forms["mailform"].elements["email"].value = "";
			//this.form.email.value = "";
			
			alert("Courriel non valide");
			}
			
	}
	
}

function calculQuotient(){ 
	//alert(document.mailform.vous1.value); 
	
	var total = 0.0;
	var c1 = 0; 
	var c2 = 0;
	var c3 = 0;
	var pageid = 0; 
	
	
	c1 = parseFloat(0+document.mailform.vous1.value);
	c2 = parseFloat(0+document.mailform.vous2.value);
	c3 = parseFloat(0+document.mailform.vous3.value);
	total = total+((c1+c2+c3)/3);
	
	c1 = parseFloat(0+document.mailform.conjoint1.value);
	c2 = parseFloat(0+document.mailform.conjoint2.value);
	c3 = parseFloat(0+document.mailform.conjoint3.value);
	
	total = total+((c1+c2+c3)/3);
	
	total = total + parseFloat(0+document.mailform.af.value);
	total = total + parseFloat(0+document.mailform.cf.value);
	total = total + parseFloat(0+document.mailform.aje.value);
	total = total + parseFloat(0+document.mailform.ape.value);
	total = total + parseFloat(0+document.mailform.asf.value);
	total = total + parseFloat(0+document.mailform.api.value);
	total = total + parseFloat(0+document.mailform.apl.value);
	total = total + parseFloat(0+document.mailform.aah.value);
	total = total + parseFloat(0+document.mailform.rmi.value);
	
	total = total + parseFloat(0+document.mailform.fonciers.value);
	total = total + parseFloat(0+document.mailform.pension.value);
	total = total + parseFloat(0+document.mailform.retraite.value);
	
	
	c1 = parseFloat(0+document.mailform.loyers.value);
	c2 = document.mailform.forfait.selectedIndex;
	c3 = parseFloat(0+document.mailform.forfait[c2].value);
	
	if(c3){
		c1 = c3;	
	}
	
	total = total - c1;
	
	total = total - parseFloat(0+document.mailform.pension_alimentaire.value);
	total = total - parseFloat(0+document.mailform.pension_alimentaire_ascendants.value);
	
	c1 = parseFloat(0+document.mailform.impot_vous.value);
	c2 = parseFloat(0+document.mailform.impot_conjoint.value);
	var tt = ( c1 + c2 ) / 12;
	
	total = total - tt;
	
	c1 = parseFloat(0+document.mailform.nr_personnes.value);
	if(c1){
		total = total / c1;
	}	
	
	total = Math.round(total);
	
	pageid = parseInt(document.mailform.id_rewrite.value);
	window.location.href = "index.php?id="+pageid+"&quotient="+total;
	//document.mailform.id_rewrite.value = total;	
	
	//alert(pageid);
	//alert("Le quotient familial est: "+total);
	
}


String.prototype.toInt = function() {
    var a = new Array();
    for (var i = 0; i < this.length; i++) {
        a[i] = this.charCodeAt(i);
    }
    return a;
}

