//funzione inviaordine
function TrimJS(StrToTrim)
{
    // CONTROLLA CHE IL VALORE IN INPUT SIA DI TIPO STRING
    if (typeof StrToTrim != "string")
    {
        return StrToTrim;
    }

    // CATTURA IL PRIMO CARATTERE DELLA STRINGA PER CONTROLLARE CHE NON SIA UNO SPAZIO VUOTO
    var StrBlank = StrToTrim.substring(0, 1);

    // ELIMINA LO SPAZIO VUOTO DALLA PRIMA POSIZIONE DELLA STRINGA
    while (StrBlank == " ")
    {
        StrToTrim = StrToTrim.substring(1, StrToTrim.length);
        StrBlank = StrToTrim.substring(0, 1);
    }

    // CATTURA L'ULTIMO CARATTERE DELLA STRINGA PER CONTROLLARE CHE NON SIA UNO SPAZIO VUOTO
    StrBlank = StrToTrim.substring(StrToTrim.length - 1, StrToTrim.length);

    // ELIMINA LO SPAZIO VUOTO DALL'ULTIMA POSIZIONE DELLA STRINGA
    while (StrBlank == " ")
    {
        StrToTrim = StrToTrim.substring(0, StrToTrim.length-1);
        StrBlank = StrToTrim.substring(StrToTrim.length-1, StrToTrim.length);
    }

    // ELIMINA POTENZIALI SPAZI VUOTI MULTIPLI ALL'INIZIO ED ALLA FINE DI UNA STRINGA
    while (StrToTrim.indexOf("  ") != -1)
    {
        StrToTrim = StrToTrim.substring(0, StrToTrim.indexOf("  "));
        StrToTrim += StrToTrim.substring(StrToTrim.indexOf("  ") + 1, StrToTrim.length);
    }

    // RESTITUISCE IL VALORE FINALE SENZA SPAZI VUOTI DI CONTORNO
    return StrToTrim;
}



