this.name='shEAMainWnd'; this.focus(); function recalculateAlcoholPercentage() { var alcozs = parseFloat(gE('alcozs').value); // consumed ounces var alcpct = parseFloat(gE('alcpct').value); // alcohol percent var bodywt = parseFloat(gE('bodywt').value); // body weight var tsca = parseFloat(gE('tsca').value); // time since starting to consume ANY alcohol if (isNaN(alcozs) || isNaN(alcpct) || isNaN(bodywt) || isNaN(tsca)) { result = "?"; message = "Date incorecte"; } else { var result = ((alcozs * 0.03381402) * alcpct * 0.075 / (bodywt * 2.2046244210837774)) - (tsca * 0.015); result = result.toFixed(2); message = ''; if (result < 0) { result = '~ 0.00'; message = "Alcoolemia este neglijabila."; } else { if (result == "NaN") { result = "?"; message = "Date incorecte"; } else { if (result > 0.08) message = "Alcoolemia depaseste limita de 0.08 % peste care a conduce constituie infractiune"; if (result < 0.08) message = "Alcoolemia nu depaseste limita de 0.08 % peste care a conduce devine infractiune"; } } } gE('alcoholLev').innerHTML = result; gE('alcoholMsg').innerHTML = message; } var newCillinders = { 6 : { 20: { 'min' : '0', 'max' : '1600', 'price' : '0.15' } , 21: { 'min' : '1601', 'max' : '2000', 'price' : '0.35' } , 22: { 'min' : '2001', 'max' : '2500', 'price' : '0.5' } , 23: { 'min' : '2501', 'max' : '3000', 'price' : '0.7' } , 24: { 'min' : '3000', 'max' : '0', 'price' : '1' } } , 5 : { 15: { 'min' : '0', 'max' : '1600', 'price' : '0.5' } , 16: { 'min' : '1601', 'max' : '2000', 'price' : '0.6' } , 17: { 'min' : '2001', 'max' : '2500', 'price' : '0.9' } , 18: { 'min' : '2501', 'max' : '3000', 'price' : '1.1' } , 19: { 'min' : '3000', 'max' : '0', 'price' : '1.3' } } , 4 : { 10: { 'min' : '0', 'max' : '1600', 'price' : '1.3' } , 11: { 'min' : '1601', 'max' : '2000', 'price' : '1.4' } , 12: { 'min' : '2001', 'max' : '2500', 'price' : '1.5' } , 13: { 'min' : '2501', 'max' : '3000', 'price' : '1.6' } , 14: { 'min' : '3000', 'max' : '0', 'price' : '1.7' } } , 3 : { 5: { 'min' : '0', 'max' : '1600', 'price' : '1.8' } , 6: { 'min' : '1601', 'max' : '2000', 'price' : '1.8' } , 7: { 'min' : '2001', 'max' : '2500', 'price' : '1.8' } , 8: { 'min' : '2501', 'max' : '3000', 'price' : '1.8' } , 9: { 'min' : '3000', 'max' : '0', 'price' : '1.8' } } , 2 : { 2: { 'min' : '0', 'max' : '1600', 'price' : '2' } , 3: { 'min' : '1601', 'max' : '2000', 'price' : '2' } , 4: { 'min' : '2000', 'max' : '0', 'price' : '2' } } } var newAges = { '1' : { 'min' : '0', 'max' : '6', 'coef' : '0.9', 'reduction' : '15' } , '2' : { 'min' : '6', 'max' : '24', 'coef' : '1.8', 'reduction' : '25' } , '3' : { 'min' : '24', 'max' : '48', 'coef' : '2.3', 'reduction' : '32' } , '4' : { 'min' : '48', 'max' : '72', 'coef' : '2.5', 'reduction' : '43' } , '5' : { 'min' : '72', 'max' : '0', 'coef' : '2.7', 'reduction' : '47' } } function isInt (str) { var i = parseInt (str); if (isNaN (i)) return false; i = i . toString (); if (i != str) return false; return true; } function num_format (x) { var str = new String (x); var newstr = ""; var nr_caractere = str.length; if (nr_caractere <= 3) return str; for (var i = 0; i < nr_caractere; i++) { if (! ((nr_caractere - i) % 3) && i > 0) newstr = newstr + "."; newstr = newstr + str.charAt(i); } return (newstr); } function forceNum (number) { return number.length ? number : 0; } function recalculateTax() { form = document.forms['taxesForm']; newPolId = form.newPollutionId; newCmcube = form.newCmc; newCarAge = form.newAge; newCmcubePrice = gE('newCmcPrice'); newCarAgeCoef = gE('newCoef'); newCarAgeReduction = gE('newReduction'); newTax = document.getElementById('newSpecialTax'); if ( newCmcube.value.length && !isInt (newCmcube.value) ) { newCmcube.value = newCmcube.value.substring (0, newCmcube.value.length - 1); return; } newPolCillinders = newCillinders[newPolId.value]; theValue = forceNum (newCmcube.value); for (i in newPolCillinders) { if ( (parseInt (theValue) >= parseInt (newPolCillinders[i]['min']) && parseInt (theValue) <= parseInt (newPolCillinders[i]['max'])) || (!parseInt (newPolCillinders[i]['max']) && parseInt (theValue) > parseInt (newPolCillinders[i]['min'])) ) { price = newPolCillinders[i]['price']; break; } } try { newCmcubePrice.innerHTML = price; } catch(e) { newCmcubePrice.innerHTML = ''; } newCarAgeCoef.innerHTML = newAges[newCarAge.value]['coef']; newCarAgeReduction.innerHTML = newAges[newCarAge.value]['reduction']; newTax.innerHTML = (parseFloat (forceNum (newCmcube.value)) * parseFloat (forceNum (price)) * parseFloat (forceNum (newAges[newCarAge.value]['coef'])) * (100 - parseFloat (forceNum (newAges[newCarAge.value]['reduction']))) / 100).toFixed(2); }