// crea l'oggetto per la comunicazione AJAX con il server   
// compatibile con tutti i browser che supportano AJAX   
function crea_http_req() {   
    var req = false;   
    if (typeof XMLHttpRequest != "undefined")   
        req = new XMLHttpRequest();   
    if (!req && typeof ActiveXObject != "undefined") {   
        try {   
            req=new ActiveXObject("Msxml2.XMLHTTP");   
        } catch (e1) {   
            try {   
                req=new ActiveXObject("Microsoft.XMLHTTP");   
            } catch (e2) {   
                try {   
                    req=new ActiveXObject("Msxml2.XMLHTTP.4.0");   
                } catch (e3) {   
                    req=null;   
                }   
            }   
        }   
    }   
  
    if(!req && window.createRequest)   
        req = window.createRequest();   
  
    if (!req) alert("Il browser non supporta AJAX");   
  
    return req;   
}   
  
// l'oggetto per comunicare con il server   
var http_req = crea_http_req();

   
var http_req = crea_http_req();   
// invia i dati del form al server   
function invia_dati_login() {   
    var dati_post = "username=" + encodeURIComponent( document.getElementById("username").value ) + "&password=" + encodeURIComponent( document.getElementById("password").value );    
    http_req.open('GET', 'new/inc/login.asp?' + dati_post, true);   
    http_req.onreadystatechange = gestisci_risposta;
	http_req.send(null);
  
}   
// recupero e gestisco la risposta inviata dal server   
function gestisci_risposta() {   
    if(http_req.readyState == 4) {   
        var esito = http_req.responseText;   
if (esito==2){ 
document.getElementById("username").value='';
document.getElementById("password").value='';
window.alert('I dati immessi non sono validi');
 }
if(esito==4){
document.getElementById('login').style.display='none';
document.getElementById('iscrizione').style.display='none';
document.getElementById('utentiOnline').style.display='block';
document.getElementById('logout').style.display='block';
document.getElementById("accesso").value="ok";
document.getElementById('tuo_nome').innerHTML ='Ciao <b>'+document.getElementById("username").value+'</b>, accedi al tuo <a href=\"javascript:profilo();creaPaginaPersonale()\">profilo</a> - <a href=\"new/inc/logout.asp\" title=\"bye bye....\">logOut</a>';
//document.getElementById('contenuto_schedaF').style.display='none';
//document.getElementById('contenuto_schedaM').style.display='block';
//document.getElementById('barra_titolo_chiusa').style.display='block';
//creaPaginaPersonale();
}
}  
}