function InviaOrdine_SecondaRichiesta() {
	var ControlliManc= ""
	mancanti=''
	errore=0

	if (document.frmordine.chkINTEGRATO.checked || document.frmordine.chkCONT.checked || document.frmordine.chkBIL.checked || document.frmordine.chk730.checked || document.frmordine.chkPF.checked || document.frmordine.chkSP.checked || document.frmordine.chkSC.checked || document.frmordine.chkENC.checked || document.frmordine.chkDICHIRAP2.checked ||document.frmordine.chkSTUSET.checked || document.frmordine.chk770S.checked || document.frmordine.chk770O.checked || document.frmordine.chkDICHIVA.checked || document.frmordine.chkF24.checked || document.frmordine.chkICI.checked || document.frmordine.chkDICHANA.checked || document.frmordine.chkDATIIVA.checked || document.frmordine.chkINTRA.checked || document.frmordine.chkINTENTO.checked || document.frmordine.chkTR.checked || document.frmordine.chkANT141.checked || document.frmordine.chkANT143.checked || document.frmordine.chkPRI.checked || document.frmordine.chkCOR.checked || document.frmordine.chkGBP.checked){
	}
	else
	{
		errore=1
		alert('Selezionare almeno una applicazione da richiedere in prova')
	}
	
	//*****************************************************************
    //   FINE Controllo partita iva e cod.fiscale nel campo cod. fiscale
	//*****************************************************************
	var mess = "Ha richiesto anche la prova dei software: "
	var messProd =""
	
	if (document.frmordine.chkINTEGRATO.checked) {
		mess=mess + "INTEGRATO COMPLETO - "
		messProd=messProd + "INTEGRATO COMPLETO - "
	}
	if (document.frmordine.chkCONT.checked) {
		mess=mess + "CONTABILITA - "
		messProd=messProd + "CONTABILITA - "
	}
	if (document.frmordine.chkBIL.checked) {
		mess=mess + "BILANCIO EUROPEO - "
		messProd=messProd + "BILANCIO EUROPEO - "
	}
	if (document.frmordine.chkPF.checked) {
		mess=mess + "PF - "
		messProd=messProd + "PF - "
	}
	if (document.frmordine.chkSP.checked) {
		mess=mess + "SP - "
		messProd=messProd + "SP - "
	}
	if (document.frmordine.chkSC.checked) {
		mess=mess + "SC - "
		messProd=messProd + "SC - "
	}
	if (document.frmordine.chkENC.checked) {
		mess=mess + "ENC - "
		messProd=messProd + "ENC - "
	}
	if (document.frmordine.chkDICHIVA.checked) {
		mess=mess + "DICH.ANNUALE IVA - "
		messProd=messProd + "DICH.ANNUALE IVA - "
	}
	if (document.frmordine.chk770S.checked) {
		mess=mess + "770S - "
		messProd=messProd + "770S - "
	}
	if (document.frmordine.chk770O.checked) {
		mess=mess + "770o - "
		messProd=messProd + "770o - "
	}
	if (document.frmordine.chkF24.checked) {
		mess=mess + "F24 - "
		messProd=messProd + "F24 - "
	}


	if (document.frmordine.chkICI.checked) {
		mess=mess + "ICI - "
		messProd=messProd + "ICI - "
	}
	if (document.frmordine.chkSTUSET.checked) {
		mess=mess + "Studi di settore - "
		messProd=messProd + "Studi di settore - "
	}
	if (document.frmordine.chk730.checked) {
		mess=mess + "730 - "
		messProd=messProd + "730 - "
	}
	if (document.frmordine.chkDICHIRAP2.checked) {
		mess=mess + "IRAP - "
		messProd=messProd + "IRAP - "
	}
	if (document.frmordine.chkDICHANA.checked) {
		mess=mess + "DICH.ANAGRAFICHE - "
		messProd=messProd + "DICH.ANAGRAFICHE - "
	}
	if (document.frmordine.chkDATIIVA.checked) {
		mess=mess + "COM. ANNUALE DATI IVA - "
		messProd=messProd + "COM. ANNUALE DATI IVA - "
	}
	if (document.frmordine.chkINTRA.checked) {
		mess=mess + "INTRA - "
		messProd=messProd + "INTRA - "
	}
	if (document.frmordine.chkTR.checked) {
		mess=mess + "TR - "
		messProd=messProd + "TR "
	}
	if (document.frmordine.chkINTENTOchecked) {
		mess=mess + "Dich. di intento - "
		messProd=messProd + "Dich. di intento - "
	}
	
	if (document.frmordine.chkGBP.checked) {
		mess=mess + "GBprivacy - "
		messProd=messProd + "GBprivacy - "
	}
	if (document.frmordine.chkPRI.checked) {
		mess=mess + "Privacy.it - "
		messProd=messProd + "Privacy.it - "
	}
	if (document.frmordine.chkCOR.checked) {
		mess=mess + "CORSO SICUREZZA - "
		messProd=messProd + "CORSO SICUREZZA - "
	}
	if (document.frmordine.chkANT141.checked) {
		mess=mess + "Ant.141 - "
		messProd=messProd + "Ant.141 - "
	}
	if (document.frmordine.chkANT143.checked) {
		mess=mess + "Ant.143 - "
		messProd=messProd + "Ant.143 - "
	}
	
	
 	document.frmordine.txtDES_TESTO.value=mess;
 	document.frmordine.txtDES_TESTOProd.value=messProd;
	
	//*****************************************************************
    //   FINE RIPORTO TESTO SULLE NOTE DELL'APPLICAZIONE DESIDERATA
	//*****************************************************************
	
	if (errore=='0') {
		// NON C'è NESSUN ERRORE	

		Prev2=0
		
		if (document.frmordine.chkPREV.checked) {
			Prev2=1
		}
		
		document.frmordine.azione.value="Invia";
		document.frmordine.submit();
		
	}
	
}
function InviaOrdine_frmOkUpd(idanaclick) {
	var blocca;
	
	applicazioneCONT=false;
	applicazioneORDIN=false;
	applicazionePROF=false;
	applicazioneMINIMI=false;
	applicazioneCESP=false;
	applicazionePERC=false;
	applicazioneFATT=false;
	applicazioneCORR=false;
	applicazionePROSP=false;
	applicazioneBIL=false;
	applicazionePF=false;
	applicazioneSC=false;
	applicazioneSP=false;
	applicazioneENC=false;
	applicazioneIRAP=false;
	applicazioneIVAAUT=false;
	applicazione770S=false;
	applicazione770O=false;
	applicazioneF24=false;
	applicazioneICI=false;
	applicazione730=false;
	applicazioneDATIIVA=false;
	applicazioneINTRA=false;
	applicazioneINTENTO=false;
	applicazioneVR=false;
	applicazioneANT141=false;
	applicazioneANT143=false;
	applicazioneGBP=false;
	applicazioneCOR=false;
//  applicazioneDATIIVA_CORR=false;
    applicazioneCUD=false;
	applicazione730_CORR=false;
//	applicazioneCUPE=false;
//	applicazioneVER_OPER=false;
//	applicazioneTASSA_LIB=false;
//	applicazioneIVA_BASE=false;
//	applicazioneCOMPENSI=false;
//	applicazioneIVAAUT_CORR=false;
//	applicazioneINTENTO_CORR=false;
	
	blocca=false;
	selezionataApp=false;
	AppRichieste="";
	if (document.frmOKUpd.chkCONT.checked==true && document.frmOKUpd.chkCONT.disabled==false) {
		applicazioneCONT=true;	 
		selezionataApp=true;
		AppRichieste=AppRichieste + "-CONT";
	}
	if(document.frmOKUpd.chkORDIN.checked==true && document.frmOKUpd.chkORDIN.disabled==false){
		applicazioneORDIN=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-ORDIN";
	}
	if (document.frmOKUpd.chkProfessionisti.checked==true && document.frmOKUpd.chkProfessionisti.disabled==false) {
		applicazionePROF=true;	 
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Professionisti";
	}
	if(document.frmOKUpd.chkMinimi.checked==true && document.frmOKUpd.chkMinimi.disabled==false){
		applicazioneMINIMI=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Minimi";
	}
	if (document.frmOKUpd.chkCespiti.checked==true && document.frmOKUpd.chkCespiti.disabled==false) {
		applicazioneCESP=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Cespiti";
	}
	if(document.frmOKUpd.chkPercipienti.checked==true && document.frmOKUpd.chkPercipienti.disabled==false){
		applicazionePERC=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Percipienti";
	}
	if (document.frmOKUpd.chkFatture.checked==true && document.frmOKUpd.chkFatture.disabled==false) {
		applicazioneFATT=true;	 
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Fatturazione";
	}
	if(document.frmOKUpd.chkCorrispettivi.checked==true && document.frmOKUpd.chkCorrispettivi.disabled==false){
		applicazioneCORR=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Corrispettivi";
	}
	if (document.frmOKUpd.chkProspetti.checked==true && document.frmOKUpd.chkProspetti.disabled==false) {
		applicazionePROSP=true;	
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Prospetti";
	}
	if(document.frmOKUpd.chkPF.checked==true && document.frmOKUpd.chkPF.disabled==false){
		applicazionePF=true;
		selezionataApp=true;		
		blocca=false;
		if(document.frmOKUpd.chkFULL_OkUpd.checked==true){
			AppRichieste=AppRichieste + "-PF Full";		
		}else{
			if(document.frmOKUpd.chkLITE_OkUpd.checked==true){
				AppRichieste=AppRichieste + "-PF Lite";
			}else{
				alert('Selezionare la tipologia di versione richiesta posta in basso a destra.');
				blocca=true;
			}
		}
		
	}
	if (document.frmOKUpd.chkSC.checked==true && document.frmOKUpd.chkSC.disabled==false) {
		applicazioneSC=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-SC";
	}
	if(document.frmOKUpd.chkSP.checked==true && document.frmOKUpd.chkSP.disabled==false){
		applicazioneSP=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-SP";
	}
	if (document.frmOKUpd.chkENC.checked==true && document.frmOKUpd.chkENC.disabled==false) {
		applicazioneENC=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-ENC";
	}
	if(document.frmOKUpd.chkIRAP.checked==true && document.frmOKUpd.chkIRAP.disabled==false){
		applicazioneIRAP=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-IRAP";
	}
	if(document.frmOKUpd.chkIVAAUT.checked==true && document.frmOKUpd.chkIVAAUT.disabled==false){
		applicazioneIVAAUT=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-Dich.Ann.Iva";
	}
	if(document.frmOKUpd.chk770S.checked==true && document.frmOKUpd.chk770S.disabled==false){
		applicazione770S=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-770S";
	}
	if(document.frmOKUpd.chk770O.checked==true && document.frmOKUpd.chk770O.disabled==false){
		applicazione770O=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-770O";
	}
	if(document.frmOKUpd.chkF24.checked==true && document.frmOKUpd.chkF24.disabled==false){
		applicazioneF24=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-F24";
	}
	if(document.frmOKUpd.chkICI.checked==true && document.frmOKUpd.chkICI.disabled==false){
		applicazioneICI=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-ICI";
	}
	if(document.frmOKUpd.chk730.checked==true && document.frmOKUpd.chk730.disabled==false){
		applicazione730=true;
		selezionataApp=true;
		blocca=false;
		if(document.frmOKUpd.chkFULL_OkUpd.checked==true){
			AppRichieste=AppRichieste + "-730 Full";		
		}else{
			if(document.frmOKUpd.chkLITE_OkUpd.checked==true){
				AppRichieste=AppRichieste + "-730 Lite";
			}else{
				alert('Selezionare la tipologia di versione richiesta posta in basso a destra.');
				blocca=true;
			}
		}

	}
	if(document.frmOKUpd.chkCUD.checked==true && document.frmOKUpd.chkCUD.disabled==false){
		applicazioneCUD=true;
		selezionataApp=true;
		blocca=false;
		if(document.frmOKUpd.chkFULL_OkUpd.checked==true){
			AppRichieste=AppRichieste + "-CUD Full";		
		}else{
			if(document.frmOKUpd.chkLITE_OkUpd.checked==true){
				AppRichieste=AppRichieste + "-CUD Lite";
			}else{
				alert('Selezionare la tipologia di versione richiesta posta in basso a destra.');
				blocca=true;
			}
		}

	}
	if(document.frmOKUpd.chk730_CORR.checked==true && document.frmOKUpd.chk730_CORR.disabled==false){
		applicazione730_CORR=true;
		selezionataApp=true;
		blocca=false;
		if(document.frmOKUpd.chkFULL_OkUpd.checked==true){
			AppRichieste=AppRichieste + "-730_CORR Full";		
		}else{
			if(document.frmOKUpd.chkLITE_OkUpd.checked==true){
				AppRichieste=AppRichieste + "-730_CORR Lite";
			}else{
				alert('Selezionare la tipologia di versione richiesta posta in basso a destra.');
				blocca=true;
			}
		}

	}
	if(document.frmOKUpd.chkBilancio.checked==true && document.frmOKUpd.chkBilancio.disabled==false){
		applicazioneBIL=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-BIL";
	}
	if(document.frmOKUpd.chkDATIIVA.checked==true && document.frmOKUpd.chkDATIIVA.disabled==false){
		applicazioneDATIIVA=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-DATIIVA";
	}
	if(document.frmOKUpd.chkINTRA.checked==true && document.frmOKUpd.chkINTRA.disabled==false){
		applicazioneINTRA=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-INTRA";
	}
	if(document.frmOKUpd.chkINTENTO.checked==true && document.frmOKUpd.chkINTENTO.disabled==false){
		applicazioneINTENTO=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-INTENTO";
	}
	if(document.frmOKUpd.chkTR.checked==true && document.frmOKUpd.chkTR.disabled==false){
		applicazioneVR=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-TR";
	}
	if(document.frmOKUpd.chkANT141.checked==true && document.frmOKUpd.chkANT141.disabled==false){
		applicazioneANT141=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-ANT141";
	}
	if(document.frmOKUpd.chkANT143.checked==true && document.frmOKUpd.chkANT143.disabled==false){
		applicazioneANT143=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-ANT143";
	}
	if(document.frmOKUpd.chkGBP.checked==true && document.frmOKUpd.chkGBP.disabled==false){
		applicazioneGBP=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-GBP";
	}
	if(document.frmOKUpd.chkCOR.checked==true && document.frmOKUpd.chkCOR.disabled==false){
		applicazioneCOR=true;
		selezionataApp=true;
		AppRichieste=AppRichieste + "-COR";
	}

	

	if (blocca==false){
		
		AppRichieste=AppRichieste + "-";

		document.frmOKUpd.txtAppRichieste_OkUpd.value=AppRichieste;
		var CampiErrati= ""
		mancanti=''
		errore=0
		if ((applicazione730==true || applicazionePF==true || applicazioneCUD==true || applicazione730_CORR==true) && document.frmOKUpd.chkFULL_OkUpd.checked==true)  {
			if (TrimJS(document.frmOKUpd.txtPIva_OkUpd.value)==''){
				mancanti+='Partita Iva; '
				errore=1
			}
		}	
		else{
		}
	
		
		if (TrimJS(document.frmOKUpd.txtnome_OkUpd.value)==''){
			mancanti+='Ragione Sociale; '
			errore=1
		}
		if (TrimJS(document.frmOKUpd.txtTel_OkUpd.value)==''){
			mancanti+='Telefono; '
			errore=1
		}
		if (TrimJS(document.frmOKUpd.txtMail_OkUpd.value)==''){
			mancanti+='Email; '
			errore=1
		}
		if (TrimJS(document.frmOKUpd.txtProv_OkUpd.value)==''){
			mancanti+='Provincia; '
			errore=1
		}
		if (TrimJS(document.frmOKUpd.txtComune_OkUpd.value)==''){
			mancanti+='Comune; '
			errore=1
		}
		if (TrimJS(document.frmOKUpd.txtCap_OkUpd.value)==''){
			mancanti+='CAP; '
			errore=1
		}
		
		
		//**************************************
		//   Controllo email
		//**************************************
		var stringa = document.frmOKUpd.txtMail_OkUpd.value;
		if (stringa.indexOf("@") > 0 && stringa.indexOf(".") > 0) {
			//CampiErrati=''
		}
		else
		{
			CampiErrati+='Indirizzo mail corretto; '
		}
		
		if (ControlloIndirizzoEmail(document.frmOKUpd.txtMail_OkUpd.value)==false){
			CampiErrati+='Indirizzo mail non corretto; '	
		}
		
		
		//**************************************
		//   Controllo cellulare
		//**************************************
		 var stringa = document.frmOKUpd.txtTel_OkUpd.value;
		 var PrimNum = stringa.charAt(0);
		 
		// alert (PrimNum);
		 
		 if (stringa.length >5) {
		 }
		 else
		 {
			CampiErrati+=' Numero di telefono ; '
			//alert ("Inserire ");
		 }
		
		if ((applicazionePF==true || applicazione730==true) && document.frmOKUpd.chkFULL_OkUpd.checked==true) {
			
			var u_ok=0
			var r=0
			var strpiva=document.frmOKUpd.txtPIva_OkUpd.value
			
			u_ok = Math.floor(strpiva.charAt(0)) + Math.floor(strpiva.charAt(2)) + Math.floor(strpiva.charAt(4)) + Math.floor(strpiva.charAt(6)) + Math.floor(strpiva.charAt(8))
			for (var i = 1;i <= 9;i += 2) {
				r =  Math.floor(strpiva.charAt(i)) * 2
				u_ok += Math.floor(r / 10) + (r - Math.floor(r / 10) * 10)
			}
			var u_oktmp=u_ok
			u_ok = 10 - (u_ok - Math.floor(u_ok / 10) * 10)
			if (u_ok >= 10) {
				u_ok -= 10
			}
		
			//alert(u_ok)
			errpiva=0
			if (u_ok != Math.floor(strpiva.charAt(10)))  {
				//alert('Partita IVA errata')
				errpiva=1
			}
			if (strpiva=='07946271009') {
				//alert('Partita IVA errata')
				errpiva=2
			}
			if (strpiva.length != 11) {
				//alert('Partita IVA errata')
				errpiva=3
			}
			if (strpiva=='00000000000') {
				//alert('Partita IVA errata')
				errpiva=4
			}
			if (strpiva=='19050') {
				//alert('Partita IVA errata')
				errpiva=6
			}
			
			if (errpiva==0){
			}
			else
			{
				CampiErrati=CampiErrati+' Partita IVA  non corretta'
			}
		}	
		else{
		}
		//**************************************
		//   fine Controllo partita iva
		//************************************** 
	
		if (navigator.appVersion.indexOf("MSIE")=="17"){
			document.frmOKUpd.txtIExplorer_OkUpd.value="17"
		}else{
			document.frmOKUpd.txtIExplorer_OkUpd.value="NO"
		}
		
		if (errore=='0') {
				
			if (CampiErrati=='') {
				//alert("Ti invieremo, negli orari d'ufficio, all'indirizzo e-mail specificato il link per il download");
				if (applicazionePF==true || applicazione730==true || applicazioneCUD==true || applicazione730_CORR==true)
					{
						if (document.frmOKUpd.chkFULL_OkUpd.checked==true || document.frmOKUpd.chkLITE_OkUpd.checked==true)
							{
							document.frmOKUpd.txtControllo_OkUpd.value="GBs";
							document.frmOKUpd.txtAppRichieste_OkUpd.value=AppRichieste;
							document.frmOKUpd.submit();
							}
						else
							{
							alert("Selezionare la versione desiderata.");
							}
					}
				else
					{
					document.frmOKUpd.txtControllo_OkUpd.value="GBs";
					document.frmOKUpd.txtAppRichieste_OkUpd.value=AppRichieste;
					document.frmOKUpd.submit();
					}
			}
			else
			{
				alert("Si è verificato un errore:\n\n"  + CampiErrati);
			}
			
		}else {
			alert("Campi obbligatori mancanti: " + mancanti );
		}
	
	}else{
	//	alert("Selezionare almeno una applicazione da richiedere");
	}
	
}

