
function RoundIt(Value,Digits) {
 var P=Math.pow(10,Digits);
 var R=Math.round(Value*P)/P;
 var G=true;
 while(G) {
  R=String(R);
  var L=R.length;
  var I=R.indexOf('.');
  if (I == -1) {
   R=R+'.';
  } else {
   var D=L-I-1;
   if (D < Digits) {
    R=R+'0';
   } else {
    G=false;
   }
  }
 }
 return R;
}
function poundtokg(){
	theForm = document.forms["theconverterfrm"]
	poundval = theForm["wtpounds"].value	
	if(!isNaN(poundval) && poundval != ""){
		poundval = parseFloat(poundval)		
	}
	else
		poundval = 0

	theForm["wtkgs"].value = RoundIt(poundval * 0.4536, 2)
}
function kgtopound(){
	theForm = document.forms["theconverterfrm"]
	kgval = theForm["wtkgs"].value	
	if(!isNaN(kgval) && kgval != ""){
		kgval = parseFloat(kgval)		
	}
	else
		kgval = 0

	theForm["wtpounds"].value = RoundIt(kgval / 0.4536, 2)
}

function inchtocms(){
	theForm = document.forms["theconverterfrm"]
	inchval = theForm["diminch"].value	
	if(!isNaN(inchval) && inchval != ""){
		inchval = parseFloat(inchval)		
	}
	else
		inchval = 0

	theForm["dimcms"].value = RoundIt(inchval * 2.54, 2)
}

function cmstoinch(){
	theForm = document.forms["theconverterfrm"]
	cmsval = theForm["dimcms"].value	
	if(!isNaN(cmsval) && cmsval != ""){
		cmsval = parseFloat(cmsval)		
	}
	else
		cmsval = 0

	theForm["diminch"].value = RoundIt(cmsval / 2.54, 2)
}


