function formatDollar(passedValue){
//      This function accepts the passed string and separates the dollars and cents and
//        returning a formatted value including a dollar sign, commas and decimal point:
//           1 - determines the position of the decimal point using the string method indexOf()
//           2 - separate the dollars and cents
//           3 - insert commas after every three dollar positions
//           4 - format the cents
//           5 - return the formatted result
//      This file does not appear when the source is viewed via the browser
        var inttDollars = "";
        var strReturnedFormat = "";      // The returned formatted value
        var strOutDollars = "";
        var intDecipos = passedValue.indexOf("."); // Determine decimal position
        if (intDecipos == -1)
           {
             intDecipos=passedValue.length        // No decimal position found
           }

        var intDollars=passedValue.substring(0,intDecipos); // Get the dollars
        var intDollen = intDollars.length;        // Determine the number of dollar positions 
                                                  // so commas can be inserted every 3 positions

        if (intDollen > 3) {
           while (intDollen > 0) 
           {
                 inttDollars = intDollars.substring(intDollen - 3, intDollen)
                 if (inttDollars.length == 3) 
                    {
                      strOutDollars = "," + inttDollars + strOutDollars
                      intDollen = intDollen - 3
                    } 
                 else 
                    {
                      strOutDollars = inttDollars + strOutDollars
                      intDollen = 0
                    }
           }
             if (strOutDollars.substring (0,1) == ",")
                {
                  intDollars = strOutDollars.substring (1,strOutDollars.length)
                }
             else
                {
                  intDollars = strOutDollars 
                }
        }

        var cents = passedValue.substring(intDecipos + 1,intDecipos + 3) // the 3 determines degree of accuracy

        if (cents == "")
           {
             cents = "00"
           }
        else
             if (cents.length == 1)
                {
                  cents = cents + "0"
                }
        strReturnedFormat  = "$" + intDollars + "." + cents
        return strReturnedFormat 
     
}
