<!--
/*
'°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
' Copyright (C) 2003 Gianluca Bracca.
' Tutti i diritti riservati.
' http://www.gianlucabracca.com  -  Email: info@gianlucabracca.com
'°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
	
'-------------------------------------------------------
' NOME:			supporto.js
'
' DESCRIZIONE:	Client side scripts
' DATA:			09/06/2003
'-------------------------------------------------------
*/

//Validatore form del sito
function GODOT_ValidaForm(NOMEFORM){
	var bErrore = false
	var msg = "Attenzione!\n"
	var errore = ""
	switch (NOMEFORM) 
		{ 
			case "frmUserLogin": 
				bErrore = false
				break;
			case "frmUserIscrizione": 
				var username = document.forms[NOMEFORM].username.value;
				var password = document.forms[NOMEFORM].password.value;
				var confermapassword = document.forms[NOMEFORM].confermapassword.value;
				var email = document.forms[NOMEFORM].email.value;
				var nome = document.forms[NOMEFORM].nome.value;
				var cognome = document.forms[NOMEFORM].cognome.value;
				var citta = document.forms[NOMEFORM].citta.value;
				var provincia = document.forms[NOMEFORM].provincia.value;
				var regione = document.forms[NOMEFORM].regione.value;
				var data_nascita = document.forms[NOMEFORM].data_nascita.value;
				var accetto = document.forms[NOMEFORM].accetto.checked;
				if (username.length==0){
					bErrore = true
					errore = errore + "\nUsername obbligatorio.";
				}
				if (password.length==0){
					bErrore = true
					errore = errore + "\nPassword obbligatorio.";
				}
				if (confermapassword.length==0){
					bErrore = true
					errore = errore + "\nConferma Password obbligatorio.";
				}
				if (confermapassword!=password){
					bErrore = true
					errore = errore + "\nPassword e Conferma Password non coincidono.";
				}
				if (email.length==0){
					bErrore = true
					errore = errore + "\nEmail obbligatorio.";
				}
				if (GODOT_CheckEmail(email)==false){
					bErrore = true
					errore = errore + "\nIndirizzo Email non valido.";
				}
				if (nome.length==0){
					bErrore = true
					errore = errore + "\nNome obbligatorio.";
				}
				if (cognome.length==0){
					bErrore = true
					errore = errore + "\nCognome obbligatorio.";
				}
				if (provincia.length==0){
					bErrore = true
					errore = errore + "\nProvincia obbligatorio.";
				}
				if (citta.length==0){
					bErrore = true
					errore = errore + "\nCittà obbligatorio.";
				}
				if ((isNaN(provincia)==false) || (provincia.length<2)){
					bErrore = true
					errore = errore + "\nInserisci una Provincia valida.";
				}
				if (regione.length==0){
					bErrore = true
					errore = errore + "\nRegione obbligatorio.";
				}
				if (data_nascita.length==0){
					bErrore = true
					errore = errore + "\nData di nascita è obbligatorio.";
				}				
				if (accetto==false){
					bErrore = true
					errore = errore + "\nDevi aver letto ed accettato la Nota Informativa.";
				}
				break;
			case "frmUserModifica": 
				var password = document.forms[NOMEFORM].password.value;
				var confermapassword = document.forms[NOMEFORM].confermapassword.value;
				var email = document.forms[NOMEFORM].email.value;
				var nome = document.forms[NOMEFORM].nome.value;
				var cognome = document.forms[NOMEFORM].cognome.value;
				var provincia = document.forms[NOMEFORM].provincia.value;
				var citta = document.forms[NOMEFORM].citta.value;
				if (confermapassword!=password){
					bErrore = true
					errore = errore + "\nNuova Password e Conferma nuova password non coincidono.";
				}
				if (email.length==0){
					bErrore = true
					errore = errore + "\nEmail obbligatorio.";
				}
				if (GODOT_CheckEmail(email)==false){
					bErrore = true
					errore = errore + "\nIndirizzo Email non valido.";
				}
				if (nome.length==0){
					bErrore = true
					errore = errore + "\nNome obbligatorio.";
				}
				if (cognome.length==0){
					bErrore = true
					errore = errore + "\nCognome obbligatorio.";
				}
				if (provincia.length==0){
					bErrore = true
					errore = errore + "\nProvincia obbligatorio.";
				}
				if ((isNaN(provincia)==false) || (provincia.length<2)){
					bErrore = true
					errore = errore + "\nInserisci una Provincia valida.";
				}
				if (citta.length==0){
					bErrore = true
					errore = errore + "\nCittà obbligatorio.";
				}
				break;
			case "frmContatti": 
				bErrore = true
				errore = errore + "\nIl form non è ancora attivo.";
				break;
			case "frmSondaggio": 
				bErrore = true
				totaledomande = document.forms[NOMEFORM].CVoto.length;
				for(i=0;i<totaledomande;i++){
					if(document.forms[NOMEFORM].CVoto[i].checked){bErrore=false}
				}
				errore = errore + "\nSeleziona un\'opzione da votare.";
				break;
		}

	if (bErrore==true){
		alert(msg + errore)
	}else{
		document.forms[NOMEFORM].submit();
	}
}

//Valida un indirizzo email
function GODOT_CheckEmail(INDIRIZZO){
	ValoreEmail = INDIRIZZO
	PosizioneAt = ValoreEmail.indexOf("@");
	PosizionePunto = ValoreEmail.indexOf(".");
	if(PosizioneAt==-1 || PosizioneAt==0 || PosizionePunto==-1 || PosizionePunto==0 || PosizioneAt==ValoreEmail.length-1){ 
		return false;
	}else{
		return true;
	}
}




// Richiama la popup della chat
function GODOT_StartChat(){
	window.open('../chat/entrata_chat.asp','Chat','status=no,scrollbars=no,resizable=yes,width=600,height=440');
}
// Gestore focus su textbox
function GODOT_FocusTextBox(OBJ,BACKGROUND,TESTO){
	//Se IE5+ o NS6+
	if (document.documentElement){
		OBJ.style.backgroundColor=BACKGROUND;
		OBJ.style.color=TESTO;
	}
}

//-->

