//Send this function a string and if it needs comman and zeroes appropriately
//it will send them back with commas and decimals

function commasDecimals(fixit)
{

var tempString = "";

  //MAKE SURE THAT THE LAST 3 DIGITS = ".00"
  if ((fixit.indexOf('.') == (fixit.length - 2))&&(fixit.length != 1))
    {
      fixit += "0";
    }
  else if ((fixit.indexOf('.') == (fixit.length - 1))&&(fixit.length != 1))
    {
      fixit += "00";
    }
  else if (fixit.indexOf('.') == -1 )
    {
      fixit += ".00";
    }

  //Now, Add commas
  if (fixit.substring(fixit.indexOf('.'),0).length > 3)
    {
      //Add first comma, based on length of number from decimal
      tempString = fixit.substring(fixit.indexOf('.')-3,0) + "," + fixit.substring(fixit.length,fixit.indexOf('.')-3);
      fixit = tempString;

      //Now add more commas while necessary, based on length of number from first visible comma in the string
      while (fixit.indexOf(",") > 3)
        {
          tempString = fixit.substring(fixit.indexOf(',')-3,0) + "," + fixit.substring(fixit.length,fixit.indexOf(',')-3);
          fixit = tempString;
        }
    }

  //remove potential error "-," for negative numbers a multiple of 3 digits in length
  if ((fixit.indexOf('-') == 0)&&(fixit.indexOf(',') == 1))
    {
      tempString = "-" + (fixit.substring(fixit.length,fixit.indexOf(',')+1));
      fixit = tempString;
    }

  //Fix requested by Jennifer Kohl - remove everything decimal and after - this is what is done in the application
  tempString = fixit.substring(0,fixit.indexOf('.'));
  fixit = tempString;

    return fixit;
}