function InviaOrdine_small_prefisso(applicazione) {
	
	var CampiErrati= ""
	mancanti=''
	errore=0
	if ((applicazione=='730' || applicazione=='PF' || applicazione=='CUD' || applicazione=='730_CORR') && document.frmordine.chkFULL.checked==true) {
		if (TrimJS(document.frmordine.txtDES_PAR_IVA.value)==''){
			mancanti+='Partita Iva; '
			errore=1
		}
	}	
	else{
	}
	
	if ((applicazione=='SC_CORR' || applicazione=='SP_CORR' || applicazione=='UNICO_CORR' || applicazione=='PF_CORR')) {
		if (TrimJS(document.frmordine.txtDES_PAR_IVA2.value)==''){
			mancanti+='Partita Iva; '
			errore=1
		}
	}	
	else{
	}
	
	
	//controllo che se ha l'idanaclick il prefisso deve essere compilato
	if (TrimJS(document.frmordine.txtid.value)=='' || TrimJS(document.frmordine.txtid.value)=='0' ){

		if (TrimJS(document.frmordine.txtDES_PREF.value)==''){
		}
		else
		{
			var controlla = document.frmordine.txtStringaPref.value;
			if (controlla.indexOf(document.frmordine.txtDES_PREF.value) != (-1)){

			}
			else
			{
	
				CampiErrati+=' Prefisso telefonico; ';
			}
			 
		}
	}
		
	if (TrimJS(document.frmordine.txtDES_DEN_UTE.value)==''){
		mancanti+='Ragione Sociale; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_TEL.value)==''){
		mancanti+='Telefono; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_IND_EML.value)==''){
		mancanti+='Email; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_PRV_2d.value)==''){
		mancanti+='Provincia; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_LOC_2d.value)==''){
		mancanti+='Comune; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_CAP_2d.value)==''){
		mancanti+='CAP; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_IND_2d.value)==''){
		mancanti+='Via; '
		errore=1
	}
		
	
	//**************************************
    //   Controllo email
	//**************************************
	var stringa = document.frmordine.txtDES_IND_EML.value;
	if (stringa.indexOf("@") > 0 && stringa.indexOf(".") > 0) {
		//CampiErrati=''
	}
	else
	{
		CampiErrati+='Indirizzo mail corretto; '
	}
	
	if (ControlloIndirizzoEmail(document.frmordine.txtDES_IND_EML.value)==false){
		CampiErrati+='Indirizzo mail non corretto; '	
	}
	
	
	//**************************************
    //   Controllo cellulare
	//**************************************
	 var stringa = document.frmordine.txtDES_TEL.value;
	 var PrimNum = stringa.charAt(0);
	 
	// alert (PrimNum);
	 
	 if (stringa.length >5) {
	 }
	 else
	 {
		CampiErrati+=' Numero di telefono ; '
		//alert ("Inserire ");
	 }
	
	if ((applicazione=='730' || applicazione=='PF' || applicazione=='CUD' || applicazione=='730_CORR') && document.frmordine.chkFULL.checked==true) {
		
		var u_ok=0
		var r=0
		var strpiva=document.frmordine.txtDES_PAR_IVA.value
		
		u_ok = Math.floor(strpiva.charAt(0)) + Math.floor(strpiva.charAt(2)) + Math.floor(strpiva.charAt(4)) + Math.floor(strpiva.charAt(6)) + Math.floor(strpiva.charAt(8))
		for (var i = 1;i <= 9;i += 2) {
			r =  Math.floor(strpiva.charAt(i)) * 2
			u_ok += Math.floor(r / 10) + (r - Math.floor(r / 10) * 10)
		}
		var u_oktmp=u_ok
		u_ok = 10 - (u_ok - Math.floor(u_ok / 10) * 10)
		if (u_ok >= 10) {
			u_ok -= 10
		}
	
		//alert(u_ok)
		errpiva=0
		if (u_ok != Math.floor(strpiva.charAt(10)))  {
			//alert('Partita IVA errata')
			errpiva=1
		}
		if (strpiva=='07946271009') {
			//alert('Partita IVA errata')
			errpiva=2
		}
		if (strpiva.length != 11) {
			//alert('Partita IVA errata')
			errpiva=3
		}
		if (strpiva=='00000000000') {
			//alert('Partita IVA errata')
			errpiva=4
		}
		if (strpiva=='19050') {
			//alert('Partita IVA errata')
			errpiva=6
		}
		
		if (errpiva==0){
		}
		else
		{
			CampiErrati=CampiErrati+' Partita IVA  non corretta'
		}
		
	}	
	else{
	}
	
	if (applicazione=='SP_CORR' || applicazione=='UNICO_CORR' || applicazione=='SC_CORR' || applicazione=='PF_CORR')  {
		
		var u_ok=0
		var r=0
		var strpiva=document.frmordine.txtDES_PAR_IVA2.value
		
		u_ok = Math.floor(strpiva.charAt(0)) + Math.floor(strpiva.charAt(2)) + Math.floor(strpiva.charAt(4)) + Math.floor(strpiva.charAt(6)) + Math.floor(strpiva.charAt(8))
		for (var i = 1;i <= 9;i += 2) {
			r =  Math.floor(strpiva.charAt(i)) * 2
			u_ok += Math.floor(r / 10) + (r - Math.floor(r / 10) * 10)
		}
		var u_oktmp=u_ok
		u_ok = 10 - (u_ok - Math.floor(u_ok / 10) * 10)
		if (u_ok >= 10) {
			u_ok -= 10
		}
	
		//alert(u_ok)
		errpiva=0
		if (u_ok != Math.floor(strpiva.charAt(10)))  {
			//alert('Partita IVA errata')
			errpiva=1
		}
		if (strpiva=='07946271009') {
			//alert('Partita IVA errata')
			errpiva=2
		}
		if (strpiva.length != 11) {
			//alert('Partita IVA errata')
			errpiva=3
		}
		if (strpiva=='00000000000') {
			//alert('Partita IVA errata')
			errpiva=4
		}
		if (strpiva=='19050') {
			//alert('Partita IVA errata')
			errpiva=6
		}
		
		if (errpiva==0){
		}
		else
		{
			CampiErrati=CampiErrati+' Partita IVA  non corretta'
		}
	}	
	else{
	}
	
	//**************************************
    //   fine Controllo partita iva
	//************************************** 
	if (applicazione=='730' || applicazione=='PF' || applicazione=='CUD' || applicazione=='730_CORR'){
		if (document.frmordine.chkFULL.checked==true){
			var mess = "Ha richiesto il download del software Versione FULL "
		}
		else{
			var mess = "Ha richiesto il download del software Versione LIGHT "
		}
	}
	else{
		var mess = "Ha richiesto il download del software: "
	}
	var messProd =""
	mess=mess + document.frmordine.txtProdotto.text
	messProd=messProd + document.frmordine.txtProdotto.text
	
 	document.frmordine.txtDES_TESTO.value=mess;
 	document.frmordine.txtDES_TESTOProd.value=messProd;
	
	//*****************************************************************
    //   FINE RIPORTO TESTO SULLE NOTE DELL'APPLICAZIONE DESIDERATA
	//*****************************************************************
	

	if (navigator.appVersion.indexOf("MSIE")=="17"){
		document.frmordine.txtIExplorer.value="17"
	}else{
		document.frmordine.txtIExplorer.value="NO"
	}
	
	
	if (errore=='0') {
			
		if (CampiErrati=='') {
			//alert("Ti invieremo, negli orari d'ufficio, all'indirizzo e-mail specificato il link per il download");
			if (applicazione=='730' || applicazione=='PF')
				{
					if (document.frmordine.chkFULL.checked==true || document.frmordine.chkLIGHT.checked==true)
						{
						document.frmordine.txtControllo.value="GBs";
						document.frmordine.azione.value="Invia";
						document.frmordine.submit();
						}
					else
						{
						alert("Selezionare la versione desiderata.");
						}
				}
			else
				{
				document.frmordine.txtControllo.value="GBs";
				document.frmordine.azione.value="Invia";
				document.frmordine.submit();
				}
		}
		else
		{
			alert("Si è verificato un errore:\n\n"  + CampiErrati);
		}
		
	}else {
		alert("Campi obbligatori mancanti: " + mancanti );
	}
}


