function InputPassword(frm,stato,p1,p2) {
	with (frm) {
	if (stato == "on") {
		document.getElementById(p1).style.display = "none";
		document.getElementById(p2).style.display = "inline";
		document.getElementById(p2).style.width = "116px";
		document.getElementById(p2).focus()
	} else {
		if (txtPassword.value == "") {
			document.getElementById(p2).style.display = "none";
			document.getElementById(p1).style.display = "inline";
			txtPassword_tmp.value = "password"
		}
	}
	}
}
	
function CheckValue(frm,n) {
	with (frm) {
		switch (n) {
			case 0:
				if (txtNickname.value == "username" || txtNickname.value == "password") txtNickname.value = "";
				break;
				
			case 1:
				if (txtNickname.value == "") txtNickname.value = "username"
				break;					
		}
	}
}


function CheckNum(num,anno) {
	with (document.frmScheda) {
		var n = num.value;
		if ((String(n*1)=="NaN")||(n=="")||(n>anno)||(n==0)) {num.value=""}
		else {num.value=Math.round(n*Math.pow(10,2))/Math.pow(10,2)}
	}
}

function checkDesc(txt,n) {
	with (document.frmModificaEditori) {
		switch (n) {
			case 1:
				if (chkLang[0].checked) {txtDesc_it.value = txt}
				if (chkLang[1].checked) {txtDesc_en.value = txt}
				if (chkLang[2].checked) {txtDesc_sa.value = txt}
				break;
			case 2:
				if (chkLangDistr[0].checked) {txtDescDistr_it.value = txt}
				if (chkLangDistr[1].checked) {txtDescDistr_en.value = txt}
				if (chkLangDistr[2].checked) {txtDescDistr_sa.value = txt}
				break;
		}			
	}
}

