// JavaScript Document

<!-- Hide the script from old browsers --
 function a(txt) {
       self.status = txt;
	   return true;
       }

 function b() {
     self.status = "";
	 return true;
    }
// --End Hiding Here -->


function frmRegister()
{
  // check to see if the field is blank
  if (document.frmRegister.username.value == "")
  {
    alert("The \"Username\" field cannot be empty!");
    document.frmRegister.username.focus();
    return (false);
  }
  return true;
}//function frmRegister()


//Function to create xmlhttpOjbect 
 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 GetXmlHttpObject()

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
 
 
 
  
//Another very userful function
function showHint(str)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="get_hint.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


/*
   // check to see if the field is blank
  if (document.frmRegister.txtEmail.value == "")
  {
    alert("The \"Email\" field cannot be empty!");
    document.frmRegister.txtEmail.focus();
    return (false);
  }
  
     // check to see if the field is blank
  if (document.frmRegister.txtEmail.value == "")
  {
    alert("The \"Email\" field cannot be empty!");
    document.frmRegister.txtEmail.focus();
    return (false);
  }
  
  // test if valid email address, must have @ and .
  var checkEmail = "@.";
  var checkStr = document.frmRegister.txtEmail.value;
  var EmailValid = false;
  var EmailAt = false;
  var EmailPeriod = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkEmail.length;  j++)
    {
      if (ch == checkEmail.charAt(j) && ch == "@")
        EmailAt = true;
      if (ch == checkEmail.charAt(j) && ch == ".")
        EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
		EmailValid = true
		break;
	}
  }
  if (!EmailValid)
  {
    alert("The e-mail address you entered is invalid.\n Please check it and make necessary correction.");
    document.frmRegister.txtEmail.focus();
    return (false);
  }
  
    // check to see if the field is blank
  if (document.frmRegister.txtPassword.value == "")
  {
    alert("The \"Password\" field cannot be empty!");
    document.frmRegister.txtPassword.focus();
    return (false);
  }
    // check to see if the characters are less than 4
  if (document.frmRegister.txtPassword.value.length < 5)
  {
    alert("The Password must be at least of 5 characters.");
    document.frmRegister.txtPassword.focus();
    return (false);
  }
    // check to see if the field is blank
  if (document.frmRegister.txtConfirm.value == "")
  {
    alert("The \"Re-enter Password\" field cannot be empty! This is necessary for the confirmation of your password");
    document.frmRegister.txtConfirm.focus();
    return (false);
  }
  
   // check to see if  Password match each other
  if (document.frmRegister.txtPassword.value != document.frmRegister.txtConfirm.value) {
alert("Passwords didn't match! Please enter your password again in the \"Password\" and \"Re-enter Password\" fields for confirmation.");
document.frmRegister.txtPassword.focus();
return false;
}
  
   // check to see if the field is blank
  if (document.frmRegister.txtFName.value == "")
  {
    alert("The \"First Name\" field cannot be empty!");
    document.frmRegister.txtFName.focus();
    return (false);
  }

var FName = document.frmRegister.txtFName.value;

   for (i=0;i < FName.length; i++)
     { 
       ch = FName.charAt(i);
	   
	   if (ch==" "){
	   alert("\"First name:\" field cannot contain a space.");
    document.frmRegister.txtFName.focus();
        return (false);
	   }
	}//for
   // check to see if the field is blank
  if (document.frmRegister.txtLName.value == "")
  {
    alert("The \"Last Name\" field cannot be empty!");
    document.frmRegister.txtLName.focus();
    return (false);
  }
  
var LName = document.frmRegister.txtLName.value;

   for (i=0;i < LName.length; i++)
     { 
       ch = LName.charAt(i);
	   
	   if (ch==" "){
	   alert("\"Last name:\" field cannot contain a space.");
    document.frmRegister.txtLName.focus();
        return (false);
	   }
	}//for
 // check to see if the field is blank
  if (document.frmRegister.Optdays.value == "")
  {
    alert("The Day of Birth of the \"Date of Birth\" field cannot be empty!");
    document.frmRegister.Optdays.focus();
    return (false);

  }
*/