function ongletClick(ong){
	vonglet=document.frm.onglet.value;
	l="index.php?id_apporteur="+document.frm.id_apporteur.value+"&param="+document.frm.param.value+"&ong="+ong/*+"&mnn="+document.frm.monnaie.value*/;
	l+="&revenuEmp="+strtoint(document.frm.salnet.value)+"&revenuCoEmp="+strtoint(document.frm.revenuCoEmp.value)+
		"&snb="+strtoint(document.frm.salnb.value)+"&snb2="+strtoint(document.frm.salnb2.value)+
		"&avp="+strtoint(document.frm.autrevp.value)+"&lp="+strtoint(document.frm.loyper.value)+
		"&rf="+strtoint(document.frm.revfin.value)/*+"&all="+strtoint(document.frm.alloc.value)+
		"&ap="+strtoint(document.frm.aidper.value)*/+"&ar="+strtoint(document.frm.autrev.value);
	l+="&lo="+strtoint(document.frm.loyer.value)+"&rp="+strtoint(document.frm.respri.value)+
		"&rss="+strtoint(document.frm.ressec.value)+"&rl="+strtoint(document.frm.resloc.value)+
		"&cs="+strtoint(document.frm.conso.value)+"&vt="+strtoint(document.frm.voiture.value)+
		"&pm="+strtoint(document.frm.perm.value)+"&ac="+strtoint(document.frm.autcr.value)+
		"&pen="+strtoint(document.frm.pension.value);
	if (document.getElementById('simuID')) {
		l += "&simuID="+document.frm.simuID.value+"&urlSF="+document.frm.urlSF.value
	}
	location=l;
	return false;
}
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\351cessite Microsoft Internet Explorer 5 ou Netscape Navigator 4!");
	}
}
function convertItem(item) {
	var v=strtoint(item.value);
	if (v==0){
		item.value="";
	}
	else{
		item.value=inttostr(Math.round(v*coeffconvert));
	}
}
function suivClick() {
	vonglet=document.frm.onglet.value;
	if (vonglet==1) return ongletClick(2)
	else if (vonglet==2) return ongletClick(3)
	else if (vonglet==4) return ongletClick(4);
}
function calcTotRevenus() {
	salnet = strtoint(document.frm.salnet.value);
	salnb =  strtoint(document.frm.salnb.value);
	if (salnb<=0) {
		alert("nombre de mois d'emprunteur incorrect");
		document.frm.salnb.focus();
		return false;
	} 
	else {
		salnet = salnet*salnb/12;
	}
	salnet2 = strtoint(document.frm.revenuCoEmp.value);
	salnb2 =  strtoint(document.frm.salnb2.value);
	if (document.frm.revenuCoEmp.value != '' && salnb2<=0){
		alert("nombre de mois de conjoint incorrect");
		document.frm.salnb2.focus();
		return false;
	}
	salnet2 = salnet2*salnb2/12;
	autrevp = strtoint(document.frm.autrevp.value);
	loyper = strtoint(document.frm.loyper.value);
	revfin = strtoint(document.frm.revfin.value);
	//alloc = strtoint(document.frm.alloc.value);
	//aidper = strtoint(document.frm.aidper.value);
	autrev = strtoint(document.frm.autrev.value);
	rev = salnet+salnet2+autrevp+loyper+revfin+autrev;
	if (document.frm.onglet.value==4) {
		oldrev=strtoint(document.frm.revenus.value);
		if (rev!=oldrev) viderResult();
	}
	document.frm.revenus.value =inttostr(rev);
}
function calcTotCharges() {
	loyer = strtoint(document.frm.loyer.value);
	respri = strtoint(document.frm.respri.value);
	ressec = strtoint(document.frm.ressec.value);
	resloc = strtoint(document.frm.resloc.value);
	conso = strtoint(document.frm.conso.value);
	voiture = strtoint(document.frm.voiture.value);
	perm = strtoint(document.frm.perm.value);
	autcr = strtoint(document.frm.autcr.value);
	pension = strtoint(document.frm.pension.value);
	chrg = loyer+respri+ressec+resloc+conso+voiture+perm+autcr+pension;
	if (document.frm.onglet.value==4) {
		oldchrg=strtoint(document.frm.charges.value);
		if (chrg!=oldchrg) viderResult();
	}
	document.frm.charges.value = inttostr(chrg);
}
function viderResult() {
	document.frm.mensualite.value="";
	document.frm.montant10.value="";
	document.frm.montant12.value="";
	document.frm.montant15.value="";
	document.frm.montant20.value="";
	document.frm.montant25.value="";
}
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 convertClick() {
	vonglet=document.frm.onglet.value;
	vmonnaie=document.frm.monnaie.value;
	document.frm.monnaie.value=1-vmonnaie;
	mmax=(vonglet==1)?7:10;
	if	(vmonnaie==0) {
		coeffconvert=1/pariteEuro;
		if ((document.images)&&((vonglet==1)||(vonglet==2))) {
			document.images['convert'].src='../img/<?php if ($id_apporteur!="") { echo $id_apporteur."/"; } ?>brd_fr.gif';
			for (i=1; i<=mmax; i++) {
				document.images['monnaie'+i].src='../img/<?php if ($id_apporteur!="") { echo $id_apporteur."/"; } ?>euro.gif';
			}
		}
	} 
	else {
		coeffconvert=pariteEuro;
		if ((document.images)&&((vonglet==1)||(vonglet==2))) {
			document.images['convert'].src='../img/<?php if ($id_apporteur!="") { echo $id_apporteur."/"; } ?>brd_eu.gif';
			for (i=1; i<=mmax; i++) {
				document.images['monnaie'+i].src='../img/<?php if ($id_apporteur!="") { echo $id_apporteur."/"; } ?>f.gif';
			}
		}
	}
	convertItem(document.frm.salnet);
	convertItem(document.frm.revenuCoEmp);
	convertItem(document.frm.autrevp);
	convertItem(document.frm.loyper);
	convertItem(document.frm.revfin);
	//convertItem(document.frm.alloc);
	//convertItem(document.frm.aidper);
	convertItem(document.frm.autrev);
	convertItem(document.frm.loyer);
	convertItem(document.frm.respri);
	convertItem(document.frm.ressec);
	convertItem(document.frm.resloc);
	convertItem(document.frm.conso);
	convertItem(document.frm.voiture);
	convertItem(document.frm.perm);
	convertItem(document.frm.autcr);
	convertItem(document.frm.pension);
	if (vonglet==1) calcTotRevenus()
	else if (vonglet==2) calcTotCharges()
	else {ongletClick(vonglet);}
	return false;
}
