// Funzioni per la validazione del form di registrazione

function ValidateScratchCode (idInput_1, idInput_2, idInput_3, idImage, idProblem, idSolution) {
	var code_1 = document.getElementById(idInput_1).value;
	var code_2 = document.getElementById(idInput_2).value;
	var code_3 = document.getElementById(idInput_3).value;
    var img = document.getElementById(idImage);
    var divProblem = document.getElementById(idProblem);
    var divSolution = document.getElementById(idSolution);
    
    if ((code_1.length != 5) || (code_2.length != 5) || (code_3.length != 5)) {
		divProblem.innerHTML = "Lo scratch code non è inserito correttamente.";
        divProblem.style.display = "block";
        divSolution.innerHTML = "Inserisci tutte le 3 serie di cifre che compongono il tuo scratch-code.";
        divSolution.style.display = "block";
        img.style.display = "inline";
        return false;
    }
    else {
		divProblem.style.display = "none";
        divSolution.style.display = "none";
        img.style.display = "none";
        return true;
    }
}

function ValidatePromoUser (idInput_1, idInput_2, idImage, idProblem, idSolution) {
	var promotion = document.getElementById(idInput_1);
	var code = document.getElementById(idInput_2).value;
	var img = document.getElementById(idImage);
    var divProblem = document.getElementById(idProblem);
    var divSolution = document.getElementById(idSolution);
	
	if ((promotion.selectedIndex <= 0) || (code.length == 0)) {
		divProblem.innerHTML = "I dati della promozione non sono stati inseriti correttamente.";
        divProblem.style.display = "block";
        divSolution.innerHTML = "Seleziona dall'elenco la promozione alla quale partecipi ed inserisci il codice che hai ricevuto.";
        divSolution.style.display = "block";
        img.style.display = "inline";
        return false;
	}
	else {
		divProblem.style.display = "none";
        divSolution.style.display = "none";
        img.style.display = "none";
        return true;
	}
	
}

function ValidateAccountType (idInput_1, idInput_2, idInput_3, idImage, idProblem, idSolution) {
	var type_1 = document.getElementById(idInput_1).checked;
	var type_2 = document.getElementById(idInput_2).checked;
	var type_3 = document.getElementById(idInput_3).checked;
    var img = document.getElementById(idImage);
    var divProblem = document.getElementById(idProblem);
    var divSolution = document.getElementById(idSolution);
    
    if (!type_1 && !type_2 && !type_3) {
		divProblem.innerHTML = "Non è stato selezionato il tipo di account.";
        divProblem.style.display = "block";
        divSolution.innerHTML = "E' necessario scegliere uno dei tipi di account disponibili per proseguire.";
        divSolution.style.display = "block";
        img.style.display = "inline";
        return false;
	}
	else {
		divProblem.style.display = "none";
        divSolution.style.display = "none";
        img.style.display = "none";
        return true;
	}
}

function ValidateUsername (idInput, idImage, idProblem, idSolution) {
                
        var user = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (((user.length > 0) && (user.length < 5)) || (user.length > 30)) {
                divProblem.innerHTML = "Lo username inserito non rispetta le dimensioni necessarie.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci uno username di dimensioni comprese tra 5 e 30 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (user.length == 0) {
                        divProblem.innerHTML = "Il campo 'Username' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario scegliere uno username per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else
                        if ((user.length >= 5) && (user.length <= 30)) {
                                if (divProblem != undefined) {
                                        divProblem.style.display = "none";
                                        divSolution.style.display = "none";
                                        img.style.display = "none";
                                }
                                return true;
                        }
        }
}


