function feedcal() {
	document.feed.A1.value=removeformat(document.feed.A.value);
	document.feed.B.value=format((document.feed.A1.value/2.2*0.1).toString());
	document.feed.C1.value=removeformat(document.feed.C.value);
	document.feed.D.value=format((document.feed.A1.value*(document.feed.C1.value/100)).toString());
	document.feed.E.value=format(((document.feed.B.value/document.feed.D.value*2000)/1000).toString());
	document.feed.F.value=format((document.feed.E.value/3.04).toString());
	document.feed.G.value=format((50/document.feed.F.value).toString());	
}
	

function format(str) {
str = str.toString().replace(/\$|\,/g,'');
if(isNaN(str))
str = "0";
sign = (str == (str = Math.abs(str)));
str = Math.floor(str*100+0.50000000001);
cents = str%100;
str = Math.floor(str/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((str.length-(1+i))/3); i++)
str = str.substring(0,str.length-(4*i+3))+','+
str.substring(str.length-(4*i+3));
return (((sign)?'':'-') + str + '.' + cents);
}

function removeformat(str) {
  var objRegExp = /\(/;
  var strMinus = '';

  //check if negative
  if(objRegExp.test(str)){
    strMinus = '-';
  }

  objRegExp = /\)|\(|[,]/g;
  str = str.replace(objRegExp,'');
  if(str.indexOf('$') >= 0){
    str = str.substring(1, str.length);
  }
  return strMinus + str;
}
