function pround(val)
{
  var newval=100*val;
  newval = Math.round(newval);
  var dollars = Math.floor(newval/100);
  var cents = newval - dollars * 100;
  if (cents == 0) {var centst = new String("00");}
  if (cents < 10) {var centst = "0" + String(cents);}
  if (cents > 9) {var centst = new String(cents);}
  return (dollars + "." + centst);
}
function apround(val)
{
  var newval=1000*val;
  newval = Math.round(newval);
  var dollars = Math.floor(newval/1000);
  var cents = newval - dollars * 1000;
  if (cents == 0) {var centst = new String("000");}
  if (cents > 9 && cents < 100) {var centst = "0" + String(cents);}
  if (cents < 10) {var centst = "00" + String(cents);}
  if (cents >= 100) {var centst = new String(cents);}
  return (dollars + "." + centst);
}
function Blend()
{
  var TB = 1 * document.f.B1.value + 1 * document.f.B2.value;
  if (document.f.B3.value > 0) { TB = TB + 1 * document.f.B3.value; }
  if (document.f.B4.value > 0) { TB = TB + 1 * document.f.B4.value; }
  if (document.f.B5.value > 0) { TB = TB + 1 * document.f.B5.value; }

  var BR = 0;
  if (document.f.R1.value > 0) 
  { BR = BR + document.f.R1.value * document.f.B1.value / TB; }
  if (document.f.R2.value > 0) 
  { BR = BR + document.f.R2.value * document.f.B2.value / TB; }
  if (document.f.R3.value > 0) 
  { BR = BR + document.f.R3.value * document.f.B3.value / TB; }
  if (document.f.R4.value > 0) 
  { BR = BR + document.f.R4.value * document.f.B4.value / TB; }
  if (document.f.R5.value > 0) 
  { BR = BR + document.f.R5.value * document.f.B5.value / TB; }
  
 
  document.f.TB.value = pround(TB); 
  document.f.BR.value = apround(BR); 
}
