ah=screen.availHeight;
aw=screen.availWidth;

TheHeight=(ah/2)-(550/2);
TheWidth=(aw/2)-(650/2);

TheHeight2=(ah/2)-(350/2);
TheWidth2=(aw/2)-(300/2);



var xmlHttp; // This var is used for all Ajax in this page.

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;
}


function IsNumeric(strString)  {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

      for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}



function send_login_req()
{
	document.getElementById('login_response').innerHTML = '&nbsp;';
	req_user = document.getElementById('Username').value;
	req_pass = document.getElementById('Password').value;
	
	if ((req_user != '') && (req_pass != ''))
	{
		xmlHttp=GetXmlHttpObject();
		var url="login_p.php";
		url=url+"?Username="+req_user;
		url=url+"&Password="+req_pass;
		url=url+"&sid="+Math.random();
		
		xmlHttp.onreadystatechange=stateLoginReq;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}


function stateLoginReq(){
	if (xmlHttp.readyState==4)
	{
		
		ajax_response = xmlHttp.responseText;
		
		text_response = '<font color=\'#336699\'>';
		switch(ajax_response)
		{
			case 'B':
		  	text_response += 'Your username has been blocked';
			break;
			
			case 'E':
		  	text_response += 'Your email address has not been verified';
			break;
			
			case 'OK':
		  	window.location.reload();
			break;
			
			case 'C':
		  	text_response += 'Please enter username and password';
			break;
			
			case 'P':
		  	text_response += 'Incorrect username or password';
			break;
			
			default :
			location.reload(true);
			break;
			
		}
		text_response += '</font>';
		
		document.getElementById('login_response').innerHTML = text_response;
		new Effect.Highlight('login_response',{startcolor:'#D12E32', endcolor:'#FAFAFA', duration: 5.0});
		
	}
}

function send_logout_req()
{
		xmlHttp=GetXmlHttpObject();
		var url="logout_p.php";
		url=url+"?sid="+Math.random();
		
		xmlHttp.onreadystatechange=stateLogoutReq;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}

function stateLogoutReq(){
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.responseText == 1){
			window.location.reload();
		}
		else alert(xmlHttp.responseText);
	}
}