function ValidatePassword (idInput, idImage, idProblem, idSolution) {
        
        var pwd = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (((pwd.length > 0) && (pwd.length < 5)) || (pwd.length > 30)) {
                divProblem.innerHTML = "La password inserita non rispetta le dimensioni necessarie.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci una password di dimensioni comprese tra 5 e 30 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (pwd.length == 0) {
                        divProblem.innerHTML = "Il campo 'Password' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire una password per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateVerificaPassword (idInput, idCheckInput, idImage, idProblem, idSolution) {
        
        var pwd = document.getElementById(idInput).value;
        var verPwd = document.getElementById(idCheckInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (pwd != verPwd) {
                divProblem.innerHTML = "Il campo 'Verifica password' non coincide con la password inserita.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci nuovamente la password, digitandola attentamente in entrambi i campi.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (verPwd.length == 0) {
                        divProblem.innerHTML = "Il campo 'Verifica password' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "Inserisci anche in questo campo la password scelta per verificare di averla scritta correttamente.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateNewPassword (idInput, idCheckInput, idImage1, idProblem1, idSolution1, idImage2, idProblem2, idSolution2) {
        
        var pwd = document.getElementById(idInput).value;
        var verPwd = document.getElementById(idCheckInput).value;
        var img1 = document.getElementById(idImage1);
        var divProblem1 = document.getElementById(idProblem1);
        var divSolution1 = document.getElementById(idSolution1);
        var img2 = document.getElementById(idImage2);
        var divProblem2 = document.getElementById(idProblem2);
        var divSolution2 = document.getElementById(idSolution2);
        
        if (((pwd.length > 0) && (pwd.length < 5)) || (pwd.length > 30)) {
                divProblem1.innerHTML = "La password inserita non rispetta le dimensioni necessarie.";
                divProblem1.style.display = "block";
                divSolution1.innerHTML = "Inserisci una password di dimensioni comprese tra 5 e 30 caratteri.";
                divSolution1.style.display = "block";
                img1.style.display = "inline";
                divProblem2.style.display = "none";
                divSolution2.style.display = "none";
                img2.style.display = "none";
                return false;
        }
        if (pwd != verPwd) {
                divProblem2.innerHTML = "Il campo 'Verifica password' non coincide con la password inserita.";
                divProblem2.style.display = "block";
                divSolution2.innerHTML = "Inserisci nuovamente la password, digitandola attentamente in entrambi i campi.";
                divSolution2.style.display = "block";
                img2.style.display = "inline";
                divProblem1.style.display = "none";
                divSolution1.style.display = "none";
                img1.style.display = "none";
                return false;
        }
        else {
                divProblem1.style.display = "none";
                divSolution1.style.display = "none";
                img1.style.display = "none";
                divProblem2.style.display = "none";
                divSolution2.style.display = "none";
                img2.style.display = "none";
                return true;
        }
}


function ValidateEmail (idInput, idImage, idProblem, idSolution) {
        var email = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (email.length == 0) {
                divProblem.innerHTML = "<br />Il campo 'E-mail' non è stato compilato.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario inserire un indirizzo e-mail per proseguire.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
                        divProblem.innerHTML = "<br />L'indirizzo e-mail inserito non è corretto.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire un indirizzo e-mail valido per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}



function ValidateNickname (idInput, idImage, idProblem, idSolution) {
        
        var nick = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (((nick.length > 0) && (nick.length < 3)) || (nick.length > 30)) {
                divProblem.innerHTML = "Il nickname inserito non rispetta le dimensioni necessarie.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci un nickname di dimensioni comprese tra 5 e 30 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (nick.length == 0) {
                        divProblem.innerHTML = "Il campo 'Nickname' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario scegliere un nickname per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidatePrivacy (idInput, idImage, idProblem, idSolution) {
        
        var privacy = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (!privacy.checked) {
                divProblem.innerHTML = "E' necessario esprimere il consenso al trattamento dei dati personali.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Leggi l'informativa sulla privacy e poi seleziona la casella qui a fianco.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}


function ValidateConditions (idInput, idImage, idProblem, idSolution) {
        
        var conditions = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (!conditions.checked) {
                divProblem.innerHTML = "E' necessario accettare le condizioni generali del sito.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Leggi le note legali e poi seleziona la casella qui a fianco.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}





function ValidateCode (source, arguments) {
        
        if (arguments.Value.length < 4)
                arguments.IsValid = false;
        else
                arguments.IsValid = true;
}


function ValidateName (idInput, idImage, idProblem, idSolution) {
        
        var name = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        var result;

        if (name.length > 50) {
                divProblem.innerHTML = "Il nome inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci soltanto il primo nome, per un massimo di 50 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (name.length == 0) {
                        divProblem.innerHTML = "Il campo 'Nome' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il nome per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateSurname (idInput, idImage, idProblem, idSolution) {
        
        var surname = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (surname.length > 50) {
                divProblem.innerHTML = "Il cognome inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci soltanto un cognome o i primi 50 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (surname.length == 0) {
                        divProblem.innerHTML = "Il campo 'Cognome' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il cognome per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateDate(idDay, idMonth, idYear, idImage, idProblem, idSolution) {
        
        var day = document.getElementById(idDay).value;
        var month = document.getElementById(idMonth).value;
        var year = document.getElementById(idYear).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
                
        var leapYear = ((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0)));
        var result = false;
        
        if ((day == 0) || (month == 0) ||(year == 0))
                result = false;
        else
        {        
                if (month == 2) {
                        if (leapYear)
                                if ((day > 0) && (day <= 29))
                                        result = true;
                                else
                                        result = false;
                      
                        if (!leapYear)
                                if ((day > 0) && (day <= 28))
                                        result = true;
                                else
                                        result = false;
                }
                else {
                        if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
                                if ((day > 0) && (day <= 30))
                                        result = true;
                                else
                                        result = false;
                        else {
                                
                                if ((month != 2) || (month != 4) || (month != 6) || (month != 9) || (month != 11))
                                        if ((day > 0) && (day <= 31))
                                                result = true;
                                        else
                                                result = false;
                        }
                }
        }
        
        if (result == false) {
                divProblem.innerHTML = "La data inserita non è corretta.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Verificare giorno, mese e anno selezionati.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
        
        return result;
}


function ValidateSex (idInput1, idInput2, idImage, idProblem, idSolution) {
        
        var male = document.getElementById(idInput1);
        var female = document.getElementById(idInput2);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (!(male.checked) && !(female.checked)) {
                divProblem.innerHTML = "Non è stato selezionato il proprio sesso.";
				divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario secegliere il proprio genere per proseguire.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}


function ValidateDrvCorporate (idInput, idImage, idProblem, idSolution) {
        
        var corporate = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (corporate.length > 100) {
                divProblem.innerHTML = "La ragione sociale inserita è troppo lunga.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Abbreviare, se possibile, alcuni termini per non superare i 100 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (corporate.length == 0) {
                        divProblem.innerHTML = "Il campo 'Ragione sociale' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire la ragione sociale della scuola guida per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateDrvSchoolRole (idInput, idImage, idProblem, idSolution) {
        
        var role = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (role.length > 100) {
                divProblem.innerHTML = "Il ruolo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire un ruolo che non superi i 100 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (role.length == 0) {
                        divProblem.innerHTML = "Il campo 'Ruolo' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario il proprio ruolo nella scuola guida per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateSchoolCorporate (idInput, idImage, idProblem, idSolution) {
        
        var corporate = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (corporate.length > 100) {
                divProblem.innerHTML = "Il nome della scuola inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Abbreviare, se possibile, alcuni termini per non superare i 100 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (corporate.length == 0) {
                        divProblem.innerHTML = "Non è stato inserito il nome della scuola.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il nome della scuola per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateSchoolRole (idInput, idImage, idProblem, idSolution) {
        
        var role = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (role.length > 100) {
                divProblem.innerHTML = "Il ruolo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire un ruolo che non superi i 100 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (role.length == 0) {
                        divProblem.innerHTML = "Il campo 'Ruolo' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario il proprio ruolo nella scuola per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}

function ValidateState (idInput, idImage, idProblem, idSolution) {
	var state = document.getElementById(idInput);
	var img = document.getElementById(idImage);
	var divProblem = document.getElementById(idProblem);
	var divSolution = document.getElementById(idSolution);
	
	if(state.selectedIndex == 0)
	{
		divProblem.innerHTML = "Non è stato selezionato il proprio stato di residenza";
		divProblem.style.display = "block";
		divSolution.innerHTML = "E' necessario indicare il proprio stato per proseguire.";
		divSolution.style.display = "block";
		img.style.display = "inline";
		return false;
	}
	else 
	{
		divProblem.style.display = "none";
		divSolution.style.display = "none";
		img.style.display = "none";
		return true;
	}
}

function ValidateArea (idInput, idImage, idProblem, idSolution)
{
	var area = document.getElementById(idInput);
	var img = document.getElementById(idImage);
	var divProblem = document.getElementById(idProblem);
	var divSolution = document.getElementById(idSolution);
	
	if(area.selectedIndex == 0)
	{
		divProblem.innerHTML = "Non è stata selezionata la propria regione di residenza.";
		divProblem.style.display = "block";
		divSolution.innerHTML = "E' necessario indicare la propria regione per proseguire.";
		divSolution.style.display = "block";
		img.style.display = "inline";
		return false;
	}
	else 
	{
		divProblem.style.display = "none";
		divSolution.style.display = "none";
		img.style.display = "none";
		return true;
	}
}


function ValidateProvince (idInput, idImage, idProblem, idSolution) {
        
        var prov = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (prov.selectedIndex == 0) {
                divProblem.innerHTML = "Non è stata selezionata la propria provincia di residenza.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario indicare la propria provincia per proseguire.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}


function ValidateTownDropDownList (idInput, idImage, idProblem, idSolution) {
        
        var town = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
		if (town.selectedIndex == 0) 
		{
				divProblem.innerHTML = "E' necessario indicare il proprio comune per proseguire.";
				divProblem.style.display = "block";
				divSolution.innerHTML = "Non è stato selezionato il proprio comune di residenza.";
				divSolution.style.display = "block";
				img.style.display = "inline";
				return false;
		}
		else
		{
				divProblem.style.display = "none";
				divSolution.style.display = "none";
				img.style.display = "none";
				return true;
		}
}

function ValidateTown (idInput, idImage, idProblem, idSolution) {
        
        var town = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (town.length > 50) {
                divProblem.innerHTML = "Il comune inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire il nome del comune di residenza in modo che non superi i 50 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (town.length == 0) {
                        divProblem.innerHTML = "Il campo 'Comune' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il proprio comune di residenza per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}

function ValidateAddress (idInput, idImage, idProblem, idSolution) {
        
        var address = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (address.length > 200) {
                divProblem.innerHTML = "L'indirizzo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Abbreviare, se possibile, alcuni termini per non superare i 200 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (address.length == 0) {
                        divProblem.innerHTML = "Il campo 'Indirizzo' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il proprio indirizzo per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}





function ValidateZipcode (idInput, idImage, idProblem, idSolution) {
        
        var zip = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if ((zip.length != 5) && (zip.length > 0)) {
                divProblem.innerHTML = "Il C.A.P. inserito non è corretto.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Controlla di averlo digitato correttamente e reinseriscilo.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (zip.length == 0) {
                        divProblem.innerHTML = "Il campo 'C.A.P.' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il proprio C.A.P. per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidatePhone (idInput, idImage, idProblem, idSolution) {
                        
        var phone = document.getElementById(idInput).value;
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        var img = document.getElementById(idImage);
        
        if (phone.length == 0) {
                divProblem.innerHTML = "Non è stato inserito il numero di telefono.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario inserire il numero di telefono per proeguire.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}



// NEWS


function ValidateTitoloNews (idInput, idImage, idProblem, idSolution) {
        
        var titolo = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (titolo.length > 200) {
                divProblem.innerHTML = "Il titolo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire il titolo della news in modo che non superi i 200 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (titolo.length == 0) {
                        divProblem.innerHTML = "Il campo 'Titolo' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il titolo per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateCorpoNews (idInput, idImage, idProblem, idSolution) {
        
        var corpo = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (corpo.length > 2000) {
                divProblem.innerHTML = "Il testo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire il testo della news in modo che non superi i 2000 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (corpo.length == 0) {
                        divProblem.innerHTML = "Il campo 'Testo' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il testo per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}

// NEWSLETTER


function ValidateOggettoNewsletter (idInput, idImage, idProblem, idSolution) {
        
        var oggetto = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (oggetto.length > 200) {
                divProblem.innerHTML = "L'oggetto inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire l'oggetto della newsletter in modo che non superi i 200 caratteri.";
				divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (oggetto.length == 0) {
                        divProblem.innerHTML = "Il campo 'Oggetto' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire l'oggetto per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateCorpoNewsletter (idInput, idImage, idProblem, idSolution) {
        
        var corpo = document.getElementById(idInput).value;

        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (corpo.length > 2000) {
                divProblem.innerHTML = "Il testo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire il testo della news in modo che non superi i 2000 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (corpo.length == 0) {
                        divProblem.innerHTML = "Il campo 'Testo' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il testo per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}

// LIVE


function ValidateLiveLessonTitle (idInput, idImage, idProblem, idSolution) {
        
        var titolo = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (titolo.length > 200) {
                divProblem.innerHTML = "Il titolo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire il titolo della lezione in modo che non superi i 200 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (titolo.length == 0) {
                        divProblem.innerHTML = "Il campo 'Titolo' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il titolo per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateLiveLessonDescription (idInput, idImage, idProblem, idSolution) {
        
        var descrizione = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (descrizione.length > 200) {
                divProblem.innerHTML = "Il testo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire il testo della descrizione in modo che non superi i 100 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (descrizione.length == 0) {
                        divProblem.innerHTML = "Il campo 'Descrizione' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire la descrizione per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}


function ValidateLivePlanningDatetime(idStart, idEnd, idImage, idProblem, idSolution){

        
        var planningStart = document.getElementById(idStart).value;
        var planningEnd = document.getElementById(idEnd).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (parseInt(planningStart.split(".").join("")) > parseInt(planningEnd.split(".").join(""))){
                divProblem.innerHTML = "L'orario di inizio deve precedere quello della fine.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Controllare meglio gli orari inseriti.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else return true;
}

function ValidateLiveResourceFile (idInput, idImage, idProblem, idSolution) {
        
        var resourceFile = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (resourceFile.length > 200) {
            divProblem.innerHTML = "Il testo inserito è troppo lungo.";
            divProblem.style.display = "block";
            divSolution.innerHTML = "Il file non deve superare i 200 caratteri.";
            divSolution.style.display = "block";
            img.style.display = "inline";
            return false;
        }
        else {        
            divProblem.style.display = "none";
            divSolution.style.display = "none";
            img.style.display = "none";
            return true;        
        }
}

function ValidateLiveResourceName (idInput, idImage, idProblem, idSolution) {
        
        var resourceName = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (resourceName.length > 50) {
                divProblem.innerHTML = "Il testo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Il nome del file non deve superare i 50 caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (resourceName.length == 0) {
                        divProblem.innerHTML = "Il campo 'Nome' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire un file per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}

// ALTRO

function ValidateBannerFile(idInput, idImage, idProblem, idSolution) {
    
        var bannerFile = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (bannerFile.length > 100) {
            divProblem.innerHTML = "Il nome del file inserito è troppo lungo.";
            divProblem.style.display = "block";
            divSolution.innerHTML = "Il nome del file non deve superare i 100 caratteri.";
            divSolution.style.display = "block";
            img.style.display = "inline";
            return false;
        } else {
                if (bannerFile.length == 0) {
                    divProblem.innerHTML = "Il campo 'nuovo banner' non è stato compilato.";
                    divProblem.style.display = "block";
                    divSolution.innerHTML = "E' necessario inserire un file per proseguire.";
                    divSolution.style.display = "block";
                    img.style.display = "inline";
                    return false;
                } else {
                    if (bannerFile.indexOf(".swf") != (bannerFile.length - 4)) {
                        divProblem.innerHTML = "Il tipo di banner atteso è Flash, con estensione '.swf'.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire un file '.swf' per proseguire..";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                    } else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                    }
                }
        }
}

function ValidatePageFile(idInput, idImage, idProblem, idSolution) {
    
        var pageFile = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (pageFile.length > 100) {
            divProblem.innerHTML = "Il nome del file inserito è troppo lungo.";
            divProblem.style.display = "block";
            divSolution.innerHTML = "Il nome del file non deve superare i 100 caratteri.";
            divSolution.style.display = "block";
            img.style.display = "inline";
            return false;
        } else {
                if (pageFile.length == 0) {
                    divProblem.innerHTML = "Il campo 'pagina linkata' non è stato compilato.";
                    divProblem.style.display = "block";
                    divSolution.innerHTML = "E' necessario inserire un file per proseguire.";
                    divSolution.style.display = "block";
                    img.style.display = "inline";
                    return false;
                } else {
                    if (pageFile.indexOf(".aspx") != (pageFile.length - 5)) {
                        divProblem.innerHTML = "Il tipo di pagina attesa è ASP.NET, con estensione '.aspx'.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire un file '.aspx' per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                    } else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                    }
                }
        }
}


function ValidateOrdering (idInput, idImage, idProblem, idSolution) {

        var numeric = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        var regExpr = /[0-9]/;
        if (numeric != "") {
                if (!regExpr.test(numeric)) {
                        divProblem.innerHTML = "Il numero d'ordine inserito non è corretto.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "---";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
        else {
                divProblem.innerHTML = "Non è stato inserito il numero d'ordine.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserire un numero per l'ordinamento dell'offerta.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
}

function ValidateSerialNumber (idInput, idImage, idProblem, idSolution) {

        var numeric = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        var regExpr = /[0-9]/;
        if (numeric != "") {
                if (!regExpr.test(numeric)) {
                        divProblem.innerHTML = "Il numero seriale inserito non è corretto.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "I numeri seriali possono contenere soltanto cifre da 0 a 9.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
        else {
                divProblem.innerHTML = "Non è stato inserito il numero seriale.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci un numero di serie per proseguire.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
}

function ValidateSerials (idInput_start, idInput_end, idImage, idProblem, idSolution) {
        
        var input_start = document.getElementById(idInput_start).value;
        var input_end =  document.getElementById(idInput_end).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (input_start > input_end) {
                divProblem.innerHTML = "Il numero di serie iniziale è maggiore di quello finale!";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Verificare i dati inseriti e riprovare.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                return true;
        }
}

function ValidateRequired (idInput, maxLength, name, idImage, idProblem, idSolution) {

        var input = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (input.length > maxLength) {
                divProblem.innerHTML = "Il testo inserito è troppo lungo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Inserisci un testo non superiore a " + maxLength.toString + " caratteri.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (input.length == 0) {
                        divProblem.innerHTML = "Il campo '" + name + "' non è stato compilato.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario compilare il campo per proseguire.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        } 

}

// Funzioni per la validazione dei criteri di ricerca per i Report

function ValidateRole (idInput, idImage, idProblem, idSolution) {
        var input = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (input.selectedIndex == 0) {
                divProblem.innerHTML = "Non è stato selezionato nessun ruolo.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario scegliere il ruolo in base al quale effettuare la ricerca.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                return true;
        }  
}

function ValidateReportDate(idSelSearch, idDay, idMonth, idYear, idImage, idProblem, idSolution) {
        
        var day = document.getElementById(idDay).value;
        var month = document.getElementById(idMonth).value;
        var year = document.getElementById(idYear).value;
        var selSearch = document.getElementById(idSelSearch);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
                
        var leapYear = ((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0)));
        var result = false;
        
        if ((day == 0) || (month == 0) ||(year == 0))
                result = false;
        else
        {        
                if (month == 2) {
                        if (leapYear)
                                if ((day > 0) && (day <= 29))
                                        result = true;
                                else
                                        result = false;
                      
                        if (!leapYear)
                                if ((day > 0) && (day <= 28))
                                        result = true;
                                else
                                        result = false;
                }
                else {
                        if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
                                if ((day > 0) && (day <= 30))
                                        result = true;
                                else
                                        result = false;
                        else {
                                
                                if ((month != 2) || (month != 4) || (month != 6) || (month != 9) || (month != 11))
                                        if ((day > 0) && (day <= 31))
                                                result = true;
                                        else
                                                result = false;
                        }
                }
        }
        
        if (result == false) {
                divProblem.innerHTML = "La data inserita non è corretta.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Verificare giorno, mese e anno selezionati.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (selSearch.selectedIndex == 0) {
                        divProblem.innerHTML = "Non è stato selezionato il criterio di ricerca per la data.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario selezionare un tipo di scadenza.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
        
        return result;
}

function ValidateExpirationType (idInput, idImage, idProblem, idSolution) {
        
        var prov = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (prov.selectedIndex == 0) {
                divProblem.innerHTML = "Non è stato selezionato il tipo di scadenza per le card.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario selezionare un tipo di scadenza.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}

function ValidateCardType (idInput, idImage, idProblem, idSolution) {
        
        var prov = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (prov.selectedIndex == 0) {
                divProblem.innerHTML = "Non è stato selezionato il tipo di scratch-card.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario selezionare un tipo di scratch-card associate alla campagna.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}

function ValidateDuration (idInput, idImage, idProblem, idSolution) {
        var duration = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (duration.length == 0) {
                divProblem.innerHTML = "Non è stata inserita la durata delle scratch-card.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario impostare la durata delle card.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                if (!/^[0-9]/.test(duration)) {
                        divProblem.innerHTML = "La durata inserita non è corretta.";
                        divProblem.style.display = "block";
                        divSolution.innerHTML = "E' necessario inserire il numero di giorni/ingressi di validità.";
                        divSolution.style.display = "block";
                        img.style.display = "inline";
                        return false;
                }
                else {
                        divProblem.style.display = "none";
                        divSolution.style.display = "none";
                        img.style.display = "none";
                        return true;
                }
        }
}

function ValidateFileUpload (idInput, idImage, idProblem, idSolution) {
        
        var fileUpld = document.getElementById(idInput);
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (fileUpld.value == "") {
                divProblem.innerHTML = "Non è stato selezionato nessun file.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario selezionare un file da inviare.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
        }
}

function ValidatePromotionalCodeType (idInput, idImage, idProblem, idSolution) {
		var selectType = document.getElementById(idInput);
		var img = document.getElementById(idImage);
		var divProblem = document.getElementById(idProblem);
		var divSolution = document.getElementById(idSolution);
		
		if (selectType.selectedIndex == 0) {
			divProblem.innerHTML = "Non è stato selezionato il tipo di codici.";
			divProblem.style.display = "block";
			divSolution.innerHTML = "E' necessario selezionare che tipo di codici si vogliono generare.";
			divSolution.style.display = "block";
			img.style.display = "inline";
			return false;
		}
		else {
			divProblem.style.display = "none";
			divSolution.style.display = "none";
			img.style.display = "none";
			return true;
		}
		
}

function ValidateGeneration(selectType, numCodes, codeLength, idImage, idProblem, idSolution) {
		var selectType = document.getElementById(selectType);
		var codeType = selectType.options[selectType.selectedIndex].value
		var numCodes = document.getElementById(numCodes).value;
		var codeLength = document.getElementById(codeLength).value;
		var img = document.getElementById(idImage);
		var divProblem = document.getElementById(idProblem);
		var divSolution = document.getElementById(idSolution);
		
		if ((codeType == "NUM") && (codeLength == 4) && (numCodes > 10000)) {
				divProblem.innerHTML = "Il numero di codici richiesto è incompatibile con la lunghezza fissata.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "Ridurre il numero di codici o aumentarne la lunghezza.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
		else {
			divProblem.style.display = "none";
			divSolution.style.display = "none";
			img.style.display = "none";
			return true;
		}

}

function ValidateLength (idInput, idImage, idProblem, idSolution) {
        var len = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (len.length == 0) {
                divProblem.innerHTML = "Non è stata inserita la lunghezza dei codici.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario impostare la lunghezza desiderata per i codici da generare.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
				if (!/^[0-9]/.test(len)) {
						divProblem.innerHTML = "Il valore inserito non è corretto.";
						divProblem.style.display = "block";
						divSolution.innerHTML = "E' necessario inserire un valore numerico.";
						divSolution.style.display = "block";
						img.style.display = "inline";
						return false;
				}
				else {
						if ((len < 4) || (len > 18)) {
								divProblem.innerHTML = "Il numero inserito non è fuori dall'intervallo consentito.";
								divProblem.style.display = "block";
								divSolution.innerHTML = "Inserire una lunghezza compresa tra 4 e 18 caratteri..";
								divSolution.style.display = "block";
								img.style.display = "inline";
								return false;
						}
						else {
								divProblem.style.display = "none";
								divSolution.style.display = "none";
								img.style.display = "none";
								return true;
						}
				}
        }
}

function ValidateCodeNumber (idInput, idImage, idProblem, idSolution) {
        var number = document.getElementById(idInput).value;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if (number.length == 0) {
                divProblem.innerHTML = "Non è stato inserito il numero dei codici.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "E' necessario impostare il numero di codici da generare.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
        }
        else {
				if (!/^[0-9]/.test(number)) {
						divProblem.innerHTML = "Il valore inserito non è corretto.";
						divProblem.style.display = "block";
						divSolution.innerHTML = "E' necessario inserire un valore numerico.";
						divSolution.style.display = "block";
						img.style.display = "inline";
						return false;
				}
				else {
						if (number > 100000) {
								divProblem.innerHTML = "Il numero inserito supera i limiti fissati.";
								divProblem.style.display = "block";
								divSolution.innerHTML = "E' necessario inserire un numero di codici compreso tra 1 e 100.000.";
								divSolution.style.display = "block";
								img.style.display = "inline";
								return false;
						}
						else {
								divProblem.style.display = "none";
								divSolution.style.display = "none";
								img.style.display = "none";
								return true;
						}
				}
        }
}

function ValidateSelect (idInput, idImage, idProblem, idSolution, problem, solution) {
        var selectedIndex = document.getElementById(idInput).selectedIndex;
        var img = document.getElementById(idImage);
        var divProblem = document.getElementById(idProblem);
        var divSolution = document.getElementById(idSolution);
        
        if ((selectedIndex == 0) || (selectedIndex = null)) {
			divProblem.innerHTML = problem;
			divProblem.style.display = "block";
			divSolution.innerHTML = solution;
			divSolution.style.display = "block";
            img.style.display = "inline";
			return false;
        }
        else {
			divProblem.style.display = "none";
			divSolution.style.display = "none";
			img.style.display = "none";
			return true;
        }
}




 function ValidateTempUnlockCode (idInput, idImage, idProblem, idSolution){
            var inputTxt = document.getElementById(idInput).value;
            var img = document.getElementById(idImage);
            var divProblem = document.getElementById(idProblem);
            var divSolution = document.getElementById(idSolution);
            if (inputTxt.length != 4)
            {
                divProblem.innerHTML = "Il codice richiesto deve essere di 4 cifre.";
                divProblem.style.display = "block";
                divSolution.innerHTML = "<br />E' necessario inserire un codice valido.";
                divSolution.style.display = "block";
                img.style.display = "inline";
                return false;
            }
            else
            {   
                divProblem.style.display = "none";
                divSolution.style.display = "none";
                img.style.display = "none";
                return true;
            }
        }


