function clearField(a){document.getElementById(a).value="";document.getElementById(a).style.color="#000000";document.getElementById(a).style.fontWeight="bold";return true}function fillField(a,b){if(document.getElementById(a).value==""){document.getElementById(a).value=b;document.getElementById(a).style.color="#AAAAAA";document.getElementById(a).style.fontWeight="normal"}return true}var xmlhttp;
function checkUsername(a){document.getElementById("userCheck").innerHTML="Checking username availability...";xmlhttp=GetXmlHttpObject();if(xmlhttp==null)alert("Browser does not support HTTP Request");else{var b="match_user.php";b=b+"?u="+a;xmlhttp.onreadystatechange=stateChanged;xmlhttp.open("GET",b,true);xmlhttp.send(null)}}
function stateChanged(){if(xmlhttp.readyState==4){xmlhttp.responseText=="Correct and available username."&&checkInputs();document.getElementById("userCheck").innerHTML=xmlhttp.responseText}}function GetXmlHttpObject(){if(window.XMLHttpRequest)return new XMLHttpRequest;if(window.ActiveXObject)return new ActiveXObject("Microsoft.XMLHTTP");return null}
function checkEmail(a){if(/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(a)){document.getElementById("emailCheck").innerHTML="Valid email format.";checkInputs()}else document.getElementById("emailCheck").innerHTML="Invalid email format"}
function checkInputs(){if(document.getElementById("emailCheck").innerHTML=="Valid email format."&&document.getElementById("userCheck").innerHTML=="Correct and available username."){document.getElementById("register_go").disabled=false;document.getElementById("submit_disabled").innerHTML=""}};
