
function count_credit(){
//window.alert(document.getElementById("tabcredits").getElementsByTagName("tr").length - 1);
document.frm_etude.credit_count.value = document.getElementById("tabcredits").getElementsByTagName("tr").length - 1;
}

function count_immo(){
//window.alert(document.getElementById("pat_immo").getElementsByTagName("tr").length - 1);
document.frm_etude.immo_count.value = document.getElementById("pat_immo").getElementsByTagName("tr").length - 1;
}


//Crédit

//proprio
function show_proprio() {
	
	f = document.frm_etude;
	
	if(f.logement[1].checked == true || f.logement[2].checked == true) {
		document.getElementById("question_proprio").style.display = "";
		
	}else{
		document.getElementById("question_proprio").style.display = "none";
	}
	
}

//patrimoine
function show_patrimoine() {
	
	f = document.frm_etude;
	
	if(f.logement[0].checked == true || f.proprio[0].checked == true) {
		document.getElementById("patrimoine_immo").style.display = "";
	}
	else {
		document.getElementById("patrimoine_immo").style.display = "none";
	}

}

//champs coemprunteur
function show_coemp() {
	
	f = document.frm_etude;
	tab_champs = new Array("salaire_co_mois","salaire_co","profession_co","contrat_co","anciennete_co_mois","anciennete_co_an","jour_naiss_co", "mois_naiss_co", "annee_naiss_co", "nom_co", "prenom_co");
	taille_tab = tab_champs.length;

	if(f.co[1].checked == false) {
		for(i = 0; i < taille_tab; i++) {
			f.elements[tab_champs[i]].disabled = false;
			f.elements[tab_champs[i]].style.backgroundColor = "#f8f8f8";
			document.getElementById('civ_co_1').disabled=false;
			document.getElementById('civ_co_2').disabled=false;
			document.getElementById('civ_co_3').disabled=false;
		}	
	}
	else {
		for(i = 0; i < taille_tab; i++) {
			f.elements[tab_champs[i]].disabled = true;
			f.elements[tab_champs[i]].style.backgroundColor = "#dddddd";
			document.getElementById('civ_co_1').disabled=true;
			document.getElementById('civ_co_2').disabled=true;
			document.getElementById('civ_co_3').disabled=true;
		}
	}
	
}

//ligne patrimoine
function add_immo(){  
  var newLigne = document.getElementById("pat_immo").insertRow(-1);
  var tabBiens = document.getElementById("pat_immo");
	var numBien = tabBiens.getElementsByTagName("tr").length - 2;
	numBien++;
	monnaieencours = "&euro;";
  newCell = newLigne.insertCell(0);
  newCell.innerHTML = "Bien immobilier n°" + numBien;
  newCell = newLigne.insertCell(1);
  newCell.innerHTML = "<select name='immo_type"+ numBien +"' class=\"iselect\" style='width:177px;'><option value=''></option><option value=1 >Résidence principale</option><option value=2 >Résidence secondaire</option><option value=3 >Investissement locatif - Défiscalisation</option><option value=4 >Investissement locatif - Autre</option></select>";
  newCell = newLigne.insertCell(2);
  newCell.innerHTML = "<input type=text name=immo_valeur"+ numBien +" size=7 value='0' class=\"itext\"> "+ monnaieencours;
}

//credits
function add_credit()
	{
	var monnaieencours;
	var tabcredits = document.getElementById("tabcredits");
	var lignecredit = tabcredits.getElementsByTagName("tr").length;

	if(lignecredit < 30) {
		monnaieencours = "&euro;";
		//document.frm_etude.credit_count.value = lignecredit+1;
		
		in0 = "&nbsp; ";
		in1 = "Crédit n°"+(lignecredit);
		in2 = "<select name='credit_type"+lignecredit+"' class=\"iselect\" style='width:135px;'><option value=\"\"></option><option value=\"1\">Consommation</option><option  value=\"2\">Immobilier</option><option  value=\"3\">Personnel</option><option  value=\"4\">Prêt à taux zéro</option><option  value=\"5\">Réserve d'argent</option><option  value=\"6\">Autres</option></select>";
		in2bis = "&nbsp; ";
		in3 = "<center><input type='text' class=\"itext\"  style=\"width:50px;\" name='credit_mensualite"+lignecredit+"'> "+monnaieencours+"/mois</center>";
		//in3bis = "&nbsp; ";
		in4 = "<center><input type='text' class=\"itext\"  style=\"width:100px;\" name='credit_restant"+lignecredit+"'>&nbsp;"+monnaieencours+"&nbsp;&nbsp;</center>";
		in4bis = "&nbsp; ";
		in5 = "<center><input type=radio name='credit_inclure"+lignecredit+"' checked>Oui &nbsp;<input type=radio name='credit_inclure"+lignecredit+"'>Non</center>";
		//in5bis = "&nbsp; ";
		var l = tabcredits.insertRow(tabcredits.rows.length); 
		var c = l.insertCell(l.cells.length);

		c.innerHTML = in0; 
		c = l.insertCell(l.cells.length); 
		c.innerHTML = in1; 
		c = l.insertCell(l.cells.length); 
		c.innerHTML = in2;
		c = l.insertCell(l.cells.length);
		c.innerHTML = in2bis;
		c = l.insertCell(l.cells.length);
		c.innerHTML = in3;
		c = l.insertCell(l.cells.length);
		//c.innerHTML = in3bis;
		//c = l.insertCell(l.cells.length);
		c.innerHTML = in4;
		c = l.insertCell(l.cells.length);
		c.innerHTML = in4bis;
		c = l.insertCell(l.cells.length);
		c.innerHTML = in5;
		//c = l.insertCell(l.cells.length);
		//c.innerHTML = in5bis;
		//c = l.insertCell(l.cells.length);
		lignecredit++;
		}
	}