// Les couts pour chaque modele a l'unite les modeles dans l'ordre : 2240,3240,5000,8640,8800,imprimante			var cout_modele = new Array(1299.00, 2295.00, 2975.00, 2920.00, 3600.00, 350.00);			// calcul les champs de la colonne 'Using DAP Mobile Computing'			function dap_precalc(f,s)			{				// modifie 24 mars 2005				//var valeur = valider_textbox(s); 				//eval("f."+s.name+".value=valeur");				// modifie 24 mars 2005 -  Ces 2 lignes remplacent les 2 lignes en comment plus haut				valider_textbox(f,s);				eval("var valeur = f."+s.name+".value");				// Calculs sur certains champs				if (s.name == "tech_cout") {					valeur = formatUSD(valeur);				} else if (s.name == "tech_transac") {					valeur *=.5;				} else if (s.name == "data_total" || s.name == "data_heure" || s.name == "data_salaire") {					valeur = 0;				} else if (s.name == "papier_cout") {					valeur = formatUSD((valeur - (valeur * .6)));				}				// Met a jour le champs calcule du champs modifie				eval("f.dap_"+s.name+".value=valeur");				// Met a jour d'autres champs du formulaires				f.papier_total.value = f.tech_total.value * f.tech_appel.value;				f.dap_papier_total.value = f.papier_total.value;			}			// Calcul les couts des unites selon la quantite			function dap_unitecalc(f,s)			{				// modifie 24 mars 2005				//var qua = valider_textbox(s); 				//eval("f."+s.name+".value=qua");				// modifie 24 mars 2005 -  Ces 2 lignes remplacent les 2 lignes en comment plus haut				valider_textbox(f,s);				eval("var qua = f."+s.name+".value");				var cout;				if (s.name == "modele_2240")					cout = cout_modele[0];				else if (s.name == "modele_3240")					cout = cout_modele[1];				else if (s.name == "modele_5000")					cout = cout_modele[2];				else if (s.name == "modele_8640")					cout = cout_modele[3];				else if (s.name == "modele_8800")					cout = cout_modele[4];				else if (s.name == "modele_imprimante")					cout = cout_modele[5];				eval("f.dap_"+s.name+".value=formatUSD(qua*cout)");			}			// Sert a valider si ce qui est entree dans une textbox est valide (numerique seulement)			function valider_textbox(f,s)			{				eval("var valeur = f."+s.name+".value");				if (valeur==".") {					valeur = "0.";					eval("f."+s.name+".value=valeur");				} else if (isNaN(valeur)) {					valeur = valeur.substr(0,valeur.length-1);					if (!valeur) valeur = 0;					eval("f."+s.name+".value=valeur");				}			}			// Modifie 24 mars 2005 - Ancienne fonction/* 			function valider_textbox(s) *//* 			{ *//* 				eval("var valeur = document.form1."+s.name+".value"); *//* 				 *//* 				if (valeur==".") *//* 					valeur = "0."; *//*  *//* 				// si valeur invalide, on met un contenu valide *//* 				if (isNaN(valeur)) { *//* 					valeur = valeur.substr(0,valeur.length-1); *//* 					if (!valeur) valeur = 0; *//* 				} *//*  *//* 				return valeur; *//* 			} */			// Fonction qui calcul le ROI (appelle au click du bouton)			function calc_roi(f)			{				f.econo_techm.value = (f.tech_transac.value - f.dap_tech_transac.value) * f.tech_appel.value;				f.econo_par_techj.value = formatUSD(((f.econo_techm.value / 60) * f.tech_cout.value));				f.econo_techj.value = formatUSD((pfwc(f.econo_par_techj.value) * f.tech_total.value));				f.econo_techa.value = formatUSD((pfwc(f.econo_techj.value) * f.tech_jour.value));				f.cout_data.value = formatUSD((f.data_total.value * f.data_heure.value * f.data_salaire.value));				f.econo_dataj.value = formatUSD((f.cout_data.value - (f.dap_data_total.value * f.dap_data_heure.value)));				f.econo_dataa.value = formatUSD((f.econo_dataj.value * f.tech_jour.value));				f.cout_papier.value = formatUSD((f.papier_total.value * f.papier_cout.value));				f.cout_imprimante.value = formatUSD((f.dap_papier_cout.value * f.papier_total.value));				f.econo_papierj.value = formatUSD((f.cout_papier.value - f.cout_imprimante.value));				f.econo_papiera.value = formatUSD((f.econo_papierj.value * f.tech_jour.value));				f.econo_net_annee.value = formatUSD((pfwc(f.econo_techa.value) + pfwc(f.econo_dataa.value) + pfwc(f.econo_papiera.value)));				f.cout_initial.value = formatUSD(calc_cout_initial(f));				// ancienne formule, change le 14 mars 2005				//var econo_net_value = ""+format((((pfwc(f.econo_net_annee.value) - pfwc(f.cout_initial.value)) / pfwc(f.cout_initial.value)) * 100), 0);				//econo_net_value = econo_net_value.substr(0, econo_net_value.length-1);				//f.roi_annee1.value = econo_net_value;				// ancienne formule, change le 14 mars 2005				//f.periode_remboursement.value = format((pfwc(f.cout_initial.value) / (pfwc(f.econo_net_annee.value) / f.tech_jour.value) / 12), 2);								f.periode_remboursement.value = format((pfwc(f.cout_initial.value) / (pfwc(f.econo_net_annee.value) / 12)), 2);				return;			}						function calc_cout_initial(f)			{				var arrinput = f.getElementsByTagName("INPUT");				var reg = new RegExp("dap_modele_", "i");				var total=0;				for (var i=0; i<arrinput.length; i++) {					if (arrinput[i].name.match(reg)) {						eval("total+=pfwc(f."+arrinput[i].name+".value);");					}				}				if(isNaN(total))					total=0;				return total;			}			// http://javascript.internet.com/forms/currency-format.html (12000 => 12,000.00)			function formatUSD(num) {								if(isNaN(num))					num = "0";									num = Math.floor(num*100+0.50000000001);				cents = num%100;				num = Math.floor(num/100).toString();				if(cents<10)					cents = "0" + cents;								for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)					num = num.substring(0,num.length-(4*i+3))+','+				num.substring(num.length-(4*i+3));				return (num + '.' + cents);			}			function format(expr,decplaces) 			{				var str=""+Math.round(eval(expr)*Math.pow(10,decplaces)); 				while(str.length<=decplaces)					str="0"+str;				var decpoint=str.length-decplaces;				return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);			}			// Parse les float qui contiennent des comma (,)			function pfwc(num)			{				var ret = "";				for (var i=0; i<num.length; i++) {					var c = ""+num.substr(i,1);					if (c!=",")						ret += c				}								return parseFloat(ret);			}