
		var xmlhttp;

		function login(username,password)
		{
                        
			xmlhttp=GetXmlHttpObject();
			if (xmlhttp==null)
			  {
			  alert ("Browser does not support HTTP Request");
			  return;
			  }

			var url="area_riservata/modules/login.php";
                        var paramsUsername = "username="+username;
                        var paramsPassword = "password="+password;

                        //Send the proper header information along with the request



			xmlhttp.onreadystatechange=stateChangedLogin;

                        xmlhttp.open("POST", url, true);
                        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlhttp.send(paramsUsername+"&"+paramsPassword);


                       
		}

		function stateChangedLogin()
		{
			if (xmlhttp.readyState==4)
			{
                                var responseLogin = xmlhttp.responseText;

                                if(responseLogin == 'OK-ENTRAPURE')
                                    {
                                       window.location.reload();
                                    }
                                else
                                    {
                                        
                                        
                                        document.getElementById('errorArea').innerHTML=responseLogin;
                                        document.getElementById('errorArea').style.display = 'inline';
                                        document.getElementById('progressBar').style.display = 'none';
                                        document.getElementById('submitArea').style.display = 'inline';
                                    }
				
			}
		}



		function showLogin()
		{
			 document.getElementById('datiaccesso').style.display = 'inline';
		}

        function check(form)
        {
            if(form.username.value == '')
               {
                   alert('Inserire la username!');
                   form.username.focus();
                   return false;
               }
             if(form.password.value =='')
                 {
                      alert('Inserire la password!');
                      form.password.focus();
                     return false;
                 }

             document.getElementById('progressBar').style.display = 'inline';
             document.getElementById('submitArea').style.display = 'none';

	     login(form.username.value,form.password.value);
        }




