function dp(price) 
{
   string = "" + price;
   number = string.length - string.indexOf('.');
   if (string.indexOf('.') == -1)
      return string + '.00';
   if (number == 1)
      return string + '00';
   if (number == 2)
      return string + '0';
   if (number > 3)
      return string.substring(0,string.length-number+3);
return string;
}

function calculate()
{
 var timechoice = document.lcrdesigned.timeframe.value;

 if (timechoice == "D") {
    document.lcrdesigned.dailytotal.value = dp((document.lcrdesigned.amount.value))
    document.lcrdesigned.weeklytotal.value = dp((document.lcrdesigned.dailytotal.value)*7)
    document.lcrdesigned.monthlytotal.value = dp((document.lcrdesigned.weeklytotal.value)*4.3)
    document.lcrdesigned.yearlytotal.value = dp((document.lcrdesigned.monthlytotal.value)*12)
    document.lcrdesigned.projecttotal.value = dp((document.lcrdesigned.yearlytotal.value)*5)
 }

 if (timechoice == "W") {
    document.lcrdesigned.weeklytotal.value = dp((document.lcrdesigned.amount.value))
    document.lcrdesigned.dailytotal.value = dp((document.lcrdesigned.amount.value)/7)
    document.lcrdesigned.monthlytotal.value = dp((document.lcrdesigned.weeklytotal.value)*4.3)
    document.lcrdesigned.yearlytotal.value = dp((document.lcrdesigned.monthlytotal.value)*12)
    document.lcrdesigned.projecttotal.value = dp((document.lcrdesigned.yearlytotal.value)*5)
 }

 if (timechoice == "M") {
    document.lcrdesigned.monthlytotal.value = dp((document.lcrdesigned.amount.value))
    document.lcrdesigned.weeklytotal.value = dp((document.lcrdesigned.amount.value)/4.3)
    document.lcrdesigned.dailytotal.value = dp((document.lcrdesigned.weeklytotal.value)/7)
    document.lcrdesigned.yearlytotal.value = dp((document.lcrdesigned.monthlytotal.value)*12)
    document.lcrdesigned.projecttotal.value = dp((document.lcrdesigned.yearlytotal.value)*5)
 }

 if (timechoice == "Y") {
    document.lcrdesigned.yearlytotal.value = dp((document.lcrdesigned.amount.value))
    document.lcrdesigned.monthlytotal.value = dp((document.lcrdesigned.yearlytotal.value)/12)
    document.lcrdesigned.weeklytotal.value = dp((document.lcrdesigned.monthlytotal.value)/4.3)
    document.lcrdesigned.dailytotal.value = dp((document.lcrdesigned.weeklytotal.value)/7)
    document.lcrdesigned.projecttotal.value = dp((document.lcrdesigned.yearlytotal.value)*5)
 }

 if (timechoice == "P") {
    document.lcrdesigned.projecttotal.value = dp((document.lcrdesigned.amount.value))
    document.lcrdesigned.yearlytotal.value = dp((document.lcrdesigned.projecttotal.value)/5)
    document.lcrdesigned.monthlytotal.value = dp((document.lcrdesigned.yearlytotal.value)/12)
    document.lcrdesigned.weeklytotal.value = dp((document.lcrdesigned.monthlytotal.value)/4.3)
    document.lcrdesigned.dailytotal.value = dp((document.lcrdesigned.weeklytotal.value)/7)
 }

}
