// Dimensional Weight Calculator
function doweight(form){
  var shipment, vol, volw, fweight, unit, units; 
  var form = document.getElementById(form);
 
  if (form.shipment[0].checked){
    shipment = form.shipment[0].value;
  }else {
    shipment = form.shipment[1].value;
  }
  if (form.units[0].checked){
    unit = form.units[0].value;
  }else {
    unit = form.units[1].value;
  }
  
 vol = form.length.value * form.width.value * form.height.value;
 
 if (shipment == "domestic"){             // domestic
    if (unit == "imperial"){
      convfact = 194;                      // english units
    }else {
      convfact = 7000;                     // metric units
    }
  }else {                                  // International
    if (unit == "imperial"){
      convfact = 166;                      // english units
    }else {
      convfact = 6000;                     // metric units
    }
  }
  volw = vol / convfact;
  fweight = Math.round(volw*Math.pow(10,0))/Math.pow(10,0);  //round up
  if( vol != 0 && ( isNaN( fweight ) || fweight < 1 ) ) fweight = 1;  // mimiumn of 1
  if (unit == "imperial"){
    units = " Pound(s)";
  }else {
    units = " Kilogram(s)";
  }
form.answer.value = parseFloat(fweight)+units;  
  return false;
}
