	var httpSubmit = createRequestObject();
	
	function addUser()
	{
  		str = getFormValues(document.form1);
		httpSubmit.open('post', 'ajaxScripts/addUser.php');
		httpSubmit.onreadystatechange = handleResponse;
		httpSubmit.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1");
		httpSubmit.send(str);
		document.getElementById("responseContent").setAttribute("class","loading");
		showResponseLayer();
		scroll(0,0);
	}
	
	function handleResponse()
	{
		if(httpSubmit.readyState == 4)
		{
			var response = httpSubmit.responseXML;
			
			switch(response.getElementsByTagName("exitCode")[0].firstChild.nodeValue)
       		{           				
				case '0':
					var content = response.getElementsByTagName("content")[0].firstChild.nodeValue;
					document.getElementById("responseContent").setAttribute("class","responses");
					document.getElementById("responseContent").innerHTML = content;
					setTimeout("document.location = '"+response.getElementsByTagName("returnPage")[0].firstChild.nodeValue+"'", 2500);
           			break;

				case '-2':
					//debug purpose-----------------------------
					alert(Sarissa.serialize(response));
					break;
					//debug purpose-----------------------------
						
				case '7':
       			case '-1':
       			default:
					var content = response.getElementsByTagName("content")[0].firstChild.nodeValue;
					document.getElementById("responseContent").setAttribute("class","error");
					document.getElementById("responseContent").innerHTML = content;
           			break;
			}
		}
		else
		{
			document.getElementById("responseContent").innerHTML = "Processing data...";
		}
	}
	
	function checkForInsertion()
	{
		if(document.getElementById('termini').checked != true || document.getElementById('datiPers').checked != true)
		{
			document.form1.Submit.disabled = true;
		}
		else
		{
			document.form1.Submit.disabled = false;
		}
	}
	
	function clickDisabledTip()
	{
		if(!document.getElementById('termini').checked || !document.getElementById('datiPers').checked)
		{
			document.getElementById('tipSpan').innerHTML = "Per registrarti devi accettare i termini d'uso!";
			setTimeout("document.getElementById('tipSpan').innerHTML = \"\";",2000);
			
		}
	}
	
	// Select dinamiche provincia / comuni -----------------------------------------------------
	var httpComuni = createRequestObject();
	var span = "";

	function populateComuniSelect(selectName, spanName, comune)
	{
		span = spanName;
		provincia = document.getElementById(selectName).value;
		httpComuni.open('get', 'ajaxScripts/populateComuniSelect.php?provincia='+provincia+'&comune='+comune);
		httpComuni.onreadystatechange = handleResponseComuniSelect;
		httpComuni.send(null);
	}

	function handleResponseComuniSelect()
	{
		if(httpComuni.readyState == 4)
		{
			var response = httpComuni.responseText;
			document.getElementById(span).innerHTML = "";
			document.getElementById(span).innerHTML = response;
		}
		else
		{
			document.getElementById(span).innerHTML = "<select class=\"testoSemplice\" disabled><option>Wait..</option></select>";
		}
	}
	// Select dinamiche provincia / comuni -----------------------------------------------------
	
	