// JavaScript Document
function createButton(imgPath, btn_top, btn_left, pos, id)
{
  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 wrapper = document.getElementById("wrapper")
  var img = document.createElement("img")

  wrapper.appendChild(img)
  if (!img.setAttribute) return false
  img.setAttribute("id",id)
  img.style.position = pos
  img.style.top = btn_top
  img.style.marginLeft = btn_left
  img.setAttribute("src",imgPath)
  img.setAttribute("alt","Back Button")
  img.onclick = function() {history.go(-1)};
}

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)
}

