<!-- // *** contact.js ***

// --- global variables ---

var oForm = 0;       // object set by initPage

var eFirst = "@";
var eSecond = "sweetcanproductions";
var eThird = "com";

// --- functions ---

function msgDone()
{
  var wName = sTrim(oForm.realname.value,'B');
  var wEmail = sTrim(oForm.email.value,'B');
  var wSubject = sTrim(oForm.subject.value,'B');
  var wMessage = sTrim(oForm.theMessage.value,'B');

  if (wSubject.length <= 0)
  {
     wSubject = "Sweet Can Productions -";
     oForm.subject.value = wSubject;
  }
  if (wName.length <= 0)
  {
    showError(oForm.realname,"Name is required.");
    return false;
  }
  if (oForm.email.value.length <= 0)
  {
    showError(oForm.email,"Email address is required.")
    return false;
  }

  if (!isValidEmail(oForm.email.value))
  {
    showError(oForm.email,"You entered an invalid email address.")
    return false;
  }

  if (wMessage.length <= 0)
  {
    showError(oForm.theMessage,"There is no message.");
    return false;
  }

  oForm.realname.value = wName;
  oForm.subject.value  = wSubject;
  oForm.theMessage.value = wMessage;

  oForm.redirect.value = "http://sweetcanproductions.com/contact_ty.htm";
  oForm.recipient.value = "contact"+eFirst+eSecond+"."+eThird;
  oForm.submit();
  oForm.theMessage.focus();
}

function showError(oFField,imsg)
{
  alert(imsg+"\nPlease try again.");
  oFField.focus();
}

function initPage()
{
  // *** set contact text ***
  document.getElementById('eContact').childNodes[0].nodeValue = "contact"+eFirst+eSecond+"."+eThird;
  // *** set globals ***
  oForm = document.getElementById('fContact');

  // *** reset message area ***
  oForm.email.value = "";
  oForm.theMessage.value = "";
  oForm.realname.value = "";
  oForm.email.value = "";
  oForm.subject.value = "Sweet Can Productions - ";

  // *** set focus ***
  oForm.realname.focus();
}

