function rounde(nentier) 
{
return Math.floor(nentier);
}
function r2(n2) 
{
return Math.ceil(n2);
}
function round8(nhuit) 
{
return Math.round(nhuit * 100000000) / 100000000;
}
function round(arrondi) 
{
return Math.round(arrondi * 100) / 100;
}
function calcul() 
{
texte_tp = document.ordi.texte_tp.value;
text_tqc = document.ordi.text_tqc.value;
nombre_qte = document.ordi.nombre_qte.value;
surplus_frais = round(document.ordi.frais_transport.value);
prix = 0;
prix += round(document.ordi.prix_systeme.value);
prix += round(document.ordi.frais_transport.value);
prix += round(document.ordi.processeur_p.value);
prix += round(document.ordi.memoire_vive_p.value);
prix += round(document.ordi.disque_rigide_p.value);
prix += round(document.ordi.lecteur_cd_p.value);
prix += round(document.ordi.combo_g_dvd_p.value);
prix += round(document.ordi.graveur_p.value);
prix += round(document.ordi.carte_maitresse_p.value);
prix += round(document.ordi.carte_video_p.value);
prix += round(document.ordi.carte_son_p.value);
prix += round(document.ordi.lecteur_3etdemi_p.value);
prix += round(document.ordi.fax_modem_p.value);
prix += round(document.ordi.carte_reseau_p.value);
prix += round(document.ordi.moniteur_p.value);
prix += round(document.ordi.boitier_p.value);
prix += round(document.ordi.clavier_p.value);
prix += round(document.ordi.souris_p.value);
prix += round(document.ordi.haut_parleur_p.value);
prix += round(document.ordi.sys_expl_p.value);
prix += round(document.ordi.imprimante_p.value);
prix += round(document.ordi.numeriseur_p.value);
prix += round(document.ordi.autre1a_p.value);
prix += round(document.ordi.autre1b_p.value);
prix += round(document.ordi.autre1c_p.value);

// Calcul de l'escompte

chiffre_escompte=document.ordi.chiffre_escompte.value;
if(chiffre_escompte==0)
{
valeurescompte=0;
document.ordi.escompte.value ="";
document.ordi.texte_escompte.value="";
document.ordi.pour_cent_esc.value="";
}
else
{
valeurescompte=round8(prix/document.ordi.market.value*nombre_qte*chiffre_escompte/100);
document.ordi.escompte.value=round(valeurescompte);
document.ordi.texte_escompte.value="Esc. de";
document.ordi.pour_cent_esc.value="%";
}

if (nombre_qte>1)
transport_qte=(nombre_qte-1)*(0+surplus_frais);
else
transport_qte=0;

csoustotal = round8(round8(prix/document.ordi.market.value*nombre_qte)-valeurescompte-transport_qte);
cttps = round8(csoustotal*texte_tp/100);
cttvq = round8((csoustotal+cttps)*text_tqc/100);
cgrandtotal = csoustotal+cttps+cttvq;
tsoustotal = round(csoustotal);
tcttps = round(cttps);
tcttvq = round(cttvq);
tcgrandtotal = round(cgrandtotal);
t2soustotal = round(csoustotal);
t2cttps = r2(cttps);
t2cttvq = r2(cttvq);
t2cgrandtotal = round(cgrandtotal);
if ((round(round(csoustotal)-rounde(csoustotal))==.1)|(round(round(csoustotal)-rounde(csoustotal))==.2)|(round(round(csoustotal)-rounde(csoustotal))==.3)|(round(round(csoustotal)-rounde(csoustotal))==.4)|(round(round(csoustotal)-rounde(csoustotal))==.5)|(round(round(csoustotal)-rounde(csoustotal))==.6)|(round(round(csoustotal)-rounde(csoustotal))==.7)|(round(round(csoustotal)-rounde(csoustotal))==.8)|(round(round(csoustotal)-rounde(csoustotal))==.9))
document.ordi.sous_totala.value = tsoustotal+"0";
else if(round(csoustotal)==rounde(csoustotal))
document.ordi.sous_totala.value = t2soustotal+".00";
else
document.ordi.sous_totala.value = round(csoustotal);
if ((round(round(cttps)-rounde(cttps))==.1)|(round(round(cttps)-rounde(cttps))==.2)|(round(round(cttps)-rounde(cttps))==.3)|(round(round(cttps)-rounde(cttps))==.4)|(round(round(cttps)-rounde(cttps))==.5)|(round(round(cttps)-rounde(cttps))==.6)|(round(round(cttps)-rounde(cttps))==.7)|(round(round(cttps)-rounde(cttps))==.8)|(round(round(cttps)-rounde(cttps))==.9))
document.ordi.tax_tps.value = tcttps+"0";
else if(round(cttps)==r2(cttps))
document.ordi.tax_tps.value = t2cttps+".00";
else
document.ordi.tax_tps.value = round(cttps);
if ((round(round(cttvq)-rounde(cttvq))==.1)|(round(round(cttvq)-rounde(cttvq))==.2)|(round(round(cttvq)-rounde(cttvq))==.3)|(round(round(cttvq)-rounde(cttvq))==.4)|(round(round(cttvq)-rounde(cttvq))==.5)|(round(round(cttvq)-rounde(cttvq))==.6)|(round(round(cttvq)-rounde(cttvq))==.7)|(round(round(cttvq)-rounde(cttvq))==.8)|(round(round(cttvq)-rounde(cttvq))==.9))
document.ordi.tax_tvq.value = tcttvq+"0";
else if(round(cttvq)==r2(cttvq))
document.ordi.tax_tvq.value = t2cttvq+".00";
else
document.ordi.tax_tvq.value = round(cttvq);
if ((round(round(cgrandtotal)-rounde(cgrandtotal))==.1)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.2)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.3)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.4)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.5)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.6)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.7)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.8)|(round(round(cgrandtotal)-rounde(cgrandtotal))==.9))
document.ordi.grand_total.value = tcgrandtotal+"0";
else if(round(cgrandtotal)==r2(cgrandtotal))
document.ordi.grand_total.value = t2cgrandtotal+".00";
else
document.ordi.grand_total.value = round(cgrandtotal);

