/* Controllo riempimento campi */

	var loginForm;

	//Attach an "onLoad" event to the current window
	window.onload = init;
	
	//Initialization function
	function init() {
		//Attaching the onSubmit event to the login form
		loginForm = document.getElementById('login');
		loginForm.onsubmit = function () {
			return canSubmit(this);
		}
		
		//Setting focus to the user field
		loginForm.username.focus();
	}

	function filled(field) {
		if (field.value == "" || field.value == null) {
			return false;
		} else {
			return true;
		}
	}
	
	function canSubmit(form) {
		if (!filled(form.username)) {
			alert("Per favore inserire la username.");
			form.username.focus();
			return false;
		}
		
		if (!filled(form.password)) {
			alert("Per favore inserire la password.");
			form.password.focus();
			return false;
		}

		return true;
	}

