test
-- "on mouseUp
  puppetSprite 12, false
  getValues
  go to frame 2
end"
-- "**********************************************************************"
-- "on mouseUp
  global calcType
  puppetSprite 12, false
  getValues
  go to frame 5
  
end"
-- "**********************************************************************"
-- "on mouseUp
  puppetSprite 12, false
  getValues
  go to frame 8
end"
-- "**********************************************************************"
-- "on mouseUp
  global calcType
  puppetSprite 12, false
  getValues
  go to frame 11
end"
-- "**********************************************************************"
-- "on mouseUp
  global calcType
  puppetSprite 12, false
  getValues
    go to frame 14
end"
-- "**********************************************************************"
-- "on mouseUp
  global calcType
  puppetSprite 12, false
  getValues
  go to frame 17
end"
-- "**********************************************************************"
-- "on mouseUp
  global calcType
  puppetSprite 12, false
  getValues
  calculateTotal
  go to frame 20
end"
-- "**********************************************************************"
-- "on exitFrame
  global qnum, numValues, mouseIsDown, direction, maxQ, totalValue, onetimeValue, totalassetsValue, livingValue, shortfall, thisRoll, baseColor, darkColor
  set thisRoll = 0
  puppetSprite 39, true
  set baseColor = 215
  set darkColor = 255
  set the floatprecision = 2
  --set totalValue = 0
  --set livingValue = 0
  --set onetimeValue= 0
  --set totalassetsValue = 0
  --set shortfall = 0
  -- set the text of member "onetime" = "$0"
  --set the text of member "living" = "$0"
  --set the text of member "totalassets" = "$0"
  --set the text of member "total" = "$0"
  --set maxQ = 14
  --set direction = 0
  -- set mouseIsDown = "false"
  -- set qnum = 0
  set numValues = list(6000, 5000, 0, 100000, 20000, 120000, 25000, 40000, 15000, 2000, 20, 50000, 50000, 0)
  getValues
  puppetSprite 12, true
end"
-- "**********************************************************************"
-- "on enterframe
  global thisRoll
  set n = 42
  repeat while (n < 49)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n)) and (n <> 42)) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  set n = 16
  repeat while (n < 21)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n))) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  otherroll
end


on exitFrame
  go the frame
end
"
-- "**********************************************************************"
-- "on exitFrame
  puppetSprite 12, true
  set the locV of sprite 12 = 7 + the locV of sprite 16
  set the text of member "info" = "A typical funeral costs about $6,000 but can run double that.  Cremation is less expensive, costing as little as $1,300, although some states require you to buy a coffin anyway."
end"
-- "**********************************************************************"
-- "on enterframe
  global thisRoll
  set n = 42
  repeat while (n < 49)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n)) and (n <> 43)) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  set n = 16
  repeat while (n < 21)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n))) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  otherroll
end

on exitFrame
  go the frame
end

on mouseDown
  global numValues
  if (rollover(16) or rollover(21)) then
    set the locV of sprite 12 = 7 + the locV of sprite 21
    set the text of member "info" = "A typical funeral costs about $6,000 but can run double that.  Cremation is less expensive, costing as little as $1,300, although some states require you to buy a coffin anyway."
  end if
  if (rollover(17) or rollover(22)) then
    set the locV of sprite 12 = 7 + the locV of sprite 22
    set the text of member "info" = "Include the maximum out-of-pocket costs allowed by your medical insurance plus airfare for immediate family attending the funeral."
  end if
  if (rollover(18) or rollover(23)) then
    set the locV of sprite 12 = 7 + the locV of sprite 23
    set the text of member "info" = "Federal inheritance taxes range from 37% to 55% of estates valued at $600,000 or more.  Some states impose taxes on estates worth less than that amount, so consult an attorney if you're not sure."
  end if
end
"
-- "**********************************************************************"
-- "on exitFrame
  puppetSprite 12, true
  set the locV of sprite 12 = 7 + the locV of sprite 16
  set the text of member "info" = "If any relatives would continue to live in your home after your death, it is smart to make sure that the mortgage can be paid off."
end"
-- "**********************************************************************"
-- "on enterframe
  global thisRoll
  set n = 42
  repeat while (n < 49)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n)) and (n <> 44)) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  set n = 16
  repeat while (n < 21)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n))) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  otherroll
