function RemoveErrorMessage()
{
	if (document.getElementById("ErrorContainer").innerHTML != '&nbsp;')
	{
		document.getElementById("ErrorContainer").innerHTML = '&nbsp;'
	}
}

function DoLogin()
{
	var PostParameters = '';
	
	PostParameters = "txtLoginName="+document.getElementById("txtLoginName").value;
	PostParameters = PostParameters + "&txtPassword="+document.getElementById("txtPassword").value;
	PostParameters = PostParameters + "&process=1";
	
	xmlHttpDoLogin=GetXmlHttpObject()

	if (xmlHttpDoLogin==null)
  {
		alert ("Your browser does not support AJAX!");
		return;
  } 
		
	document.getElementById("ThumperDivLogin").style.display = '';
	
	var url="ajax_calls/login_new.php";

	xmlHttpDoLogin.onreadystatechange = DisplayLoginResult;

	xmlHttpDoLogin.open("POST", url, true);	
	xmlHttpDoLogin.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpDoLogin.setRequestHeader("Content-length", PostParameters.length);
	xmlHttpDoLogin.setRequestHeader("Connection", "close");
	xmlHttpDoLogin.send(PostParameters);	
}


function DisplayLoginResult()
{	
	if (xmlHttpDoLogin.readyState==4 || xmlHttpDoLogin.readyState=="complete")
	{				
		ResponseText = xmlHttpDoLogin.responseText;
		if (ResponseText == 9006)
		{
			window.location.href = "error_page.php";
			return;
		}
		
		var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
		
		var ArrSplit = ResponseText.split("****");
			
		switch (ArrSplit[1])
		{
			case "1":				
				window.location.href = ArrSplit[0];
				document.getElementById("ThumperDivLogin").style.display = 'none';
				return;
				break;
				
			case "2":
				window.location.href = ArrSplit[0];
				document.getElementById("ThumperDivLogin").style.display = 'none';
				return;
				break;
				
			case "3":
				document.getElementById("LoginBoxContainer").innerHTML = "";
				document.getElementById("LoginBoxContainer").innerHTML = ArrSplit[0];

				document.getElementById("ThumperDivLogin").style.display = 'none';
				break;
		}						
	}	
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	return xmlHttp;
}