function validateFieldsEdi() {
	with (document.frmModificaEditori) {

		var Lang = ver.value;
	
		//validazione errori
		var err1 = (txtAzienda.value.length < 1);
		var err2 = (selLocalita.value == 0);
		var err3 = (txtSedeLegale.value.length < 1);		
		var err4 = (txtUserID.value.length < 1);
		var err5 = (txtPassword.value.length < 8);
		var err6 = (txtPassword.value != txtPassword1.value);				
		var err7 = (txtP_IVA.value != "") && (txtP_IVA.value.length != 11);
		var err8 = (txtCF.value != "") && ((txtCF.value.length != 11) && (txtCF.value.length != 16));
		var err9 = ((txtDesc_it.value != "") && !(checkChars(txtDesc_it.value)));
		var err10 = ((txtDesc_en.value != "") && !(checkChars(txtDesc_en.value)));
		var err11 = ((txtDesc_sa.value != "") && !(checkChars(txtDesc_sa.value)));
		var err12 = ((txtDescDistr_it.value != "") && !(checkChars(txtDescDistr_it.value)));
		var err13 = ((txtDescDistr_en.value != "") && !(checkChars(txtDescDistr_en.value)));
		var err14 = ((txtDescDistr_sa.value != "") && !(checkChars(txtDescDistr_sa.value)));
		var err15 = ((txtMail.value != "") && !(emailValidation(frmModificaEditori)));
		var err16 = ((txtRespEdiMail.value != "") && !(emailValidation(frmModificaEditori)));
		var err17 = ((txtRespProdMail.value != "") && !(emailValidation(frmModificaEditori)));
		var err18 = ((txtRespCommMail.value != "") && !(emailValidation(frmModificaEditori)));
		var err19 = ((txtRespAmmMail.value != "") && !(emailValidation(frmModificaEditori)));

		//Costruzione messaggio di errore
		var msgErr = Locale("Č necessario compilare correttamente il campo ","It is necessary to correctly fill out ","Bisonzat de cumpilare sa parte ",Lang);
		if (err1) {
			msgErr = msgErr + Locale("Ragione sociale","Business name","Resone sotziale",Lang);
			txtAzienda.focus()
		} else if (err2) {
			msgErr = msgErr + Locale("Localitā","City/Town field","Logu",Lang);
			selLocalita.focus()
		} else if (err3) {
			msgErr = msgErr + Locale("Sede legale","Registered office","Sea legale",Lang);
			txtSedeLegale.focus()
		} else if (err4) {
			msgErr = msgErr + "Username";
			txtUserID.focus()
		} else if (err5) {
			msgErr = msgErr + "Password";
			txtPassword.focus()
		} else if (err6) {
			msgErr = msgErr + Locale("Conferma password","Password confirm","Cunfirma password",Lang); 
			txtPassword1.focus() 				
		} else if (err7) {
			msgErr = msgErr + Locale("P.IVA","VAT r.n. field","P.IVA",Lang);
			txtPiva.focus()
		} else if (err8) {
			msgErr = msgErr + Locale("Codice Fiscale","Taxpayer Code correctly","Cōditze fiscale a manera giusta",Lang); 			
			txtCF.focus()
		} else if (err9) {
			msgErr = Locale("Il campo Annotazioni contiene caratteri non validi","The Notes field contains invalid characters","Su campu Notas particulares cuntenet carātires imbālidos",Lang);
			chkLang[0].checked = true;
			txtDesc.value = txtDesc_it.value;
			txtDesc.focus()
		} else if (err10) {
			msgErr = Locale("Il campo Annotazioni contiene caratteri non validi","The Notes field contains invalid characters","Su campu Notas particulares cuntenet carātires imbālidos",Lang);
			chkLang[1].checked = true;
			txtDesc.value = txtDesc_en.value;
			txtDesc.focus()
		} else if (err11) {
			msgErr = Locale("Il campo Annotazioni contiene caratteri non validi","The Notes field contains invalid characters","Su campu Notas particulares cuntenet carātires imbālidos",Lang);
			chkLang[2].checked = true;
			txtDesc.value = txtDesc_sa.value;
			txtDesc.focus()
		} else if (err12) {
			msgErr = Locale("Il campo Note sulla distribuzione contiene caratteri non validi","The Notes on distribution field contains invalid characters","Su campu Notas apitzu de sa distributzione cuntenet carātires imbālidos",Lang);
			chkLangDistr[0].checked = true;
			txtDescDistr.value = txtDescDistr_it.value;
			txtDescDistr.focus()
		} else if (err13) {
			msgErr = Locale("Il campo Note sulla distribuzione contiene caratteri non validi","The Notes on distribution field contains invalid characters","Su campu Notas apitzu de sa distributzione cuntenet carātires imbālidos",Lang);
			chkLangDistr[1].checked = true;
			txtDescDistr.value = txtDescDistr_en.value;
			txtDescDistr.focus()
		} else if (err14) {
			msgErr = Locale("Il campo Note sulla distribuzione contiene caratteri non validi","The Notes on distribution field contains invalid characters","Su campu Notas apitzu de sa distributzione cuntenet carātires imbālidos",Lang);
			chkLangDistr[2].checked = true;
			txtDescDistr.value = txtDescDistr_sa.value;
			txtDescDistr.focus()
		} else if (err15) {
			msgErr = msgErr + "E-mail (" + Locale("dati anagrafici editore","publisher details","datos de su editore",Lang) + ")";
			txtMail.focus()
		} else if (err16) {
			msgErr = msgErr + "E-mail (" + Locale("responsabile editoriale","editorial manager","responsābile editoriale",Lang) + ")";
			txtRespEdiMail.focus()
		} else if (err17) {
			msgErr = msgErr + "E-mail (" + Locale("responsabile produzione","production manager","responsābile de produtzione",Lang) + ")";
			txtRespProdMail.focus()
		} else if (err18) {
			msgErr = msgErr + "E-mail (" + Locale("responsabile commerciale","sales manager","responsābile cumerciale",Lang) + ")";
			txtRespCommMail.focus()
		} else if (err19) {
			msgErr = msgErr + "E-mail (" + Locale("responsabile amministrativo","administrative manager","responsābile aministrativu",Lang) + ")";
			txtRespAmmMail.focus()
		}
		
	}
	
	//Stampa messaggi d'errore
	var errori = (err1 || err2 || err3 || err4 || err5 || err6 || err7 || err8 || err9 || err10 || err11 || err12 || err13 || err14 || err15 || err16 || err17 || err18 || err19);
	if (errori) { alert(msgErr) }
	return !(errori);
}
