﻿function VerificaCampi(frm)
{
	if (frm.cognome.value=='') 
    {
        alert("Il campo cognome è obbligatorio");
        frm.cognome.focus();
        return (false);
    }
    if (frm.nome.value=='') 
    {
        alert("Il campo nome è obbligatorio");
        frm.nome.focus();
        return (false);
    }

    if (frm.indirizzo.value=='') 
    {
        alert("Il campo indirizzo è obbligatorio");
        frm.indirizzo.focus();
        return (false);
    }
    if (frm.citta.value=='') 
    {
        alert("Il campo città è obbligatorio");
        frm.citta.focus();
        return (false);
    }
    if (frm.provincia.value=='') 
    {
        alert("Il campo provincia è obbligatorio");
        frm.provincia.focus();
        return (false);
    }
        if (frm.cap.value=='') 
    {
        alert("Il campo cap è obbligatorio");
        frm.cap.focus();
        return (false);
    }
    if (frm.email.value=='') 
    {
        alert("Il campo e-mail è obbligatorio");
        frm.email.focus();
        return (false);
    }
        if ((frm.email.value.indexOf(".") <= 2) || (frm.email.value.indexOf("@") <= 0))
        {
            alert("Il campo e-mail inserito non è valido");
            frm.email.focus();
            return (false);
        }
    if (frm.username.value=='') 
    {
        alert("Il campo username è obbligatorio");
        frm.username.focus();
        return (false);
    }
    if (frm.username.value.length < 4) 
    {
        alert("Il campo username deve contenere almeno 4 caratteri");
        frm.username.focus();
        return (false);
    }
    if (frm.password.value=='') 
    {
        alert("Il campo password è obbligatorio");
        frm.password.focus();
        return (false);
    }
    if (frm.password.value.length < 4) 
    {
        alert("Il campo password deve contenere almeno 4 caratteri");
        frm.password.focus();
        return (false);
    }
    if (frm.password.value != frm.passwordconf.value) 
    {
        alert("Il campo password e conferma password non coincidono");
        frm.password.focus();
        return (false);
    }
    
        if (frm.acc[0].checked!=true) 
    {
        alert("Il consenso al trattamento dei dati personali è necessario.");
        frm.nome.focus();
        return (false);
    }
    return true;
}

function CheckPartitaCodiceFisc(path)
{
	//debugger;
	if(document.getElementById("ctl00_ContentPlaceHolder1_PartitaIva").value == "" && document.getElementById("ctl00_ContentPlaceHolder1_CodiceFiscale").value  == "")
	{
		alert('Inserire il codice fiscale o la partita iva!')
//		document.getElementById("ctl00_ContentPlaceHolder1_lblError").style.visibility = "visible";
//		document.getElementById("ctl00_ContentPlaceHolder1_lblError").value = "Partita iva o codice fiscale obbligatorio";
		return false;
	}
	else
	{
		//alert('ritorno true -> partita e cod non vuoti')
		//document.getElementById("aspnetForm").action = "registrazioneStep.aspx?ElencoLibriOrderBy=alfabetico&ElencoLibriPage=0&action=Registrati";
		
		Page_ClientValidate();
		return Page_IsValid;
		
//		if(path != '')
//			document.getElementById("aspnetForm").action = path;
	}
	
	return true;
}

function ApriPopUp(pagina, titolo, width, height) 
{   
   var h = (window.screen.height / 2) - 180;
   var w = (window.screen.width / 2) - 220;

   window.open(pagina, 'Pippo', 'top=' + h + ',left=' + w + ',width=' + width + ',height=' + height + ',status=no,resizable=yes,scrollbars=yes');
}
