﻿// JScript 文件

function convertFunc( formname, num_to_change, mult )
{
  with( document.forms[formname] )
  {
     var num_change = num_to_change.value;
	 var mult_by = mult.value;
	 if( mult_by == "" )
     {
	    if (num_change < 0)
		{ 
		   result.value = "0";
		   num_to_change.value = "0";
		   alert('请输入一个大于零的数字');
		   return ;
		}
		else
		{
		   var nresult=num_change;
		   result.value = nresult;
		}
		if (isNaN(nresult))
		{
		  result.value = "0"; 
		  num_to_change.value = "0";
		  alert('请输入一个数字');
		}
     }
	 else
	 {
	    if( num_change < 0 )
		{
		   result.value = "0";
		   num_to_change.value = "0";
		   alert('请输入一个大于零的数字');
		   return ;
		}
		else
		{
		   var nresult=twoDps(num_change * mult_by);
		   result.value = nresult;
		}
		if (isNaN(nresult))
		{
		  result.value = "0"; 
		  num_to_change.value = "0";
		  alert('请输入一个数字');
		}
	 }
  }
}

function twoDps( item )
{
  return ( parseInt( item * 100 ) / 100 );
}
function checkCountry()
{
	for( j = 0 ; j < customcountries.length ; j++ )
    {
        if( customcountries[j] == ctryCode )
        {
			return true;        
		}
    }
	return false;
 
}
function changeConvFactor()
{
	var chkCustomCountry = checkCountry();

	if ( chkCustomCountry )
	{
		convfact = 5000;
	}
}
function changeunits( element )
{
	unitType=null;
	if(element[0].checked)
	{ 	
		unitType=element[0].value;
		form=element[0].form;
	}
	else 
	{	
		unitType=element[1].value;
		form=element[1].form;
	}
	
  	if(unitType != null)
	{
  		units = unitType;

  		if( units == "imp" || units == "in" )
  		{
   	 		lenunt = "in.gif";
    		wgtunt = "lb.gif";
    		convfact = 166;
    		roundfact = 1;
    		baseweight = 1;
  		}
  		else
  		{
    		lenunt = "cm.gif";
    		wgtunt = "kg.gif";
    		convfact = 6000;
			roundfact = 0.5;
    		baseweight = 0.5;

			//Start Change: Mukeshs: 8th Sep'05
			//Call the method to change the convfact if required
			//changeConvFactor();
			//End  Change: Mukeshs: 8th Sep'05
  		}

  		if( typeof( document.images["lenim"] ) != "undefined" )
  		{
    		document.images["lenim"].src =   "../images/"+lenunt;
    		document.images["higim"].src =   "../images/"+lenunt;
    		document.images["widim"].src =   "../images/"+lenunt;
    		document.images["volim"].src =   "../images/"+wgtunt;
  		}
  		//doweight(form, false, false, false);
	}
}