
<!--

function log(i){
return Math.log(i) * Math.LOG10E;
}

function ln(i){
return Math.log(i);
}

function sq(i){
return i * i;
}

function sqr(i){
return Math.sqrt(i);
}


function power(x,y){
return Math.pow(x,y);
}

function eTo(x){
return Math.exp(x);
}


codes = new Array;
codeparts = new Array;
var rfactor = 100000;
var tovalue;

function showToValue(){
with (document.convert_form){
if (to_param.value.indexOf('e') > 0 || tovalue * rfactor < 1) {
to_param.value = tovalue;
return;
}
to_param.value = Math.round(tovalue * rfactor) / rfactor;
to_param.value = setCommas(to_param.value);
}}


function setDecPts(){
with (document.convert_form){
dp = decpts.options[decpts.selectedIndex].text;
rfactor = Math.pow(10, dp);
unitConvert();
}}


function setCommas(x){
var cc = 0;
var dp;
var temp = '';
if (x.indexOf('e') > 0) return x;
dp = x.indexOf('.');
if (dp >= 0 && dp <= 3) return x;
if (dp > 0) {
temp = x.substring(dp, x.length);
x = x.substring (0 , dp);
}
for (i = x.length  ; i >= 0; i--){
if (cc == 3){
cc = 0;
if ((x.charAt(i-1) >= '0') && (x.charAt(i-1) <= '9')){temp = ',' + x.substring(i, i + 1) + temp;}
else {
temp = x.substring(i, i + 1) + temp;
}}
else {
temp = x.substring(i, i + 1) + temp;
}
cc++;
}
return temp;
}

function unitLoad(){
with (document.convert_form){

for (i = 0; i < from_unit.options.length; i++) {codes[i] = from_unit.options[i].value;}

codeparts = from_unit.options[from_unit.selectedIndex].value.split('|');
findunit = codeparts[0];
findtype = codeparts[1];
to_unit.options.length = 0;

for (i = 0; i < codes.length; i++){
codeparts = codes[i].split('|');
if (codeparts[1]  == findtype) {
	to_unit.options[to_unit.options.length] = new Option(codeparts[0],codes[i]);
	if (codeparts[0] == findunit) {to_unit.options[to_unit.options.length - 1].selected = true;}
	}
}
to_unit.options[to_unit.options.length] = new Option("___________________");
to_param.value = "";
}}

function unitConvert(){
with (document.convert_form){

if (from_param.value > ''){
unitcode = from_unit.options[from_unit.selectedIndex].value;
codeparts = unitcode.split('|');
frommult = parseFloat(codeparts[2]);
fromadd = parseFloat(codeparts[3]);

unitcode = to_unit.options[to_unit.selectedIndex].value;
codeparts = unitcode.split('|');
tomult = parseFloat(codeparts[2]);
toadd = parseFloat(codeparts[3]);

fromvalue = parseFloat(from_param.value);
tovalue = ((fromvalue * frommult + fromadd) - toadd) / tomult;
showToValue();
}}}

//-->
