function formatRawAmount($amount, $curr) {
    $dblAmount = $amount + 0.0;

    // Build Currency format table
    $curFormat = Array();
    $curFormat["036"]=2;
    $curFormat["124"]=2;
    $curFormat["203"]=2;
    $curFormat["208"]=2;
    $curFormat["348"]=2;
    $curFormat["392"]=0;
    $curFormat["554"]=2;
    $curFormat["578"]=2;
    $curFormat["702"]=2;
    $curFormat["752"]=2;
    $curFormat["756"]=2;
    $curFormat["826"]=2;
    $curFormat["840"]=2;
    $curFormat["978"]=2;
    $curFormat["985"]=2;

    $digCurr = $this->getISOCurrency("" . $curr);
    $exponent = $curFormat[$digCurr];
    $strAmount = "" . Round($dblAmount, $exponent);
    $strRetVal = "" . $strAmount;

    // decimal position
    $curpos = strpos($strRetVal, ".");

    // Pad with zeros
    if($curpos == true) {
      $padCount = $exponent - (strlen($strRetVal) - $curpos - 1);
      for($i=0;$i<$padCount;$i++) {
        $strRetVal .= "0";
      }
    } else {
      $padCount = $exponent;
      for($i=0;$i<$padCount;$i++) {
        $strRetVal .= "0";
      }
    }

    if($curpos !== false) {
      $strRetVal = substr($strRetVal, 0, $curpos) . substr($strRetVal, $curpos+1);
    }
    return $strRetVal;
  }