function validateForm(objFrm){
   the_form = (typeof(objFrm)=='object')? objFrm:document.forms[objFrm];
	msg='';
	if(the_form.userName.value == '') msg += "ATTENZIONE: USERNAME e' un campo obbligatorio\n";

	if(the_form.pwd.value == '') msg += "ATTENZIONE: PASSWORD e' un campo obbligatorio\n";
   else if(!IsValidPWD(the_form.pwd.value)) msg += "ATTENZIONE: La password puo' contenere solo lettere e numeri ed i seguenti caratteri _ - \n";

	if(the_form.nome.value == '') msg += "ATTENZIONE: NOME e' un campo obbligatorio\n";
	if(the_form.cognome.value == '') msg += "ATTENZIONE: COGNOME e' un campo obbligatorio\n";

	if(the_form.email.value == '') msg += "ATTENZIONE: EMAIL e' un campo obbligatorio\n";
   else if(!checkEmail(the_form.email.value)) msg += "ATTENZIONE: EMAIL non valida\n";

   if(the_form.userName.value != the_form.email.value) msg += 'ATTENZIONE: USERNAME e EMAIL devono essere uguali.\n'
   if(the_form.pwd.value != the_form.pwdConfirm.value) msg += 'ATTENZIONE: Ricontrolla la password, non e\' uguale alla conferma.\n'


	if(!the_form.cbPrivacy.checked){
		msg += "ATTENZIONE: Senza il consenso alla privacy non è possibile iscriverti.\nCome puoi leggere nell'informativa, il consenso si riferisce esclusivamente alla possibilità di memorizzare nel nostro database i tuoi dati\n";
		the_form.cbPrivacy.checked = true;
	}

   if(msg != ''){ alert (msg); _doPostBack = false;}
   else _doPostBack = true;

   return _doPostBack;
}

function validateFormLogin(objFrm){

	the_form = (typeof(objFrm)=='object')? objFrm:document.forms[objFrm];
	msg='';

	if(the_form.txtPwdLogin.value == '') msg += "ATTENZIONE: PASSWORD e' un campo obbligatorio\n";
   else if(!IsValidPWD(the_form.txtPwdLogin.value)) msg += "ATTENZIONE: La password puo' contenere solo lettere e numeri ed i seguenti caratteri _ - \n";

	if(the_form.txtEmailLogin.value == '')msg += "ATTENZIONE: EMAIL e' un campo obbligatorio\n";
   else if(!checkEmail(the_form.txtEmailLogin.value)) msg += "ATTENZIONE: EMAIL non valida\n";


   if(msg != ''){ alert (msg); _doPostBack = false;}
   else _doPostBack = true;

   return _doPostBack;
}

function setUN(){
	the_form.userName.value=the_form.email.value;
}

function checkRight( caso ) {
	msg2='';
	if(!checkEmail(the_form.email.value)) msg2 += "ATTENZIONE: EMAIL non valida\n";
	if(!IsValidPWD(str)) msg2 += "ATTENZIONE: La password puo' contenere solo lettere e numeri ed i seguenti caratteri _ - \n";

	if( caso==1 ){
		if(the_form.userName.value != the_form.email.value) msg2+='ATTENZIONE: USERNAME e EMAIL devono essere uguali.\n'
		if(the_form.pwd.value != the_form.pwdConfirm.value) msg2+='ATTENZIONE: Ricontrolla la password, non e\' uguale alla conferma.\n'
		//checkTel();
		//if( typeof(the_form.cap) != 'undefined' && the_form.cap.value != '') checkCAP();
	}

	if (msg2 == ''){
		return true;
	}else{
		alert(msg2);
		return false;
	}
}

function checkCAP() {
	var cap_re = new RegExp("^[0-9]{5}$");
	str = the_form.cap.value
	if(cap_re.test(str) == false) msg2 += "ATTENZIONE: hai inserito un C.A.P. non valido \n";
}
function checkTel() {
	var Tel_re = new RegExp("[0-9\(\)\-/ ]+");
	str = the_form.tel_uff.value
	if(Tel_re.test(str) == false) msg2 += "ATTENZIONE: hai inserito un numero di telefono non valido \n";
}

