function ongletClick(ong) {
	l="index.php?id_apporteur="+document.frm.id_apporteur.value+"&mnn="+document.frm.monnaie.value+"&param="+document.frm.param.value+"&ong="+ong;

	l+="&achat="+strtoint(document.frm.achat.value);
	l+="&apport="+strtoint(document.frm.apport.value);
	l+="&revalTotal="+strtoint(document.frm.revalTotal.value);
	l+="&fraisSupp="+strtoint(document.frm.fraisSupp.value);
 	l+="&loyer="+strtoint(document.frm.loyer.value);
	if ((onglet==1)||(onglet==9)) {
		l+="&dureeSim="+(document.frm.dureeSim.options[document.frm.dureeSim.selectedIndex].text);
	} else {
		l+="&dureeSim="+document.frm.dureeSim.value;
	}
	
	l+="&txFrais="+strtofloat(document.frm.txFrais.value);
	l+="&txi="+strtofloat(document.frm.tauxInteret.value);
	l+="&txa="+strtofloat(document.frm.tauxAssurance.value);
	if ((onglet==2)||(onglet==9)) {
		l+="&nature="+document.frm.nature.selectedIndex;
		l+="&duree="+(document.frm.duree.options[document.frm.duree.selectedIndex].text);
	} else {
		l+="&nature="+document.frm.nature.value;
		l+="&duree="+document.frm.duree.value;
	}
	
	l+="&superficie="+strtoint(document.frm.superficie.value);
	l+="&augmentLoyer="+strtofloat(document.frm.augmentLoyer.value);
	if ((onglet==3)||(onglet==9)) {
		l+="&type="+document.frm.type.selectedIndex;
	} else {
		l+="&type="+document.frm.type.value;
	}
 
	l+="&dureeSimA="+strtoint(document.frm.dureeSimA.value);
	l+="&dureeSimB="+strtoint(document.frm.dureeSimB.value);
	l+="&revalTotalA="+strtoint(document.frm.revalTotalA.value);
	l+="&revalTotalB="+strtoint(document.frm.revalTotalB.value);
	l+="&revalTotalC="+strtoint(document.frm.revalTotalC.value);
	l+="&rendement="+strtofloat(document.frm.rendement.value);

	location=l;
	return false;
}
function convertClick() {
	monnaie=1-document.frm.monnaie.value;
	document.frm.monnaie.value=monnaie;
	coeff=(monnaie==1)?1/pariteEuro:pariteEuro;
	document.frm.achat.value=inttostr(strtoint(document.frm.achat.value)*coeff);
	document.frm.apport.value=inttostr(strtoint(document.frm.apport.value)*coeff);
	document.frm.fraisSupp.value=inttostr(strtoint(document.frm.fraisSupp.value)*coeff);
	document.frm.loyer.value=inttostr(strtoint(document.frm.loyer.value)*coeff);
	ongletClick(onglet);
}
function printClick() {
	bn=navigator.appName;
	bv=navigator.appVersion;
	nsv=parseFloat(bv);
	iev=bv.substring(bv.indexOf('MSIE ')+5);
	iev=parseFloat(iev);
	if ((bn=="Netscape" && nsv>=4) || (bn=="Microsoft Internet Explorer" && iev>=5))
		print()
	else
		alert("Cette fonction nécessite Microsoft Internet Explorer 5 ou Netscape Navigator 4!");
}
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function calcClick() {
	return ongletClick((onglet==9)?9:1);
}
function achatChange() {
	achat=strtoint(document.frm.achat.value);
	
	if ((onglet==2)||(onglet==9)) {
		document.frm.achat2.value=inttostr(achat);
		txFraisChange();
	}
	
	if ((onglet==3)||(onglet==9)) {
		document.frm.achat3.value=inttostr(achat);
	}
	
	if ((onglet==4)||(onglet==9)) {
		revalTotal2Change();
	}
	
	fraisSupp=calcFraisSupp();
	document.frm.fraisSupp.value=inttostr(fraisSupp);
	fraisSuppChange();
}
function calcFraisSupp() {
	achat=strtoint(document.frm.achat.value);
	if ((onglet==3)||(onglet==9)) {
		type=document.frm.type.selectedIndex;
	} else {
		type=strtoint(document.frm.type.value);
	}
	superficie=strtoint(document.frm.superficie.value);
	var r;
	if (superficie==0) {
		r=Math.floor(achat*1.5/100/200)*200;
	} else {
		r=superficie*((type==0)?32:55);
	}
	return r;
}
function apportChange() {
	apport=strtoint(document.frm.apport.value);
	
	if ((onglet==2)||(onglet==9)) {
		document.frm.apport2.value=inttostr(apport);
		coutAcq=strtoint(document.frm.coutAcq.value);
		mntPret=coutAcq-apport;
		document.frm.mntPret.value=inttostr(mntPret);
		calcMensualite();
	}
	
	if ((onglet==6)||(onglet==9)) {
		document.frm.apport3.value=inttostr(apport);
		calcApportFin();
	}
}
function calcMensualite() { // onglet=2 ou onglet=9
	if ((onglet!=2)&&(onglet!=9)) alert(5124);
	mntPret=strtoint(document.frm.mntPret.value);
	duree=strtoint(document.frm.duree.options[document.frm.duree.selectedIndex].text);
	tauxInteret=strtofloat(document.frm.tauxInteret.value);
	tauxAssurance=strtofloat(document.frm.tauxAssurance.value);
	mensualite=calcMens(mntPret,duree,tauxInteret,tauxAssurance);
	document.frm.mensualite.value=inttostr(mensualite);
	
	if (onglet==9) {
		dureeSim=strtoint(document.frm.dureeSim.options[document.frm.dureeSim.selectedIndex].text);
	} else {
		dureeSim=strtoint(document.frm.dureeSim.value);
	}
	resteDu=mntPret;
	totalInteret=0;
	totalAssurance=0;
	for (i=0; i<dureeSim; i++) {
		for (m=0; m<12; m++) {
			interet=resteDu*tauxInteret/1200;
			if (modeAssurance==1) {
				assurance=resteDu*tauxAssurance/1200;
			} else {
				assurance=mntPret*tauxAssurance/1200;
			}
			principal=mensualite-interet-assurance;
			resteDu-=principal;
			totalInteret+=interet;
			totalAssurance+=assurance;
		}
	}
	document.frm.resteDu.value=inttostr(resteDu);
	document.frm.totalInteret.value=inttostr(totalInteret);
	document.frm.totalAssurance.value=inttostr(totalAssurance);
}
function dureeSimChange() {
	if ((onglet==1)||(onglet==9)) {
		dureeSim=strtoint(document.frm.dureeSim.options[document.frm.dureeSim.selectedIndex].text);
	} else {
		dureeSim=strtoint(document.frm.dureeSim.value);
	}
	i=dureeSim-1;
	if ((onglet==4)||(onglet==9)) {
		document.frm.dureeSim2.selectedIndex=i;
		revalTotal2Change();
	}
	if ((onglet==5)||(onglet==9)) {
		totalLoyer=calcTotalLoyer();
		document.frm.totalLoyer.value=inttostr(totalLoyer);
	}
	if ((onglet==6)||(onglet==9)) {
		document.frm.dureeSim3.selectedIndex=i;
		calcApportFin();
	}
}
function revalTotalChange() {
	revalTotal=strtoint(document.frm.revalTotal.value);
	if ((onglet==4)||(onglet==9)) {
		document.frm.revalTotal2.value=inttostr(revalTotal);
		dureeSim=strtoint(document.frm.dureeSim2.options[document.frm.dureeSim2.selectedIndex].text);
		revalAnnuel=(Math.pow(1+revalTotal/100,1/dureeSim)-1)*100;
		document.frm.revalAnnuel.value=floattostr(revalAnnuel);
		achat=strtoint(document.frm.achat.value);
		plusValue=achat*revalTotal/100;
		document.frm.plusValue.value=inttostr(plusValue);
	}
}
function fraisSuppChange() {
	fraisSupp=strtoint(document.frm.fraisSupp.value);
	if ((onglet==3)||(onglet==9)) {
		document.frm.fraisSupp2.value=inttostr(fraisSupp);
		calcTxSuppl();
	}
}
function calcTxSuppl() { // onglet=3 ou onglet=9
	if ((onglet!=3)&&(onglet!=9)) alert(6481);
	achat=strtoint(document.frm.achat.value);
	fraisSupp=strtoint(document.frm.fraisSupp.value);
	txFraisSupp=(achat!=0)?fraisSupp/achat*100:0;
	document.frm.txFraisSupp.value=floattostr(txFraisSupp);
}
function loyerChange() {
	loyer=strtoint(document.frm.loyer.value);
	if ((onglet==5)||(onglet==9)) {
		document.frm.loyer2.value=inttostr(loyer);
		totalLoyer=calcTotalLoyer();
		document.frm.totalLoyer.value=inttostr(totalLoyer);
	}
}
function calcTotalLoyer() {
	loyer=strtoint(document.frm.loyer.value);
	augmentLoyer=strtofloat(document.frm.augmentLoyer.value);
	if ((onglet==1)||(onglet==9)) {
		dureeSim=strtoint(document.frm.dureeSim.options[document.frm.dureeSim.selectedIndex].text);
	} else {
		dureeSim=strtoint(document.frm.dureeSim.value);
	}
	loyerAn=loyer*12;
	totalLoyer=loyerAn;
	for (i=1; i<dureeSim; i++) {
		loyerAn*=1+augmentLoyer/100;
		totalLoyer+=loyerAn;
	}
	return totalLoyer;
}
function achat2Change() {
	achat=strtoint(document.frm.achat2.value);
	document.frm.achat.value=inttostr(achat);
	achatChange();
}
function natureChange() {
	txFrais=(document.frm.nature.selectedIndex==0)?6:2.5;
	document.frm.txFrais.value=floattostr(txFrais);
	txFraisChange();
}
function txFraisChange() {
	achat=strtoint(document.frm.achat.value);
	txFrais=strtofloat(document.frm.txFrais.value);
	mntFrais=achat*txFrais/100;
	document.frm.mntFrais.value=inttostr(mntFrais);
	coutAcq=achat+mntFrais;
	document.frm.coutAcq.value=inttostr(coutAcq);
	apport2Change();
}
function apport2Change() {
	apport=strtoint(document.frm.apport2.value);
	document.frm.apport.value=inttostr(apport);
  apportChange();
}
function dureeChange() {
	var d=document.frm.duree.options[document.frm.duree.selectedIndex].text;
	st=eval("document.frm.tauxInteretDefault"+d+".value");
	document.frm.tauxInteret.value=floattostr(st);
	calcMensualite();
}
function achat3Change() {
	achat=strtoint(document.frm.achat3.value);
	document.frm.achat.value=inttostr(achat);
	achatChange();
}
function typeChange() {
	superficieChange();
}
function superficieChange() {
	superficie=strtoint(document.frm.superficie.value);
	if (superficie>0) {
		fraisSupp=superficie*((document.frm.type.selectedIndex==0)?32:55);
		document.frm.fraisSupp2.value=inttostr(fraisSupp);
	}
	fraisSupp2Change();
}
function fraisSupp2Change() {
	//achat=strtoint(document.frm.achat3.value);
	fraisSupp=strtoint(document.frm.fraisSupp2.value);
	document.frm.fraisSupp.value=floattostr(fraisSupp);
	fraisSuppChange();
	//document.frm.txFraisSupp.value=floattostr(fraisSupp/achat*100);
}
function dureeSim2Change() {
	i=document.frm.dureeSim2.selectedIndex
	if (onglet==9) {
		document.frm.dureeSim.selectedIndex=i;
	} else {
		document.frm.dureeSim.value=document.frm.dureeSim2.options[i].text;
	}
	dureeSimChange();
}
function revalTotal2Change() {
	revalTotal=strtoint(document.frm.revalTotal2.value);
	document.frm.revalTotal.value=inttostr(revalTotal);
	revalTotalChange();
}
function loyer2Change() {
	loyer=strtoint(document.frm.loyer2.value);
	document.frm.loyer.value=inttostr(loyer);
	loyerChange();
}
function augmentLoyerChange() {
	totalLoyer=calcTotalLoyer();
	document.frm.totalLoyer.value=inttostr(totalLoyer);
}
function apport3Change() {
	apport=strtoint(document.frm.apport3.value);
	document.frm.apport.value=inttostr(apport);
	//calcApportFin();
	apportChange();
}
function calcApportFin() {
	apport=strtoint(document.frm.apport.value);
	rendement=strtofloat(document.frm.rendement.value);
	if ((onglet==1)||(onglet==9)) {
		dureeSim=strtoint(document.frm.dureeSim.options[document.frm.dureeSim.selectedIndex].text);
	} else {
		dureeSim=strtoint(document.frm.dureeSim.value);
	}
	apportFin=apport*(1+rendement/100*dureeSim);
	document.frm.apportFin.value=inttostr(apportFin);
	gainApport=apportFin-apport;
	document.frm.gainApport.value=inttostr(gainApport);
}
function dureeSim3Change() {
	i=document.frm.dureeSim3.selectedIndex
	if (onglet==9) {
		document.frm.dureeSim.selectedIndex=i;
	} else {
		document.frm.dureeSim.value=document.frm.dureeSim3.options[i].text;
	}
	dureeSimChange();
}
function pris(i,duree) {
 var p=1;
 for (var j=0; j<duree; j++) p*=(1+i);
 return p
}
function calcMens(mnt,dur,txi,txa) {
 mis=dur*12;
 if(modeAssurance==1) {
  txm=(txi+txa)/1200;
  prw=pris(txm,mis);
  result=mnt*prw*txm/(prw-1);
 } else {
  txm=txi/1200;
  prw=pris(txm,mis);
  result=mnt*(prw*txm/(prw-1)+txa/1200);
 }
 return result;
}
function recopier(cl,c2) {
	var t=cl.value;
	eval("document.frm."+c2+".value=t");
}
