function calculer()
{
	var f=document.formulaire;

	//-- Vérifications
	if (( isNaN(parseInt(f.prix_achatnet.value,10))) || (f.prix_achatnet.value==0)){
		//alert("Montant incorrect !");
		return;
	}

	//-- Initialisation
	var montant,natbien,honoraires,taxes,fraisnotaire,taux,ajout;
	//montant = parseInt(f.prix_achatnet.value,10);
	montant = strtoint(f.prix_achatnet.value);
	nature = f.nature.options[f.nature.selectedIndex].text;
	honoraires = 0;	
	
	if (nature=="Maison / Appartement - neuf")	natbien = "neuf";
	if (nature=="Maison / Appartement - ancien")	natbien = "ancien";
	if (nature=="Appartement - neuf")		natbien = "neuf";
	if (nature=="Appartement - ancien")		natbien = "ancien";
	if (nature=="Terrain + Construction")		natbien = "batir";
	if (nature=="Terrain seul")			natbien = "batir";
	if (nature=="Maison / Appartement - VEFA")	natbien = "neuf";
	if (nature=="VEFA - Appartement")		natbien = "neuf";
	if (nature=="Construction Seule")		{id_notaire.innerHTML="<font size=2><b>0</b> €</font>"; return; }
	
	
	//-- Tableau statique
	trancheD = new Array(    0, 3051,  6101,   16771);
	trancheF = new Array(3050, 6100, 16770, 99999999);
	taux_0     = new Array(    5,   3.3,   1.65,    0.825);
	ajout_0    = new Array(    0, 51.85,  152.5,   290.85);
	fraisdivers = 500;
	tauxTVA  = 19.600;
	tauxAnc  = 4.890;
	tauxNeu  = 0.715;
	tauxBat  = 4.890;


	//-- Calcul des honoraires
	montant = Math.round(montant);
	for (i=0; i < 4 ;i++) {
		if(trancheD[i]<montant && montant<trancheF[i]) {
			taux = taux_0[i];
			ajout = ajout_0[i];
			break;
		}	
	}

	//-- Calcul des taxes
	if (natbien=="neuf") 	taxes = montant/(1+tauxTVA/100)*0.615/100;
	if (natbien=="ancien") 	taxes = montant*4.89/100;
	if (natbien=="batir") 	taxes = montant * tauxBat / 100;

	//-- Frais de notaire
	fraisnotaire = (montant*taux/100+ajout)*(1+tauxTVA/100) + fraisdivers + taxes ;
	fraisnotaire = Math.round(fraisnotaire);

	//-- Affichage résultat
	s_fraisnotaire = inttostr(fraisnotaire);
	id_notaire.innerHTML=">font size=2><span class=rouge><b>"+s_fraisnotaire+"</b> €</span></font>";
	
	//-- Montant total
	total = fraisnotaire+montant;
	total = Math.round(total);

	//-- Affichage résultat
	s_total = inttostr(total);
	id_total.innerHTML="<font size=2><b>"+s_total+"</b> €</font>";
	
	
}

function lectnb(si) {
 var result="";
 for (var pi=0;pi<si.length;pi++) {
  var ci=si.charAt(pi);
  if ((ci!="0")||(result!=""))
   if (ci>="0" && ci<="9")
    result+=ci
   else if ((ci==",")||(ci=="."))
    result+="."
   else if ((ci=="-")&&(result==""))
    result+="-";
 }
 if (result=="") result="0";
 return result;
}

function strtoint(si) {
 return parseInt(lectnb(si));
}

function SelectText(area)
{
document.getElementById("area").select()
}

function strtofloat(sf) {
 return parseFloat(lectnb(sf));
}

function inttostr(i) {
 var result="";
 i=Math.round(parseFloat(i));
 si=i.toString();
 if (isNaN(si)) si="0";
 bi = 0;
 for (pi=si.length-1;pi>=0;pi--) {
  ci = si.charAt(pi);
  if ((bi==0)&&(pi!=si.length-1)&&(ci!="-")) {
   result=ci+" "+result;
  } else {
   result=ci+result;
  }
  bi=(bi+1)%3;
 }
 return result;
}

function floattostr(f) {
 f=Math.round(f*10000)/10000;
 var sf = f.toString();
 var result = "";
 for (pi=0;pi<sf.length;pi++) {
  cf = sf.charAt(pi);
  if (cf=='.')
   result += ','
  else
   result += cf;
 }
 return result;
}



