// JavaScript Document
function verification()
{		
	if(document.getElementById("email_box").value!="")
	{
		if(document.getElementById("password_box").value!="")
		{
			xhr= getxmlhttpreq();
			url="login/verification.php";
			param="email="+document.getElementById("email_box").value+"&password="+document.getElementById("password_box").value;
			xhr.open("POST",url,true);
		 	xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   		 	xhr.onreadystatechange=req_handler;
		 	xhr.send(param);
		}
		else alert("The password field can't be empty.");
	}
	else alert("The e-mail field can't be empty.");
};

function req_handler() //the handler for the signin button
{
	if (xhr.readyState==4)
	{
	  srv_response=xhr.responseText;
	  if (srv_response.slice(0,8)=="login=ok")
	  {	
		if(document.getElementById("whoscomp").checked)
		{
			expdate=new Date();
			expdate.setDate(expdate.getDate()+2000);
			document.cookie="email="+document.getElementById("email_box").value+";expires="+expdate.toGMTString();
			document.cookie="password="+document.getElementById("password_box").value+";expires="+expdate.toGMTString();
		};
		window.location.replace('home.php');
	  }
	  else
	  {   
	    alert(srv_response);
	  }
	};
};