<!--

//mostra elemento
function mostra(id){
if (document.getElementById){
if(document.getElementById(id).style.display == 'none'){
document.getElementById(id).style.display = 'block';
} else {
document.getElementById(id).style.display = 'none';
}
}
}


//creazione utente
function valida_nuovoutente() {
	
	var cognome = document.frm_reg.user_surname.value;
	var nome = document.frm_reg.user_name.value;
	var email = document.frm_reg.user_email.value;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
	if (cognome == "") {
		alert("Il campo 'cognome' è obbligatorio");
		document.frm_reg.user_surname.focus();
		return false;
	}
	
	else if (nome == "") {
		alert("Il campo 'nome' è obbligatorio");
		document.frm_reg.user_name.focus();
		return false;
	}
	
	else if (email == "") {
		alert("Il campo 'email' è obbligatorio");
		document.frm_reg.user_email.focus();
		return false;
	}
	
	else if ((email != "") && (!email_reg_exp.test(email))) {
		alert("Inserire un indirizzo email corretto");
		document.frm_reg.user_email.select();
		return false;
	}

	else {
			document.frm_reg.action = '../processor/crea-utente.php';
			document.frm_reg.submit();
	}
	
}


//creazione utente
function valida_cambiapwd() {
	
	var old_pwd = document.frm_reg.old_pwd.value;
	var new_pwd = document.frm_reg.new_pwd.value;
	var retype_pwd = document.frm_reg.retype_pwd.value;
	var lunghezza_pwd = document.frm_reg.new_pwd.value.length;
	
	if (old_pwd == "") {
		alert("Non hai inserito la vecchia password");
		document.frm_reg.old_pwd.focus();
		return false;
	}
	
	else if (new_pwd == "") {
		alert("Non hai inserito la nuova password");
		document.frm_reg.new_pwd.focus();
		return false;
	}
	
	else if (lunghezza_pwd < 6) {
		alert("La nuova password deve contenere almeno 6 caratteri");
		document.frm_reg.new_pwd.focus();
		return false;
	}

	else if (retype_pwd == "") {
		alert("Non hai confermato la password");
		document.frm_reg.retype_pwd.focus();
		return false;
	}

	else if (new_pwd != retype_pwd) {
		alert("Conferma password errata");
		document.frm_reg.retype_pwd.focus();
		document.frm_reg.retype_pwd.value = "";
		return false;
	}

	else {
			document.frm_reg.action = '../processor/cambia-password.php';
			document.frm_reg.submit();
	}
	
}



function valida_contenuto(actionlink) {
	
	var titolo = document.frm_reg.content_title.value;
	var testo = document.frm_reg.content_text.value;
	var giorno = document.frm_reg.date_d.value;
	var mese = document.frm_reg.date_m.value;
	var anno = document.frm_reg.date_y.value;
	var data = new Date(parseInt(anno, 10), parseInt(mese-1, 10), parseInt(giorno, 10));

	
	if (titolo == "") {
		alert("Non hai inserito il titolo");
		document.frm_reg.content_title.focus();
		return false;
	}
	
	else if (testo == "") {
		alert("Non hai inserito il testo integrale");
		document.frm_reg.content_text.focus();
		return false;
	}
	
	else if (!(data.getFullYear()==parseInt(anno, 10) && data.getMonth()+1==parseInt(mese, 10) && data.getDate()==parseInt(giorno, 10))) {
	alert("Attenzione: la data di pubblicazione selezionata non è valida");
	document.frm_reg.date_d.focus();
	return false;
	}

	else {
			document.frm_reg.action = actionlink;
			document.frm_reg.submit();
	}
	
}




function valida_profilo(actionlink) {
	
	var year = document.frm_reg.profile_year.value;
	var email = document.frm_reg.user_email.value;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	var giorno = document.frm_reg.birth_day.value;
	var mese = document.frm_reg.birth_month.value;
	var anno = document.frm_reg.birth_year.value;
	var data = new Date(parseInt(anno, 10), parseInt(mese-1, 10), parseInt(giorno, 10));

	if (giorno == "gg") {
		alert("Attenzione: il giorno di nascita non è stato selezionato");
		document.frm_reg.birth_day.focus();
		return false;
	}
	
	else if (mese == "mm") {
		alert("Attenzione: il mese di nascita non è stato selezionato");
		document.frm_reg.birth_month.focus();
		return false;
	}
	
	else if (anno == "aaaa") {
		alert("Attenzione: l'anno di nascita non è stato selezionato");
		document.frm_reg.birth_year.focus();
		return false;
	}
	
	else if (!(data.getFullYear()==parseInt(anno, 10) && data.getMonth()+1==parseInt(mese, 10) && data.getDate()==parseInt(giorno, 10))) {
		alert("Attenzione: la data di nascita selezionata non è valida");
		document.frm_reg.birth_day.focus();
	return false;
	}
	
	else if (year == "aaaa") {
		alert("L'anno di frequentazione del Master è obbligatorio");
		document.frm_reg.profile_year.focus();
		return false;
	}
	
	else if (email == "") {
		alert("L'email principale è obbligatoria");
		document.frm_reg.user_email.focus();
		return false;
	}
	
	else if ((email != "") && (!email_reg_exp.test(email))) {
		alert("Inserire un indirizzo email corretto");
		document.frm_reg.user_email.select();
		return false;
	}
	
	else if (document.frm_reg.consenso.checked == false) {
		alert("Devi autorizzare il trattamento dei tuoi dati personali");
		document.frm_reg.consenso.focus();
		return false;
	}
	
	else {
			document.frm_reg.action = actionlink;
			document.frm_reg.submit();
	}
	
}


//-->
