function ongletClick(ong,winName) {
	l="index.php?param="+document.frm.param.value+"&ong="+ong+"&mnn="+document.frm.monnaie.value;
	l+="&mnt="+strtoint(document.frm.montant.value);
	l+="&txi="+strtofloat(document.frm.tauxInteret.value);
	l+="&txir="+strtofloat(document.frm.tauxInteretRev.value);
	l+="&txa="+strtofloat(document.frm.tauxAssurance.value);
	l+="&per="+document.frm.perso.value;
	l+="&vt1="+strtofloat(document.frm.varTaux1.value);
	l+="&vt2="+strtofloat(document.frm.varTaux2.value);
	l+="&vt3="+strtofloat(document.frm.varTaux3.value);
	l+="&prev="+strtoint(document.frm.pourcentRev.value);
	//l+="&pourcentFixe="+strtoint(document.frm.pourcentFixe.value);
	//alert(document.frm.pourcentFixe.value);

	if ((onglet==1)||(onglet==9)) {
		l+="&dur="+document.frm.duree.options[document.frm.duree.selectedIndex].text;
		l+="&duri="+document.frm.dureeInterm.options[document.frm.dureeInterm.selectedIndex].text;
		l+="&durv="+document.frm.dureeRev.options[document.frm.dureeRev.selectedIndex].text;
		l+="&hau="+document.frm.hausse.options[document.frm.hausse.selectedIndex].value;
		l+="&bai="+document.frm.baisse.options[document.frm.baisse.selectedIndex].value;
	} else {
		l+="&dur="+document.frm.duree.value;
		l+="&duri="+document.frm.dureeInterm.value;
		l+="&durv="+document.frm.dureeRev.value;
		l+="&hau="+document.frm.hausse.value;
		l+="&bai="+document.frm.baisse.value;
	}

	if ((onglet==6)||(onglet==9)) {
		l+="&dv1="+document.frm.varDuree1.options[document.frm.varDuree1.selectedIndex].text;
		l+="&dv2="+document.frm.varDuree2.options[document.frm.varDuree2.selectedIndex].text;
		l+="&dv3="+document.frm.varDuree3.options[document.frm.varDuree3.selectedIndex].text;
	} else {
		l+="&dv1="+document.frm.varDuree1.value;
		l+="&dv2="+document.frm.varDuree2.value;
		l+="&dv3="+document.frm.varDuree3.value;
	}
	
	if (ongletClick.arguments.length<2) {
		location=l;
	} else {
		window.open(l,winName,'scrollbars=yes,resizable=yes,width=650,height=700');
	}

	return false;
}
function convertClick() {
	monnaie=1-document.frm.monnaie.value;
	document.frm.monnaie.value=monnaie;
	coeff=(monnaie==1)?1/pariteEuro:pariteEuro;
	document.frm.montant.value=inttostr(Math.round(strtoint(document.frm.montant.value)*coeff));
	return ongletClick(onglet);
}
function dureeChange() {
	d=document.frm.duree.options[document.frm.duree.selectedIndex].text;
	s=eval("document.frm.tauxInteret"+d+".value");
	document.frm.tauxInteret.value = floattostr(s);
	s=eval("document.frm.tauxInteretRev"+d+".value");
	document.frm.tauxInteretRev.value = floattostr(s);
	
	di=document.frm.dureeInterm.options[document.frm.dureeInterm.selectedIndex].text;
	dureeInterm=document.frm.dureeInterm;
	for (i=dureeInterm.length-1; i>=0; i--) dureeInterm.options[i]=null;
	opt=new Array;
	for (i=0; i<d-1; i++) {
		opt[i]=new Option(i+1,"");
		dureeInterm.options[i]=opt[i];
	}
	document.frm.dureeInterm.selectedIndex=Math.min(di-1,d-2);
}
function calcClick() {
	if ((onglet==1)||(onglet==6))
		return ongletClick(2)
	else
		return ongletClick(onglet);
}
function persoClick(p,o) {
	document.frm.perso.value=p;
	if (persoClick.arguments.length<2) o=onglet;
	ongletClick(o);
}
function calcCoefPret(i,d)	{
	p=1;
	for (j=0; j<d; j++) p*=(1+i);
	return p;
}
function calcMens(mnt,dur,txi,txa) {
	mis=dur*12;
	if(modeAssurance==1) {
		txm=(txi+txa)/1200;
		prw=calcCoefPret(txm,mis);
		result=mnt*prw*txm/(prw-1);
	} else {
		txm=txi/1200;
		prw=calcCoefPret(txm,mis);
		result=mnt*(prw*txm/(prw-1)+txa/1200);
	}
	return result;
}
function calculer() {
	monnaie=document.frm.monnaie.value;
	if (monnaie==1) {
		monnaieSymbole=" €";
	} else {
		monnaieSymbole=" F";
	}
	montant=document.frm.montant.value;
	txa=strtofloat(document.frm.tauxAssurance.value);
	mensualitefix=calcMens(montant,duree,document.frm.tauxInteret.value,txa);
	annuifix=mensualitefix*12;

	totannuivar=0;
	for (i=1; i<=duree; i++) {
		obj = eval("document.frm.txv"+i);
		stxv = obj.value;
		tauxvar = strtofloat(stxv);
		mensualitevar=(calcMens(montant,duree,tauxvar,txa)*pourcentRev+mensualitefix*(100-pourcentRev))/100;
		annuivar=mensualitevar*12;
		totannuivar+=annuivar;

		obj = eval("document.frm.mnv"+i);
		obj.value = inttostr(mensualitevar)+monnaieSymbole;
		obj = eval("document.frm.ttv"+i);
		obj.value = inttostr(annuivar)+monnaieSymbole;

		obj = eval("document.frm.mnf"+i);
		obj.value = inttostr(mensualitefix)+monnaieSymbole;
		obj = eval("document.frm.ttf"+i);
		obj.value = inttostr(annuifix)+monnaieSymbole;

		obj = eval("document.frm.mne"+i);
		obj.value = inttostr(-mensualitevar+mensualitefix)+monnaieSymbole;
		obj = eval("document.frm.tte"+i);
		obj.value = inttostr(-annuivar+annuifix)+monnaieSymbole;
	}
	document.frm.tgv.value=inttostr(totannuivar)+monnaieSymbole;
	document.frm.tgf.value=inttostr(annuifix*duree)+monnaieSymbole;
	document.frm.tge.value=inttostr(-totannuivar+annuifix*duree)+monnaieSymbole;
}
function txchange(ednum) {
	if (ednum>1) {
		obj = eval("document.frm.txv"+ednum);
		txv = strtofloat(obj.value);
		if (txv > tauxvarmaxi) txv = tauxvarmaxi;
		if (txv < tauxvarmini) txv = tauxvarmini;
		obj.value = floattostr(txv);
		obj = eval("document.frm.txv"+(ednum-1));
		txvp = strtofloat(obj.value);
		obj = eval("document.frm.vartxv"+(ednum-1));
		obj.value = floattostr(txv-txvp);
	}else{
		document.frm.txv1.value=floattostr(tauxInteretRev+tauxAssurance);
	}
	if (ednum!=duree) {
		obj = eval("document.frm.txv"+(ednum+1));
		txvs = strtofloat(obj.value);
		obj = eval("document.frm.vartxv"+ednum);
		obj.value = floattostr(txvs-txv);
	}
	calculer()
}
function vartxchange(ednum) {
	for (i=ednum;i<duree;i++) {
		obj = eval("document.frm.txv"+i);
		txv = strtofloat(obj.value);
		obj = eval("document.frm.vartxv"+i);
		vartxv = strtofloat(obj.value);
		txvs = txv+vartxv;
		if (txvs > tauxvarmaxi) txvs = tauxvarmaxi;
		if (txvs < tauxvarmini) txvs = tauxvarmini;
		obj.value = floattostr(Math.round((txvs-txv)*100)/100);
		obj = eval("document.frm.txv"+(i+1));
		obj.value = floattostr(Math.round(txvs*100)/100);
	}
	calculer();
}
function up(ednum) {
	obj = eval("document.frm.vartxv"+ednum);
	v = Math.round((strtofloat(obj.value)+.5)*100)/100;
	obj.value = floattostr(v);
	vartxchange(ednum);
	return false;
}
function down(ednum) {
	obj = eval("document.frm.vartxv"+ednum);
	v = Math.round((strtofloat(obj.value)-.5)*100)/100;
	obj.value = floattostr(v);
	vartxchange(ednum);
	return false;
}
function curseurClick(pourcentFixe) {
//	document.frm.pourcentFixe.value=pourcentFixe
	document.frm.pourcentRev.value=100-pourcentFixe;
	ongletClick(onglet);
}