// LOGIN E LOGOUT
function Login(){
	var parametri = $('#form_login').serialize();
	
	
	document.getElementById('errore_login').innerHTML='';
	jQuery.ajax({
			type: "GET",
				cache: false,
				url: "core/login.php",
				data: parametri+"",
				success: function(msg){
					if(msg=='1'){
                        StartAttesa();
						document.getElementById('errore_login').innerHTML='Accesso eseguito. Attendere il reindirizzamento.';
						location.href='index.php';
					}else{
						document.getElementById('errore_login').innerHTML='Accesso negato. Login e/o password errati.';
                        return false;
					}
				}
			});
}

function Registrazione(){
	var l = document.form_registrazione.l.value;
	var p1 = document.form_registrazione.p1.value;
	var p2 = document.form_registrazione.p2.value;
	var e = document.form_registrazione.e.value;
	
	if(trim(l)==""){
		document.getElementById('errore_registrazione').innerHTML='Registrazione fallita. Inserire un nickname valido.';
		return false;
	}
	
	if(p1!=p2){
		document.getElementById('errore_registrazione').innerHTML='Registrazione fallita. Password non coincidenti.';
		return false;
	}
	
	
	StartAttesa();
	jQuery.ajax({
			type: "GET",
				cache: false,
				url: "core/registrazione.php",
				data: "",
				success: function(msg){
					if(msg=='1'){
						location.href='index.php';
					}
				}
			});
}

function Logout(){
	StartAttesa();
	jQuery.ajax({
			type: "GET",
				cache: false,
				url: "core/logout.php",
				data: "",
				success: function(msg){
					if(msg=='1'){
						location.href='index.php';
					}
				}
			});
}