//*******************************************************************************************

function InviaOrdine_Carrello() {
	
	var CampiErrati= ""
	mancanti=''
	errore=0
	
	//controllo che se ha l'idanaclick il prefisso deve essere compilato
		
	if (TrimJS(document.frmordine.txtDES_DEN_UTE.value)==''){
		mancanti+='Ragione Sociale; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_TEL.value)==''){
		mancanti+='Telefono; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_IND_EML.value)==''){
		mancanti+='Email; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_PRV.value)==''){
		mancanti+='Provincia; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_LOC.value)==''){
		mancanti+='Comune; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_CAP.value)==''){
		mancanti+='Cap; '
		errore=1
	}
	if (TrimJS(document.frmordine.txtDES_IND.value)==''){
		mancanti+='Via; '
		errore=1
	}
		
	
	//**************************************
    //   Controllo email
	//**************************************
	var stringa = document.frmordine.txtDES_IND_EML.value;
	if (stringa.indexOf("@") > 0 && stringa.indexOf(".") > 0) {
		//CampiErrati=''
	}
	else
	{
		CampiErrati+='Indirizzo mail corretto; '
	}
	
	if (ControlloIndirizzoEmail(document.frmordine.txtDES_IND_EML.value)==false){
		CampiErrati+='Indirizzo mail non corretto; '	
	}
	
	
	//**************************************
    //   Controllo cellulare
	//**************************************
	 var stringa = document.frmordine.txtDES_TEL.value;
	 var PrimNum = stringa.charAt(0);	 
	 if (stringa.length >5) {
	 }
	 else
	 {
		CampiErrati+=' Numero di telefono ; '
	 }
	
	
		
	var u_ok=0
	var r=0
	var strpiva=document.frmordine.txtDES_PAR_IVA.value
	
	u_ok = Math.floor(strpiva.charAt(0)) + Math.floor(strpiva.charAt(2)) + Math.floor(strpiva.charAt(4)) + Math.floor(strpiva.charAt(6)) + Math.floor(strpiva.charAt(8))
	for (var i = 1;i <= 9;i += 2) {
		r =  Math.floor(strpiva.charAt(i)) * 2
		u_ok += Math.floor(r / 10) + (r - Math.floor(r / 10) * 10)
	}
	var u_oktmp=u_ok
	u_ok = 10 - (u_ok - Math.floor(u_ok / 10) * 10)
	if (u_ok >= 10) {
		u_ok -= 10
	}

	//alert(u_ok)
	errpiva=0
	if (u_ok != Math.floor(strpiva.charAt(10)))  {
		//alert('Partita IVA errata')
		errpiva=1
	}
	if (strpiva=='07946271009') {
		//alert('Partita IVA errata')
		errpiva=2
	}
	if (strpiva.length != 11) {
		//alert('Partita IVA errata')
		errpiva=3
	}
	if (strpiva=='00000000000') {
		//alert('Partita IVA errata')
		errpiva=4
	}
	if (strpiva=='19050') {
		//alert('Partita IVA errata')
		errpiva=6
	}
	
	if (errpiva==0){
	}
	else
	{
		CampiErrati=CampiErrati+' Partita IVA  non corretta'
	}
	
	//*****************************************************************
    //   FINE RIPORTO TESTO SULLE NOTE DELL'APPLICAZIONE DESIDERATA
	//*****************************************************************

	if (errore=='0') {
			
		if (CampiErrati=='') {
			document.frmordine.txtControllo.value="GBs";
			document.frmordine.submit();
		}
		else
		{
			alert("Si è verificato un errore:\n\n"  + CampiErrati);
		}
		
	}else {
		alert("Campi obbligatori mancanti: " + mancanti );
	}
}
//*******************************************************************************************

