﻿// JScript File

 function Recalc()
    {
        document.HostForm.tot1.value = "";
        document.HostForm.tot2.value = "";
        document.HostForm.tot3.value = "";
        document.HostForm.tot4.value = "";
        tot = 0;
        tipo = 0;
        if (document.HostForm.RadioButton1.checked)
            tipo = 1;
        if (document.HostForm.RadioButton2.checked)
            tipo = 2;
        if (document.HostForm.RadioButton3.checked)
            tipo = 3;    
        if (document.HostForm.RadioButton4.checked)
            tipo = 4;    
        
        anni = document.HostForm.DropDownList8.value;
        opz1 = document.HostForm.DropDownList1.value * 45;        
        opz2 = document.HostForm.DropDownList2.value * 25;   
        opz3 = document.HostForm.DropDownList3.value * 50;
        opz4 = document.HostForm.DropDownList4.value * 180;
                  
        switch(tipo) 
        {
          case 0:
            alert("Devi selezionare il servizio che intendi acquistare.");
            break;
          case 1:
            tot = 250 * anni;                  
            document.HostForm.tot1.value = tot + opz1 + opz2 + opz4;
            break;                      
          case 2:
            tot = 120 * anni;      
            opz5 = document.HostForm.DropDownList5.value * 25;
            opz6 = document.HostForm.DropDownList6.value * 35;
            opz7 = document.HostForm.DropDownList7.value * 60;
            opz8 = 0;
            if (document.HostForm.mailIll.checked)
                opz8 = 70;
            document.HostForm.tot2.value = tot + opz1 + opz2 + opz4 + opz5 + opz6 + opz7 + opz8;            
            break;                    
          case 3:
            tot = 360 * anni;  
	    opz8 = 0;
	    if (document.HostForm.mailIll.checked)
                opz8 = 140;          
            document.HostForm.tot3.value = tot + opz1 + opz2 + opz3 + opz4 + opz8;
		
            break;            
          case 4:
            tot = 180 * anni;
            opz5 = document.HostForm.DropDownList5.value * 50;           
            opz6 = document.HostForm.DropDownList6.value * 75;
            opz7 = document.HostForm.DropDownList7.value * 120;            
            document.HostForm.tot4.value = tot + opz1 + opz2 + opz3 + opz4 + opz5 + opz6 + opz7;
            break;                      
        }        
    }
    
    function valSubmit() {
        Recalc();
        var doc = document.forms[0];
        var msg = "";
        if (doc.TextBox1.value == "") 
        {
            msg += "- Inserisci l'indirizzo web da registrare.\n";
        }                   
        if (!doc.RadioButton5.checked) 
        {
            msg += "- Devi accettare le condizioni del contratto.\n";
        }  
        if (!doc.RadioButton7.checked) 
        {
            msg += "- Devi accettare le clausole vessatorie.\n";
        }  
        if (!doc.RadioButton9.checked) 
        {
            msg += "- Devi accettare la legge 196 sulla privacy.\n";
        }     
        // DATI AZIENDA
        if (doc.RagSoc.value == "") 
        {
            msg += "- Devi inserire la ragione sociale.\n";
        }  
        if (doc.SocAddress.value == "") 
        {
            msg += "- Devi inserire l'indirizzo dell'azienda.\n";
        }  
        if (doc.SocNumber.value == "") 
        {
            msg += "- Devi inserire il numero civico dell'azienda.\n";
        }  
        if (doc.SocCap.value == "") 
        {
            msg += "- Devi inserire il cap dell'azienda.\n";
        }  
        if (doc.SocProv.value == "") 
        {
            msg += "- Devi inserire la provincia dell'azienda.\n";
        }  
        if (doc.SocCom.value == "") 
        {
            msg += "- Devi inserire il comune dell'azienda.\n";
        }  
        if (doc.SocTel.value == "") 
        {
            msg += "- Devi inserire il telefono dell'azienda.\n";
        }  
        if (doc.SocPiva.value == "") 
        {
            msg += "- Devi inserire la partita iva aziendale.\n";
        }  
        if (doc.SocCF.value == "") 
        {
            msg += "- Devi inserire il codice fiscale dell'azienda.\n";
        }  
        if (doc.SocEmail.value == "") 
        {
            msg += "- Devi inserire l'email dell'azienda.\n";
        }  
        // DATI RAPPRESENTANTE FISCALE
        if (doc.Name.value == "") 
        {
            msg += "- Devi inserire il nome del rapresentante fiscale.\n";
        }  
        if (doc.SurName.value == "") 
        {
            msg += "- Devi inserire il cognome del rapresentante fiscale.\n";
        }  
        if (doc.Address.value == "") 
        {
            msg += "- Devi inserire l'indirizzo del rapresentante fiscale.\n";
        }  
        if (doc.Number.value == "") 
        {
            msg += "- Devi inserire il numero civico del rapresentante fiscale.\n";
        }  
        if (doc.CAP.value == "") 
        {
            msg += "- Devi inserire il cap del rapresentante fiscale.\n";
        }  
        if (doc.Provincia.value == "") 
        {
            msg += "- Devi inserire la provincia del rapresentante fiscale.\n";
        }  
        if (doc.Comune.value == "") 
        {
            msg += "- Devi inserire il comune del rapresentante fiscale.\n";
        }  
        if (doc.Tel.value == "") 
        {
            msg += "- Devi inserire il telefono del rapresentante fiscale.\n";
        }  
        if (doc.CF.value == "") 
        {
            msg += "- Devi inserire il codice fiscale del rapresentante fiscale.\n";
        }  
        if (doc.Email.value == "") 
        {
            msg += "- Devi inserire l'email del rapresentante fiscale.\n";
        }  
        
        
        if (msg == "") {
            doc.submit();
            return true;
        } 
        else 
        {
        alert("Si sono verificati i seguenti errori:\n" + msg);
        return false;
        } 
    }