..........
Please wait
for the
wheel to
disappear
before
beginning.

Environmental Benefit calculator

First find the highest EB score that your property can earn,
then try different tank and rain-garden set-ups



The Little Stringybark Creek project is providing funding to householders in the catchment who retain stormwater on their properties. We will pay a set price for a given benefit to the health of Little Stringybark Creek (in addition to state and federal government rebates). The current price is the minimum price you will be paid: if you agree to install a tank or rain-garden on your property at the current price, you will receive an initial payment at the current price, and then an additional payment once we have arrived at the final price of environmental benefit to the creek.

About this page...

This calculator works out the environmental benefit (EB) that you can achieve
using tanks or rain-gardens to keep stormwater on your property.

  • Start on the 'Your property tab' to find the maximum EB (and funding) your property can score.
  • Then try different tank or rain-garden set-ups on the next two tabs.
  • The summary tab allows you to export a table that can be used to submit your
    stormwater tender.
  • The comparison tab allows you to compare the effects of varying tank size
    or tank-water uses on your EB score and the amount of water the tank will provide.


Current price being paid: $1500 per environmental benefit unit

Hover the mouse here for more details about this price

The price rose from $1000 to $1500 on 22 Jun 2010.

The current price potentially equals $1500 - $2400
for most Mt Evelyn households (in addition to up to $1500
from Victorian and Federal Government rebates for
rainwater tanks).

We are seeking householders who are willing to install a
rainwater tank/rain-garden/infiltration system now at that
price. The price will increase until our budget has been
spent. Early bidders will ensure that they get funding, and
they will receive an additional payment at the end of the
auction (all successful bidders will be paid the final price).

This page helps you work out the environmental benefit you
could achieve on your property, and how much you could be
paid. Start by filling in the details on the 'Your
property' tab to find the potential EB of your property.


First, fill in the areas of roof and paving on your property that are connected to the street drainage by pipes.