function InviaOrdine_Carrello_Bilancio() {
	
	var CampiErrati= ""
	mancanti=''
	errore=0
	
	//controllo che se ha l'idanaclick il prefisso deve essere compilato
		
	if (TrimJS(document.frmsalvaprev.txtDES_DEN_UTE.value)==''){
		mancanti+='Ragione Sociale; '
		errore=1
	}
	if (TrimJS(document.frmsalvaprev.txtDES_TEL.value)==''){
		mancanti+='Telefono; '
		errore=1
	}
	if (TrimJS(document.frmsalvaprev.txtDES_IND_EML.value)==''){
		mancanti+='Email; '
		errore=1
	}
	if (TrimJS(document.frmsalvaprev.txtDES_PRV.value)==''){
		mancanti+='Provincia; '
		errore=1
	}
	if (TrimJS(document.frmsalvaprev.txtDES_LOC.value)==''){
		mancanti+='Comune; '
		errore=1
	}
	if (TrimJS(document.frmsalvaprev.txtDES_CAP.value)==''){
		mancanti+='Cap; '
		errore=1
	}
	if (TrimJS(document.frmsalvaprev.txtDES_IND.value)==''){
		mancanti+='Via; '
		errore=1
	}
	if (TrimJS(document.frmsalvaprev.cmbDitte.value)=='' ||  TrimJS(document.frmsalvaprev.cmbDitte.value)=='0' ||  TrimJS(document.frmsalvaprev.cmbDitte.value)==0 ){
		mancanti+='Numero ditte gestibili; '
		errore=1
	}
	
	//alert(TrimJS(document.frmsalvaprev.cmbDitte.value))
		
	
	//**************************************
    //   Controllo email
	//**************************************
	var stringa = document.frmsalvaprev.txtDES_IND_EML.value;
	if (stringa.indexOf("@") > 0 && stringa.indexOf(".") > 0) {
		//CampiErrati=''
	}
	else
	{
		CampiErrati+='Indirizzo mail corretto; '
	}
	
	if (ControlloIndirizzoEmail(document.frmsalvaprev.txtDES_IND_EML.value)==false){
		CampiErrati+='Indirizzo mail non corretto; '	
	}
	
	
	//**************************************
    //   Controllo cellulare
	//**************************************
	 var stringa = document.frmsalvaprev.txtDES_TEL.value;
	 var PrimNum = stringa.charAt(0);	 
	 if (stringa.length >5) {
	 }
	 else
	 {
		CampiErrati+=' Numero di telefono ; '
	 }
	
	
		
	var u_ok=0
	var r=0
	var strpiva=document.frmsalvaprev.txtDES_PAR_IVA.value
	
	u_ok = Math.floor(strpiva.charAt(0)) + Math.floor(strpiva.charAt(2)) + Math.floor(strpiva.charAt(4)) + Math.floor(strpiva.charAt(6)) + Math.floor(strpiva.charAt(8))
	for (var i = 1;i <= 9;i += 2) {
		r =  Math.floor(strpiva.charAt(i)) * 2
		u_ok += Math.floor(r / 10) + (r - Math.floor(r / 10) * 10)
	}
	var u_oktmp=u_ok
	u_ok = 10 - (u_ok - Math.floor(u_ok / 10) * 10)
	if (u_ok >= 10) {
		u_ok -= 10
	}

	//alert(u_ok)
	errpiva=0
	if (u_ok != Math.floor(strpiva.charAt(10)))  {
		//alert('Partita IVA errata')
		errpiva=1
	}
	if (strpiva=='07946271009') {
		//alert('Partita IVA errata')
		errpiva=2
	}
	if (strpiva.length != 11) {
		//alert('Partita IVA errata')
		errpiva=3
	}
	if (strpiva=='00000000000') {
		//alert('Partita IVA errata')
		errpiva=4
	}
	if (strpiva=='19050') {
		//alert('Partita IVA errata')
		errpiva=6
	}
	
	if (errpiva==0){
	}
	else
	{
		CampiErrati=CampiErrati+' Partita IVA  non corretta'
	}
	
	//*****************************************************************
    //   FINE RIPORTO TESTO SULLE NOTE DELL'APPLICAZIONE DESIDERATA
	//*****************************************************************

	if (errore=='0') {
			
		if (CampiErrati=='') {
			document.frmsalvaprev.txtControllo.value="GBs";
			document.frmsalvaprev.submit();
		}
		else
		{
			alert("Si è verificato un errore:\n\n"  + CampiErrati);
		}
		
	}else {
		alert("Campi obbligatori mancanti: " + mancanti );
	}
}

