var ulRunningTotal = 0
var usFileCount = 0
var ulLastRequest = 0

function checkboxclicked(usWhichOne, ulFileSize)
{
  if (document.forms[0].elements[usWhichOne].checked)
  {
    ulRunningTotal += ulFileSize
    usFileCount++

    if (ulRunningTotal > 3000000)
    {
      alert("The " + usFileCount + " selected files exceeds the maximum " +
        "requestable 3,000,000 bytes!")
    }
  }
  else
  {
    ulRunningTotal -= ulFileSize
    usFileCount--

    if (ulRunningTotal > 3000000)
    {
      alert("The remaining " + usFileCount + " files selected still exceeds " +
        "3,000,000 bytes!")
    }
  }
}
function clearedselections()
{
  ulRunningTotal = 0
  usFileCount = 0
}
function submittedform()
{
  if (ulRunningTotal > 0 && ulRunningTotal == ulLastRequest)
  {
    alert("You already submitted this form!  You may hit the 'Click here " +
      "to clear selected files' button at the bottom of the form, select " +
      "more files, and then submit a new request.")
    return(false)
  }

  if (ulRunningTotal > 3000000)
  {
    alert("Your selected files exceed 3,000,000 bytes!  Your request will " +
      "not be submitted.")
    return(false)
  }
  if (ulRunningTotal == 0)
  {
    alert("No files have been selected!  Your request will not be submitted.")
    return(false)
  }
  if (confirm("You're requesting " + usFileCount + " files consisting of " +
    ulRunningTotal + " bytes worth of data to be sent to your E-Mail.  Are " +
    "you sure you want these?"))
  {
    ulLastRequest = ulRunningTotal
    return(true)
  }
  return(false)
}
function givecookie(name, value)
{
  stTheDate = new Date()
  stExpireDate = new Date()

  stExpireDate.setTime(stTheDate.getTime() + 60*60*24*365*1000)

  document.cookie = name + "=" + escape(value) + " " +
    escape(stTheDate) + "; expires=" + stExpireDate.toGMTString()
}
function findcookie(szName)
{
  var szSearch = szName + "="
  var usOffset = 0
  var usEnding = 0

  if (document.cookie.length > 0)
  {
    usOffset = document.cookie.indexOf(szSearch)

    if (usOffset != -1)
    {
      usOffset += szSearch.length
      usEnding = document.cookie.indexOf(";", usOffset)

      if (usEnding == -1)
        usEnding = document.cookie.length

      return(unescape(document.cookie.substring(usOffset, usEnding)) + "<p>")
    }
  }
  return("")
}