function number_format(src,nv) {
	nv=parseInt(nv,10);
	if (nv>0||nv>9) nv=0; 
	cm = Math.pow(10,nv);
	s = src.value;
	
	if (cm>1) {	
		f= strtofloat(s);
		f2= parseFloat(Math.round(f*cm)) / cm;
		i2= Math.floor(f2);
		v2= Math.round(cm * (f2-i2));
		sv2= "0000000000"+v2;
		sv2d=sv2.length-nv;
		sv2f=sv2.length;
		sv2= sv2.substring(sv2d,sv2f);
		
		sf = inttostr(i2)+","+sv2;
	} else {
		i=strtoint(s);
		sf=inttostr(i);
	}
	src.value=sf;
}	






function select_value(select,value){
   for(i=0;i<select.options.length;i++){
      if(select.options[i].value==value){
         select.options[i].selected=true;
         return;
	  }
   }
}

function select_radio(radio,value){
   for(i=0;i>radio.length;i++){
      if(radio[i].value==value){
         radio[i].checked=true;
         return;
	  }
   }
}

function popup(f,nom, w, h) {
   var top=0;
   var left=0;
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
  myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=yes,menubar=yes,top='+top+',left='+left +',width=' + w + ',height=' + h );
  myWin.focus();
}

function tinypopup(f,nom, w, h) {
   var top=0;
   var left=0;
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
  myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=yes,menubar=no,top='+top+',left='+left +',width=' + w + ',height=' + h );
  myWin.focus();
}


function youpla(header,imgName)
{
	var head=header.style;
	
	if (head.display=="none")
	{
		head.display="";
	}
	else
	{
		head.display="none";
	}
}	

function youplaplus(header,imgName)
{
var head=document.getElementById(header).style;

if (head.display=="none")
{
head.display="block"; // ou block- inline
document.getElementById(imgName).src = "images/moins.gif";
}
else
{
head.display="none";
document.getElementById(imgName).src = "images/plus.gif"; 
}
} 

function youplamodifier(header,imgName)
{
var head=document.getElementById(header).style;

if (head.display=="none")
{
head.display="inline"; // ou block
document.getElementById(imgName).src = "images/modifier-moins.png";
}
else
{
head.display="none";
document.getElementById(imgName).src = "images/modifier-plus.png"; 
}
} 


// accordeon
var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.accordion=function(){
	function slider(n){this.n=n; this.a=[]}
	slider.prototype.init=function(t,e,m,o,k){
		var a=T$(t), i=s=0, n=a.childNodes, l=n.length; this.s=k||0; this.m=m||0;
		for(i;i<l;i++){
			var v=n[i];
			if(v.nodeType!=3){
				this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
				if(o==s){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1} s++
			}
		}
		this.l=s
	};
	slider.prototype.pr=function(f,d){
		for(var i=0;i<this.l;i++){
			var h=this.a[i].h, c=this.a[i].c, k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
			if((k!=1&&c.d==-1)&&(f==1||i==d)){
				c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
			}else if(k>0&&(f==-1||this.m||i==d)){
				c.d=-1; h.className=''; su(c,-1)
			}
		}
	};
	function su(c){c.t=setInterval(function(){sl(c)},20)};
	function sl(c){
		var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
		c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
		if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
	};
	return{slider:slider}
}();


var TINY={};function T$(i){return document.getElementById(i)}function T$$(e,p){return p.getElementsByTagName(e)}TINY.accordion=function(){function slider(n){this.n=n;this.a=[]}slider.prototype.init=function(t,e,m,o,k){var a=T$(t),i=s=0,n=a.childNodes,l=n.length;this.s=k||0;this.m=m||0;for(i;i<l;i++){var v=n[i];if(v.nodeType!=3){this.a[s]={};this.a[s].h=h=T$$(e,v)[0];this.a[s].c=c=T$$('div',v)[0];h.onclick=new Function(this.n+'.pr(0,'+s+')');if(o==s){h.className=this.s;c.style.height='auto';c.d=1}else{c.style.height=0;c.d=-1}s++}}this.l=s};slider.prototype.pr=function(f,d){for(var i=0;i<this.l;i++){var h=this.a[i].h,c=this.a[i].c,k=c.style.height;k=k=='auto'?1:parseInt(k);clearInterval(c.t);if((k!=1&&c.d==-1)&&(f==1||i==d)){c.style.height='';c.m=c.offsetHeight;c.style.height=k+'px';c.d=1;h.className=this.s;su(c,1)}else if(k>0&&(f==-1||this.m||i==d)){c.d=-1;h.className='';su(c,-1)}}};function su(c){c.t=setInterval(function(){sl(c)},20)};function sl(c){var h=c.offsetHeight,d=c.d==1?c.m-h:h;c.style.height=h+(Math.ceil(d/5)*c.d)+'px';c.style.opacity=h/c.m;c.style.filter='alpha(opacity='+h*100/c.m+')';if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'}clearInterval(c.t)}};return{slider:slider}}();
// accordeon