end

on exitFrame
  go the frame
end

on mouseDown
  global numValues
  if (rollover(16) or rollover(21)) then
    set the locV of sprite 12 = 7 + the locV of sprite 21
    set the text of member "info" = "If any relatives would continue to live in your home after your death, it is smart to make sure that the mortgage can be paid off."
  end if
  if (rollover(17) or rollover(22)) then
    set the locV of sprite 12 = 7 + the locV of sprite 22
    set the text of member "info" = "Credit card debt, car loans, student loans.  You don't want to saddle your executor or relatives with selling other assets in your estate just to pay off your debts."
  end if
  if (rollover(18) or rollover(23)) then
    set the locV of sprite 12 = 7 + the locV of sprite 23
    set the text of member "info" = "Figure on $15,000 per year for a public university or use the College Savings Calculator."
  end if
  if (rollover(19) or rollover(24)) then
    set the locV of sprite 12 = 7 + the locV of sprite 24
    set the text of member "info" = "This is any extra amount that you may want your family to have.  You should probably include at least $25,000 for an emergency fund."
  end if
end
"
-- "**********************************************************************"
-- "on exitFrame
  puppetSprite 12, true
  set the locV of sprite 12 = 7 + the locV of sprite 16
  set the text of member "info" = "Enter your current annual after-tax living expenses.  The calculator multiplies this by 0.8, because it is assumed that your family's living expenses will decline 20 percent after you are gone."
end"
-- "**********************************************************************"
-- "on enterframe
  global thisRoll
  set n = 42
  repeat while (n < 49)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n)) and (n <> 45)) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  set n = 16
  repeat while (n < 21)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n))) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  otherroll
end

on exitFrame
  go the frame
end

on mouseDown
  global numValues
  if (rollover(16) or rollover(21)) then
    set the locV of sprite 12 = 7 + the locV of sprite 21
    set the text of member "info" = "Enter your current annual after-tax living expenses.  The calculator multiplies this by 0.8, because it is assumed that your family's living expenses will decline 20 percent after you are gone."
  end if
  if (rollover(17) or rollover(22)) then
    set the locV of sprite 12 = 7 + the locV of sprite 22
    set the text of member "info" = "Enter an estimate of your spouse's annual take-home pay."
  end if
  if (rollover(18) or rollover(23)) then
    set the locV of sprite 12 = 7 + the locV of sprite 23
    set the text of member "info" = "How much will your family receive annually in Social Security survivorship benefits?"
  end if
end
"
-- "**********************************************************************"
-- "on exitFrame
  global shortfall
  calculateTotal
  puppetSprite 12, true
  set the locV of sprite 12 = 7 + the locV of sprite 16
  set the text of member "info" = "How many years will your family need help covering the difference between income and expenses?"
  calcNum string(shortfall)
  set incomeString = the result
  calcDollar string(incomeString)
  set tempResult = the result
  if char 1 of tempResult = "-" then
    delete char 1 of tempResult
  end if
  
  if (shortfall > 0) then
    set the text of member 27 = "Without your work income, your family will face an annual shortfall of  " & tempResult & ".  Insurance will be needed to cover this shortfall until circumstances change (as when your children become employed)."
  end if
  if (shortfall < 0) then
    set the text of member 27 = "Without your work income, your family will earn  " & tempResult & " more than they need annually."
  end if
  if (shortfall = 0) then
    set the text of member 27 = "Without your work income, your family's earnings will exactly match their needs."
  end if
  
end"
-- "**********************************************************************"
-- "on enterframe
  global thisRoll
  set n = 42
  repeat while (n < 49)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n)) and (n <> 46)) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  set n = 16
  repeat while (n < 21)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n))) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  otherroll
end

on exitFrame
  go the frame
end

on mouseDown
  global numValues
  if (rollover(16) or rollover(21)) then
    set the locV of sprite 12 = 7 + the locV of sprite 21
    set the text of member "info" = "How many years will your family need help covering the difference between income and expenses?"
  end if
end
"
-- "**********************************************************************"
-- "on exitFrame
  puppetSprite 12, true
  set the locV of sprite 12 = 7 + the locV of sprite 16
  set the text of member "info" = "If you already have some life insurance coverage, how much will those policies pay upon your death?"