// Pourcentage pour 12 versements égaux //

if(cgrandtotal<150)
document.ordi.mvers1.value ="";
if((cgrandtotal>149.999)&&(cgrandtotal<400))
document.ordi.mvers1.value = round((round(cgrandtotal)+round(cgrandtotal*10.25/100))/12);
if((cgrandtotal>399.999)&&(cgrandtotal<600))
document.ordi.mvers1.value = round((round(cgrandtotal)+round(cgrandtotal*7.80/100))/12);
if((cgrandtotal>599.999)&&(cgrandtotal<1000))
document.ordi.mvers1.value = round((round(cgrandtotal)+round(cgrandtotal*6.95/100))/12);
if((cgrandtotal>999.999)&&(cgrandtotal<1500))
document.ordi.mvers1.value = round((round(cgrandtotal)+round(cgrandtotal*6.30/100))/12);
if((cgrandtotal>1499.999)&&(cgrandtotal<100000))
document.ordi.mvers1.value = round((round(cgrandtotal)+round(cgrandtotal*5.95/100))/12);

// Pourcentage pour 24 versements égaux //

if(cgrandtotal<150)
document.ordi.mvers2.value ="";
if((cgrandtotal>149.999)&&(cgrandtotal<400))
document.ordi.mvers2.value = round((round(cgrandtotal)+round(cgrandtotal*15.40/100))/24);
if((cgrandtotal>399.999)&&(cgrandtotal<600))
document.ordi.mvers2.value = round((round(cgrandtotal)+round(cgrandtotal*12.60/100))/24);
if((cgrandtotal>599.999)&&(cgrandtotal<1000))
document.ordi.mvers2.value = round((round(cgrandtotal)+round(cgrandtotal*11.70/100))/24);
if((cgrandtotal>999.999)&&(cgrandtotal<1500))
document.ordi.mvers2.value = round((round(cgrandtotal)+round(cgrandtotal*10.95/100))/24);
if((cgrandtotal>1499.999)&&(cgrandtotal<100000))
document.ordi.mvers2.value = round((round(cgrandtotal)+round(cgrandtotal*10.55/100))/24);

