// JavaScript Document
function createButton(ie6b,ie7,node)
{
  var opening = "/index.php?n="
  var closing = ")"
  var url = opening + node

  if (!document.getElementById) return false
  if (!document.createElement) return false
  if (!document.insertBefore) return false
  if (!document.appendChild) return false
  if (!document.createTextNode) return false

  var btn_top = "32em"
  var btn_left = "3.7em"
  if (ie7)
  {
    var wrapper = document.getElementById("wrapper")
    var btn = document.createElement("a")
    var img = document.createElement("img")
    wrapper.appendChild(btn)
    btn.appendChild(img)
    if (!btn.setAttribute) return false
    btn.setAttribute("id","bbutton")
    btn.style.position = "fixed"
    btn.style.top = btn_top
    btn.style.marginLeft = btn_left
    btn.setAttribute("href",url)
    btn.setAttribute("alt","Back Button")
    img.setAttribute("src","/images/site/back_btn.png")
    img.style.textDecoration = "none"
    img.style.border = "none"
  }
  else if (ie6b)
  {
    var wrapper = document.getElementById("wrapper")
    var btn = document.createElement("a")
    var img = document.createElement("img")
    wrapper.appendChild(btn)
    btn.appendChild(img)
    if (!btn.setAttribute) return false
    btn.setAttribute("id","bbutton")
    btn.style.position = "absolute"
    btn.style.top = btn_top
    btn.style.marginLeft = btn_left
    btn.setAttribute("href",url)
    btn.setAttribute("alt","Back Button")
    img.setAttribute("src","/images/site/back_btn.png")
    img.style.textDecoration = "none"
    img.style.border = "none"
  }
  else
  {
    var wrapper = document.getElementById("wrapper")
    var btn = document.createElement("img")
    wrapper.appendChild(btn)
    if (!btn.setAttribute) return false
    btn.setAttribute("id","bbutton")
    btn.style.position = "fixed"
    btn.style.top = btn_top
    btn.style.marginLeft = btn_left
    btn.setAttribute("src","/images/site/back_btn.png")
    btn.setAttribute("alt","Back Button")
    btn.setAttribute("onclick","goBackOnePage();")
  }
}

function Validate_Form(name)
{
  var str
  var catValue
  if (name == 'drha')
  {
    str = document.getElementById('category')
    catValue = str.value;
    if (str.value == 'select')
    {
      alert("Please choose a category.")
      str.focus()
      return 0
    }
    str = document.getElementById('firstName')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your first name.")
      str.focus()
      return 0
    }
    str = document.getElementById('lastName')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your last name.")
      str.focus()
      return 0
    }
    str = document.getElementById('emailAddress')
    if (str.value.search("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$") < 0)
    {
      alert("Please enter a valid email address.")
      str.focus()
      return 0
    }
    str = document.getElementById('subject')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter a subject.")
      str.focus()
      return 0;
    }
    if (catValue == 'prayer')
    {
      str = document.getElementById('comments')
      if (str.value.search("\\w+") < 0)
      {
        alert("Don't forget to include your request for prayer.")
        str.focus()
        return 0
      }
    }
    if (catValue != 'treat' && catValue != 'reading')
    {
      str = document.getElementById('comments')
      if (str.value.search("\\w+") < 0)
      {
        alert("Don't forget to write your comment, request, or question.")
        str.focus()
        return 0
      }
    }
    document.forms['drha'].submit()
  }
  else if (name == 'client')
  {
    str = document.getElementById('firstName')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your first name.")
      str.focus()
      return 0
    }
    str = document.getElementById('lastName')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your last name.")
      str.focus()
      return 0
    }
    str = document.getElementById('mailAddr')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your mailing address.")
      str.focus()
      return 0
    }
    str = document.getElementById('city')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your city.")
      str.focus()
      return 0
    }
    str = document.getElementById('state')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your state.")
      str.focus()
      return 0
    }
    str = document.getElementById('zip')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your zip code.")
      str.focus()
      return 0
    }
    str = document.getElementById('country')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your country.")
      str.focus()
      return 0
    }
    str = document.getElementById('phone')
    if (str.value.search("\\w+") < 0)
    {
      alert("Please enter your phone number.")
      str.focus()
      return 0
    }
    str = document.getElementById('emailAddress')
    if (str.value.search("\\w+@\\w+\\.\\w+") < 0)
    {
      alert("Please enter a valid email address.")
      str.focus()
      return 0
    }
    if (!document.getElementById('agreement').checked)
    {
      alert("Please check the box after reading the information")
      document.getElementById('agreement').focus()
      return 0
    }
    document.forms['client'].submit()
  }
  else
  {
    alert("Sorry. Your request cannot be processed. The webmaster has been alerted.")
  }
}

function displayPayChoice(field)
{
  alert(document.getElementById(field).checked)
}

function goBackOnePage()
{
  history.go(-1)
}
