function toggle_div(id) {
    var diq = document.getElementById(id).style;
    diq.display=(diq.display=="none") ? "" : "none";

} 

function hasWhiteSpace(s) 
{

     reWhiteSpace = new RegExp(/^\s+$/);

     // Check for white space
     if (reWhiteSpace.test(s)) {
          alert("Please Check Your Fields For Spaces");
          return false;
     }
return true;
}

var xmlHttp

function check_username(str)
{ 
xmlHttp=GetXmlHttpObject();


				 if(str.indexOf(' ') != -1) {
				 document.getElementById("uresult").innerHTML="Username may not contain spaces";
				 document.getElementById("UserID").style.backgroundColor="#ff0000";
				 document.getElementById("UserID").style.color="#ffffff";
				 return false;
				 }


if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/includes/check_username.php?username="+str;
//url=url+"&number="+EmailNumber;
xmlHttp.onreadystatechange=function(){UsernamestateChanged();};
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function UsernamestateChanged() { 
        //document.getElementById("result" + TheNumber).innerHTML="checking, please wait";
		//alert(xmlHttp.responseText);
        if (xmlHttp.readyState==4){
                 
				 if(xmlHttp.responseText == "Sorry, that username is taken") {
				 document.getElementById("uresult").innerHTML=xmlHttp.responseText;
				 document.getElementById("UserID").style.backgroundColor="#ff0000";
				 document.getElementById("UserID").style.color="#ffffff";
				 }
				 
				 if(xmlHttp.responseText == "Username Ok") {
				 document.getElementById("uresult").innerHTML=xmlHttp.responseText;
				 document.getElementById("UserID").style.backgroundColor="#006600";
				 document.getElementById("UserID").style.color="#ffffff";
				 }
        }
}

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;
}
// JavaScript Document