// Pourcentage pour 36 versements égaux //

if(cgrandtotal<150)
document.ordi.mvers3.value ="";
if((cgrandtotal>149.999)&&(cgrandtotal<400))
document.ordi.mvers3.value = round((round(cgrandtotal)+round(cgrandtotal*19.55/100))/36);
if((cgrandtotal>399.999)&&(cgrandtotal<600))
document.ordi.mvers3.value = round((round(cgrandtotal)+round(cgrandtotal*16.45/100))/36);
if((cgrandtotal>599.999)&&(cgrandtotal<1000))
document.ordi.mvers3.value = round((round(cgrandtotal)+round(cgrandtotal*15.45/100))/36);
if((cgrandtotal>999.999)&&(cgrandtotal<1500))
document.ordi.mvers3.value = round((round(cgrandtotal)+round(cgrandtotal*14.65/100))/36);
if((cgrandtotal>1499.999)&&(cgrandtotal<100000))
document.ordi.mvers3.value = round((round(cgrandtotal)+round(cgrandtotal*14.20/100))/36);

// Pourcentage pour 6 mois sans versements/12 égaux //

if(cgrandtotal<150)
document.ordi.mvers4.value ="";
if((cgrandtotal>149.999)&&(cgrandtotal<400))
document.ordi.mvers4.value = round((round(cgrandtotal)+round(cgrandtotal*17.25/100))/12);
if((cgrandtotal>399.999)&&(cgrandtotal<600))
document.ordi.mvers4.value = round((round(cgrandtotal)+round(cgrandtotal*12.20/100))/12);
if((cgrandtotal>599.999)&&(cgrandtotal<1000))
document.ordi.mvers4.value = round((round(cgrandtotal)+round(cgrandtotal*11.20/100))/12);
if((cgrandtotal>999.999)&&(cgrandtotal<1500))
document.ordi.mvers4.value = round((round(cgrandtotal)+round(cgrandtotal*10.35/100))/12);
if((cgrandtotal>1499.999)&&(cgrandtotal<100000))
document.ordi.mvers4.value = round((round(cgrandtotal)+round(cgrandtotal*9.95/100))/12);

// Pourcentage pour 9 mois sans versements/12 égaux //

if(cgrandtotal<150)
document.ordi.mvers5.value ="";
if((cgrandtotal>149.999)&&(cgrandtotal<400))
document.ordi.mvers5.value = round((round(cgrandtotal)+round(cgrandtotal*20.05/100))/12);
if((cgrandtotal>399.999)&&(cgrandtotal<600))
document.ordi.mvers5.value = round((round(cgrandtotal)+round(cgrandtotal*14.50/100))/12);
if((cgrandtotal>599.999)&&(cgrandtotal<1000))
document.ordi.mvers5.value = round((round(cgrandtotal)+round(cgrandtotal*13.40/100))/12);
if((cgrandtotal>999.999)&&(cgrandtotal<1500))
document.ordi.mvers5.value = round((round(cgrandtotal)+round(cgrandtotal*11.25/100))/12);
if((cgrandtotal>1499.999)&&(cgrandtotal<100000))
document.ordi.mvers5.value = round((round(cgrandtotal)+round(cgrandtotal*12.05/100))/12);

if(document.ordi.sous_totala.value=="NaN")
alert('Attention, mettre un chiffre sur ce que vous venez de mettre !');
}
