
// JavaScript Document

function checkEnter(event){
	var code = 0;

	code = event.which ? event.which : event.keyCode;
		
	if (code==13){ 
		formSubmit();
		event.returnValue = false;
	}
}

//function formSubmit(){
function getPostAnswer(){
		var temp;
		var main;
		var second;

		var informationbar = document.getElementById('informationbar');
		var username = document.login.username.value;
		var password = document.login.password.value;
		var side = document.login.side.value;
		
		var ajax = newAjax();
		ajax.open("POST", "login.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
			
				document.getElementById('formUserPass').className = "MediumFormItem";
				informationbar.className ="ActiveIB"
			
				temp = ajax.responseText;
				
				if (temp == "error=0"){
					document.location.href = "http://www.doggybio.com/member/";
				} else {
					main = "Please check the information you submitted.";
					temp = temp.substr(6);
					switch(temp){
						case "1":
							second = "Invalid Username/Password Combination";
							document.getElementById('formUserPass').className = "MediumFormItemError";
							break;
						default:
							second = "Unknown error";
							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">'+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>';
				}
			} else {
				//Sending...
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send("username="+username+"&password="+password+"&side="+side);
	}
	
	function closeInformationBar(){
		document.getElementById('informationbar').className ="HiddenIB";
		document.getElementById('informationbar').innerHTML = "<!-- Information Bar -->";	
	}