// JavaScript Document

if (document.images) {
}

/* Function that swaps images. */

function di20(id, newSrc) {
    var theImage = FWFindImage(document, id, 0);
    if (theImage) {
        theImage.src = newSrc;
    }
}

/* Functions that track and set toggle group button states. */

function FWFindImage(doc, name, j) {
    var theImage = false;
    if (doc.images) {
        theImage = doc.images[name];
    }
    if (theImage) {
        return theImage;
    }
    if (doc.layers) {
        for (j = 0; j < doc.layers.length; j++) {
            theImage = FWFindImage(doc.layers[j].document, name, 0);
            if (theImage) {
                return (theImage);
            }
        }
    }
    return (false);
}



function marume(n)
{
             if (n==0) return 0;
		else {
		h=Math.log(Math.abs(n))*Math.LOG10E;
		i=3-Math.floor(h);
		j=n*Math.pow(10,i);
		return Math.round(j)/Math.pow(10,i);
               }
}
function marume1(n)
{
	var i;
        var yuuko;
        yuuko=1000;
	if(n==0)
		return 0;
	else
	{
		for(i=0;Math.abs(n)<yuuko;i++)
			n=n*10;
		return Math.round(n)/Math.pow(10,i);
	}
}

function calc01(Tani)
{
	var s,t,u;
	with(Tani)
	{
		u=input.value;
		if(Math.abs(u)>=0)
		{
			s=taniA.options[taniA.selectedIndex].value;
			t=taniA.options[taniB.selectedIndex].value;
			result.value=marume(u*(t/s));
		}
		else
			alert("正しい数値を入力してください");
	}
}

function calcTe()
{
	var s,t,u;
	with(document.TeForm)
	{
		s=taniA.selectedIndex;
		t=taniB.selectedIndex
		u=input.value;
		if(u==0 || Math.abs(u)>0)
		{
			if(s==1)
				u=(u-32)*(5/9);
			else if(s==2)
				u=u-273.16;
			if(t==1)
				u=u*(9/5)+32;
			else if(t==2)
				u=u*1+273.16;
			result.value=marume(u);
		}
		else
			alert("正しい数値を入力してください");
	}
}
