


function checkPw(dialogFields)
{
          if ((dialogFields.utente.value != "")&&(dialogFields.password.value != "")&&(dialogFields.nrivista.value != "")&&(dialogFields.codice.value != ""))
          {
			document.getElementById('msg').style.display="block";
          	document.getElementById('msg').innerHTML="Login in corso...";
            verifica_user(dialogFields.utente.value,dialogFields.password.value,dialogFields.nrivista.value,dialogFields.codice.value)
          }
          else
          {
           	alert("Controlla i campi")

          }
}




function CreateXmlHttpReq(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}


function myHandler2()
{
    if (myRequest.readyState == 4 && myRequest.status == 200)
    {
    	document.getElementById('msg').innerHTML="";
    	document.getElementById('msg').style.display="none";
    	if (myRequest.responseText=="errore")
    	{
    		document.getElementById('avviso').innerHTML="Login errato, controllare i campi";
    	}
    	else if (myRequest.responseText=="errore2")
    	{
    		document.getElementById('avviso').innerHTML="Codice rivista errato";
    	}
    	else
    	{
      		location.href='/winextra/index.php'
    	}
    }
}

function verifica_user(user,pwd,numeroselezionato,pwdnum)
{
    myRequest = CreateXmlHttpReq(myHandler2);
    myRequest.open("POST","/winextra/index.php?action=verifywinweb");
    myRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    myRequest.send("usr="+user+"&pwd="+pwd+"&nrivista="+numeroselezionato+"&pwdnum="+pwdnum);
}



