function chars(string,Chars) {
 var returnstring = '';
 for (var i = 0; i < string.length; i++) {
  if (Chars.indexOf(string.charAt(i)) > -1)
   returnstring = returnstring + string.charAt(i);
  }
 return returnstring;
}

function checkVal(what) {
 what.value = chars(what.value,"0123456789");
 if(what.value == '' || what.value == 0) what.value = 1;
}

function cent(amount,nodollar) {
 amount = amount - 0;
 amount = (Math.round(amount * 100))/100;
 if (amount == Math.floor(amount)) {
  amount = amount + '.00';
 } else if (amount*10 == Math.floor(amount*10)) {
  amount = amount + '0';
 }
 if(nodollar) {
  return amount;
 } else {
  return '$' + amount;
 }
}

function trim(TRIM_VALUE) {
 if(TRIM_VALUE.length < 1) {
  return "";
 }
 TRIM_VALUE = RTrim(TRIM_VALUE);
 TRIM_VALUE = LTrim(TRIM_VALUE);
 if(TRIM_VALUE=="") {
  return "";
 } else {
  return TRIM_VALUE;
 }
}


function RTrim(VALUE) {
 var w_space = String.fromCharCode(32);
 var v_length = VALUE.length;
 var strTemp = ""; 
 if(v_length < 0) {
  return"";
 }
 var iTemp = v_length -1;
 while(iTemp > -1) {
  if (VALUE.charAt(iTemp) == w_space) {
  } else {
   strTemp = VALUE.substring(0,iTemp +1);
   break;
  }
  iTemp = iTemp-1;
 }
 return strTemp;
}

function LTrim(VALUE) {
 var w_space = String.fromCharCode(32);
 if(v_length < 1) {
  return"";
 }
 var v_length = VALUE.length;
 var strTemp = "";
 var iTemp = 0;
 while(iTemp < v_length) {
  if (VALUE.charAt(iTemp) == w_space){
  } else {
   strTemp = VALUE.substring(iTemp,v_length);
   break;
  }
  iTemp = iTemp + 1;
 }
 return strTemp;
}