/**************************************************************************************************************/
// Create xmlhttp object based on browsertype
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
/**************************************************************************************************************/
// Define global variables to be used throughout
var tableBusy = false;
var tableHttp = getHTTPObject();
var step1Over = false;
var row = "";
/**************************************************************************************************************/

function CheckPrivateKey(fm)
{
	if (!tableBusy)
	{
		var url = "check_word.php?private_key="+document.getElementById('private_key').value;
		tableHttp.open("GET", url, true);
		tableHttp.onreadystatechange = checkwordverification;
		tableBusy = true;
		tableHttp.send(null);
	}
}


function checkwordverification()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var output = tableHttp.responseText;
				if(output == 'err')
				{
					alert("There is an error with your word verification text");
					document.getElementById('private_key').value = "";
					document.getElementById('private_key').focus();
                    document.getElementById("randomimgId").innerHTML = "";
                    fetch_randImg();
				}
				else
				{
					document.frmcontactinfo.submit();
				}
				tableBusy = false;
			}
			catch (e)
			{
				alert("Error: " + e.description) ;
			} // end try catch
		}
	}
}

