function loginFnc(){
one_check = 0;

if (document.form1.txt_nome_utente.value == "" && one_check == 0){
first_check = "txt_nome_utente";
one_check = 1;
}

if (document.form1.txt_password.value == "" && one_check == 0){
first_check = "txt_password";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 1;
document.form1.submit();
}
	else{
	document.form1[first_check].focus();
	}
}

function loginFnc2(){
one_check = 0;

if (document.form1.txt_nome_utente_2.value == "" && one_check == 0){
first_check = "txt_nome_utente_2";
one_check = 1;
}

if (document.form1.txt_password_2.value == "" && one_check == 0){
first_check = "txt_password_2";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 25;
document.form1.submit();
}
	else{
	document.form1[first_check].focus();
	}
}


function InvioPassword(){
one_check = 0;

if (document.form1.txt_ricordami_password_email.value == "" && one_check == 0){
first_check = "txt_ricordami_password_email";
one_check = 1;
}

if (document.form1.txt_ricordami_password_email.value == "la-tua-email@dominio.xx" && one_check == 0){
first_check = "txt_ricordami_password_email";
one_check = 1;
}

if (checkMail("txt_ricordami_password_email") == false && one_check == 0){
first_check = "txt_ricordami_password_email";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 3;
document.form1.submit();
}
	else{
	document.form1[first_check].focus();
	}
}

function QuickRequest(){
one_check = 0;
if (document.form1.txt_quick_nome.value == "" && one_check == 0){
first_check = "txt_quick_nome";
one_check = 1;
}

if (document.form1.txt_quick_cognome.value == "" && one_check == 0){
first_check = "txt_quick_cognome";
one_check = 1;
}

if (checkMail("txt_quick_email") == false && one_check == 0){
first_check = "txt_quick_email";
one_check = 1;
}

if (document.form1.txt_quick_text.value == "" && one_check == 0){
first_check = "txt_quick_text";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 4;
document.form1.submit();
}
else{
	document.form1[first_check].focus();
	}
}

function logoutFnc(){
document.form1.HdnFnc.value = 2;
document.form1.submit();
}

function sendmail(){
one_check = 0;

if (document.form1.txtName.value == "" && one_check == 0){
first_check = "txtName";
one_check = 1;
}

if (document.form1.txtLastName.value == "" && one_check == 0){
first_check = "txtLastName";
one_check = 1;
}

if (checkMail("txtEmail") == false && one_check == 0){
first_check = "txtEmail";
one_check = 1;
}

if (document.form1.txMsg.value == "" && one_check == 0){
first_check = "txMsg";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 5;
document.form1.submit();
}
else{
	if (first_check != "accetta[0]"){
	document.form1[first_check].focus();
	}
}
}


