// JavaScript Document

function controllo_registrazione(){

	if (document.getElementById("nome").value.length <= 0) {
		alert("Per completare l'iscrizione è necessario inserire il tuo nome.");
		document.getElementById("nome").focus()
		return false;
	}
	
	if (document.getElementById("cognome").value.length <= 0) {
		alert("Per completare l'iscrizione è necessario inserire il tuo cognome.");
		document.getElementById("cognome").focus()
		return false;
	}
	
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	var email = document.getElementById("email").value;
	
	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
		alert("Inserire un indirizzo email corretto.");
		document.getElementById("email").focus()
		return false;
	} 

	if (document.getElementById("username").value.length <= 0) {
		alert("Inserisci il tuo username.");
		document.getElementById("username").focus()
		return false;
	}
	
	if (document.getElementById("password").value.length <= 0) {
		alert("Inserisci la password.");
		document.getElementById("password").focus()
		return false;
	}
	
	if (document.getElementById("password").value != document.getElementById("conferma_password").value) {
		alert("La password confermata è diversa da quella scelta, controllare.");
		document.frm_registra.conferma_password.value = "";
		document.frm_registra.conferma_password.focus();
		return false;
	} 
	
	if (!document.getElementById("accetto").checked) {
		alert("Devi accettare i termini di servizio.");
		return false;
	}
	
	document.frm_registra.action = "default.asp";
	document.frm_registra.submit();
}


function controllo_modifica(){

	if (document.getElementById("nome").value.length <= 0) {
		alert("Per completare l'iscrizione è necessario inserire il tuo nome.");
		document.getElementById("nome").focus()
		return false;
	}
	
	if (document.getElementById("cognome").value.length <= 0) {
		alert("Per completare l'iscrizione è necessario inserire il tuo cognome.");
		document.getElementById("cognome").focus()
		return false;
	}
		
	if (document.getElementById("password").value != document.getElementById("conferma_password").value) {
		alert("La password confermata è diversa da quella scelta, controllare.");
		document.frm_registra.conferma_password.value = "";
		document.frm_registra.conferma_password.focus();
		return false;
	} 
		
	document.frm_registra.action = "default.asp";
	document.frm_registra.submit();
}


function controllo_esame() {
	
	if (document.getElementById("titolo_esame").value.length <= 0) {
		alert("Inserisci il titolo dell'esame.");
		document.getElementById("id_esame").focus()
		return false;
	}
	if (document.getElementById("testo_domanda").value.length <= 0) {
		alert("Inserisci cosa ti ha chiesto.");
		document.getElementById("testo_domanda").focus()
		return false;
	}
	if (document.getElementById("citta").value.length <= 0) {
		alert("Scegli una città dall'elenco.");
		document.getElementById("citta").focus()
		return false;
	}
	if (document.getElementById("facolta").value.length <= 0) {
		alert("Scegli una facoltà dall'elenco.");
		document.getElementById("facolta").focus()
		return false;
	}
	if ((document.getElementById("nome_prof").value.length <= 0) && (document.getElementById("cognome_prof").value.length <= 0)) {
		alert("Inserisci il professore.");
		document.getElementById("cognome_prof").focus()
		return false;
	}

	document.frm_pubblica.action = "/esame/pubblica/default.asp";
	document.frm_pubblica.submit();
}



function controllo_commento() {
	
	if (document.getElementById("id_utente").value.length <= 0) {
		alert("Per inserire un commento devi essere registrato.");
		document.getElementById("testo_commento").focus()
		return false;
	}

	if (document.getElementById("testo_commento").value.length <= 0) {
		alert("Inserisci un commento.");
		document.getElementById("testo_commento").focus()
		return false;
	}

	document.frm_comm.action = "/esame/pubblica/commento.asp";
	document.frm_comm.submit();
}




function controllo_abuso() {
	
	if (document.getElementById("motivo").value.length <= 0) {
		alert("Inserisci un motivo per la segnalazione.");
		document.getElementById("motivo").focus()
		return false;
	}

	document.frm_abuso.action = "/contatti/abuso.asp";
	document.frm_abuso.submit();
}






//AUTOCOMPLETAMENTO


// FINE AUTOCOMPLETAMENTO





function controlla_dati(){

	if (document.getElementById("username").value.length <= 0) {
		alert("Inserisci l'username.");
		document.getElementById("username").focus()
		return false;
	}
	
	if (document.getElementById("pwd").value.length <= 0) {
		alert("Inserisci la password.");
		document.getElementById("pwd").focus()
		return false;
	}
				
	document.frm_admin.action = "test_pwd.asp";
	document.frm_admin.submit();
}