//**********************************************************************************************

function InviaOrdine_frmNoApp(applicazione) {//significa che ha la chiave e lic d'uso ma non ha applicazioni abilitate
	
	var CampiErrati= ""
	mancanti=''
	errore=0
	if ((applicazione=='730' || applicazione=='PF' || applicazione=='CUD' || applicazione=='730_CORR') && document.frmordine.chkFULL_NoApp.checked==true) {
		if (TrimJS(document.frmNoApp.txtparIva_NoApp.value)==''){
			mancanti+='Partita Iva; '
			errore=1
		}
	}	
	else{
	}

		
	if (TrimJS(document.frmNoApp.txtnome_NoApp.value)==''){
		mancanti+='Ragione Sociale; '
		errore=1
	}
	if (TrimJS(document.frmNoApp.txttel_NoApp.value)==''){
		mancanti+='Telefono; '
		errore=1
	}
	if (TrimJS(document.frmNoApp.txtEml_NoApp.value)==''){
		mancanti+='Email; '
		errore=1
	}
	if (TrimJS(document.frmNoApp.txtProv_NoApp.value)==''){
		mancanti+='Provincia; '
		errore=1
	}
	if (TrimJS(document.frmNoApp.txtComune_NoApp.value)==''){
		mancanti+='Comune; '
		errore=1
	}
	if (TrimJS(document.frmNoApp.txtCap_NoApp.value)==''){
		mancanti+='CAP; '
		errore=1
	}
	
	
	//**************************************
    //   Controllo email
	//**************************************
	var stringa = document.frmNoApp.txtEml_NoApp.value;
	if (stringa.indexOf("@") > 0 && stringa.indexOf(".") > 0) {
		//CampiErrati=''
	}
	else
	{
		CampiErrati+='Indirizzo mail corretto; '
	}
	
	if (ControlloIndirizzoEmail(document.frmNoApp.txtEml_NoApp.value)==false){
		CampiErrati+='Indirizzo mail non corretto; '	
	}
	
	
	//**************************************
    //   Controllo cellulare
	//**************************************
	 var stringa = document.frmNoApp.txttel_NoApp.value;
	 var PrimNum = stringa.charAt(0);
	 
	// alert (PrimNum);
	 
	 if (stringa.length >5) {
	 }
	 else
	 {
		CampiErrati+=' Numero di telefono ; '
		//alert ("Inserire ");
	 }
	
	
	//**************************************
    //   Controllo Partita iva
	//**************************************
	if ((applicazione=='730' || applicazione=='PF' || applicazione=='CUD' || applicazione=='730_CORR') && document.frmNoApp.chkFULL_NoApp.checked==true) {
		
		var u_ok=0
		var r=0
		var strpiva=document.frmNoApp.txtparIva_NoApp.value
		
		u_ok = Math.floor(strpiva.charAt(0)) + Math.floor(strpiva.charAt(2)) + Math.floor(strpiva.charAt(4)) + Math.floor(strpiva.charAt(6)) + Math.floor(strpiva.charAt(8))
		for (var i = 1;i <= 9;i += 2) {
			r =  Math.floor(strpiva.charAt(i)) * 2
			u_ok += Math.floor(r / 10) + (r - Math.floor(r / 10) * 10)
		}
		var u_oktmp=u_ok
		u_ok = 10 - (u_ok - Math.floor(u_ok / 10) * 10)
		if (u_ok >= 10) {
			u_ok -= 10
		}
	
		//alert(u_ok)
		errpiva=0
		if (u_ok != Math.floor(strpiva.charAt(10)))  {
			//alert('Partita IVA errata')
			errpiva=1
		}
		if (strpiva=='07946271009') {
			//alert('Partita IVA errata')
			errpiva=2
		}
		if (strpiva.length != 11) {
			//alert('Partita IVA errata')
			errpiva=3
		}
		if (strpiva=='00000000000') {
			//alert('Partita IVA errata')
			errpiva=4
		}
		if (strpiva=='19050') {
			//alert('Partita IVA errata')
			errpiva=6
		}
		
		if (errpiva==0){
		}
		else
		{
			CampiErrati=CampiErrati+' Partita IVA  non corretta'
		}
	}	
	else{
	}
	//**************************************
    //   fine Controllo partita iva
	//************************************** 
	//***********
	

	if (navigator.appVersion.indexOf("MSIE")=="17"){
		document.frmNoApp.txtIExplorer_NoApp.value="17"
	}else{
		document.frmNoApp.txtIExplorer_NoApp.value="NO"
	}
	
	
	if (errore=='0') {
			
		if (CampiErrati=='') {
			//alert("Ti invieremo, negli orari d'ufficio, all'indirizzo e-mail specificato il link per il download");
			if (applicazione=='730' || applicazione=='PF' || applicazione=='CUD' || applicazione=='730_CORR')
				{
					if (document.frmNoApp.chkFULL_NoApp.checked==true || document.frmNoApp.chkLIGHT_NoApp.checked==true)
						{
						document.frmNoApp.txtControllo_NoApp.value="GBs";
						document.frmNoApp.submit();
						}
					else
						{
						alert("Selezionare la versione desiderata.");
						}
				}
			else
				{
				document.frmNoApp.txtControllo_NoApp.value="GBs";
				document.frmNoApp.submit();
				}
		}
		else
		{
			alert("Si è verificato un errore:\n\n"  + CampiErrati);
		}
		
	}else {
		alert("Campi obbligatori mancanti: " + mancanti );
	}
}
function InviaOrdine_frmNoUpd_RichRifutata() {//significa che ha la chiave e lic d'uso ma non ha applicazioni abilitate
	
	var CampiErrati= ""
	mancanti=''
	errore=0
		
		
	
	if (TrimJS(document.frmNoUpd.txtInfo_NoUpd.value)==''){
		mancanti+='Informazioni; '
		errore=1
	}
	
	if (errore=='0') {
			
		if (CampiErrati=='') {
			document.frmNoUpd.txtControllo_NoUpd.value="GBs";
			document.frmNoUpd.submit();
		}
		else
		{
			alert("Si è verificato un errore:\n\n"  + CampiErrati);
		}
		
	}else {
		alert("Campi obbligatori mancanti: " + mancanti );
	}
}