end"
-- "**********************************************************************"
-- "on enterframe
  global thisRoll
  set n = 42
  repeat while (n < 49)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n)) and (n <> 47)) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  set n = 16
  repeat while (n < 21)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n))) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  otherroll
end

on exitFrame
  go the frame
end

on mouseDown
  global numValues
  if (rollover(16) or rollover(21)) then
    set the locV of sprite 12 = 7 + the locV of sprite 21
    set the text of member "info" = "If you already have some life insurance coverage, how much will those policies pay upon your death?"
  end if
  if (rollover(17) or rollover(22)) then
    set the locV of sprite 12 = 7 + the locV of sprite 22
    set the text of member "info" = "If you have other assets that could be sold to generate cash, enter the total value of those assets."
  end if
end
"
-- "**********************************************************************"
-- "on otherRoll
  global thisRoll, baseColor
  if (thisRoll <> 0) and not(rollover(42) or rollover(43) or rollover(44) or rollover(45) or rollover(46) or rollover(47) or rollover(48) or rollover(16) or rollover(17) or rollover(18) or rollover(19) or rollover(20)) then
    resetColors 0
  end if
end"
-- "**********************************************************************"
-- "on getValues
  global numValues
  --get values
  set n = 0
  repeat while (n < 13)
      set n = n + 1
    if n = 11 then
      set incomeString = line 1 of the text of member (n + 44)
      calcNum incomeString
      set incomeString = the result
      setAt numValues n, value(incomeString)
      if getAt(numvalues, n) > 100 then
        setAt numValues n, 100
      end if
      if getAt(numvalues, n) < 0 then
        setAt numValues n, 0
      end if
      if getAt(numvalues, n) = 1 then
        set the text of member (n + 44) = getAt(numvalues, n) & " year"
      else
        set the text of member (n + 44) = getAt(numvalues, n) & " years"
      end if
      
    else
      set incomeString = line 1 of the text of member (n + 44)
      calcNum string(incomeString)
      set incomeString = the result
      setAt numValues n, value(incomeString)
      calcDollar string(incomeString)
      set incomeString = the result
      set the text of member (n + 44) = incomeString
    end if
    
  end repeat
  
end

"
-- "**********************************************************************"
-- "on calcDollar thisString
  set minus = "false"
  set n = 0
  if (char 1 of thisString = "-") then
    delete char 1 of thisString
    set minus = "true"
  end if
  
  set x = the number of chars in thisString
  repeat while (n < x)
    set n = n + 1
    if (char n of thisString = ".") then
      if (the number of chars in thisString - n > 2) then
        delete char (n + 3) to (the number of chars in thisString) of thisString
      end if
      set x = n - 1
    end if
  end repeat
  set n = 0
  repeat while (n < x - 1)
    set n = n + 1
    if (n mod 3 = 0) then
      set thisString = chars(thisString,1,x - n) & "," & chars(thisString,x - n + 1,the number of chars in thisString)
    end if
  end repeat
  if minus = "false" then
    set thisString = "$" & thisString
  else
    set thisString = "-$" & thisString
  end if
  if char (the number of chars in thisString) of thisString = "." then
    set thisString = thisString & "0"
  end if
  if char ((the number of chars in thisString) - 1) of thisString = "." then
    set thisString = thisString & "0"
  end if
  return thisString
end
"
-- "**********************************************************************"
-- "on calcNum thisString
  if (the number of chars in thisString = 0) then
    set thisString = "0"
  end if
  set minus = "false"
  set n = 1
  set decimal = "false"
  repeat while (n <= the number of chars in thisString)
    if not((value(char n of thisString) >= 0) and (value(char n of thisString) <= 9)) then
      if (not(char n of thisString = ".")) or decimal = "true" then
        if ((char n of thisString = "-") and (n = 1)) then
          set minus = "true"
        end if
        delete char n of thisString
      else
        set decimal = "true"
        set n = n + 1
      end if
    else
      set n = n + 1
    end if
  end repeat
  set zeros = TRUE
  repeat while (zeros = TRUE)
    if (char 1 of thisString) = "0" then
      delete char 1 of thisString
    else
      set zeros = FALSE
    end if
  end repeat
  if decimal = "true" then
    set zeros = TRUE
    repeat while (zeros = TRUE)
      if (char (the number of chars in thisString) of thisString) = "0" then
        delete char (the number of chars in thisString) of thisString
      else
        set zeros = FALSE
      end if
    end repeat
  end if
  
  if thisString = "." then
    set thisString = "0"
  end if
  
  if (the number of chars in thisString = 0) then
    set thisString = "0"
  end if
  if (minus = "true") and not(thisString = "0") then
    set thisString = "-" & thisString
  end if
  repeat while (the number of chars in thisString) > 8
    delete char (the number of chars in thisString) of thisString
    
  end repeat
  if char (the number of chars in thisString) of thisString = "." then
    delete char (the number of chars in thisString) of thisString
  end if
  
  return thisString
