
var xmlHttp_check_register;

function check_register(){

	str = document.getElementById("reg_username").value;
	str_pass = document.getElementById("reg_password").value;
	str_pass2 = document.getElementById("reg_password2").value;
	str_email = document.getElementById("reg_email").value;
	//if(!str)return;
	
xmlHttp_check_register=GetXmlHttpObject_check_register();
if (xmlHttp_check_register==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="http://www.oldstockcars.com/vfsn/check_register.php";
url=url+"?q="+str;
url=url+"&r="+str_pass;
url=url+"&s="+str_pass2;
url=url+"&u="+str_email;
url=url+"&sid="+Math.random();
xmlHttp_check_register.onreadystatechange=stateChanged_check_register;
xmlHttp_check_register.open("GET",url,true);
xmlHttp_check_register.send(null);
} 

function stateChanged_check_register() 
{ 
if (xmlHttp_check_register.readyState==4)
{ 

		if(!xmlHttp_check_register.responseText)return;

		//alert(xmlHttp_check_register.responseText);
		if(xmlHttp_check_register.responseText=="Spaces found in username! Please remove and try again." || xmlHttp_check_register.responseText=="Username already being used! Please try another name."){
			document.getElementById("notification").innerHTML=xmlHttp_check_register.responseText;
			document.getElementById("notification").style.display='block';
			document.getElementById("reg_username").value = "";
			document.getElementById("reg_username").focus();
			timer1=window.setTimeout("hide_notification()",3000)
		}

		if(xmlHttp_check_register.responseText=="Spaces found in password! Please remove and try again."){
			document.getElementById("notification").innerHTML=xmlHttp_check_register.responseText;
			document.getElementById("notification").style.display='block';
			document.getElementById("reg_password").value = "";
			document.getElementById("reg_password").focus();	
			timer1=window.setTimeout("hide_notification()",3000)
		}

		if(xmlHttp_check_register.responseText=="Passwords did not match please try again."){
			document.getElementById("notification").innerHTML=xmlHttp_check_register.responseText;
			document.getElementById("notification").style.display='block';
			document.getElementById("reg_password").value = "";
			document.getElementById("reg_password2").value = "";
			document.getElementById("reg_password").focus();
			timer1=window.setTimeout("hide_notification()",3000)
		}

		if(xmlHttp_check_register.responseText=="Email address was not valid! Please re-enter a valid email address."){
			document.getElementById("notification").innerHTML=xmlHttp_check_register.responseText;
			document.getElementById("notification").style.display='block';
			document.getElementById("reg_email").value = "";
			document.getElementById("reg_email").focus();
			timer1=window.setTimeout("hide_notification()",3000)
		}

}
}

function hide_notification(){
			document.getElementById("notification").style.display='none';
}

function GetXmlHttpObject_check_register()
{
var xmlHttp_check_register=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp_check_register=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp_check_register=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp_check_register=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp_check_register;
}
