function format(valeur,decimal,separateur) {
// formate un chiffre avec 'decimal' chiffres après la virgule et un separateur
	var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ; 
	var val=Math.floor(Math.abs(valeur));
	if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}
	var val_format=val+"";
	var nb=val_format.length;
	for (var i=1;i<4;i++) {
		if (val>=Math.pow(10,(3*i))) {
			val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
		}
	}
	if (decimal>0) {
		var decim=""; 
		for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
		deci=decim+deci.toString();
		val_format=val_format+"."+deci;
	}
	if (parseFloat(valeur)<0) {val_format="-"+val_format;}
	return val_format;
}

function afficher() {
	var val=document.forms[0].elements["chiffre"].value;
	var deci=document.forms[0].elements["decimal"].value;
	document.forms[0].elements["resultat"].value=format(val,deci,document.forms[0].elements["liste"].options[document.forms[0].elements["liste"].selectedIndex].value);
}


function CalculeTotaux()
{
MM_validateForm('nb_surfacenue','','NisNum','nb_angles','','NisNum','nb_moquette','','NisNum','nb_coexpo','','NisNum','nb_basic','','NisNum','nb_standard','','NisNum','nb_azur','','NisNum','nb_etoile','','NisNum');
total_surfacenue = document.commande.prix_surfacenue.value * document.commande.nb_surfacenue.value;
document.commande.total_surfacenue.value = total_surfacenue;
total_angles = document.commande.prix_angles.value * document.commande.nb_angles.value;
document.commande.total_angles.value = total_angles;
total_moquette = document.commande.prix_moquette.value * document.commande.nb_moquette.value;
document.commande.total_moquette.value = total_moquette;
total_coexpo = document.commande.prix_coexpo.value * document.commande.nb_coexpo.value;
document.commande.total_coexpo.value = total_coexpo;
total_inscription=document.commande.total_inscription.value*1;

total_basic = document.commande.prix_basic.value * document.commande.nb_basic.value;
document.commande.total_basic.value = total_basic;
//total_basic2 = document.commande.prix_basic2.value * document.commande.nb_basic2.value;
//document.commande.total_basic2.value = total_basic2;
//total_basic3 = document.commande.prix_basic3.value * document.commande.nb_basic3.value;
//document.commande.total_basic3.value = total_basic3;

total_standard = document.commande.prix_standard.value * document.commande.nb_standard.value;
document.commande.total_standard.value = total_standard;

total1_etoile = document.commande.prix_etoile.value * document.commande.nb_etoile.value;
document.commande.total1_etoile.value = total1_etoile;

if(document.commande.habillage2_etoile.checked)
        {total2_etoile=document.commande.prix_habillage2_etoile.value * 1;
		document.commande.total2_etoile.value = total2_etoile;}
		else
		{total2_etoile=0;
		document.commande.total2_etoile.value = total2_etoile;}
if(document.commande.habillage4_etoile.checked)
        {total3_etoile=document.commande.prix_habillage4_etoile.value * 1;
		document.commande.total3_etoile.value = total3_etoile;}
		else
		{total3_etoile=0;
		document.commande.total3_etoile.value = total3_etoile;}

total_azur = document.commande.prix_azur.value * document.commande.nb_azur.value;
document.commande.total_azur.value = total_azur;
//total_zenith = document.commande.prix_zenith.value * document.commande.nb_zenith.value;
//document.commande.total_zenith.value = total_zenith;

sous_total1 = total_surfacenue + total_angles + total_moquette + total_coexpo + total_inscription;
//sous_total2 = total_basic + total_basic2 + total_basic3 + total1_etoile + total2_etoile + total3_etoile + total_azur;
sous_total2 = total_basic + total_standard + total1_etoile + total2_etoile + total3_etoile + total_azur;

document.commande.sous_total1.value  = format(sous_total1,2,'');
document.commande.sous_total2.value  = format(sous_total2,2,'');
total_stand=sous_total1 + sous_total2;
document.commande.total_stand.value  = format(total_stand,2,'');

if(document.commande.catal_logoaffiche.checked)
        {total_logoaffiche=document.commande.prix_logoaffiche.value * 1;
		document.commande.total_logoaffiche.value = total_logoaffiche;}
		else
		{total_logoaffiche=0;
		document.commande.total_logoaffiche.value = total_logoaffiche;}
		
if(document.commande.catal_logoplanvisite.checked)
        {total_logoplanvisite=document.commande.prix_logoplanvisite.value * 1;
		document.commande.total_logoplanvisite.value = total_logoplanvisite;}
		else
		{total_logoplanvisite=0;
		document.commande.total_logoplanvisite.value = total_logoplanvisite;}
		
if(document.commande.catal_docplan1.checked)
        {total_docplan1=document.commande.prix_docplan1.value * 1;
		document.commande.total_docplan1.value = total_docplan1;}
		else
		{total_docplan1=0;
		document.commande.total_docplan1.value = total_docplan1;}
if(document.commande.catal_docplan2.checked)
        {total_docplan2=document.commande.prix_docplan2.value * 1;
		document.commande.total_docplan2.value = total_docplan2;}
		else
		{total_docplan2=0;
		document.commande.total_docplan2.value = total_docplan2;}
if(document.commande.catal_docplan3.checked)
        {total_docplan3=document.commande.prix_docplan3.value * 1;
		document.commande.total_docplan3.value = total_docplan3;}
		else
		{total_docplan3=0;
		document.commande.total_docplan3.value = total_docplan3;}
if(document.commande.catal_docplan4.checked)
        {total_docplan4=document.commande.prix_docplan4.value * 1;
		document.commande.total_docplan4.value = total_docplan4;}
		else
		{total_docplan4=0;
		document.commande.total_docplan4.value = total_docplan4;}
if(document.commande.catal_docplan5.checked)
        {total_docplan5=document.commande.prix_docplan5.value * 1;
		document.commande.total_docplan5.value = total_docplan5;}
		else
		{total_docplan5=0;
		document.commande.total_docplan5.value = total_docplan5;}
		
if(document.commande.catal_docpromo.checked)
        {total_docpromo=document.commande.prix_docpromo.value * 1;
		document.commande.total_docpromo.value = total_docpromo;}
		else
		{total_docpromo=0;
		document.commande.total_docpromo.value = total_docpromo;}
		
if(document.commande.catal_docsac.checked)
        {total_docsac=document.commande.prix_docsac.value * 1;
		document.commande.total_docsac.value = total_docsac;}
		else
		{total_docsac=0;
		document.commande.total_docsac.value = total_docsac;}
if(document.commande.catal_pubsac.checked)
        {total_pubsac=document.commande.prix_pubsac.value * 1;
		document.commande.total_pubsac.value = total_pubsac;}
		else
		{total_pubsac=0;
		document.commande.total_pubsac.value = total_pubsac;}

//total_pub = total_3couv_quadri + total_2couv_quadri + total_4couv_quadri+total_1page_quadri+total_1page_nb+total_demipage_quadri+total_demipage_nb+total_pub_internet+total_sac+total_insertion;
total_pub = total_logoaffiche + total_logoplanvisite + total_docplan1 + total_docplan2 + total_docplan3 + total_docplan4 + total_docplan5 + total_docpromo + total_docsac + total_pubsac;
document.commande.total_pub.value  = format(total_pub,2,'');
total_general=total_stand+total_pub;
//document.commande.total_general.value  = total_general;
document.commande.total_general.value  = format(total_general,2,'');

}