// JavaScript Document
function getPostAnswer(){
		var response;
		var temp;
		var main;
		var second;

		var informationbar = document.getElementById('informationbar');
		var username = document.register.username.value;
		var email = document.register.email.value;
		var password = document.register.password.value;
		var password2 = document.register.password2.value;
		var alternate_email = document.register.alternate_email.value;
		
		var ajax = newAjax();
		ajax.open("POST", "register.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
			
				document.getElementById('formUsername').className = "MediumFormItem";
				document.getElementById('formEmail').className = "MediumFormItem";
				document.getElementById('formPassword').className = "MediumFormItem";
				document.getElementById('formAlternateEmail').className = "MediumFormItem";
				document.getElementById('informationbar').className ="ActiveIB"
			
				response = ajax.responseText;
				
				if (response == "error=0"){
					main = 'You registered successfully, please check your email.';
					second = '<a href="http://www.doggybio.com/member/form_login.php">Login</a>';
					informationbar.innerHTML = '<table width="600" border="0" cellpadding="0" cellspacing="0" class="GreenInformationBar"><tr><td height="5" id="ibupper"></td></tr><tr><td id="ibmiddle"><table width="600" border="0" cellspacing="0" cellpadding="0"><tr><td width="5"></td><td width="590"><table width="590" border="0" cellspacing="0" cellpadding="0"><tr><td id="ibmaintxt">'+main+'</td><td id="ibclosetxt"><span class="Link" onclick="closeInformationBar()">close</span></td></tr><tr><td id="ibsecondtxt">'+second+'</td><td></td></tr></table></td><td width="5"></td></tr></table></td></tr><tr><td height="5" id="iblower"></td></tr></table>';
					document.getElementById('content').innerHTML = "<p>Welcome to DoggyBio.com</p>";
				} else {
					links = "Please check the information you submitted.";
					temp = response.substr(6);
					switch(temp){
						case "1":
							temp = "You already own a DoggyBio account.";
							break;
						case "2":
							temp = "All fields are required.";
							break;
						case "3":
							temp = "Password entries don't match.";
							document.getElementById('formPassword').className = "MediumFormItemError";
							break;
						case "4":
							temp = "Invalid email.";
							document.getElementById('formEmail').className = "MediumFormItemError";
							break;
						case "5":
							temp = "Invalid alternate email.";
							document.getElementById('formAlternateEmail').className = "MediumFormItemError";
							break;
						case "6":
							temp = "Other member registered that email.";
							document.getElementById('formEmail').className = "MediumFormItemError";
							break;
						case "7":
							temp = "Other member registered that alternate email.";
							document.getElementById('formAlternateEmail').className = "MediumFormItemError";
							break;
						case "8":
							temp = "Other member registered that username.";
							document.getElementById('formUsername').className = "MediumFormItemError";
							break;
						case "9":
							temp = "You cannot use the same email and alternate email.";
							document.getElementById('formEmail').className = "MediumFormItemError";
							document.getElementById('formAlternateEmail').className = "MediumFormItemError";
							break;
						default:
							temp = "Unknown error:<br>"+response;
							break;
					}
					informationbar.innerHTML = '<table width="600" border="0" cellpadding="0" cellspacing="0" class="RedInformationBar"><tr><td height="5" id="ibupper"></td></tr><tr><td id="ibmiddle"><table width="600" border="0" cellspacing="0" cellpadding="0"><tr><td width="5"></td><td width="590"><table width="590" border="0" cellspacing="0" cellpadding="0"><tr><td id="ibmaintxt">'+temp+'</td><td id="ibclosetxt"><span class="Link" onclick="closeInformationBar()">close</span></td></tr><tr><td id="ibsecondtxt">'+links+'</td><td></td></tr></table></td><td width="5"></td></tr></table></td></tr><tr><td height="5" id="iblower"></td></tr></table>';
				}
			} else {
				//Sending...
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send("username="+username+"&email="+email+"&password="+password+"&password2="+password2+"&alternate_email="+alternate_email);
	}
	
	function closeInformationBar(){
		document.getElementById('informationbar').className ="HiddenIB";
		document.getElementById('informationbar').innerHTML = "<!-- Information Bar -->";	
	}