"HTMLargs" <- function(x) {
  # returns a string with the arguments as a="arg1", b="arg2", and so on
  names <- names(x)
  if (length(x) > 0) str <- " " else str <- ""
  for (i in seq(along = x))
    str <- paste(str, names[i], "=", jsQuote(x[[i]]), " ", sep = "")
  return(str)  #correction 9 Dec 2009 as per http://code.google.com/p/rpad/issues/detail?id=5
      }
     roofarea <- pavearea <- roofarea1 <- hasseptic <- hastank <- tab1 <- 0
     HTMLon()
     HTMLtag("table style='font-family:arial;font-size:10pt'"); 
     HTMLtag("tr"); HTMLtag("td")
     cat("Roof area:"); HTMLtag("/td"); HTMLtag("td")
     HTMLinput("roofarea", roofarea, size = 5, id = "roof",
                style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
     cat("sq m")
     HTMLtag("/td"); HTMLtag("/tr");HTMLtag("tr"); HTMLtag("td")
     cat("Paved area:"); HTMLtag("/td"); HTMLtag("td")
     HTMLinput("pavearea", pavearea, size = 5, id = "pave",
               style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
     cat("sq m")
     HTMLtag("/td"); HTMLtag("/tr");HTMLtag("/table")
     HTMLoff()
    

Connected or unconnected?

Connected or unconnected?
See the FAQ page for help.
If your roof or paving drains to land or an earthen drain, then
your property is likely to be having much less of an impact on
the creek than houses that are connected to the stormwater drainage system

Working out areas?.

To calculate area:

  • divide the roof or paving into rectangles;
  • multiply the length and width (in metres) of each rectangle together to get the area in sq m;
  • add all the areas together.

If your property is part of the Stormwater Fund program (in the Little Stringybark Creek catchment, the NE part of Mt Evelyn, Melbourne, Victoria, Australia), we can give you estimates for your property, calculated from aerial photos and council records: contact Darren Bos:
dbos@unimelb.edu.au, Ph: 8344 9248 Mobile: 0447 551 522


     source("/var/www/Rpad/modelfunctions.R")
     library(chron)
     current.price <- 1500
     tab1 <- 1
     tank.summary <- data.frame(Detail = c("Overflow frequency from system (d/y)",
                      "Target overflow frequency (d/y)",
                      "Overflow frequency index (A)",
                      "Volume retained by the sytem (kL/y)",
                      "Target volume to be retained (kL/y)",
                      "Volume reduction index (B)",
                      "Volume of filtered flow from system (kL/y)",
                      "Target filtered flow volume (kL/y)",
                      "Target for maximum permissible filtered flow (L/h)",
                      "Filtered flow index (C)",
                      "75th percentile P concentration from system (mg/L)",
                      "Target 75th percentile P concentration (mg/L)",
                      "75th percentile N concentration from system (mg/L)",
                      "Target 75th percentile N concentration (mg/L)",
                      "75th percentile TSS concentration from system (mg/L)",
                      "Target 75th percentile TSS concentration (mg/L)",
                      "WQ index (Mean of P, N and TSS indices) (D)",
                      "EB index (Mean of indices A, B, C and D)"))

     if(roofarea == "" | pavearea == "" )  
      stop("Please enter a value in both boxes (can be zero).", call. = FALSE)
     options(chron.origin = c(month = 12, day = 30, year = 1899))
     #hourly runoff data for 1965, 1967 and 1970
     #calculated using ...
     hro3y <- read.csv("/var/www/Rpad/Croydon hrly rainrunoff 656770.csv")
     hro3y <- data.frame(datetime = chron(as.character(hro3y$date), 
                                          as.character(hro3y$time),
                                          format = c(dates = "d/m/y", times = "h:m:s")),
                         date = chron(as.character(hro3y$date),
                                format = c(dates = "d/m/y")),
                         year = hro3y$year, month = NA,
                         runoff.mm = hro3y$ir11,
                         daten = as.numeric(chron(as.character(hro3y$date),
                                format = c(dates = "d/m/y"))))
     #ir11 rainfall with 1st mm of each event removed with at least 1h separating events
     hro3y$month <- month.day.year(hro3y$date)$month
     hro3y$year[hro3y$year == 1966] <- 1965  #the first year goes from April to March
     monthly.ET <- read.csv("/var/www/Rpad/monthly ET.csv")
     monthly.ET$ETmmh <- monthly.ET$ETmm.d/24
     hro3y$ETmmh <- monthly.ET$ETmmh[match(hro3y$month, monthly.ET$month)]
     dro3y <- read.csv("/var/www/Rpad/Croydon daily rainrunoff 656770.csv")
     dro3y <- data.frame(date = chron(as.character(dro3y$date),
                                      format = c(dates = "d/m/y")),
                         year = NA,
                         runoff.mm.d = dro3y$ir11, 
                         daten = as.numeric(chron(as.character(dro3y$date),
                                      format = c(dates = "d/m/y"))))
     dro3y$year <- month.day.year(dro3y$date)$year
     dro3y$year[dro3y$year == 1966] <- 1965   
     dro1y <- dro3y[dro3y$year < 1967,]
     hro1y <- hro3y[hro3y$year < 1967,]
     preurban.ro.kL <- round((roofarea + 
		       pavearea)*954*10^(1.3143*log10(954) - 2.7464)/100000,0)
     total.ro.kL <- round(sum(dro1y$runoff.mm)*(roofarea +
		    pavearea)/1000, 0)
     maxEBI <- round((roofarea + pavearea)/100 ,2)
     maxEBItank <- roofarea*0.59/100
############return to this summary template 
#    results <- data.frame(Summary = 
#                           c("Tank","Rain-garden", "Total","Maximum achievable for this property"),
#                           EB.score = c(0,0,0,maxEBI),
#                           Water.savings.in.kL = c(0,0,0,round(mean(ann.harvestable[,2]),0)))
     HTMLon()
     HTMLtag("p style='text-align:center;font-size:11pt;font-weight:bold'")
     cat("Your property has the potential to earn", BR,
     maxEBI, " Environmental Benefit Units", BR, 
     "worth $", round(current.price*maxEBI,0), " (+ $1500 govt rebates = $",
     round(1500 + current.price*maxEBI,0), ").", sep="")
     HTMLtag("/p")
     cat("With a rainwater tank draining all of your roof, and
     overflowing to the street drainage you could potentially
     earn", round(maxEBItank ,2), "EBs")  
     BR; BR
     cat("To score an EB closer to", maxEBI, "you will most likely
     need a rainwater tank overflowing to an infiltration system or
     a raingarden that also drains your paved area.")
     BR; BR
     cat("To find the EB score for a rainwater tank (with or without a
     rain-garden), go to the tank tab first.", BR,
         "If you just want  a raingarden, go to the rain-garden tab")
     BR
     BR
     HTMLtag("i")
     HTMLh3("More information on the potential environmental benefit
     of your property")
     HTMLtag("/i")
     cat("The stormwater that runs off the roof and paving of Mt
     Evelyn properties is damaging Little Stringybark Creek in four
     ways that are measured by the Environmental benefit index.", BR)
     HTMLtag("ol"); HTMLtag("li")
     cat("Every time it rains, stormwater runs off your property,
     collecting pollutants as it goes,disturbing the plants and
     animals of the creek on more than  100 days a year.  You score a
     higher EB if you can keep runoff on your property for all but the
     biggest storms (ideally allowing runoff 12 or fewer days a year,
     like before Mt Evelyn was developed).", BR, BR)
     HTMLtag("li"); HTMLtag("/li")
     cat("A much larger volume of water runs off our roofs and
     paving than was the case when your property was part of a forest.
     As a forest the area now covered by your ") 
     cat(round(roofarea + pavearea, 0))
     cat(" sq m of roof and paving would have provided ")
     cat(preurban.ro.kL)
     cat(" kilolitres to the creek each year (on average), mainly as
     filtered, dry-weather flow.  It now delivers ")
     cat(total.ro.kL)
     cat(" kilolitres to the creek each year, all as polluted storm
     flow. You score a higher EB if you can reduce the volume of
     stormwater running off your property by harvesting it and using
     it. In Melbourne, each person uses an average 73 kilolitres each
     year, so there is great potential for reducing your mains water
     usage, by collecting and using at least some of the
     excess, nuisance ")
     cat(-preurban.ro.kL + total.ro.kL)
     cat(" kilolitres generated by the roof and paving of your
     property each year.", BR, BR)
     HTMLtag("li"); HTMLtag("/li")
     cat("Roofs and roads prevent water from filtering into the soil,
     resulting in reduced dry-weather flows.  You score a higher EB
     if you have a filtration system that allows adequately slow,
     filtered flow get to the stream over the whole year.", BR, BR)
     HTMLtag("li"); HTMLtag("/li")
     cat("The stormwater flowing through pipes is polluted.  You score
     a higher EB if you have a filtration system that provides
     filtered flows with reduced concentrations of the pollutants
     nitrogen, phosphorus and suspended sediments.")
     HTMLtag("/li"); HTMLtag("/ol")
     cat("The 'Your tank' and 'Your rain-garden tabs' (above) will
     help you design a system that will provide the greatest
     protection to Little Stringybark Creek and give you the best
     possible EB.")
     HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
     HTMLoff()
       
     HTMLon()
     H("input", type="button", value="...then click here to find the potential EB this property can earn",
       onclick="thisPage.calcTab1()",
     style="font-family:arial;font-size:10pt;background-color:#92BCE6;color:#745A32")
    HTMLoff()
    

Tank, rain-garden tabs?...

Before going on to the tank and rain-garden tabs, make sure you press the
blue button to refresh any new information entered on this tab.

     HTMLon()
     H("input", type="button", value="Click here for confirmation of information entered so far",
       onclick="javascript:thisPage.refreshTab2()", 
       style="font-size:10pt;color:#B22222;background-color:#92BCE6;font-weight:bold")
    HTMLoff()
    
        if(sum(ls() %in% c("percroof", "firstflush", "tankvol", "isgarden", "garden.area", "npeople",
                        "carfreq", "iscar", "istoilet", "iswmac", "ishw"))  == 0){
        firstflush <- tankvol <- carfreq <- garden.area <- percroof <- npeople <- ""
        isgarden <- iscar <- istoilet <- iswmac <- ishw <- 0
                                                                       }
        if(sum(ls() %in% c("Af", "Ap", "perim")) == 0){Af <- NA; Ap <- NA; perim <- NA}
        ffto <- "land- not a rain-garden"
    
     if(sum(dir() == "tankdata.RData") == 1)
       {
       load("tankdata.RData")
       }
     HTMLon()
     if(roofarea == 0 & pavearea == 0){  
     cat("Before filling in this form, you need to have filled in all your property details on the 
               Property tab", BR, "(If you have already filled in the
          property tab, press the above 'refresh' button.)", BR, BR)
                                                      }
     HTMLtag("b")
     cat("Roof area:")
     HTMLtag("/b")
    if(roofarea > 0){
     percroof1 <- 0
     type <- "text"; type1 <- "hidden"
     cat(BR, "You estimated that your property has", roofarea, 
               "sq m of roof connected to underground street drainage.", BR, 
               "Enter the percentage of this roof area that will drain to your tank below." ,BR)
                         }
      HTMLoff()
     HTMLon()
     cat("Percentage of roof area draining to tank:")
     HTMLinput("percroof", percroof, size=3, type="text", 
               id="inpr", style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
     cat("%")
     BR; BR
     HTMLtag("b")
     cat("The tank:")
     HTMLtag("/b")
     cat(BR, "Volume of tank to be installed: ",
         HTMLinput("tankvol", tankvol, size = 6, id="intv", 
              style="font-family:arial;font-size:10pt;color:#745A32;text-align:right"), "litres", BR, 
         "Volume of first flush")
     HTMLinput("firstflush", firstflush, size = 3, id="inff",
            style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
     cat("litres, to be diverted to ")
     HTMLselect("ffto", id="selectffto", 
                text=c("land- not a rain-garden",
                         "a rain-garden",
                         "the stormwater drain"), 
                optionvalue="",
                style="font-family:arial;font-size:10pt;color:#745A32")
      HTMLoff()


Tip...

The larger the area you can capture
with your tank, the better


Tip...

Tanks are typically 2000 to 10000 litres.
While bigger tanks have bigger yields,
the increase in yield diminishes as tanks get
bigger. You can create some graphs (on the
Tank comparisons tab) to explore this once
you have pressed the 'calculate' button below.


Tip...

  • First-flush diverters are common plumbing options for rainwater tanks
    They help keep contaminants out of the tank. Typically, they are diverted
    straight to the stormwater system, but to be eligible for Stormwater Fund
    first-flush diverters must drain to land or perhaps a rain-garden.
  • A typical number of litres in a first flush device is one-fifth of the roof area in sq m.
  • If you don't want a first-flush diverter, then set the 1st-flush volume to zero.
  • You can set the tank volume to zero if you have downpipes that you can't
    drain to a tank, but can have a first-flush diverter attached.
    This still has some environmental benefit.
      isgarden <- as.logical(isgarden); istoilet <- as.logical(istoilet)
      iswmac <- as.logical(iswmac); ishw <- as.logical(ishw)
     HTMLon()
     HTMLtag("b")
     cat("Uses:")
     HTMLtag("/b")
     cat(BR, "Check the uses that the tank water will be for:",BR)
         HTMLcheckbox("isgarden", text = "Garden watering") 
#            HTMLcheckbox("iscar", text = "Car washing")                           
         HTMLcheckbox("istoilet", text = "Toilet flushing")
         BR
         HTMLcheckbox("iswmac", text = "Washing machine")
         HTMLcheckbox("ishw", text = "Hot water system,") 
      HTMLoff()
      isgarden <- as.numeric(isgarden); istoilet <- as.numeric(istoilet)
      iswmac <- as.numeric(iswmac); ishw <- as.numeric(ishw)
     

Tip...

These are the most common options that use a lot of water.
Drinking water and water for car washing make very little
difference to annual water yields, so we have left them out.
There are some tips on using this calculator to test the
effects of different uses on the tips and hints page.
If you have an additional use for large volumes of water,
that you would like to be included in your EB score for the
Stormwater Fund program, please contact Darren Bos:
dbos@unimelb.edu.au
Ph: 8344 9248 Mobile: 0447 551 522

      HTMLon()
      HTMLtag("b")
      cat("Factors affecting usage patterns:")
      HTMLtag("/b")
      BR 
      cat("Number of people living on the property:  ")
      HTMLinput("npeople", npeople, size = 2, id="innp", 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right"); BR
      cat("Area of garden to be watered (not including any rain-gardens)")
      HTMLinput("garden.area", garden.area, size = 4, id="inga", 
        style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
      cat("sq m"); BR
    



        if(tab1 == 0) {
        stop("Please fill in the Property tab, and press the step 1
        button on that tab, before using this tab.", call. = FALSE)
                                       }
 #     if(length(ls()[ls() == "params"]) == 0){
 #        params <- c(1,0,999,432,100,1, 9) }
      if(percroof == "" & roofarea > 0)
        stop("Please enter a value in all boxes.", call. = FALSE)
      if(tankvol == 0){
         istoilet <- iswmac <- ishw <- garden.area <- 0; isgarden <- npeople <- 1
         cat("Note: tank volume is zero.
              These results model the effect of a first-flush diverter by itself.")
                       }
      if(tankvol == "" | firstflush == "" | npeople == "" |
        garden.area == "") {
         cat(tankvol, firstflush, npeople)
         stop("Please enter a value in all boxes.", call. = FALSE)
                              }
      if(sum(isgarden, istoilet, iswmac, ishw) == 0 & tankvol > 0)
         stop("Please select at least one use for your tank.", call. =  FALSE) 
      if(roofarea == 0 & percroof == "") percroof <- 0
      isgarden <- as.logical(isgarden); istoilet <- as.logical(istoilet)
      iswmac <- as.logical(iswmac); ishw <- as.logical(ishw)
      iscar <- 0
      if(npeople == 1)  npeople <- 2
 #     if(sum(c(tankvol, 
 #          (roofarea*percroof)/100, firstflush, npeople, garden.area) != params) > 0)
 #            {
         if(length(ls()[ls() == "garden.area"]) == 0 | garden.area == "") 
            stop("Please enter a value for garden area- zero if the
                  tank won't be used for garden watering", call. = FALSE)
 #             }
         if(percroof > 100 | percroof < 0)
            stop("Please make sure that the percentage value is between 0
                  and 100", call. =  FALSE)
      hastank <- TRUE
      perc.roofarea <- round(roofarea*(100-percroof)/100,0)
      perc.pavarea <- pavearea
      firstflush <- as.numeric(firstflush)
      temp <- tankstats(dailyrunoff = dro3y, 
	                tankvol = tankvol,
                        carea = roofarea*percroof/100, #tankbegin = startvol, 
                        firstflush =  firstflush,
                        npeople = npeople, 
                        garden.area = garden.area)
      tankEB.av <- tank.EBstats(budget = temp$budget, 
                                subset = 1:365, 
                                usage.descs = temp$usage.descs,
		                carea = roofarea*percroof/100,
                                mean.annrain.mm = 954,
                                ndaysro.target = 12)
      tankEB.dry <- tank.EBstats(budget = temp$budget, 
                                subset = 366:730, 
                                usage.descs = temp$usage.descs,
		                carea = roofarea*percroof/100,
                                mean.annrain.mm = 954,
                                ndaysro.target = 12)
      tankEB.wet <- tank.EBstats(budget = temp$budget, 
                                subset = 731:1095, 
                                usage.descs = temp$usage.descs,
		                carea = roofarea*percroof/100,
                                mean.annrain.mm = 954,
                                ndaysro.target = 12)
      n.uses <- dim(tankEB.av)[1]
      yieldrange <- data.frame(usage = tankEB.dry$uses,
                         consumption = as.vector(temp$consumption[1,]),
                         low = tankEB.dry$yield.kL.y,
                         av  = tankEB.av$yield.kL.y,
                         high = tankEB.wet$yield.kL.y)
      max.harvestable <- roofarea*percroof*sum(dro3y$runoff.mm.d[731:1095])/100000
      av.harvestable <- roofarea*percroof*sum(dro3y$runoff.mm.d[1:365])/100000

      uses <- c(1*isgarden, 2*iscar, 3*istoilet, 4*iswmac, 5*ishw)
      match.use <- sum(uses[order(uses)] != temp$uses.matrix[1,order(temp$uses.matrix[1,])])
      for(i in 2:dim(temp$uses.matrix)[1]){
           match.use <- c(match.use,sum(uses[order(uses)] != temp$uses.matrix[i,order(temp$uses.matrix[i,])]))
           prefindex <- which(match.use == 0)
                                      }
      pref.EBstats <- tankEB.av[prefindex,]
      total.runoff <- sum(temp$budget$inflow[1:365])
      pref.yield <- yieldrange[prefindex,]
if(ffto == "the stormwater drain")
  {
  pref.EBstats$ff.index <- 0
  pref.EBstats$total.EB <- pref.EBstats$vr.index/4
   }
wsgh <- ifelse(tankvol < 600, 0, 
               ifelse(tankvol < 2000 & istoilet, 300,
                      ifelse(tankvol < 4000 & (istoilet | iswmac), 500, 
                             ifelse(istoilet & iswmac, 1000, 
                                    ifelse(istoilet | iswmac, 900, 0)))))
nrgi <- ifelse(tankvol < 2000, 0, 
               ifelse(tankvol < 4000 & (istoilet | iswmac), 400,
                      ifelse(tankvol >= 4000 & (istoilet | iswmac), 500, 0)))
     HTMLon() # switch to html mode
     HTMLtag("p style='font-size:11pt'")
     cat("This tank will earn an Environmental Benefit Score
	  of ")
     HTMLtag("b") 
     cat(round(pref.EBstats$total.EB,2))
     HTMLtag("/b") ; HTMLtag("/p")
     HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
     HTMLtag("p style='font-size:11pt'")
     cat("It could gain the following funding:"); HTMLtag("/p")
     HTMLtag("table width='98%'");  HTMLtag("tr"); HTMLtag("td")
     cat("Current (minimum) funding from the Little Stringybark Creek project")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", pref.EBstats$total.EB * current.price, sep="")
     HTMLtag("/td"); HTMLtag("/tr");  HTMLtag("tr"); HTMLtag("td")
     cat("+ (potential)")
     HTMLtag("a
      href='http://www.ourwater.vic.gov.au/saving/home/rebates',
      target=_blank  style='color:#745A32'")
     cat("Victorian Water Smart Homes and Gardens rebate")
     HTMLtag("/a")
     cat("of")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", wsgh, sep="")
     HTMLtag("/td"); HTMLtag("/tr");  HTMLtag("tr"); HTMLtag("td")
     cat("+ (potential)")
     HTMLtag("a
      href='http://www.environment.gov.au/water/programs/nrgi/index.html',
      target=_blank  style='color:#745A32'")
     cat("National Rainwater and Greywater Initiative rebate")
     HTMLtag("/a")
     cat("of")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", nrgi, sep="")
     HTMLtag("/td"); HTMLtag("/tr"); HTMLtag("/table")
     HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
     HTMLtag("table width='98%'"); HTMLtag("tr"); HTMLtag("td")
     cat("TOTAL (MINIMUM) FUNDING FOR THIS SYSTEM")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", nrgi + wsgh + pref.EBstats$total.EB * current.price, sep="")
     HTMLtag("/td"); HTMLtag("/tr"); HTMLtag("/table")
     HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
     BR
     HTMLh4("Suggestions for improving your EB score")
     if(ffto == "the stormwater drain"){
           cat("Your score has been handicapped by diverting the
      first flush to the stormwater system, which doesn't reduce the
      number of days that stormwater runs to the creek from your
      property each year.", HTMLtag("b"),  "(This type of set-up is ineligible for
      stormwater Fund.)", HTMLtag("/b"), " Try diverting the first flush to land or to a
      rain-garden.", BR, BR)
                                         }
     cat("This tank system will provide ", pref.yield[1,4],
         " kilolitres of water in an average year, which is about ",
         round(100*pref.yield[1,4]/(npeople*78),0), "% of the average
	consumption of ", npeople, " people.", BR, sep="")
     if(pref.yield[1,4] < 0.70*sum(dro1y$runoff.mm)*(roofarea)/1000){
      cat(BR, "To increase the yield of water you can harvest from this tank, try more uses or a bigger tank ")
                                                                             }
     if(pref.yield[1,4] < 0.70*sum(dro1y$runoff.mm)*(roofarea)/1000 & percroof < 100){
            cat("or try connecting more of your available roof area.")
                                                                                                         }
     cat(BR,BR, "To see the effect of different uses and different
		 tank sizes, see the 'Tank comparisons' tab")
     cat(BR, BR, "Your EB is only ",
     round(10000*pref.EBstats$total.EB/(roofarea + pavearea),0), 
     "% of the maximum potential EB of your property (", 
     round((roofarea + pavearea)/100, 2),
     ").  A rainwater tank by itself could achieve at best an EB of ",
     round(maxEBItank,2),
     ", because:", sep="")
     HTMLtag("ol class='body' style='list-style-type:lower-alpha'")
     HTMLtag("li")
     cat("it does not capture water from paved areas;")
     HTMLtag("/li"); HTMLtag("li")
     cat("if it overflows into the stormwater drainage system, it is
	  not allowing water be filtered and delivered slowly to the stream.")
     HTMLtag("/li"); HTMLtag("/ol")
     cat("To achieve closer to the full potential EB of your property,
	  you need to direct the tank's overflow (and any paving
	  runoff) to an infiltration system.  To see how much your EB
	  can be improved by doing this, go onto the 'Your
	  rain-garden' tab", BR)
     if(ffto == "a rain-garden"){
           cat(BR, "You have opted to divert your first-flush to a
      rain-garden. This tab assumes that this first
      flush has no environmental impact, but it will be included as
      part of the inflow into your raingarden on the next tab.", BR)
                                 }
     HTMLh4("Technical details")
     tank.summary$Value <-  c(round(pref.EBstats$ro.d,0),
                     round(pref.EBstats$rod.target,0),
                     pref.EBstats$ff.index,
                     round(pref.EBstats$volred.L/1000,1),
                     round(pref.EBstats$volred.target/1000,1),
                     pref.EBstats$vr.index,
                     0,
                     round((total.runoff - pref.EBstats$volred.target)/1000,0),
                     (roofarea*percroof/100)*0.1,  
		     0,		
                     0.35, #need to think about this percentile
                           #problem (do we count no flow as 0?)
                     0.05,
                     2.2,
                     0.6,
                     150,
                     20,
                     0,
                     pref.EBstats$total.EB)
     Html(tank.summary)
     save(roofarea, pavearea, percroof, tankvol, firstflush,
      ffto, isgarden, istoilet, iswmac, iscar, ishw, npeople,
      garden.area, hastank, nrgi, wsgh, file = "tankdata.RData")
     tank.summ <- data.frame(var = 
     c("roofarea", "pavearea", "percroof", "tankvol", "firstflush",
      "ffto", "isgarden", "istoilet", "iswmac", "ishw", 
      "npeople", "garden.area"),
     description = c("Total connected roof area (sq m)",
     "Total connected paved area (sq m)", 
     "Roof area draining to tank (sq m))",
     "Tank volume (L)",
     "Volume of first-flush diverter on tank",
     "first flush goes to...",
     "tank water is used for garden irrigation",
     "tank water is used for toilet flushing",
     "tank water is used for washing machine/laundry",
     "tank water is used for a hot water system",
     "number of people in the house",
     "area of garden to be irrigated (sq m)"),
     value = c(roofarea, pavearea, percroof, tankvol,
      firstflush, ffto, isgarden, istoilet, iswmac,
      ishw, npeople, garden.area))
     summ <- tank.summ
     HTMLoff()
     
The rain-garden's catchment
              if(sum(ls() %in% c("carea.garden", "carea.garden1","isveg", "Hp", "Hf",
                        "medium", "isoutlet", "Ho", "lined.bottom", "lined.side", "perc.pavearea", 
                        "perc.roofarea", "shape", "dim1", "dim2", "deltaAp", "shapesel"))  == 0){
        if(roofarea == 0 & percroof == "") percroof <- 0
        nrgi <- wsgh <- 0
        carea.garden <- carea.garden1 <- Ap <- Af <- Hp <- Hf <- medium <- Ho <- perc.pavearea <- ""
        shape <- dim1 <- dim2 <- deltaAp <- perc.roofarea <- ""
        lengtha <- lengthb <- shapesel <- ""
        isveg <- currentshape <- 1
        isoutlet <- lined.bottom <- lined.side <- lined.walls <- 0
                                                                       }
        shapes <- data.frame(n = 1:4, 
                             shape.desc = c("Select the shape that best describes the surface of your raingarden",
                                            "rectangular","circular or oval","irregular"),
                             shape = c("","rectangle", "circle", "irreg"))
        rgtotank <- c("How will your raingarden interact with your tank?", 
                      "Rain-garden will take overflow from tank", 
                      "Rain-garden and tank will be completely separate",
                      "Just model rain-garden without tank")
        available.roof <- roofarea
        rgtotank.index <- ifelse(hastank,3,1)
        HTMLon()
        cat("1.")
        HTMLselect("overflowselect", id="selectof",
                   text=rgtotank, optionvalue=rgtotank[1],
        style="font-family:arial;font-size:10pt;color:#745A32")
#######, onchange="javascript:thisPage.refreshTab3()"
        HTMLoff()
     
     HTMLon()
   if(sum(ls() == "hastank") == 0)  hastank <- 0
         if(hastank == 0) {
                           percroof <- 0; overflow <- 0
                           }
     if(sum(ls() %in% c("roofarea", "pavearea")) < 2){
     cat("Before filling in this tab, you need to have filled in your
          property details on the Property tab", BR, "(If you have already filled in the
          property tab, press the above refresh button.)",BR, BR)
                                                                                            }
     if(roofarea == "" | pavearea == "" ){ 
     cat("Before filling in this tab, you need to have filled in all
          your property details on the Property tab", BR, "(If you have already filled in the
          property tab, press the above refresh button.)",BR, BR)
                                                                                            }
     if(overflowselect == rgtotank[1]) 
          {cat("")}
     if(!hastank & overflowselect %in% rgtotank[2:3])
          cat("You haven't entered any tank details. Without tank
   details, you can only choose 'Just model rain-garden without tank'")
     if(overflowselect == rgtotank[2])
          {
           load("tankdata.RData")
           nrgi2 <- nrgi
           wsgh2 <- wsgh
           tankoverflow <- 1
           available.roof <- round(roofarea*(100-percroof)/100,0)
           cat("You listed the following surfaces that do not drain to
      the tank.",BR, available.roof, "sq m of roof.", BR)
      if(pavearea > 0){
      cat(round(pavearea,0), "sq m of paved area", BR)
            }
         }
     if(overflowselect == rgtotank[3])
           {
            load("tankdata.RData")
            nrgi2 <- nrgi
            wsgh2 <- wsgh
            tankoverflow <- 0
            available.roof <- round(roofarea*(100-percroof)/100,0)
            cat("You listed the following surfaces that do not drain to
      the tank.",BR, available.roof, "sq m of roof.", BR)
            if(pavearea > 0){
               cat(round(pavearea,0), "sq m of paved area", BR)
                             }
             }
      if(round(pavearea,0) + available.roof == 0)
             {
       cat("i.e. all the roof area you listed is draining to the tank")
              }
    if(overflowselect == rgtotank[4])
       {
      nrgi2 <- 0
      wsgh2 <- 0
      hastank <- 0
      tankoverflow <- 0
      available.roof <- roofarea
     cat("You listed the following surfaces that could potentially
    drain to the raingarden",BR,round(roofarea,0), "sq m of roof.", BR)
      if(pavearea > 0){
      cat(round(pavearea,0), "sq m of paved area", BR)
         }
            }

  HTMLoff()
    

       HTMLon()
          cat("Enter the areas of each surface that will drain to the raingarden")
         cat(BR, "2. Area of roof draining to the raingarden:") 
         HTMLinput("perc.roofarea", perc.roofarea, size = 3, value = available.roof, id = "prain", 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
         cat("sq m"); BR
         cat("3. Paved area draining to the rain-garden: ") 
         HTMLinput("perc.pavearea", perc.pavearea, size = 3, 
         value=round(pavearea,0), id="ppain", 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
         cat("sq m"); BR; BR
       HTMLtag("b")  
       cat("The rain-garden's design ")
       HTMLtag("/b")  
       cat("(except for item 1, compulsory itens are filled with
  typical values)"); BR; BR

       cat("1. Shape and size.", BR)
        HTMLselect("shapesel", as.vector(shapes$shape.desc),
        id="shapeSelect" ,value = currentshape,
        style="font-family:arial;font-size:10pt;color:#745A32")
        HTMLoff()
    

Tip...

The size of your raingarden is one of the most important features that affect its performance.
From the dropdown list, choose the shape that best describes the raingarden at its surface.
If you are unsure, select one, and drawings will appear to help you decide.
Once you have decided on a shape, fill in the dimension values in the boxes next to the drawing.

        currentshape <- which(shapes$shape.desc == shapesel)
        shape <- shapes$shape[shapes$shape.desc == shapesel]
         HTMLon()
        HTMLtag("table"); HTMLtag("tr"); HTMLtag("td"); HTMLtag("span style='font-size:10pt;'")
       if(shapesel == "Select the shape that best describes the surface of your raingarden"){
        cat(
        "Select a shape from the dropdown", BR, "box above before putting numbers", BR, 
        "in these boxes")
                          }
        if(shapesel == "rectangular"){
        HTMLembed("rectangle.png", ALT = "Rectangular raingardens",
        width=153, height=207)
                                  }
        if(shapesel == "circular or oval"){
        HTMLembed("ellipse.png", ALT = "Oval or circular raingardens",
        width=153, height=207) 
                                  }
        if(shapesel == "irregular"){
         HTMLembed("irreg.png", ALT = "Irregular raingardens",
        width=153, height=207)
                                    }
        HTMLtag("/td"); HTMLtag("td valign='center'"); HTMLtag("/span")
        HTMLtag("span style='font-family:Arial; font-size:10pt';")
        if(shapesel == "Select the shape that best describes the surface of your raingarden"){
        cat("")
                          }
        if(shapesel == "rectangular"){
        cat(
        "Length in metres", BR, "Width in metres")
                                  }
        if(shapesel == "circular or oval"){
        cat(
        "Length a in metres", BR, "Length b in metres")
                                  }
        if(shapesel == "irregular"){
        cat(
        "Area in sq metres", BR, "Perimeter in metres")
                                   }
        HTMLtag("/span")
        HTMLtag("/td"); HTMLtag("/tr"); HTMLtag("/table")
        HTMLoff()
     
        HTMLon()
        HTMLinput("dim1", dim1, size = 3, id = "ddim1", 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        BR
        HTMLinput("dim2", dim2, size = 3, id = "ddim2", 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        HTMLoff()
    
     HTMLon()
     cat("2. How much bigger is the area at the top of the basin than at its bottom?")
     HTMLinput("deltaAp", deltaAp, size=3, id="dAp", value=0,
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
     cat("%")
     HTMLoff()
    

Tip...

See the drawing below for a plan of a typical raingarden.
The filter is the main part of the garden filled with sand, soil or gravel (the filter medium).
The basin is the top, walled bit above the filter that will occasionally fill with water.
Enter 0% if there is no basin (e.g. if you are building an infiltration system under your lawn)
Enter 0% if the basin walls are vertical, and the basin is the same area as the filter.
Enter 10% if the basin area is 10% bigger than the filter area.

        HTMLon()
        cat("3. Check")
        isveg <- TRUE
        HTMLcheckbox("isveg", text = "", checked="checked")
        cat(" if the rain-garden has plants:")
        HTMLoff()
   

Tip...

See the drawing below for a plan of a typical raingarden.
Most raingardens will have plants, but infiltration systems won't.
If you are building an infiltration system below your lawn, select 'No' here,
because the filter will be separated from the lawn by a geotextile layer.
Stormwater Fund requires that at least half of the plants in rain-gardens
are from the recommended list of plants (See the FAQ page)

Plan of generic raingarden
        lined.side <- 0; lined.bottom <- 0; topsoil.depth <- 0
        isoutlet <- as.numeric(isoutlet)
        isoutlet <- as.numeric(isveg)
        lined.bottom <- as.numeric(lined.bottom)
        lined.side <- as.numeric(lined.side)
        topsoil.depth <- as.numeric(topsoil.depth)
        HTMLon()
        cat("4. How deep is the basin?  ")
        Hp <- 20
        HTMLinput("Hp", Hp, size = 4, id = "inHp", value = 20,
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        cat("cm"); BR
        cat("5. How deep is the filter?")
        Hf <- 100
        HTMLinput("Hf", Hf, size = 4, id = "inHf", value = 100, 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        cat("cm"); BR; BR
        cat("6. How far below the surrounding soil surface is the top of the filter?")
        topsoil.depth <- 0
        HTMLinput("topsoil.depth", topsoil.depth, size = 4, id = "intsd", value = 0, 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        cat("cm"); BR; BR
        cat("7. What medium is the topmost layer of the filter?"); BR
        HTMLselect("medium", text = c("loamy sand", "sand",
                   "gravel (scoria)"), id="selectmedium", optionvalue = "1" , 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right"); BR; BR
        cat("8. Check")
        HTMLcheckbox("isoutlet", text = "")
        cat(" if there is an standpipe with an outlet.");BR; BR
        cat("8a. If so, how high is its outlet pipe?")
        HTMLinput("Ho", Ho, size = 3, id = "inHo", 
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        cat("cm"); BR; BR
        cat("9. Check")
        HTMLcheckbox("lined.bottom", text = "")
        cat(" if the bottom of the rain-garden is lined."); BR; BR
        cat("10. What percentage of the sides is lined? ") 
        lined.side <- 0
        HTMLinput("lined.side", lined.side, size = 3, id = "lined.side", value = 0,
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        BR; BR
        cat("11. (If the garden is not completely lined), How wide is
        the canopy of any tree within 3 m of the rain-garden? ")
        BR
        cat("(add canopy widths together)") 
        adjtreed <- 0
        HTMLinput("adjtreed", adjtreed, size = 3, id = "inadjtreed", value = 0,
         style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
        cat("m")
        BR
        HTMLoff()
    

Tip...

Basins are typically 10-30 cm deep,
to allow for a short period of ponding during heavy rain.
Filters are typically 50-100 cm deep




Tip...

The best EB scores will be earned by systems with standpipes that allow
a controlled flow out of the filter, or by systems that have no standpipe
and let water filter out into surrounding soils. If the rain-garden is lined,
it will need a stand pipe. We do not recommend systems with slotted under-
drains with uncontrolled outflow. See the results for the appropriate outlet
flow rate for your system.






Tip...

Enter 0 if the walls are completely unlined.
Generally, rain-gardens will perform better if they are unlined,
but if the rain-garden is built very close to a building or road, then the sides
and bottom should be lined. If you plan to build the raingarden within 5 metres of
a building, seek advice. Buildings and roads can be protected by lining the closest
side(s) and leaving sides draining to gardens unlined.





(This will take ~20 seconds to calculate)

        if(tab1 == 0) {
        stop("Please fill in the Property tab, and press the step 1 button on that tab, before using this tab.", call. = FALSE)
                                       }
        if(shape == "")
        stop("You must select a shape for your raingarden from the dropdown box above", call. = FALSE)
         if(dim1 == "" | dim2 == "" | Hp == "" |Hf == "" | 
           medium == ""| ((Ho == "" | is.na(Ho)) & isoutlet == 1))
         stop("Please enter a value in all boxes.", call. = FALSE) 
         if(hastank){
         if(pavearea == 0) {perc.pavearea <- 0
                             } else {
                                    perc.pavearea <- as.numeric(perc.pavearea)
                                     }
         if(roofarea*(100-percroof)/100 == 0) {perc.roofarea <- 0} 
                      }
        perc.roofarea <- as.numeric(perc.roofarea); perc.pavearea <- as.numeric(perc.pavearea)
        carea.garden <- perc.roofarea + perc.pavearea  #note these odd names are a hangover 
                                             #from early code and equal actual areas in sq m
 
      Ho <- as.numeric(Ho); Hp <- as.numeric(Hp); Hf <- as.numeric(Hf)
      if(carea.garden == 0 & tankoverflow == 0)
       stop("No roof area or paved area has been identified as draining to this rain-garden", call. = FALSE)
      if(carea.garden == 0 & tankoverflow == 1)
       cat("Note: you have opted for the raingarden to only receive overflow from the tank, and no other runoff.")
      deltaAp <- as.numeric(deltaAp); lined.bottom <- as.numeric(lined.bottom)
      lined.side <- as.numeric(lined.side); adjtreed  <- as.numeric(adjtreed)
      topsoil.depth <- as.numeric(topsoil.depth)
      adjtreea <- pi*(adjtreed/2)^2
      if(lined.side > 100)
        stop("Percentage of sides lined cannot exceed 100%", call.=FALSE)
      if(isveg & medium == "gravel (scoria)")
         stop("Sorry: the calculator does not allow vegetated gravel systems", call. = FALSE)
      isveg <- as.numeric(isveg)
      if(tankoverflow == 0 | ffto != "a rain-garden"){ firstflushtorg <- 0} else {firstflushtorg <- firstflush}
      if(shape == "circle"){
          Af <- round(pi*dim1*dim2*0.25,1)
          perim <- round(pi*(3*(dim1*0.5 + dim2*0.5) - ((1.5*dim1 + 0.5*dim2)*(0.5*dim1 + 1.5*dim2))^0.5),1) 
                       #Ramanujan's approximation formula from Wikepedia
                            }
      if(shape == "rectangle"){
          Af <- dim1*dim2; perim <- 2*dim1 + 2*dim2
                               }
      if(shape == "irreg"){
          Af <- dim1; perim <- dim2
                                }
      perim <- perim*(1 -lined.side/100)
      Ap <- (100 + deltaAp)*Af/100
      isoutlet <- as.numeric(isoutlet)
      if(isoutlet == 1 & Ho > Hf)
        stop("Outlet pipe height cannot be greater than filter depth", call. = FALSE)
      if(isoutlet == 0) 
          Ho <-  Hf + Hp
      carea.tank.overflow <- ifelse(tankoverflow == 1, roofarea*percroof/100, 0) 
 #### calculate filter profile
#      fp <- "/var/www/Rpad/filtprof.RData"
      filtprof <- set.filtprof(Hp = Hp/100,  #filtr.prfile = fp,  (default not necessary)_
                   Hf = Hf/100, Af = Af,
                   topsoil.depth = topsoil.depth/100,
                   medium = medium, lined.side = lined.side) 
      if(tankoverflow){
              gardenQin <- compile.inflow(hrunoff = hro1y,
                                  carea = carea.garden,
                                  doverflow = data.frame(date = dro1y$daten,
                                                         Qover = temp$budget$overflow[dro3y$year < 1967,prefindex]), 
                                  firstflush = firstflushtorg, 
                                  carea.tank = carea.tank.overflow)
              Qin <- gardenQin$inflow
                       } else {
              Qin <- data.frame(datetime = hro1y$datetime,
                            date = hro1y$date,
                            year = hro1y$year,
                            month = hro1y$month,
                            inflow.L = hro1y$runoff.mm * carea.garden,
                            runoff = hro1y$runoff.mm * carea.garden,
                            tank.overflow = 0,
                            tank.firstflush = 0)
                               }
       gardenstats <- gardenmodel(inflow = Qin,
                     et = hro1y$ETmmh,
                     Af = Af, Pf = perim,   #sq m and m
                     Hf = Hf/100,   #m converted from cm
                     Ap = Ap,       #sq m
                     Hp = Hp/100,
                     isveg = isveg,   #m converted from cm
                     Ho = Ho/100,   #m converted from cm
                     Vstart = 0.5*0.4*Hf*Af*10,
                                        #L, converted from cm and  sq m, assumes half-full and porosity of 0.4
                     adj.tree.canopy.area = adjtreea,
                     carea = carea.garden, 
                     Ksu.mm.h = ifelse(lined.bottom, 0, 0.005),
                     outlet.rate.L.h = (carea.garden + carea.tank.overflow + Af)*0.069,
                     filtr.prfile = filtprof,
                     medium = medium
                                  )
      garden.indices <- garden.EBstats(gardenstats$budget, carea =
      carea.garden + carea.tank.overflow, gardenarea = Af)
      names(garden.indices)[names(garden.indices) == "index.score"] <- "total.score"
      if(!tankoverflow & hastank){
      names(garden.indices)[names(garden.indices) == "total.score"] <- "garden.score"
      garden.indices$tank.score <- c(pref.EBstats[1,4],0,pref.EBstats[1,8],0,0,0,0,pref.EBstats[1,9])
      garden.indices$total.score <- garden.indices$tank.score + garden.indices$garden.score
      garden.indices <- garden.indices[,c(1,2,3,5,4,6)]
                             }
      if(tankoverflow & hastank){
      tcarea <- carea.garden + carea.tank.overflow
      garden.indices$treatment[3] <- round(min(tcarea*sum(dro1y$runoff.mm.d)/1000,
                               pref.EBstats$volred.L/1000 +
      garden.indices$treatment[3]),1) #vol.red (kL)
        #total volume reduction = minimum of total runoff (to avoid
        #possible overperformance by starting half full and ending less
        #than half-full) and addition of tank + garden volume reduction
      if(firstflushtorg > 0)
          {
      garden.indices$treatment[3] <- garden.indices$treatment[3] - round(sum(Qin$tank.firstflush)/1000,1)
         } 
      Zhang.forest.ro <- 950*(1 - (1 + 2820/950)/(1 + 2820/950 + 950/1410))
      Zhang.pasture.ro <- 950*(1 - (1 + 550/950)/(1 + 550/950 + 950/1100))
      garden.indices$target[3] <- round((tcarea*sum(dro1y$runoff.mm.d) - tcarea*Zhang.forest.ro)/1000, 0) #volred.target 
                               #impervious runoff minus runoff from mature forest according to Zhang curve.
      filtvol.hitarget <- Zhang.pasture.ro*(tcarea)
      filtvol.lowtarget <- Zhang.forest.ro*(tcarea)
      garden.indices$target[2] <- round(filtvol.hitarget/1000, 0)
      filtvol <- sum(gardenstats$budget$Qexf) + 
                       sum(gardenstats$budget$out[gardenstats$budget$out <= 0.1*tcarea])  #0.1 = filtro.target
                if(filtvol > filtvol.hitarget)
                  {
                   if(filtvol.upstream + sum(gardenstats$budget$out[budget$out <= 0.1*tcarea] < filtvol.hitarget))
                      {
                        filtvol <- filtvol.hitarget
                      }else{
                   filtvol <- filtvol.upstream + sum(gardenstats$budget$out[budget$out <= 0.1*tcarea])
                            }
                   fro.index <- max(0, 1 - (filtvol - filtvol.hitarget)/filtvol.lowtarget) * tcarea/100
                   }#filtvol includes Qexf up to the target, but only out is include above target
                if(filtvol < filtvol.lowtarget)
                  {
                    fro.index <- filtvol*tcarea/(filtvol.lowtarget*100)
                  }
                if(filtvol >= filtvol.lowtarget & filtvol <= filtvol.hitarget)
                  {
                    fro.index <- tcarea/100
                  }
      garden.indices$total.score[2] <- round(fro.index,2)
      garden.indices$total.score[3] <- round((1 - (garden.indices$target[3] - 
                                             garden.indices$treatment[3])/garden.indices$target[3]) * 
                                             (carea.garden + carea.tank.overflow)/100,2)
      garden.indices$total.score[8] <- round(mean(garden.indices$total.score[c(1,2,3,7)]),2)
      garden.indices$tank.alone <- c(pref.EBstats[1,4],0,pref.EBstats[1,8],0,0,0,0,pref.EBstats[1,9])
      garden.indices <- garden.indices[,c(1,2,3,5,4)]
                             }
      inflows <- data.frame(Source = c("Direct inflow from roofs and paving", 
                                       "Overflow from tank",
                                       "First flush from tank",
                                       "Total inflow"),
                            Volume.kL.yr = c(round(sum(Qin$runoff)/1000,1),
                                             round(sum(Qin$tank.overflow)/1000,1),
                                             round(sum(Qin$tank.firstflush)/1000,1),
                                             round(sum(Qin$inflow.L)/1000,1)))
     garden.summ <- data.frame(var =
             c("overflow", "perc.roofarea", "perc.pavearea", 
               "Af", "Ap", "perim", "isveg", "Hf", "Hp", "isoutlet",
               "Ho","medium", "lined.side", "lined.bottom",
      "topsoil.depth", "adjtreea"),
             description = c("Tank overflows to rain-garden",
             "Roof area (not draining to tank) that drains to rain-garden (sq m)",
             "Paved area (not draining to tank) that drains to rain-garden (sq m)",
             "Area of filter (sq m)", "Area of pond (sq m)",
             "Perimeter of filter (m)", "The rain-garden is vegetated", 
             "Height of filter (cm)", "Height of pond (cm)",
             "The rain-garden has an outlet pipe",
             "Height of outlet pipe (cm)",
             "topmost medium of the rain-garden",
             "% of the rain-garden walls that are lined",
             "bottom of the rain-garden is lined",
             "depth of soil above filter (for under-lawn infiltration
      systems) (cm)", 
              "Area of tree canopy within 3 m of rain-garden (sq m)"))
    tank.and.garden <- 
                    c(round(garden.indices$treatment[1],0),
                     round(garden.indices$target[1],0),
                     garden.indices$total.score[1],
                     round(garden.indices$treatment[3],1),
                     round(garden.indices$target[3],1),
                     garden.indices$total.score[3],
                     round(garden.indices$treatment[2],0),
                     round(garden.indices$target[2],0),
                     (carea.garden + carea.tank.overflow + Af)*0.1,
                     garden.indices$total.score[2],
                     round(garden.indices$treatment[5],1),
                     round(garden.indices$target[5],1),
                     round(garden.indices$treatment[4],1),
                     round(garden.indices$target[4],1),
                     round(garden.indices$treatment[6],1),
                     round(garden.indices$target[6],1),
                     garden.indices$total.score[7],
                     garden.indices$total.score[8])
    if(hastank)
     {
      garden.summ$value <- c(overflow, perc.roofarea, perc.pavearea, 
               Af, Ap, perim, isveg, Hf, Hp, isoutlet,
               Ho, medium, lined.side, lined.bottom, topsoil.depth, round(adjtreea,1))
     } else {
      garden.summ$value <- c(0, perc.roofarea, perc.pavearea, 
               Af, Ap, perim, isveg, Hf, Hp, isoutlet,
               Ho, medium, lined.side, lined.bottom, topsoil.depth, round(adjtreea,1))
             }    
    if(hastank)
      {
     garden.summary <- tank.summary
     names(garden.summary)[2] <- "tank"
     garden.summary$tank.and.garden <- tank.and.garden
     summ <- rbind(tank.summ, garden.summ)
         } else {
     garden.summary <- data.frame(Detail = tank.summary$Detail,
     garden.value = tank.and.garden)
     summ <- garden.summ
                }
      HTMLon()
      if(lined.bottom & lined.side & Ho == Hf + Hp){
           cat("A problem!  If the rain-garden is fully lined, then
      you need to put in a standpipe with an outlet.", BR, BR)
                                         }

      HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
      HTMLtag("p style='font-size:11pt'")
      if(hastank){
      cat("Together this rain-garden and tank will earn an Environmental Benefit Score
	  of ")
                }else{
       cat("This rain-garden will earn an Environmental Benefit Score
	  of ")
                      }
     HTMLtag("b") 
     cat(garden.indices$total.score[8])
     HTMLtag("/b") ; HTMLtag("/p")
     HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
     HTMLtag("p style='font-size:11pt'")
     cat("It could gain the following funding:"); HTMLtag("/p")
     HTMLtag("table width='98%'");  HTMLtag("tr"); HTMLtag("td")
     cat("Current (minimum) funding from the Little Stringybark Creek project")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", garden.indices$total.score[8] * current.price, sep="")
     HTMLtag("/td"); HTMLtag("/tr");  HTMLtag("tr"); HTMLtag("td")
     cat("+ (potential)")
     HTMLtag("a
      href='http://www.ourwater.vic.gov.au/saving/home/rebates',
      target=_blank  style='color:#745A32'")
     cat("Victorian Water Smart Homes and Gardens rebate")
     HTMLtag("/a")
     cat("of")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", wsgh2, sep="")
     HTMLtag("/td"); HTMLtag("/tr");  HTMLtag("tr"); HTMLtag("td")
     cat("+ (potential)")
     HTMLtag("a
      href='http://www.environment.gov.au/water/programs/nrgi/index.html',
      target=_blank  style='color:#745A32'")
     cat("National Rainwater and Greywater Initiative rebate")
     HTMLtag("/a")
     cat("of")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", nrgi2, sep="")
     HTMLtag("/td"); HTMLtag("/tr"); HTMLtag("/table")
     HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
     HTMLtag("table width='98%'"); HTMLtag("tr"); HTMLtag("td")
     cat("TOTAL (MINIMUM) FUNDING FOR THIS SYSTEM")
     HTMLtag("/td"); HTMLtag("td align='right'")
     cat("$", nrgi2 + wsgh2 + garden.indices$total.score[8] * current.price, sep="")
     HTMLtag("/td"); HTMLtag("/tr"); HTMLtag("/table")
     HTMLtag("hr size=1 width='100%' align=center color='#008CD6'")
     BR
     HTMLh4("Suggestions for improving your EB score")
     Html(garden.indices)
     BR
     cg <- ifelse(hastank & tankoverflow, carea.garden +
      carea.tank.overflow, carea.garden)
     if(!hastank & Af < 0.25*cg){
      cat("Raingardens by themselves can only lose a relatively small
      volume of water through the plants in the garden (unless the
      raingarden is about a third the size of the roofs and roads it
      is draining).  As a result, your raingarden has scored poorly
      for volume reduction.  To increase the environmental benefit of
      your garden, try capturing your roof runoff with a rainwater
      tank and run the overflow into the raingarden")
                                  }
     if(lined.side == 100 &
      garden.indices[8, dim(garden.indices)[2]] < cg*0.9/100){
      cat("If your raingarden has at least one side that is more than 5
      m from a building or road, then try leaving those sides
      unlined. (If 50% of the raingarden walls are to be left
      unlined, enter 50 in box 9 above.)")
                                  }
     if(garden.indices[8, dim(garden.indices)[2]] >= cg*0.9/100){
     cat("This system is treating runoff from its catchment area
      really well.  Well done!")
                                  }
     ###cat("more text to come after review of the calculator so far!")
     BR; HTMLh4("Technical details")
     Html(garden.summary)
     BR
     Html(inflows)
     HTMLh4("Assumed soil and filter profile for this system")
     Html(filtprof)
     HTMLoff()

 

       HTMLon()
       cat("For your selected uses and other set-up details, compare your selected tank size with the following tank
       sizes (you can change these values, but keep commas separating
       them)")
       BR; BR
       H("input", type="text", name="tanklist", value="1000, 2500, 5000, 10000, 20000", id= "tl", size="50", 
       style="font-family:arial;font-size:10pt;color:#745A32;text-align:right")
       BR
      HTMLoff()
       

tanklist <- as.numeric(strsplit(tanklist,",")[[1]]) tanklist <- unique(c(round(tankvol/5,-2)*5,tanklist)); tanklist <- tanklist[order(tanklist)] EBtanks <- data.frame(tankvol = NA, EBI = NA, yieldav = NA, yielddry = NA, yieldwet = NA) for(i in 1:length(tanklist)){ EBtanks[i,1] <- tanklist[i] ttt <- tankstats(dailyrunoff = dro3y, tankvol = tanklist[i], carea = roofarea*percroof/100, #tankbegin = startvol, firstflush = firstflush, npeople = npeople, garden.area = garden.area) tEB.av <- tank.EBstats(budget = ttt$budget, subset = 1:365, usage.descs = ttt$usage.descs, carea = roofarea*percroof/100, mean.annrain.mm = 954, ndaysro.target = 12) tankEB.dry <- tank.EBstats(budget = ttt$budget, subset = 366:730, usage.descs = ttt$usage.descs, carea = roofarea*percroof/100, mean.annrain.mm = 954, ndaysro.target = 12) tankEB.wet <- tank.EBstats(budget = ttt$budget, subset = 731:1095, usage.descs = ttt$usage.descs, carea = roofarea*percroof/100, mean.annrain.mm = 954, ndaysro.target = 12) klsum <- function(x) {round(sum(x)/1000,1)} EBtanks[i,2:5] <- c(tEB.av$total.EB[prefindex], tEB.av$yield.kL.y[prefindex], tankEB.dry$yield.kL.y[prefindex], tankEB.wet$yield.kL.y[prefindex]) } par(mar = c(3.6,3.6,2,2)) plot(EBtanks$tankvol/1000, EBtanks$yieldav, ylim = c(0,max.harvestable), las = 1, type= 'b',,col="blue", xlab = "Tank volume (kL)", ylab = "Annual yield from tank (kL)") ebars(x = EBtanks$tankvol/1000, y0 = EBtanks$yieldav, y1 = EBtanks$yielddry, y2 = EBtanks$yieldwet, col="blue") abline(h = av.harvestable, col = "red") mtext(paste("Yields from tanks draining", roofarea*percroof/100,"sq m roof in a",npeople,"person house", sep = " "), cex= 0.75, padj = -1,col="blue") mtext(paste("used for",tankEB.av$uses[prefindex], sep = " "), cex= 0.75, padj = 1,col="blue") text(mean(range(EBtanks$tankvol))/1000, av.harvestable, "Max. yield from full roof area (in an average year)", col="red", cex=0.6, adj = c(0.5,1)) text(7,0.14*max.harvestable,"Tops of ranges: yield in a wet year (1970)", col="blue", cex=0.6, pos = 4) text(7,0.07*av.harvestable,"Points: yield in an average year (1965)", col="blue", cex=0.6, pos = 4) text(7,0,"Bottoms of ranges: yield in a dry year (1967)", col="blue", cex=0.6, pos = 4) plot(EBtanks$tankvol/1000, EBtanks$EBI, ylim = c(0,maxEBItank), las = 1, type= 'b',,col="blue", xlab = "Tank volume (kL)", ylab = "Environmental Benefit score") abline(h = maxEBItank, col = "red") mtext("EB score earned in relation to tank size",cex= 0.75, padj = -1,col="blue") text(mean(range(EBtanks$tankvol))/1000,maxEBItank,"Maximum EB score that a tank on this property can earn", col="red", cex=0.6, adj = c(0.5,1)) HTMLon() # switch to html mode showgraph() HTMLoff()
       HTMLon()
       BR
       H("input", type="button", value="Show effect of different tank sizes on your  property",
          onclick="javascript:rpad.calculateTree(dojo.byId('tab5b'))",
          style="font-family:arial;font-size:10pt;background-color:#92BCE6;color:#745A32")
       BR; BR
      HTMLtag("i")
      cat("Warning: these plots will take at least 10 seconds to calculate")
      HTMLtag("/i")
      BR; BR
      HTMLoff()
       
      rankcons <- order(tankEB.av$yield.kL.y)
      tankEB.av$consumption <- yieldrange$consumption
      EBstats <-tankEB.av[rankcons,]
      yieldrange <- yieldrange[match(EBstats$uses,yieldrange$usage),]
      plot.new() 
      n.uses1 <- length(-grep("other", EBstats$uses))  
      legend("bottomright",legend = EBstats$uses[-grep("other",
      EBstats$uses)],
           pch = c(letters,1:8)[1:n.uses1],col="blue",cex = 0.6, 
           title = "average(1965) - dry(1967) + wet year(1970)")
      par(mar = c(3.6,3.6,2,2))
      plot(yieldrange$consumption[-grep("other", EBstats$uses)], yieldrange$av[-grep("other", EBstats$uses)], 
         ylim = c(0,ceiling(max.harvestable)),
         pch = c(letters,1:8)[1:n.uses1], las = 1, col = "blue", cex = 0.8,
         xlab = "Total annual demand (kL)", ylab = "Annual yield from tank (kL)")
      mtext(paste("Yield from",tankvol/1000,"kL tank draining",
               round(roofarea*percroof/100,0),"sq m roof in a",npeople,"person house", sep = " "), cex= 0.75, padj = -1,col="blue")  
      ebars(x = yieldrange$consumption[-grep("other", EBstats$uses)], 
            y0 = yieldrange$av[-grep("other", EBstats$uses)], 
            y1 = yieldrange$high[-grep("other", EBstats$uses)], 
            y2 = yieldrange$low[-grep("other", EBstats$uses)], col="blue")
      abline(h = av.harvestable, col = "red")
      text(mean(range(yieldrange$consumption)),av.harvestable,"Max. yield
      from full roof area in an av.yr.)",
           col="red",cex=0.6,adj = c(0.5,1))
      plot(EBstats$consumption[-grep("other",
      EBstats$uses)],EBstats$total.EB[-grep("other", EBstats$uses)],
         ylim = c(0,maxEBItank),
         pch = c(letters,1:8)[1:n.uses1], las = 1, col = "blue", lwd = 2, cex = 0.8,
          xlab = "Total annual demand (kL)", ylab = "Environmental benefit score", type = 'b')
      abline(h = maxEBItank, col = rainbow(6)[1])
      text(mean(range(yieldrange$consumption)),maxEBItank,
         paste("Max EBI from a", round(tankvol/1000,0), "kL tank draining",roofarea,"sq m", sep = " "),
           col=rainbow(6)[1],cex=0.6,adj = c(0.5,1))
       mtext("Environmental benefit score", cex= 0.75, padj = -1,col="blue")      
      HTMLon()
      showgraph()
      BR
      HTMLtag("i")
      cat("You might get different relationships between different uses if you change percentage of roof area, tank size and 
      other factors on the tank calculator page")
      HTMLtag("/i")
      HTMLoff()
         

       HTMLon()
       H("input", type="button", value="Compare water savings with different uses of your tank water",
          onclick="javascript:rpad.calculateTree(dojo.byId('tab5a'))",
          style="font-family:arial;font-size:10pt;background-color:#92BCE6;color:#745A32'")
       BR
       HTMLoff()
       

Display a table summarizing results, and a second summarizing values entered for this property on the other tabs of this page. You will find a link to download the second table below it.




    write.csv(summ, "results.csv", row.names = FALSE)
    HTMLon()
    if(sum(ls() %in% c("garden.summary")) == 0)
     {
    Html(tank.summary)
     }else{
    Html(garden.summary)
         }
    BR
    cat("Summary table of data entered")
    Html(summ[,-1])
    cat("(True-False values are 1 if true, and 0 if false)")
    BR; BR
    HTMLlink(url = paste(substr(getwd(),15,40), "/results.csv", sep = ""), text = "Save a version of the summary table to your computer")
    HTMLtag("i")
    cat(BR, BR, "You can use this file as part of your bid to the
    Little Stringybark Creek Stormwater Fund.", BR, 
        "Please use your address as the file name: e.g. '3BrownSt.csv'.", BR, 
        "If you have different parts to your bid, or multiple bids, 
         number each file like this: '3BrownSt1.csv', '3BrownSt2.csv', etc.")
    HTMLtag("/i")
    HTMLoff()
    

dojo.event.connect(dojo.byId("roof"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("pave"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("inpr"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("intv"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("istoilet"), "onclick",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("isgarden"), "onclick",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("iswmac"), "onclick",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("ishw"), "onclick",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("inff"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("selectffto"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("innp"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("inga"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("selectof"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("selectof"), "onchange",
                  function() {thisPage.refreshTab3();});

dojo.event.connect(dojo.byId("ppain"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("prain"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("inHo"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("inHp"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("inHf"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("intsd"), "onchange",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("dAp"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("shapeSelect"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("shapeSelect"), "onReceive",  
                   dojo.widget.byId("shapefigs"), "calculate");

dojo.event.connect(dojo.byId("ddim1"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("ddim2"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("selectmedium"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("isveg"), "onclick",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("lined.bottom"), "onclick",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("lined.side"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("inadjtreed"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("isoutlet"), "onclick",
                  function(e) {rpad.calculateNode(e.target, true);});

dojo.event.connect(dojo.byId("tl"), "onchange",
                   function(e) {rpad.calculateNode(e.target, true);});

// this makes all Rpad updates to output boxes "yellowfade" in
// make the street select box auto update
dojo.event.connect(rpad, "updateResults", 
    function (rpadResults, data) {
        dojo.lfx.html.highlight(rpadResults, 
            dojo.gfx.color.extractRGB("#FFFF40")).play(1000);  // from color - bright yellow
        // #FFFFE0

   });
dojo.debug("hello");
" ";