function isNum(args)
{
	args = args.toString();

	if (args.length == 0)
	return false;

	for (var i = 0;  i<args.length;  i++)
	{
		if ((args.substring(i,i+1) < "0" || args.substring(i, i+1) > "9") && args.substring(i, i+1) != ".")
			{
			return false;
			}
	}

	return true;
}

function clearForm()
{
     document.tem.name1.value = "";
	 document.tem.name2.value = "";
	 document.tem.name3.value = ""; 
	 document.tem.name4.value = "";
	 document.tem.name5.value = ""; 
}

function converttem(ii,opt)
{
   var c = document.tem.name1.value;
   var f = document.tem.name2.value;
   var ra = document.tem.name3.value;
   var re = document.tem.name4.value;
   var k = document.tem.name5.value;
   
   if (c != "") c = c * 1;
   if (f != "") f = f * 1;
   if (ra != "") ra = ra * 1;
   if (re != "") re = re * 1;
   if (k != "") k = k * 1;
   
   
  if (opt == "1")
   {
       if (isNum(c))
	   { 	   
			f = 1.8*c + 32;
			k = c + 273.15;
			re = c/1.25;
			ra = f + 459.67;
		}
		else
		{
			c = c.substring(0,c.length-1);
		
		}
   }	
	else if (opt == "2")
	{
      if (isNum(f))
	   { 	   	
			c = (f-32)/1.8;
			k = c + 273.15;
			re = c/1.25;
			
			ra = f + 459.67;
		}
		else
		{
			f = f.substring(0,f.length-1);
		
		}		
	}   
	else if (opt == "3")
	{
      if (isNum(ra))
	   { 	   
		    f = ra-459.67;
			c = (f-32)/1.8;
			k = c + 273.15;
			re = c/1.25;
		}
		else
		{
			ra = ra.substring(0,ra.length-1);
		
		}		
	}
	else if (opt == "4")
	{
      if (isNum(re))
	   { 	   
		    c = re * 1.25;
			f = 1.8*c + 32;
			k = c + 273.15;
			ra = f + 459.67;
 		}
		else
		{
			re = re.substring(0,re.length-1);		
		}
	}
	else if (opt == "5")
	{
      if (isNum(k))
	   { 	   
		    c = k -273.15;
			f = 1.8*c + 32;
			re = c/1.25;
			ra = f + 459.67;	
		}
		else
		{
			k = k.substring(0,k.length-1);	
		}		
	}
	
   document.tem.name1.value = c;
   document.tem.name2.value = f;
   document.tem.name3.value = ra;
   document.tem.name4.value = re;
   document.tem.name5.value = k;	
}

