function main_registrazione()
{
	var richiestaRegistrazione = null;
		
	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 myRegistrazione()
	{
		if(richiestaRegistrazione.readyState == 4 && richiestaRegistrazione.status == 200)
		{
			document.getElementById('descrizione').innerHTML = richiestaRegistrazione.responseText;
		}
	}
	richiestaRegistrazione = CreateXmlHttpReq(myRegistrazione);
	richiestaRegistrazione.open("GET","server/registrazione.php?nick="+document.registrazione.nick.value+"&pass="+document.registrazione.pass.value+"&mail="+document.registrazione.mail.value);
	richiestaRegistrazione.send(null);
}

function controlla_nick()
{
		var richiestaNick = null;
		
	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 myNick()
	{
		document.getElementById('a_nick').innerHTML = "Caricamento...";
		if(richiestaNick.readyState == 4 && richiestaNick.status == 200)
		{
			if(richiestaNick.responseText == '1')
				var testo = new String("<span style='color: Green;'>Nick disponibile</span>");
			else if(richiestaNick.responseText == '0')
				var testo = new String("<span style='color: Red;'>Nick gi&agrave; esistente</span>");
			else if(richiestaNick.responseText == '2')
				var testo = new String("Problemi con la comunicazione al database...");
			else 
				var testo = nreString("Errore sconosciuto!");
			document.getElementById('a_nick').innerHTML = testo;

		}
	}
	richiestaNick = CreateXmlHttpReq(myNick);
	richiestaNick.open("GET","server/nick_esistente.php?nick="+document.registrazione.nick.value+"&r="+Math.random());
	richiestaNick.send(null);
}

function controlla_mail_vera()
{
	var r_valida_email = null;
		
	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 myEmail()
	{
		document.getElementById('a_mail').innerHTML = "Caricamento...";
		if(r_valida_email.readyState == 4 && r_valida_email.status == 200)
		{	
			if(r_valida_email.responseText == '1')
			document.getElementById('a_mail').innerHTML = "<span style='color: Green;'>E-Mail accettata</span>";
			else
			document.getElementById('a_mail').innerHTML = "E-Mail non accettata";
		}
	}
	r_valida_email = CreateXmlHttpReq(myEmail);
	r_valida_email.open("GET","server/controllamail.php?mail="+document.registrazione.mail.value);
	r_valida_email.send(null);
}

function controlla_mail_uguale()
{
	if(document.registrazione.mail.value == document.registrazione.c_mail.value)
	document.getElementById('a_mail_conf').innerHTML = "<span style='color: Green;'>ok</span>";
	else
	document.getElementById('a_mail_conf').innerHTML = "Questa e-mail non corrisponde a quella sopra...";

}