function showStatus(s)
{
   var el = document.getElementById("divAjaxResult");
   if (el) {
      el.innerHTML     = s;
      var rid = document.getElementById("rowStatus");
      if (rid) {
         rid.style.display = "";
      }
   } else {
     alert(s);
   }
}

function hideStatus()
{
   var el = document.getElementById("divAjaxResult");
   if (el) {
      el.innerHTML = "";
      var rid = document.getElementById("rowStatus");
      if (rid) {
         rid.style.display = "none";
      }
   }
}

function checkCaptcha(captcha)
{

   lcURL = "/public/code/html-checkcaptcha?captcha="+captcha;
   return sjaxCheckCaptcha(lcURL);
}

//--------------------------------------------
// Synchronous Query
//--------------------------------------------

function sjaxCheckCaptcha(url)
{
   if (document.getElementById) {
      var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
   }
   if (x) {
      x.open("GET", url, false);
      x.send(null);
      if (x.status != 200)    {
         showStatus("incorrect image characters.");
         return false;
      }
      return true;
   }
}

function submitXphone()
{
   hideStatus();

   var x=document.getElementById("myForm");
   if (x.PhoneNumber.value == "") {
      showStatus("Please enter valid phone #");
      x.PhoneNumber.focus();
      return false;
   }
   if (!x.captcha) {
      return true;
   }
   if (x.captcha.value == "") {
      showStatus("Please enter image characters");
      x.captcha.focus();
      return false;
   }
   if (!checkCaptcha(x.captcha.value.toUpperCase())) {
      img = document.getElementById("captchaImg");
      if (img) {
         var d = (new Date()).getTime();
         img.src = "/public/code/html-captcha?hls="+d;
         x.captcha.value = "";
      }
      return false;
   }
   return true;
}


