var factors=[2.7397260273973E-006,2.7397260273973E-005,0.00027397260273973,0.0027378507871321,0.0027379070069885,0.0027379092633269,0.0027397260273973,0.032853922534821,0.071428571428571,0.14285714285714,1,24,1440,86400,86400000,86400000000,86400000000000];
var gbrt=["millennium","century","decade","Julian year","Gregorian year","tropical year","year","month","fortnight","week","day","hour","minute","second","millisecond","microsecond","nanosecond"];
function fix(v){
if (!isFinite(v)) return "";
if (v==0) return "0";
st=""+v;
epos=st.indexOf('E');
if (epos==-1) epos=st.indexOf('e');
sdigi=Math.log(Math.abs(v)) / Math.LN10;
sdigif=Math.floor(sdigi);
if (epos==-1){
adjust=Math.pow(10, sdigif-12);
faqs=Math.round(v/adjust);
norst=""+faqs;
if (sdigif<12){
adjust2=Math.pow(10, 12-sdigif);
return (faqs / adjust2);}
else return (faqs*adjust);}
else {
zo=v*Math.pow(10, 12-sdigif);
szo=String(Math.round(zo));
inse=-1;
if (szo.charAt(0)=='-') inse=2;
else inse=1;
rest=szo.substring(inse,szo.length);
i=rest.length-1;
while (i>=0 && rest.charAt(i)=='0')
i--;
rest=rest.substring(0,i+1);
rou=szo.substring(0,inse);
if (rest.length>0) rou += "."+rest;
if (sdigif<0) sa=rou+"E";
else sa=rou+"E+";
snow=sa+sdigif;
vanow=Math.abs(parseFloat(snow));
faqsvab=Math.abs(v);
if (sdigif>=0){
if (vanow>5*faqsvab)
snow=sa+String(sdigif-1);
else if (vanow<faqsvab/5)
snow=sa+String(sdigif+1);}
else if (sdigif>=0){
if (vanow>5*faqsvab)
snow=sa+String(sdigif+1);
else if (vanow<faqsvab/5)
snow=sa+String(sdigif-1);}
vanow=parseFloat(snow);
if (vanow>1.1*v || vanow<0.9*v) return v;
else return snow;}}

function convert()
{
isNS4=(document.layers) ? true : false;
isIE4=(document.all && !document.getElementById) ? true : false;
isIE5=(document.all && document.getElementById) ? true : false;
isNS6=(!document.all && document.getElementById) ? true : false;
myform=document.forms['cform'];
w1=myform.D1.options[myform.D1.selectedIndex].value;
w2=myform.D2.options[myform.D2.selectedIndex].value;
faqsorg=factors[w2]/factors[w1];
resfaqs=myform.T1.value*faqsorg;
if (isIE5 || isNS6){
elm=document.getElementById("N1");
elm2=document.getElementById("N2");
elm.innerHTML=gbrt[w1];
elm2.innerHTML=gbrt[w2];}
if (isNaN(parseFloat(resfaqs)))
myform.T2.value="";
else
{myform.T2.value=fix(parseFloat(resfaqs))+" ";}}