end
"
-- "**********************************************************************"
-- "on calculateTotal
  global numValues, totalValue, onetimeValue, livingValue, totalassetsValue, shortfall
  set n = 0
  set onetimeValue = 0
  set livingValue = 0
  set totalassetsValue = 0
  repeat while n < 7
    set n = n + 1
    set onetimeValue = onetimeValue + (getAt(numValues, n))
  end repeat

  set livingValue = getAt(numValues, 8)
  set livingValue = integer(livingValue * 0.8)
  set livingValue = livingValue - getAt(numValues, 9) - getAt(numValues, 10)
  set shortfall = livingValue
  set livingValue = livingValue * getAt(numValues, 11)
  set totalassetsValue = getAt(numValues, 12) + getAt(numValues, 13)
  set totalValue = onetimeValue + livingValue - totalassetsValue
  calcNum string(totalvalue)
  set incomeString = the result
  calcDollar string(incomeString)
  
  if totalValue > 0 then
    set the text of member "totaltext" = "To ensure your family's continued well-being, you should have an additional " & the result & " in life insurance coverage."
  else
    set the text of member "totaltext" = "You have more than enough coverage for your family's needs."
  end if
  
  




  calcNum string(onetimevalue)
  set incomeString = the result
  calcDollar string(incomeString)
  set the text of member "totaldeath" = "One-time expenses add up to " & the result

  calcNum string(shortfall)
  set incomeString = the result
  calcDollar string(incomeString)

  set tempResult = the result
  if char 1 of tempResult = "-" then
    delete char 1 of tempResult
  end if

  if (shortfall > 0) then
    set the text of member "totalshortfall" = "Your family will experience an income shortfall of " & tempResult & " annually for " & the text of member 55 & " after your death."
  else
    set the text of member "totalshortfall" = "However, your family will earn " & tempResult & " more than they need annually for " & the text of member 55 & " after your death."
  end if
  if (shortfall = 0) then
    set the text of member "totalshortfall" = "Your family will earn exactly what they need to live on for " & the text of member 55 & " after your death."
  end if

  calcNum string(totalAssetsValue)
  set incomeString = the result
  calcDollar string(incomeString)
  if totalAssetsValue > 0 then
    set the text of member "totalassets" = "Insurance and other existing assets totaling " & the result & " will help mitigate your family's loss."
  else
    set the text of member "totalassets" = "There are no other assets to help mitigate your family's loss."
  end if
end

"
-- "**********************************************************************"
-- "on resetColors n
  global thisRoll, baseColor, darkColor
  if (thisRoll <> 0) then
      set the forecolor of member thisRoll = darkColor
    set the locV of sprite 39 = 800
  end if
  if (n <> 0) then
    if (n < 42) then
      set the forecolor of member (the memberNum of sprite n) = baseColor
    end if
    set thisRoll = (the memberNum of sprite n)
    if (n > 41) then
      set the locV of sprite 39 = 44 + (32 * (n - 42))
    end if
  else
    set thisRoll = 0
  end if
end
"
-- "**********************************************************************"
-- "on enterframe
  global thisRoll
  set n = 42
  repeat while (n < 49)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n)) and (n <> 48)) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  set n = 16
  repeat while (n < 21)
    if (rollover(n) and (thisRoll <> (the memberNum of sprite n))) then
      resetColors n
    end if
    set n = n + 1
  end repeat
  otherroll
end


on exitFrame
  go the frame
end
"
-- "**********************************************************************"
