var msg_status = true;

function EnableSubmit()
{
  var e;
  e = document.getElementById("imagesubmit");
  return true;
}
function DisableSubmit()
{
  var e;
  e = document.getElementById("imagesubmit");
  return false;
}
function showLoad ()
{
}
function sendData ()
{
  // The order of executed events is following: onLoading, onLoaded, onInteractive, onComplete.
  var url = 'http://www.thepolkadottedpencil.com/cart/filterwords.php';
  var pars = Form.serialize('cart_quantity');
  var myAjax = new Ajax.Request( url, {asynchronous: false, method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );

  return msg_status;
}
function showResponse (originalRequest)
{
  var msg = originalRequest.responseText;
  if (msg == "bad")
    {
      DisableSubmit();
      alert("We're sorry.  Your message appears to have inappropriate content, and will not be printed.\nPlease try a different personalized message.  Thanks.");
      msg_status = false;
    }
  else
    {
      EnableSubmit();
      msg_status = true;
    }

  return msg_status;
}
