var xmlHttp = getXmlHttpObject();
var obj = ''



function checkuspwd(user,pwd, nameobj){
   obj=nameobj;
   
      
   xmlHttp.open('GET', 'sys/check.php?u='+user+'&p='+pwd, true);
   xmlHttp.onreadystatechange = stateChanged_up; 
   xmlHttp.send(null);
  
}



function stateChanged_up() {
	
   if(xmlHttp.readyState == 4) {
         //Stato OK
     if (xmlHttp.status == 200) {
        var resp = xmlHttp.responseText;
        
                     
      if(resp) {
	 
         var select = document.getElementById(obj);

        if (resp == 0) {
           select.innerHTML ='Email o Password errata';
          } 
        if (resp == 1) {
			document.login.action ="access_user.php";
			document.login.submit();
          	//window.location.href = 'access_user.php' ;
          }
      }
    } else {
     alert(xmlHttp.responseText);
  }
 }
}

//funzione per abilitare Ajax, la chiamata è diversa a seconda del browser
function getXmlHttpObject()
   {
      var xmlHttp=null;
    try
      {
        //Firefox e Opera
        xmlHttp=new XMLHttpRequest();
      }
       catch(e)
      {
        //Internet Explorer
      try
       {
         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
       catch(e)
       {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
     }
return xmlHttp;
} 

