//-----------------------------------------------------------------------------------------------------------
//--- Template di file include JS
//--- 
//--- Author: eTT s.r.l. - DC, UG
//--- Edited: 28 January 2004
//---
//--- INDICE
//-----------------------------------------------------------------------------------------------------------

//==========================================================================================================
//---  FUNZIONI DI CONTROLLO PER I FORM  ----------------------------------------------------------
//==========================================================================================================

//-----------------------------------------------
function checkLogin(theForm)
{
	if (IsStringEmpty(theForm.txtLogin.value))
	{
		alert("Il campo \"login\" è obbligatorio");
		theForm.txtLogin.focus();
		return;
	}
	
	if (IsStringEmpty(theForm.txtPassword.value))
	{
		alert("Il campo \"password\" è obbligatorio");
		theForm.txtPassword.focus();
		return;
	}

	//--- Conrolli superati	
	theForm.submit();
	theForm.btnSubmit.disabled = true;		
}


//-----------------------------------------------
function domanda01(theForm)
{
	//--- Dati Anagrafici
	if (IsStringEmpty(theForm.txaDomanda.value))
	{
		alert("Il campo \"Domanda\" è obbligatorio");
		theForm.txaDomanda.focus();
		return;
	}

	//--- Conrolli superati	
	theForm.submit();
	theForm.btnSubmit.disabled = true;	
}


//-----------------------------------------------
function checkIscrizione01(theForm)
{
	//--- Dati Anagrafici
	if (IsStringEmpty(theForm.txtNome.value))
	{
		alert("Il campo \"Nome\" è obbligatorio");
		theForm.txtNome.focus();
		return;
	}

	if (IsStringEmpty(theForm.txtCognome.value))
	{
		alert("Il campo \"Cognome\" è obbligatorio");
		theForm.txtCognome.focus();
		return;
	}

	//--- Data di nascita ---
	var gg = theForm.ddmDaydataNascita.selectedIndex;
	var mm = theForm.ddmMonthdataNascita.selectedIndex;
	var aaaa = theForm.ddmYeardataNascita.selectedIndex;
	
	if (!(VerificaData(gg,mm,aaaa)))
	{
		alert("Compilare il campo \"Data di Nascita\" ");
		theForm.ddmDaydataNascita.focus();
		return;
	}
	//--- 
	
	if (theForm.ddmComuneNascita.value == -1 )
	{
		alert("Selezionare il Comune di nascita");
		theForm.ddmComuneNascita.focus();
		return;		
	}

	if (theForm.ddmSesso.value == -1 )
	{
		alert("Selezionare il sesso");
		theForm.ddmSesso.focus();
		return;		
	}
	
	
	//--- CALCOLO CODICE FISCALE
	if (IsStringEmpty(theForm.txtCodiceFiscale.value))
	{
		alert("Il campo \"Codice Fiscale\" è obbligatorio");
		theForm.txtCodiceFiscale.focus();
		return;
	}

	var txtCodiceFiscale = theForm.txtCodiceFiscale.value;
	txtCodiceFiscale = txtCodiceFiscale.toUpperCase();
	
	if ((txtCodiceFiscale) != (ComputeCF(theForm.txtCognome.value, theForm.txtNome.value, theForm.ddmDaydataNascita.value, theForm.ddmMonthdataNascita.value, theForm.ddmYeardataNascita.value, theForm.ddmComuneNascita.value, theForm.ddmSesso.value)))
	{
		alert("Il Codice fiscale non è corretto");
		theForm.txtCodiceFiscale.focus();
		return;		
	}

	//--- Informaizoni Generali
	if (IsStringEmpty(theForm.txtUsername.value))
	{
		alert("Il campo \"Username\" è obbligatorio");
		theForm.txtUsername.focus();
		return;
	}

	if (IsStringEmpty(theForm.txtPassword.value))
	{
		alert("Il campo \"Password\" è obbligatorio");
		theForm.txtPassword.focus();
		return;
	}

	if (IsStringEmpty(theForm.txtEmail.value))
	{
		alert("Il campo \"Indirizzo e-mail\" è obbligatorio");
		theForm.txtEmail.focus();
		return;
	}

	if (!IsStringEmpty(theForm.txtEmail.value))
	{
		if (!checkMail(theForm.txtEmail.value))
			return;	
	}
	

	if (theForm.ddmChiSei.value == -1 )
	{
		alert("Selezionare la tipologia di utente");
		theForm.ddmChiSei.focus();
		return;		
	}

	if (theForm.ddmNazionalita.value == -1 )
	{
		alert("Seleziona la nazionalità");
		theForm.ddmNazionalita.focus();
		return;		
	}

	if(theForm.rdbPrivacy[0].checked == false)
	{
		alert("Per poterti iscrivere alla Community Nid-Hoc è necessario accettare il trattamento dei dati personali")
		theForm.rdbPrivacy[0].focus();		
		return;
	}
	
	//--- Conrolli superati	
	theForm.submit();
	theForm.btnSubmit.disabled = true;
	theForm.btnBack.disabled = true;
}

//-----------------------------------------------
function checkCancellazione01(theForm)
{
	if (IsStringEmpty(theForm.txtUsername.value))
	{
		alert("Il campo \"Username\" è obbligatorio");
		theForm.txtUsername.focus();
		return;
	}

	if (IsStringEmpty(theForm.txtPassword.value))
	{
		alert("Il campo \"Password\" è obbligatorio");
		theForm.txtPassword.focus();
		return;
	}

	if (IsStringEmpty(theForm.txtEmail.value))
	{
		alert("Il campo \"Indirizzo e-mail\" è obbligatorio");
		theForm.txtEmail.focus();
		return;
	}

	//--- Conrolli superati	
	theForm.submit();
	theForm.btnSubmit.disabled = true;
	theForm.btnBack.disabled = true;	
}

