function checkPassword() {
 var password1
 var password2
 password1 = document.getElementById("password1").value
 password2 = document.getElementById("password2").value

 if (password1 != password2) {
	document.getElementById("messagebox").innerHTML="<span style=\"color:red;font-weight:bold;\">Enter the same password in both password boxes.</span>"
 }

}

function checkUserForm(step)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

if (step == "checkun") { 
var username 
username = document.getElementById("username").value

var url="newuser.php"
url=url+"?username="+username
url=url+"&action=checkun"
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedCheckUserForm
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

} else if (step == "checkemail") {
var email= document.getElementById("email").value

var url="newuser.php"
url=url+"?email="+email
url=url+"&action=checkemail"
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedCheckUserForm
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} else if (step == "createuser") {
var email= document.getElementById("email").value
var username = document.getElementById("username").value
var userid= document.getElementById("userid").value
var password = document.getElementById("password1").value 
var refer = document.getElementById("refer").value

var url="newuser.php"
url=url+"?email="+email
url=url+"&userid="+userid
url=url+"&username="+username
url=url+"&password="+password
url=url+"&refer="+refer
url=url+"&action=createuser"
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedAccountCreated
xmlHttp.open("GET",url,true)
xmlHttp.send(null)


}
}

function stateChangedCheckUserForm()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {

 var msg = "<span style=\"color:red;font-weight:bold;\">" + xmlHttp.responseText + "</span>"
 document.getElementById("messagebox").innerHTML=msg	
 }
}

function stateChangedAccountCreated()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 window.location="http://www.aroundthecapitol.com/login.html?refer=newuser"
 }

}


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

