

function calcul_nb_part(montant,valeur_part,chmp,total_hidden,total){
    montant=montant.replace(",",".");
	montant=montant.replace(" ","");
	valeur_part=valeur_part.replace(",",".");
	valeur_part=valeur_part.replace(" ","");
	calcul=Math.round(montant/valeur_part)
	if(!isNaN(calcul)){
		chmp.value=calcul;
		total_hidden.value=calcul*valeur_part
		document.getElementById(total).innerHTML=separeMilliers (calcul*valeur_part)+"\u20AC";
	}else{
		alert("Erreur : veuillez saisir uniquement un nombre")
	}
}
function simulateur(type,montant){
	montant=montant.replace(/[\W]/gi,"");
	if(type!="resultat_isf"){
		if(montant>25000)montant=25000
		calcul=Math.ceil(montant/0.925*4)
	}else{
		if(montant>50000)montant=50000
		calcul=Math.ceil(montant/(0.925*0.75))
	}
	if(!isNaN(calcul)){
			document.getElementById(type).innerHTML='<br /><br /><h3>R&eacute;sultats : </h3><table class="clients_partenaires"><tr><th>SOUSCRIPTION OPTIMALE</th><th>INVESTISSEMENT NET</th><th>% RENTABILIT&Eacute; ANNUELLE *</th><th>VALEUR ACQUISE</th></tr><tr class="trcolor3"><td>'+separeMilliers(calcul)+'\u20AC</td><td>'+separeMilliers(calcul-montant)+'\u20AC</td><td>5%<br/>10%<br/>15%</td><td>'+separeMilliers(Math.ceil(calcul*Math.pow(1.05,5)))+'\u20AC<br />'+separeMilliers(Math.ceil(calcul*Math.pow(1.10,5)))+'\u20AC<br />'+separeMilliers(Math.ceil(calcul*Math.pow(1.15,5)))+'\u20AC<br /></td></tr></table>';
		}else{
			alert("Erreur : veuillez saisir uniquement un nombre")
		}
}

function calcul_de(montant,pourcentage,de){

    montant=montant.replace(",",".");
	montant=montant.replace(" ","");
	pourcentage=pourcentage.replace(",",".");
	pourcentage=pourcentage.replace(" ","");
	if(pourcentage<=5){
		calcul=montant*pourcentage/100*1.196
		calcul=Math.round(calcul*100)/100
		if(!isNaN(calcul)){
			de.value=calcul;
		}else{
			alert("Erreur : veuillez saisir uniquement un nombre")
		}
	}else{
		alert("Erreur : veuillez saisir un pourcentage inf\351rieur ou \351gal \340 5%")
	}
}

function no_special_char(chaine, permalang) {
      temp = chaine.toLowerCase().replace(/[\340\341\342\343\344\345]/gi,"a");
      temp = temp.replace(/[\350\351\352\353]/gi,"e");
      temp = temp.replace(/[\354\355\356\357]/gi,"i");
      temp = temp.replace(/[\360\362\363\364\365\366\370]/gi,"o");
	  temp = temp.replace(/[\371\372\373\374]/gi,"u");
      temp = temp.replace(/[\361]/gi,"n");
	  temp = temp.replace(/[\346]/gi,"ae");
	  temp = temp.replace(/[\347]/gi,"c");
	  temp = temp.replace(/[\W]/gi,"-");
	  for(a=0;a<10;a++){
	 	if(temp.substring((temp.length-1),temp.length)=="-")temp=temp.substring(0,(temp.length-1))
		  reg = new RegExp("--", "ig");
			temp = temp.replace(reg, "-");
	  }
	  document.forms['f_edit'].elements[permalang].value=temp;
	  document.forms['f_edit'].elements['permalink'].value=temp;
  }
  

  function aff_conseillers(id)
{
	elementHTML = document.getElementById('conseiller_infos');
	var url = "/conseiller/show.html";
	o_options = new Object();
	o_options = {method: 'post',
	 postBody:'id='+id ,
	 onLoading: function ()
            {document.getElementById("indicator").style.display="block";
            document.getElementById("conseiller_infos").style.display="none";   
            },
     onComplete: function ()
            {document.getElementById("indicator").style.display="none"
            document.getElementById("conseiller_infos").style.display="block";
            }
	};
	var laRequete = new Ajax.Updater(elementHTML,url,o_options);
}

function separeMilliers (sNombre) {
	 separateurMilliers=" ";
	 var sRetour = "";
	 while (sNombre.length % 3 != 0) {
	 sNombre = "0"+sNombre;
	 }
	 for (i = 0; i < sNombre.length; i += 3) {
	 if (i == sNombre.length-1) separateurMilliers = '';
	 sRetour += sNombre.substr(i, 3)+separateurMilliers;
	 }
	 while (sRetour.substr(0, 1) == "0") {
	 sRetour = sRetour.substr(1);
	 }
	 return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
} 

function changebtn_simulateur(type){
	if(type=="ISF"){
		document.getElementById('ISF').style.display='block';
		document.getElementById('IRPP').style.display='none';	
		document.getElementsByClassName('btn_simulateur')[0].className='btn_simulateur actif2'
		document.getElementsByClassName('btn_simulateur')[1].className='btn_simulateur'
	}else{
		document.getElementById('IRPP').style.display='block';
		document.getElementById('ISF').style.display='none';	
		document.getElementsByClassName('btn_simulateur')[1].className='btn_simulateur actif2'
		document.getElementsByClassName('btn_simulateur')[0].className='btn_simulateur'
	}
	return false; 
}