function checkForm(){
document.retVal = false;
one_check = 0;

if (document.form1.txtNome.value == "" && one_check == 0){
first_check = "txtNome";
one_check = 1;
}

if (document.form1.txtCognome.value == "" && one_check == 0){
first_check = "txtCognome";
one_check = 1;
}

if (document.form1.txtCittanascita.value == "" && one_check == 0){
first_check = "txtCittanascita";
one_check = 1;
}

if (document.form1.txtDataDiNascita.value == "" && one_check == 0){
first_check = "txtDataDiNascita";
one_check = 1;
}

if (document.form1.txtDataDiNascita.value == "dd/mm/aaaa" && one_check == 0){
first_check = "txtDataDiNascita";
one_check = 1;
}

if (document.form1.txtIDdoc.value == "" && one_check == 0){
first_check = "txtIDdoc";
one_check = 1;
}

if (document.form1.txtIndirizzo2.value == "" && one_check == 0){
first_check = "txtIndirizzo2";
one_check = 1;
}

if (document.form1.txtCitta2.value == "" && one_check == 0){
first_check = "txtCitta2";
one_check = 1;
}

if (document.form1.dropDown_PrvNascita.value == "" && one_check == 0){
first_check = "dropDown_PrvNascita";
one_check = 1;
}

if (document.form1.txtDataNascita.value == "" && one_check == 0){
first_check = "txtDataNascita";
one_check = 1;
}

if (document.form1.txtTel_1.value == "" && one_check == 0){
first_check = "txtTel_1";
one_check = 1;
}

if (checkMail("txtEmail") == false && one_check == 0){
first_check = "txtEmail";
one_check = 1;
}

if (document.form1.txtEmail.value != document.form1.txtREmail.value && one_check == 0){
first_check = "txtEmail";
one_check = 1;
}

if (document.form1.txtIDuser.value == "" && one_check == 0){
first_check = "txtIDuser";
one_check = 1;
}

if (document.form1.txtPassword.value == "" && one_check == 0){
first_check = "txtPassword";
one_check = 1;
}

if (document.form1.txtPassword.value != document.form1.txtRPassword.value && one_check == 0){
first_check = "txtPassword";
one_check = 1;
}
/*
if (document.form1.txtAttivazione.value != document.form1.hidden_attivazione.value && one_check == 0){
first_check = "txtAttivazione";
one_check = 1;
}
*/
if (one_check == 0){
document.form1.HdnFnc.value = 6;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function ModificaAnagrafica(){
document.retVal = false;
one_check = 0;

if (document.form1.txtNome.value == "" && one_check == 0){
first_check = "txtNome";
one_check = 1;
}

if (document.form1.txtCognome.value == "" && one_check == 0){
first_check = "txtCognome";
one_check = 1;
}

if (document.form1.txtCittanascita.value == "" && one_check == 0){
first_check = "txtCittanascita";
one_check = 1;
}

if (document.form1.txtDataDiNascita.value == "" && one_check == 0){
first_check = "txtDataDiNascita";
one_check = 1;
}

if (document.form1.txtIDdoc.value == "" && one_check == 0){
first_check = "txtIDdoc";
one_check = 1;
}

if (document.form1.txtIndirizzo2.value == "" && one_check == 0){
first_check = "txtIndirizzo2";
one_check = 1;
}

if (document.form1.txtCitta2.value == "" && one_check == 0){
first_check = "txtCitta2";
one_check = 1;
}

if (document.form1.dropDown_PrvNascita.value == "" && one_check == 0){
first_check = "dropDown_PrvNascita";
one_check = 1;
}

if (document.form1.txtDataNascita.value == "" && one_check == 0){
first_check = "txtDataNascita";
one_check = 1;
}

if (document.form1.txtTel_1.value == "" && one_check == 0){
first_check = "txtTel_1";
one_check = 1;
}

if (checkMail("txtEmail") == false && one_check == 0){
first_check = "txtEmail";
one_check = 1;
}

if (document.form1.txtEmail.value != document.form1.txtREmail.value && one_check == 0){
first_check = "txtEmail";
one_check = 1;
}

if (document.form1.txtPassword.value == "" && one_check == 0){
first_check = "txtPassword";
one_check = 1;
}

if (document.form1.txtPassword.value != document.form1.txtRPassword.value && one_check == 0){
first_check = "txtPassword";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 7;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function clearForm(){
document.form1.txtNome.value = "";
document.form1.txtCognome.value = "";
document.form1.txtCittanascita.value = "";
document.form1.txtDataDiNascita.value = "";
document.form1.txtIDdoc.value = "";
document.form1.txtIndirizzo.value = "";
document.form1.txtCitta.value = "";
document.form1.txtCf.value = "";
document.form1.txtCap.value = "";
document.form1.txtIndirizzo2.value = "";
document.form1.txtCitta2.value = "";
document.form1.dropDown_PrvNascita.selectedIndex = 0;
document.form1.txtProvinciaAltra.value = "";
document.form1.txtDataNascita.value = "";
document.form1.txtTel_1.value = "";
document.form1.txtTel_2.value = "";
document.form1.txtEmail.value = "";
document.form1.txtREmail.value = "";
document.form1.txtIDuser.value = "";
document.form1.txtPassword.value = "";
document.form1.txtRPassword.value = "";
document.form1.txtAttivazione.value = "";
}

function pagenav(page){
document.form1.page.value = page;
document.form1.submit();
}

function addtobasket(idproduct){
document.retVal = false;
document.form1.idproduct.value = idproduct
document.form1.HdnFnc.value = 8;
document.retVal = true;
}

function deleteFromCart(id){
document.form1.idproduct.value = id;
document.form1.HdnFnc.value = 9;
document.form1.submit();
}

function inviaOrdine(){
document.retVal = false;
one_check = 0;

if (document.form1.txt_ragsoc.value == "" && one_check == 0){
first_check = "txt_ragsoc";
one_check = 1;
}

if (document.form1.txt_provincia.value == "" && one_check == 0){
first_check = "txt_provincia";
one_check = 1;
}

if (document.form1.txt_comune.value == "" && one_check == 0){
first_check = "txt_comune";
one_check = 1;
}

if (document.form1.txt_cap.value == "" && one_check == 0){
first_check = "txt_cap";
one_check = 1;
}

if (document.form1.txt_indirizzo.value == "" && one_check == 0){
first_check = "txt_indirizzo";
one_check = 1;
}

if (document.form1.txt_telefono.value == "" && one_check == 0){
first_check = "txt_telefono";
one_check = 1;
}

if (checkMail("txt_email") == false && one_check == 0){
first_check = "txt_email";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 10;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function sendPrevFnc(){
document.retVal = false;
one_check = 0;

if (document.form1.txtName.value == "" && one_check == 0){
first_check = "txtName";
one_check = 1;
}

if (document.form1.txtCognome.value == "" && one_check == 0){
first_check = "txtCognome";
one_check = 1;
}

if (document.form1.txtTelefono.value == "" && one_check == 0){
first_check = "txtTelefono";
one_check = 1;
}

if (document.form1.txtTelefono.value == "" && one_check == 0){
first_check = "txtTelefono";
one_check = 1;
}

if (checkMail("txtEmail") == false && one_check == 0){
first_check = "txtEmail";
one_check = 1;
}

if (document.form1.txtOggetto.value == "" && one_check == 0){
first_check = "txtOggetto";
one_check = 1;
}

if (document.form1.AreaEmailText.value == "" && one_check == 0){
first_check = "AreaEmailText";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 11;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function clearPrevFnc(){
document.form1.txtName.value = "";
document.form1.txtCognome.value = "";
document.form1.txtAzienda.value = "";
document.form1.txtRuolo.value = "";
document.form1.txtTelefono.value = "";
document.form1.txtEmail.value = "@";
document.form1.txtOggetto.value = "";
document.form1.AreaEmailText.value = "";
}

function SendPrivacyDoc(){
document.retVal = false;
one_check = 0;

if (document.form1.txt_ragsoc.value == "" && one_check == 0){
first_check = "txt_ragsoc";
one_check = 1;
}
if (document.form1.txt_piva.value == "" && one_check == 0){
first_check = "txt_piva";
one_check = 1;
}
if (document.form1.txt_cf.value == "" && one_check == 0){
first_check = "txt_cf";
one_check = 1;
}
if (document.form1.txt_attivita.value == "" && one_check == 0){
first_check = "txt_attivita";
one_check = 1;
}
if (document.form1.txt_indirizzo.value == "" && one_check == 0){
first_check = "txt_indirizzo";
one_check = 1;
}
if (document.form1.txt_cap.value == "" && one_check == 0){
first_check = "txt_cap";
one_check = 1;
}
if (document.form1.txt_citta.value == "" && one_check == 0){
first_check = "txt_citta";
one_check = 1;
}
if (document.form1.txt_provincia.value == "" && one_check == 0){
first_check = "txt_provincia";
one_check = 1;
}
if (document.form1.txt_telefono.value == "" && one_check == 0){
first_check = "txt_telefono";
one_check = 1;
}
if (document.form1.txt_fax.value == "" && one_check == 0){
first_check = "txt_fax";
one_check = 1;
}
if (document.form1.txt_email.value == "" && one_check == 0){
first_check = "txt_email";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 12;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function SendHaccpDoc(){
document.retVal = false;
one_check = 0;

if (document.form1.txt_ragsoc.value == "" && one_check == 0){
first_check = "txt_ragsoc";
one_check = 1;
}
if (document.form1.txt_piva.value == "" && one_check == 0){
first_check = "txt_piva";
one_check = 1;
}
if (document.form1.txt_cf.value == "" && one_check == 0){
first_check = "txt_cf";
one_check = 1;
}
if (document.form1.txt_indirizzo.value == "" && one_check == 0){
first_check = "txt_indirizzo";
one_check = 1;
}
if (document.form1.txt_cap.value == "" && one_check == 0){
first_check = "txt_cap";
one_check = 1;
}
if (document.form1.txt_citta.value == "" && one_check == 0){
first_check = "txt_citta";
one_check = 1;
}
if (document.form1.txt_provincia.value == "" && one_check == 0){
first_check = "txt_provincia";
one_check = 1;
}
if (document.form1.txt_telefono.value == "" && one_check == 0){
first_check = "txt_telefono";
one_check = 1;
}
if (document.form1.txt_fax.value == "" && one_check == 0){
first_check = "txt_fax";
one_check = 1;
}
if (document.form1.txt_email.value == "" && one_check == 0){
first_check = "txt_email";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 13;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function SendValRischDoc(azione){
document.retVal = false;
one_check = 0;

if (document.form1.txt_ragsoc.value == "" && one_check == 0){
first_check = "txt_ragsoc";
one_check = 1;
}
if (document.form1.txt_piva.value == "" && one_check == 0){
first_check = "txt_piva";
one_check = 1;
}
if (document.form1.txt_cf.value == "" && one_check == 0){
first_check = "txt_cf";
one_check = 1;
}
if (document.form1.txt_indirizzo.value == "" && one_check == 0){
first_check = "txt_indirizzo";
one_check = 1;
}
if (document.form1.txt_cap.value == "" && one_check == 0){
first_check = "txt_cap";
one_check = 1;
}
if (document.form1.txt_citta.value == "" && one_check == 0){
first_check = "txt_citta";
one_check = 1;
}
if (document.form1.txt_provincia.value == "" && one_check == 0){
first_check = "txt_provincia";
one_check = 1;
}
if (document.form1.txt_telefono.value == "" && one_check == 0){
first_check = "txt_telefono";
one_check = 1;
}
if (document.form1.txt_fax.value == "" && one_check == 0){
first_check = "txt_fax";
one_check = 1;
}
if (document.form1.txt_email.value == "" && one_check == 0){
first_check = "txt_email";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = azione;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function CommentoNews(){
document.retVal = false;
one_check = 0;

if (document.form1.txtNameCommento.value == "" && one_check == 0){
first_check = "txtNameCommento";
one_check = 1;
}
if (checkMail("txtEmailCommento") == false && one_check == 0){
first_check = "txtEmailCommento";
one_check = 1;
}
if (document.form1.txtTitoloCommento.value == "" && one_check == 0){
first_check = "txtTitoloCommento";
one_check = 1;
}
if (document.form1.txMsgCommento.value == "" && one_check == 0){
first_check = "txMsgCommento";
one_check = 1;
}

if (one_check == 0){
document.form1.HdnFnc.value = 24;
document.retVal = true;
}
else{
	document.form1[first_check].focus();
}
}

function checkMail(InputData){
Mail = document.form1[InputData].value;
var mailRet = false;
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
  	if (Filtro.test(Mail)){
	mailRet = true;}
return mailRet;}


function keyControl(){
	if( (event.keyCode < 48) || (event.keyCode > 57 ) ){
		event.keyCode = "".charCodeAt(0);
	}
}

function WinPrevOpen(){
width = (screen.width - 700)/2;
height = (screen.height - 350)/2;
win = window.open('lightwindow_preventivi.asp','popup','width=700,height=350,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,copyhistory=no,resizable=no,screenX='+width+',screenY='+height+',top='+height+',left='+width+'');
win.focus();	
}