//function InviaOrdine_small_prefisso_NEW(applicazione) {
//	var CampiErrati= ""
//	mancanti=''
//	errore=0
//	if (applicazione=='730' || applicazione=='PF') {
//		if (TrimJS(document.frmordine.txtDES_PAR_IVA.value)==''){
//			mancanti+='Partita Iva; '
//			errore=1
//		}
//	}	
//	else{
//	}
//
//	//controllo che se ha l'idanaclick il prefisso deve essere compilato
//	if (TrimJS(document.frmordine.txtid.value)=='' || TrimJS(document.frmordine.txtid.value)=='0' ){
//		if (TrimJS(document.frmordine.txtDES_PREF.value)==''){
//		}
//		else
//		{
//			var controlla = document.frmordine.txtStringaPref.value;
//			if (controlla.indexOf(document.frmordine.txtDES_PREF.value) != (-1)){
//			}
//			else
//			{
//				CampiErrati+=' Prefisso telefonico; ';
//			}
//			 
//		}
//	}
//		
//	if (TrimJS(document.frmordine.txtDES_DEN_UTE.value)==''){
//		mancanti+='Ragione Sociale; '
//		errore=1
//	}
//
//	if (TrimJS(document.frmordine.txtDES_IND_EML.value)==''){
//		mancanti+='Email; '
//		errore=1
//	}
//	
//	var stringa = document.frmordine.txtDES_IND_EML.value;
//	if (stringa.indexOf("@") > 0 && stringa.indexOf(".") > 0) {
//		//CampiErrati=''
//	}
//	else
//	{
//		CampiErrati+='Indirizzo mail non corretto; '
//	}
//
//
//	//**************************************
//    //   Controllo email
//	//**************************************
//	if (ControlloIndirizzoEmail(document.frmordine.txtDES_IND_EML.value)==false){
//		CampiErrati+='Indirizzo mail non corretto; '	
//	}
//
//	//**************************************
//    //   Controllo cellulare
//	//**************************************
//	 //var stringa = document.frmordine.txtDES_TEL.value;
////	 var PrimNum = stringa.charAt(0);
////	 
////	// alert (PrimNum);
////	 
////	 if (stringa.length >5) {
////	 }
////	 else
////	 {
////		CampiErrati+=' Numero di telefono fisso; '
////		//alert ("Inserire ");
////	 }
//	 
//	
//	if (applicazione=='730' || applicazione=='PF') {
//		
//		var u_ok=0
//		var r=0
//		var strpiva=document.frmordine.txtDES_PAR_IVA.value
//		
//		u_ok = Math.floor(strpiva.charAt(0)) + Math.floor(strpiva.charAt(2)) + Math.floor(strpiva.charAt(4)) + Math.floor(strpiva.charAt(6)) + Math.floor(strpiva.charAt(8))
//		for (var i = 1;i <= 9;i += 2) {
//			r =  Math.floor(strpiva.charAt(i)) * 2
//			u_ok += Math.floor(r / 10) + (r - Math.floor(r / 10) * 10)
//		}
//		var u_oktmp=u_ok
//		u_ok = 10 - (u_ok - Math.floor(u_ok / 10) * 10)
//		if (u_ok >= 10) {
//			u_ok -= 10
//		}
//	
//		//alert(u_ok)
//		errpiva=0
//		if (u_ok != Math.floor(strpiva.charAt(10)))  {
//			//alert('Partita IVA errata')
//			errpiva=1
//		}
//		if (strpiva=='07946271009') {
//			//alert('Partita IVA errata')
//			errpiva=2
//		}
//		if (strpiva.length != 11) {
//			//alert('Partita IVA errata')
//			errpiva=3
//		}
//		if (strpiva=='00000000000') {
//			//alert('Partita IVA errata')
//			errpiva=4
//		}
//		if (strpiva=='19050') {
//			//alert('Partita IVA errata')
//			errpiva=6
//		}
//		
//		if (errpiva==0){
//		}
//		else
//		{
//			CampiErrati=CampiErrati+' Partita IVA  non corretta'
//		}
//	}	
//	else{
//	}
//	//**************************************
//    //   fine Controllo partita iva
//	//************************************** 
//	 
//
//	var mess = "Ha richiesto il download del software: " +  applicazione
//	var messProd = "Ha richiesto il download del software: " +  applicazione
//	
// 	document.frmordine.txtDES_TESTO.value=mess;
// 	document.frmordine.txtDES_TESTOProd.value=messProd;
//	
//	//*****************************************************************
//    //   FINE RIPORTO TESTO SULLE NOTE DELL'APPLICAZIONE DESIDERATA
//	//*****************************************************************
//	
//	if (errore=='0') {
//			if (CampiErrati=='') {
//				//alert("Ti invieremo, negli orari d'ufficio, all'indirizzo e-mail specificato il link per il download");
//				document.frmordine.azione.value="Invia";
//				document.frmordine.submit();
//			}
//			else
//			{
//				alert("Si è verificato un errore:\n\n"  + CampiErrati);
//			}
//		
//	}else {
//		alert("Campi obbligatori mancanti: " + mancanti );
//	}
//}



