function GetCookie(name)
	{ 
	var cname = name + "="; //the cookie name is given an equal signs after it and assigned as cname
	var dc = document.cookie; //the main document.cookie code that will follow is assigned to dc
	var bl = "";
	if (dc.length > 0)
		{ //here the length of the cookie is checked, if it is above 0 the function continues and if not then it returns null
		begin = dc.indexOf(cname); //here the indexOf() method is used to find the location of the cookie's name and it is assigned to begin
		if (begin != -1)
			{ //if the cookie's name is not found in dc then begin is given a value of -1
			begin += cname.length; //if the name is found begin is increased by the length of the cname
			end = dc.indexOf(";", begin); //the indexOf() method now searches for a semicolon to be given to the variable end
			if (end == -1) end = dc.length; 
			return unescape(dc.substring(begin, end)); //here is where is made sure that the value of the cookie is extracted and returned using the substring() method on dc
			} 
		}
	return bl; 
	}
function checkForm()
	{
	var error = 0;
	var errormsg = "Please check the following items";

	if(document.theForm.MemNum.value == "")
		{
		var error = 1;
		var errormsg = errormsg + "\n - Member Number";
		}
	if(document.theForm.Pword.value == "")
		{
		var error = 1;
		var errormsg = errormsg + "\n - Password";
		}

	if(error == 1)
		{
		alert(errormsg);
		return false;
		}
	else
		{
		return true;
		}
	}
var url = "/LoginData.cfm"; // The server-side script
var theXMLData 	= "";
var alphaNumArr = new Array("0","A","1","B","2","C","3","D","4","E","5","F","6","G","7","H","8","I","9","J");



function handleTestHttpResponse()
	{
	if (httpb.readyState == 4)
		{
		var xmlDocument = httpb.responseXML;
		var myOutputString = "";
		var myXMLDataString = xmlDocument.xml;
		alert(myXMLDataString);
		}		
	};

function submitTestData()
	{
	//create a random string
	var myNewRandomString = pickNums(4);
	var xmlDocument = "";
	var myXMLDataString = "";
	var myOutputString = "Welcome ";
	var err = 0;
	var errMessage = "Please Provide:<br>";
	//test the form first
	if(document.signForm.MemNum.value == "")
		{err = 1; errMessage = errMessage + " Member Number<br>";}
	if(document.signForm.Pword.value == "")
		{err = 1; errMessage = errMessage + " Password<br>";}
	if(err > 0)
		{document.getElementById('Content').innerHTML	=	errMessage;}
	else
		{
			//setup the http call
			httpb.open("POST", url + '?Rand=' + myNewRandomString, false);
			httpb.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			httpb.send("MemNum=" + document.signForm.MemNum.value + '&Pword=' + document.signForm.Pword.value);
			//handle the response
			xmlDocument = httpb.responseXML;
			myXMLDataString = xmlDocument.xml;
			nodes = xmlDocument.documentElement.childNodes;
			nodeLength = nodes.length;
			if (nodeLength > 0)
				{
				if (nodeLength > 1)
					{
					for (var iag = 0; iag < nodeLength; iag++)
						{
						var thisNodeText = nodes(iag).text;
						myOutputString = myOutputString + thisNodeText + ' '; 
						
						}
						document.getElementById('LOGINAREA').innerHTML	=	"";
						
						//document.getElementById('LOGINAREA').style.visibility = 'hidden';
						window.location.href = window.location.href;// + "?access1=" + pickNums(5)
					}
				else
					{
					var thisNodeName = nodes(0).text;
					document.getElementById('Content').innerHTML	=	thisNodeName;			
}
				}
			else
				{
				alert('No Nodes');
				}
		}
	}

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();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}


function checkLoggedInStatus() {
	var foo = GetCookie("LOGGEDIN");
	if(foo == "")
		{foo1 = 1;}
	else
		{
		document.getElementById('LOGINAREA').innerHTML	=	"";
		//document.getElementById('LOGINAREA').style.visibility = 'hidden';
		}
}


function pickNums(nums)
	{
	var myString = "";
	
	for(var ilo=0; ilo<nums; ilo++)
		{
			myString = myString + Math.round((alphaNumArr.length-1)*Math.random());
		}
	return myString;
	}

var httpa = getHTTPObject(); // We create the HTTP Object
var httpb = getHTTPObject(); // We create the HTTP Object