function calcul(){
	var pret = document.hypotheque.pret.value;
	var interet = document.hypotheque.interet.options[document.hypotheque.interet.selectedIndex].value;
	var amortissement = parseInt(document.hypotheque.amortissement.options[document.hypotheque.amortissement.selectedIndex].value);
	var terme  = parseInt(document.hypotheque.terme.value);
	var nbPaiement = ""+document.hypotheque.periode.options[document.hypotheque.periode.selectedIndex].value;
	
	var temps = amortissement*parseInt(nbPaiement);
	var periodesterme = terme * parseInt(nbPaiement);
	
	interet = parseFloat(interet);

    if(interet < 0.3){
        interet = interet * 100;   
	}
	
    document.hypotheque.interet.options[document.hypotheque.interet.selectedIndex].value = interet;

    interet = interet / 100;   

	var montant = parseFloat(pret);
	if(montant != pret){
		document.hypotheque.pret.value = "Erreur";
		alert("La valeur du montant du prêt est incorrect.");
		return;
	}

	if(amortissement < terme){
		alert("L'amortissement ("+amortissement+") doit être plus grand que le terme ("+terme+").");
		document.hypotheque.paie.value = 0; 
		return;
	}
	
	var int = Math.pow((1+interet/2),(2/parseInt(nbPaiement))) - 1;  
	var intbase = Math.pow((1+interet/2),(2/12)) - 1;  
	
	if(int == 0){
		var paieb  = montant/ (amortissement * 12);
	}else{
		var paieb  = (montant * intbase) / ( 1 - ( 1/ Math.pow((1+intbase),(amortissement*12))));
	}

	var paie = paieb;
	if((nbPaiement == '52' || nbPaiement == '26'|| nbPaiement == '2'|| nbPaiement == '1' ) && int != 0 ){
		var paie = (montant * int) / ( 1 - ( 1/ Math.pow((1+int),temps)));
	}
	paie = Math.ceil(paie*100)/100;
	montant = Math.ceil(montant*100)/100;
	document.hypotheque.pret.value = montant;
	document.getElementById('resultat').innerHTML = paie;
}

function valeur(chemin){
    remplacement = chemin.value.replace(" ", "");
	remplacement = remplacement.replace(",", ".");
	chemin.value = remplacement;
}