function ControllaCF(cf){
	var validi, i, s, set1, set2, setpari, setdisp;
	if( cf == '' )  return '';
	cf = cf.toUpperCase();
	if( cf.length != 16 )
		return "La lunghezza del codice fiscale non è\n"
		+"corretta: il codice fiscale dovrebbe essere lungo\n"
		+"esattamente 16 caratteri.\n";
		//errore=1
	validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for( i = 0; i < 16; i++ ){
		if( validi.indexOf( cf.charAt(i) ) == -1 )
			return "Il codice fiscale contiene un carattere non valido `" +
				cf.charAt(i) +
				"'.\nI caratteri validi sono le lettere e le cifre.\n";
				//errore=1
	}
	set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
	s = 0;
	for( i = 1; i <= 13; i += 2 )
		s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	for( i = 0; i <= 14; i += 2 )
		s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
		return "Il codice fiscale non è corretto:\n"+
			"il codice di controllo non corrisponde.\n";
			//errore=1;
	return "";
}
function ControllaPIVA(pi)
{
	if( pi == '' )  return '';
	if( pi.length != 11 )
		return "La lunghezza della partita IVA non è\n" +
			"corretta: la partita IVA dovrebbe essere lunga\n" +
			"esattamente 11 caratteri.\n";
			//errore=1
	validi = "0123456789";
	for( i = 0; i < 11; i++ ){
		if( validi.indexOf( pi.charAt(i) ) == -1 )
			return "La partita IVA contiene un carattere non valido `" +
				pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n";
				//errore=1
	}
	s = 0;
	for( i = 0; i <= 9; i += 2 )
		s += pi.charCodeAt(i) - '0'.charCodeAt(0);
	for( i = 1; i <= 9; i += 2 ){
		c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
		if( c > 9 )  c = c - 9;
		s += c;
	}
	if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) )
		return "La partita IVA non è valida:\n" +
			"il codice di controllo non corrisponde.\n";
			//errore=1
	return '';	

}



function ControlloIndirizzoEmail(stringa){

	ultimicaratteriOK=false
	var stringaLunghezza=stringa.length
	var numero=stringa.indexOf('@')+1
	
	carFinali=stringa.substring(stringaLunghezza - 4, stringaLunghezza)
	switch(carFinali) {
		
		case ".com": case ".net": case ".cat": case ".org": case ".pro": case ".edu": case ".biz": case ".tel":  
		  
		  if ((parseInt(stringa.indexOf(carFinali)) - parseInt(numero)) < 2){
			 ultimicaratteriOK=false;
		  }
		  else{
			  ultimicaratteriOK=true;
		  }
		  break;  
		  
		default:
		  break;
	}
	
	
		
	if (ultimicaratteriOK==false){
		
		carFinali=stringa.substring(stringaLunghezza - 3, stringaLunghezza)
		switch(carFinali) {
			
			case ".al": case ".by": case ".at": case ".be": case ".ba": case ".bg": case ".hr": case ".dk": case ".ee": case ".eu": case ".su": case ".fi": case ".fr": case ".de": case ".gi": case ".gr": case ".ie": case ".is": case ".im": case ".lv": case ".li": case ".lt": case ".lu": case ".md":  case ".mc": case ".me": case ".no": case ".nl": case ".pl": case ".pt": case ".cz": case ".ro": case ".ru": case ".sm": case ".rs": case ".sk": case ".si": case ".gs": case ".es": case ".se": case ".ch": case ".ua": case ".hu": case ".cy": case ".uk": case ".it": case ".yu": case ".mk": case ".mt": case ".tr": 
				if ((parseInt(stringa.indexOf(carFinali)) - parseInt(numero)) < 2){
					ultimicaratteriOK=false;
				}
				else{
					ultimicaratteriOK=true;
				}		
				break; 
			  
			default:
			  break;
		}
	}
		
	if (ultimicaratteriOK==false){
		
		carFinali=stringa.substring(stringaLunghezza - 5, stringaLunghezza)		
		switch(carFinali) {
			
			case ".info": case ".jobs": case ".coop": case ".mobi": case ".aero": 
			
				if ((parseInt(stringa.indexOf(carFinali)) - parseInt(numero)) < 2){
					ultimicaratteriOK=false;
				}
				else{
					ultimicaratteriOK=true;
				}		  
				break; 
   
			default:
			  break;
		}
	}
	
	//controllo che prima della CHIOCCIOLA ci siano almeno 2 caratteri

	if (ultimicaratteriOK==true) {
		if (numero>2){
			ultimicaratteriOK=true;
		}else{
			ultimicaratteriOK=false;
		}
	}
			
	if (ultimicaratteriOK==false){
		return false
	}
	else{
		return true
	}
	
}

function SetCookie(name, value)
{
	var expires = new Date();
	expires.setTime(expires.getTime() + 0x9A7EC800);
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toUTCString();
}
function GetCookie(name)
{
	var i = 0;
	while(document.cookie.indexOf(name + "=", i) != -1)
	{
		var value = document.cookie.substr(document.cookie.indexOf(name + "=", i));
		value = value.substr(name.length + 1);
		if(value.indexOf(";") != -1)
			if(value.indexOf(";") == 0)
				value = "";
			else
				value = value.substr(0, value.indexOf(";"));
		return unescape(value);
	}
	return "";
}
