var PAT_INT = /^[0-9]+$/;	

function Rollover_Image(Identity_Element, Path_Image, Name_Image) {
    var Full_Path_Image = Path_Image + Name_Image;
    var Obj = document.getElementById(Identity_Element)
    if (Obj) Obj.src=Full_Path_Image;

}

function doEffect(Item,Type,Speed,Opacity) {

    switch(Type) { 
      
      case "show": 
         $("#"+Item).show(Speed);
      break; 

      case "hide": 
        $("#"+Item).hide(Speed);
      break;
      
      case "opacity": 
        $("#"+Item).fadeTo(Speed,Opacity);
      break;

      default: 
         $("#"+Item).show(Speed);
    }

}

function Rollover_Class(Identity_Element, Name_Class) {

    var Obj = document.getElementById(Identity_Element);
    if (Obj) Obj.className=Name_Class;

}

function Rollover_Class_Object(Object_Element, Name_Class) {

    var Obj = Object_Element;
    if (Obj) Obj.className=Name_Class;

}

function Rollover_Displayed(Identity_Element) {
    var Obj = document.getElementById(Identity_Element);
    if (Obj) { 
        if (Obj.style.display=='none') { 
           Obj.style.display='block';
           Position(Obj.id);
        } else {
            Obj.style.display='none';
        }
    }
}

function Vedi_Nascondi(Identity_Element, Status_Display) {
    var Obj = document.getElementById(Identity_Element);
    if (Obj) Obj.style.display=Status_Display;
}

function Vedi_Testo(Identity_Element, Inner_Html) {
    var Obj = document.getElementById(Identity_Element);
    if (Obj) Obj.innerHTML=Inner_Html;
}


function _browser() {
	var browser=navigator.appName
	var b_version=navigator.appVersion
	var version=parseFloat(b_version)
	
	return browser;
}



function Position(Identity_Element) {
    var e; 
    var b = _browser();
    if (b=='Microsoft Internet Explorer') e = window.event; else e = window.Event;
    
    var Obj = document.getElementById(Identity_Element);
    if (Obj) { 
        if (b=='Microsoft Internet Explorer') {
            Obj.style.top=e.clientY + document.body.scrollTop;
            Obj.style.left=e.clientX;
        } else {
            Obj.style.top=parseInt(document.getElementById('PosY').value) + document.body.scrollTop;
            Obj.style.left=parseInt(document.getElementById('PosX').value);        
        }
    }
}

function PositionOf(Identity_Element, Pixel_Distant) {
    var e; 
    var b = _browser();
    if (b=='Microsoft Internet Explorer') e = window.event; else e = window.Event;
   
    var Obj = document.getElementById(Identity_Element);
    if (Obj) { 
        if (b=='Microsoft Internet Explorer') {
            Obj.style.top=e.clientY + document.body.scrollTop;
            Obj.style.left=e.clientX + Pixel_Distant;
        } else {
            Obj.style.top=parseInt(document.getElementById('PosY').value) + document.body.scrollTop;
            Obj.style.left=parseInt(document.getElementById('PosX').value) + Pixel_Distant;        
        }
    }
}

function Coordinate_Mouse(e) {
    var objX = document.getElementById('PosX');
    var objY = document.getElementById('PosY');
    if (objX) objX.value=e.pageX; 
    if (objY) objY.value=e.pageY; 
}

function Assegna_Valore(Identity_Element, Valore_Element) {
    var Obj = document.getElementById(Identity_Element);
    if (Obj) Obj.value = Valore_Element;
}

function Invia(Nome_Modulo) {
    //var Obj = document.getElementById(Nome_Modulo);
    var Obj = eval("document."+Nome_Modulo);
    if (Obj) Obj.submit();
}


function Assegna_Valore_Avanzato(Identity_Element, Valore_Element, Nome_Modulo) {
    //var Obj = document.getElementById(Identity_Element);
    var Obj = eval("document."+Nome_Modulo+"."+Identity_Element);
    if (Obj) Obj.value = Valore_Element;
}

function Invia_Avanzato(Nome_Modulo, Destinazione_Modulo) {
    //var Obj = document.getElementById(Nome_Modulo);
    var Obj = eval("document."+Nome_Modulo);
    Obj.action = Destinazione_Modulo;
    if (Obj) Obj.submit();
}


function Valida_RegExp(Identity_Element, Type_Regular_Expression) {
    var Obj = document.getElementById(Identity_Element);
    
    if (eval(Type_Regular_Expression +".test(Obj.value)")==false) {
        alert('Caratteri non consentiti. Prego riprovare');
        Obj.focus();
        return false
    }
    return true
}    


function Valida_Numero_MinMax(Identity_Element, Numero_Minimo, Numero_Massimo) {
    var Obj = document.getElementById(Identity_Element);
    if (parseInt(Obj.value) > parseInt(Numero_Massimo)) {
        alert('Il numero digitato supera il massimo consentito. Prego riprovare')
        Obj.focus();
        return false;
    }
    
    if (parseInt(Obj.value) <= Numero_Minimo) {
        alert('Il numero digitato supera il minimo consentito. Prego riprovare')
        Obj.focus();
        return false;
    }
    return true;     
}


function setOrderBy(v_criteria_ord,v_direction_ord) {

    document.getElementById('CRITERIA_ORDERBY').value=v_criteria_ord;
    document.getElementById('DIRECTION_ORDERBY').value=v_direction_ord;
    
    setIMGOrderBy(v_criteria_ord,v_direction_ord)
    Invia('Modulo_Navigazione');
}
	

function setIMGOrderBy(v_criteria_ord, v_direction_ord) {
	var objIMG = document.getElementById('ORDER_'+v_criteria_ord);
	if (objIMG) {
		if (v_direction_ord.toUpperCase()=='ASC') {
			objIMG.src='images/ordup.gif';
		} else {
			objIMG.src='images/orddn.gif';
		}	
		objIMG.style.visibility='visible';
	}	
}


var XMLObj;
var Identity_Element_Destination_2;
var Nome_Modulo_2;
// AJAX functions

function getDatas(Identity_Element, Nome_Modulo, Identity_Element_Destination)
{



    var Valore_Field;
    Valore_Field = eval("document."+Nome_Modulo+"."+Identity_Element+".options[document."+Nome_Modulo+"."+Identity_Element+".selectedIndex].value");

   Identity_Element_Destination_2 = Identity_Element_Destination;
   Nome_Modulo_2 = Nome_Modulo;
   
    // per l'oggetto nativo XMLHttpRequest
    if (window.XMLHttpRequest) {
	   XMLObj = new XMLHttpRequest();
	   XMLObj.onreadystatechange = putDatas;
	   XMLObj.open("GET", "xmldata.asp?values="+Valore_Field,true);
	   XMLObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
	   XMLObj.send(null);
	// per IE
}
 
else if (window.ActiveXObject) {
	
    XMLObj = new ActiveXObject("Microsoft.XMLHTTP");
	if (XMLObj) {
		XMLObj.onreadystatechange = putDatas;
		XMLObj.open("GET", "xmldata.asp?values="+Valore_Field,true);	
		XMLObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
		XMLObj.send();
		}
	}
}

function putDatas() {

    var Ritorno_Stringa;
    var Array_Valori;
    var Array_Testo;
    var Stringa_Valori;
    var obj;
    
    if (XMLObj.readyState == 4) {
	
	   Ritorno_Stringa = XMLObj.responseText;
   	   Ritorno_Stringa = Ritorno_Stringa.replace(/chr(13)/g,"");
	   Ritorno_Stringa = Ritorno_Stringa.replace(/chr(10)/g,"");
	   //Ritorno_Stringa = Ritorno_Stringa.replace(/ù/g, "u\'");
	
	
      Array_Valori = Ritorno_Stringa.split("|");
	  obj = eval("document."+Nome_Modulo_2+"."+ Identity_Element_Destination_2);
      obj.options.length = 0;
	
	   optnew=new Option("","0");
	   obj.options.add(optnew,0);
	  
       for(i=0;i<Array_Valori.length;i++)
	   	{
		
			Stringa_Valori = Array_Valori[i];
			Array_Testo = Stringa_Valori.split("##");
			
			optnew = new Option(Array_Testo[1],Array_Testo[0]);
			obj.options.add(optnew,i+1);
		}
		
	}
}


function Vedi_Se_Uguale(Identity_Element,Value_Control) {
    var Return_Value;
    var Element_Entity = document.getElementById(Identity_Element)
    if (Element_Entity) {
        Return_Value = (Element_Entity.value==Value_Control)
    }
    return Return_Value;
}   


// Inizio - Scorrimento Verticale
// -----------------------------------------------------------------------------------
var iTimer_Vertical;
var Counter_Vertical = 0;

function Contatore_Scorrimento_Verticale(Type_Scroll, Name_Div) {
    iTimer_Vertical = setInterval("Avvia_Scorrimento_Verticale('"+Type_Scroll+"','"+Name_Div+"')",10);
}

function Avvia_Scorrimento_Verticale(Type_Scrolling,Identity_Element) {
    var Element_Div = document.getElementById(Identity_Element);
    Counter_Vertical = Counter_Vertical +1
    if (Counter_Vertical <= 10) {
        Assegna_Valore('Controllo_Anti_Click_Frenetico', '1');
        if (parseInt(Type_Scrolling)==1) Element_Div.scrollTop = parseInt(Element_Div.scrollTop)+3; else Element_Div.scrollTop = parseInt(Element_Div.scrollTop)-3;
    } else  {
        Assegna_Valore('Controllo_Anti_Click_Frenetico', '0');
        Counter_Vertical = 0;
        clearInterval(iTimer_Vertical);
    }
}
// -----------------------------------------------------------------------------------                   
// Fine - Scorrimento Verticale



// Inizio - Scorrimento Verticale Veloce
// -----------------------------------------------------------------------------------
var iTimer_Vertical_Rapid;
var Counter_Vertical_Rapid = 0;

function Contatore_Scorrimento_Verticale_Veloce(Type_Scroll, Name_Div) {
    iTimer_Vertical_Rapid = setInterval("Avvia_Scorrimento_Verticale_Veloce('"+Type_Scroll+"','"+Name_Div+"')",10);
}

function Avvia_Scorrimento_Verticale_Veloce(Type_Scrolling,Identity_Element) {
    var Element_Div = document.getElementById(Identity_Element);
    Counter_Vertical_Rapid = Counter_Vertical_Rapid +1
    if (Counter_Vertical_Rapid <= 40) {
        Assegna_Valore('Controllo_Anti_Click_Frenetico', '1');
        if (parseInt(Type_Scrolling)==1) Element_Div.scrollTop = parseInt(Element_Div.scrollTop)+6; else Element_Div.scrollTop = parseInt(Element_Div.scrollTop)-6;
    } else  {
        Assegna_Valore('Controllo_Anti_Click_Frenetico', '0');
        Counter_Vertical_Rapid = 0;
        clearInterval(iTimer_Vertical_Rapid);
    }
}
// -----------------------------------------------------------------------------------                   
// Fine - Scorrimento Verticale Veloce





// Inizio - Scorrimento Rassegna Stampa
// -----------------------------------------------------------------------------------
var iTimer_Stampa;
var Counter_Stampa = 0;

function Contatore_Scorrimento_Orizzontale(Type_Scroll, Name_Div) {
    iTimer_Stampa = setInterval("Avvia_Scorrimento_Orizzontale('"+Type_Scroll+"','"+Name_Div+"')",10);
}

function Avvia_Scorrimento_Orizzontale(Type_Scrolling,Identity_Element) {
    var Element_Div = document.getElementById(Identity_Element);
    Counter_Stampa = Counter_Stampa +1
    if (Counter_Stampa <= 40) {
        Assegna_Valore('Controllo_Anti_Click_Frenetico_Stampa', '1');
        if (parseInt(Type_Scrolling)==1) Element_Div.scrollLeft = parseInt(Element_Div.scrollLeft)+3; else Element_Div.scrollLeft = parseInt(Element_Div.scrollLeft)-3;
    } else  {
        Assegna_Valore('Controllo_Anti_Click_Frenetico_Stampa', '0');
        Counter_Stampa = 0;
        clearInterval(iTimer_Stampa);
    }
}
// -----------------------------------------------------------------------------------                   
// Fine - Scorrimento Scorrimento Rassegna Stampa


// Inizio - Scorrimento Libri in Promozione
// -----------------------------------------------------------------------------------
var iTimer;
var Counter = 0;

function Contatore_Scorrimento(Type_Scroll, Name_Div) {
    iTimer = setInterval("Avvia_Scorrimento('"+Type_Scroll+"','"+Name_Div+"')",10);
}

function Avvia_Scorrimento(Type_Scrolling,Identity_Element) {
    var Element_Div = document.getElementById(Identity_Element);
    Counter = Counter +1
    if (Counter <= 40) {
        Assegna_Valore('Controllo_Anti_Click_Frenetico', '1');
        if (parseInt(Type_Scrolling)==1) Element_Div.scrollLeft = parseInt(Element_Div.scrollLeft)+3; else Element_Div.scrollLeft = parseInt(Element_Div.scrollLeft)-3;
    } else  {
        Assegna_Valore('Controllo_Anti_Click_Frenetico', '0');
        Counter = 0;
        clearInterval(iTimer);
    }
}
// -----------------------------------------------------------------------------------                   
// Fine - Scorrimento Libri in Promozione
                    

// Inizio - Scorrimento Libri in Promozione Continuo
// -----------------------------------------------------------------------------------
var iTimer2;
function Contatore_Scorrimento_Continuo(Name_Div) {
    Vedi_Nascondi('Scroll_Avanti', 'none');
    Vedi_Nascondi('Scroll_Indietro', 'none');    
    Vedi_Nascondi('Scroll_Avanti_Off', 'block');
    Vedi_Nascondi('Scroll_Indietro_Off', 'block');    
    
    iTimer2 = setInterval("Avvia_Scorrimento_Continuo('"+Name_Div+"')",10);
}
function Stop_Scorrimento_Continuo(Name_Div) {
    clearInterval(iTimer2);
    Vedi_Nascondi('Scroll_Avanti', 'block');
    Vedi_Nascondi('Scroll_Indietro', 'block');
    Vedi_Nascondi('Scroll_Avanti_Off', 'none');
    Vedi_Nascondi('Scroll_Indietro_Off', 'none');    
    Assegna_Valore('Controllo_Anti_Click_Frenetico_2', '0');
        
}
function Avvia_Scorrimento_Continuo(Identity_Element) {
    var Element_Div = document.getElementById(Identity_Element);
    var Fine_Scroll=0;
        Fine_Scroll = parseInt(Element_Div.scrollWidth+2)-parseInt(Element_Div.offsetWidth);
        Assegna_Valore('Controllo_Anti_Click_Frenetico_2', '1');
        
        if (document.getElementById('Direzione_Scroll_Continuo').value=='0') Element_Div.scrollLeft = parseInt(Element_Div.scrollLeft)+1; else Element_Div.scrollLeft = parseInt(Element_Div.scrollLeft)-1;
        if (parseInt(Element_Div.scrollLeft)==parseInt(Fine_Scroll)) document.getElementById('Direzione_Scroll_Continuo').value='1';
        if (parseInt(Element_Div.scrollLeft)==0) document.getElementById('Direzione_Scroll_Continuo').value='0';

}
// -----------------------------------------------------------------------------------                   
// Fine - Scorrimento Libri in Promozione Continuo





// Inizio - Filo Diretto
// -----------------------------------------------------------------------------------                   
function Controlla_Modulo() {

var Campo_Registrati = document.getElementById('Modulo_Filo_Diretto_Registrati')
Cosa_Faccio.value = Campo_Registrati.value;
var Campo_Privacy = document.getElementById('Modulo_Filo_Diretto_Privacy');
Accetto_Privacy.value = Campo_Privacy.value;

var Div_Campi_Richiesti = document.getElementById('Elenco_Campi_Obbligatori')

if (Accetto_Privacy.value=='S' && document.getElementById('Sto_Inviando').value=='0') document.getElementById('Bottone_Invia').disabled=false; else document.getElementById('Bottone_Invia').disabled=true;




if (Cosa_Faccio.value=='N') {
    
    Div_Campi_Richiesti.innerHTML = '';
    for (i=0;i<=3;i++) {
         if (document.getElementById('Modulo_Filo_Diretto_N_Hidden_'+i)) { 
             if (document.getElementById('Modulo_Filo_Diretto_N_Hidden_'+i).value.length > 0) {
                 Div_Campi_Richiesti.innerHTML = Div_Campi_Richiesti.innerHTML + document.getElementById('Modulo_Filo_Diretto_N_Hidden_'+i).value + '<br>';
             }  
         }  
   }
   
} else {

    Div_Campi_Richiesti.innerHTML = '';
    for (i=0;i<=10;i++) {
         if (document.getElementById('Modulo_Filo_Diretto_S_Hidden_'+i)) { 
             if (document.getElementById('Modulo_Filo_Diretto_S_Hidden_'+i).value.length > 0) {
                 Div_Campi_Richiesti.innerHTML = Div_Campi_Richiesti.innerHTML + document.getElementById('Modulo_Filo_Diretto_S_Hidden_'+i).value + '<br>';
             }  
         }  
   }
   
}

}

function Validazione_Modulo(Nome_Modulo) {
var Modulo = eval("document."+Nome_Modulo)

var PAT_USERID = /^[A-Za-z0-9_.-]{3,20}$/;
var PAT_PASSWORD = /^[A-Za-z0-9_.-]{6,20}$/;

var PAT_EMAIL = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+[.][A-Za-z]{2,6}$/;
var PAT_PHONE = /^[+\/.\-0-9 ]+$/;
var PAT_MOBILE = /^3[0-9]{8,9}/;

Modulo_Filo_Diretto_Nome = document.getElementById('Modulo_Filo_Diretto_Nome')
Modulo_Filo_Diretto_Cognome = document.getElementById('Modulo_Filo_Diretto_Cognome')
Modulo_Filo_Diretto_Eta = document.getElementById('Modulo_Filo_Diretto_Eta')
Modulo_Filo_Diretto_Indirizzo = document.getElementById('Modulo_Filo_Diretto_Indirizzo')
Modulo_Filo_Diretto_Citta = document.getElementById('Modulo_Filo_Diretto_Citta')
Modulo_Filo_Diretto_Cap = document.getElementById('Modulo_Filo_Diretto_Cap')
Modulo_Filo_Diretto_Telefono = document.getElementById('Modulo_Filo_Diretto_Telefono')
Modulo_Filo_Diretto_Email = document.getElementById('Modulo_Filo_Diretto_Email')

Modulo_Filo_Diretto_UserId = document.getElementById('Modulo_Filo_Diretto_UserId')
Modulo_Filo_Diretto_Password = document.getElementById('Modulo_Filo_Diretto_Password')


if (Accetto_Privacy.value=='S') {
        
        if (Cosa_Faccio.value=='N') {
	    
            if (Modulo_Filo_Diretto_Nome) {
                if (Modulo_Filo_Diretto_Nome.value.length == 0) {
                        alert('Il campo NOME e\' richiesto.');
                        Modulo_Filo_Diretto_Nome.focus();
                        return false;
                }	
            }
            
            if (Modulo_Filo_Diretto_Cognome) {
                if (Modulo_Filo_Diretto_Cognome.value.length == 0) {
                        alert('Il campo COGNOME e\' richiesto.');
                        Modulo_Filo_Diretto_Cognome.focus();
                        return false;
                }	
            }
            
            if (Modulo_Filo_Diretto_Email) {
                if (Modulo_Filo_Diretto_Email.value.length > 0) {
                    if (PAT_EMAIL.test(Modulo_Filo_Diretto_Email.value)==false) {
                        alert('Caratteri non corretti nel campo EMAIL');
                        Modulo_Filo_Diretto_Email.focus();
                        return false;
                    }
                } else {
                        alert('Il campo EMAIL e\' richiesto');
                        Modulo_Filo_Diretto_Email.focus();
                        return false;
                }
            }

        } else {
        
        
                if (Modulo_Filo_Diretto_Nome) {
                    if (Modulo_Filo_Diretto_Nome.value.length == 0) {
                            alert('Il campo NOME e\' richiesto.');
                            Modulo_Filo_Diretto_Nome.focus();
                            return false;
                    }	
                }
                
                if (Modulo_Filo_Diretto_Cognome) {
                    if (Modulo_Filo_Diretto_Cognome.value.length == 0) {
                            alert('Il campo COGNOME e\' richiesto.');
                            Modulo_Filo_Diretto_Cognome.focus();
                            return false;
                    }	
                }
                
                if (Modulo_Filo_Diretto_Eta) {
                    if (Modulo_Filo_Diretto_Eta.value.length == 0) {
                            alert('Il campo ETA\' e\' richiesto.');
                            Modulo_Filo_Diretto_Eta.focus();
                            return false;
                    }	
                }
                
                
                if (Modulo_Filo_Diretto_Indirizzo) {
                    if (Modulo_Filo_Diretto_Indirizzo.value.length == 0) {
                            alert('Il campo INDIRIZZO e\' richiesto.');
                            Modulo_Filo_Diretto_Indirizzo.focus();
                            return false;
                    }	
                }
                
                if (Modulo_Filo_Diretto_Citta) {
                    if (Modulo_Filo_Diretto_Citta.value.length == 0) {
                            alert('Il campo CITTA\' e\' richiesto.');
                            Modulo_Filo_Diretto_Citta.focus();
                            return false;
                    }	
                }
                
                if (Modulo_Filo_Diretto_Cap) {
                    if (Modulo_Filo_Diretto_Cap.value.length == 0) {
                            alert('Il campo CAP e\' richiesto.');
                            Modulo_Filo_Diretto_Cap.focus();
                            return false;
                    }	
                }
                
                if (Modulo_Filo_Diretto_Telefono) {
                    if (Modulo_Filo_Diretto_Telefono.value.length > 0) {
                        if (PAT_PHONE.test(Modulo_Filo_Diretto_Telefono.value)==false) {
	                        alert('Caratteri non corretti nel campo TELEFONO');
	                        Modulo_Filo_Diretto_Telefono.focus();
	                        return false;
                        }
                    } else {
                            alert('Il campo TELEFONO e\' richiesto');
                            Modulo_Filo_Diretto_Telefono.focus();
                            return false;
                    }
                }
                
                if (Modulo_Filo_Diretto_Email) {
                    if (Modulo_Filo_Diretto_Email.value.length > 0) {
                        if (PAT_EMAIL.test(Modulo_Filo_Diretto_Email.value)==false) {
	                        alert('Caratteri non corretti nel campo EMAIL');
	                        Modulo_Filo_Diretto_Email.focus();
	                        return false;
                        }
                    } else {
                            alert('Il campo EMAIL e\' richiesto');
                            Modulo_Filo_Diretto_Email.focus();
                            return false;
                    }
                }
                
                
                 if (Modulo_Filo_Diretto_UserId) {
                    if (Modulo_Filo_Diretto_UserId.value.length > 0) {
                        if (PAT_USERID.test(Modulo_Filo_Diretto_UserId.value)==false) {
	                        alert('Caratteri non consentiti o non sufficienti (minimo 3 caratteri) nel campo USERID');
	                        Modulo_Filo_Diretto_UserId.focus();
	                        return false;
                        }
                    } else {
                            alert('Il campo USERID e\' richiesto');
                            Modulo_Filo_Diretto_UserId.focus();
                            return false;
                    }
                }
                
                 if (Modulo_Filo_Diretto_Password) {
                    if (Modulo_Filo_Diretto_Password.value.length > 0) {
                        if (PAT_USERID.test(Modulo_Filo_Diretto_Password.value)==false) {
	                        alert('Caratteri non consentiti o non sufficienti (minimo 6 caratteri) nel campo PASSWORD');
	                        Modulo_Filo_Diretto_Password.focus();
	                        return false;
                        }
                    } else {
                            alert('Il campo PASSWORD e\' richiesto');
                            Modulo_Filo_Diretto_Password.focus();
                            return false;
                    }
                }
        
        }
    } else {
        alert('Per proseguire e\' necessario accettare le condizioni di privacy');
        return false;
    }    
        
return true;    
}
// -----------------------------------------------------------------------------------                   
// Fine - Filo Diretto



function Controllo_Valore_Numerico(Identity_Element) {
    var PAT_INT = /^[0-9]{1,4}$/;
    var d = document.getElementById(Identity_Element)
    if (d) {
        if (d.value.length > 0) {
            if (PAT_INT.test(d.value)==false) {
                alert('Caratteri non consentiti');
                d.value='1';
                d.focus();
                return false;
            }
        } else {
            alert('E\' necessario inserire un valore');
            d.value='1';
            d.focus();
            return false;
        }
    }
    return true;
    
}           


// Inizio - Cliente Acquisti
// -----------------------------------------------------------------------------------                   
function Controlla_Modulo_Cliente() {

var Div_Campi_Richiesti = document.getElementById('Elenco_Campi_Obbligatori')


   Modulo_Invia_Spesa_Fattura = document.getElementById('Modulo_Invia_Spesa_Fattura')
   Modulo_Invia_Spesa_Codice_Fiscale = document.getElementById('Modulo_Invia_Spesa_Codice_Fiscale')
   Modulo_Invia_Spesa_Partita_Iva = document.getElementById('Modulo_Invia_Spesa_Partita_Iva')


    if (Modulo_Invia_Spesa_Fattura.value=='N' ) {
        document.getElementById('Modulo_Invia_Spesa_Hidden_4').value = '';
        document.getElementById('Modulo_Invia_Spesa_Hidden_5').value = '';
    }
    
    if (Modulo_Invia_Spesa_Fattura.value=='S' && Modulo_Invia_Spesa_Codice_Fiscale.value.length==0 && Modulo_Invia_Spesa_Partita_Iva.value.length==0)  {
        document.getElementById('Modulo_Invia_Spesa_Hidden_4').value = 'Codice fiscale';
        document.getElementById('Modulo_Invia_Spesa_Hidden_5').value = 'Partita IVA';
    }
    Div_Campi_Richiesti.innerHTML = '';
    for (i=0;i<=10;i++) {
         if (document.getElementById('Modulo_Invia_Spesa_Hidden_'+i)) {       
             if (document.getElementById('Modulo_Invia_Spesa_Hidden_'+i).value.length > 0) {
                      Div_Campi_Richiesti.innerHTML = Div_Campi_Richiesti.innerHTML + document.getElementById('Modulo_Invia_Spesa_Hidden_'+i).value + '<br>';
                 }
             
         }  
   }
   
   var Tipo_Pagamento_Cliente = document.getElementById('Modulo_Invia_Spesa_Tipo_Pagamento')
   var Totale_Importo_Cliente = document.getElementById('Modulo_Invia_Spesa_Totale_Importo')
   var Tipo_Pagamento_Lista = document.getElementById('Modulo_Spesa_Tipo_Pagamento')
   var Totale_Importo_Lista = document.getElementById('Modulo_Spesa_Totale')
  
   if (Tipo_Pagamento_Cliente && Totale_Importo_Cliente && Tipo_Pagamento_Lista && Totale_Importo_Lista) {
    Tipo_Pagamento_Cliente.value = Tipo_Pagamento_Lista.value;
    Totale_Importo_Cliente.value = Totale_Importo_Lista.value;
   }
   

   if (Modulo_Invia_Spesa_Fattura.value=='S') {
        Modulo_Invia_Spesa_Codice_Fiscale.disabled=false;
        Modulo_Invia_Spesa_Partita_Iva.disabled=false;
   } else {
        //Modulo_Invia_Spesa_Codice_Fiscale.value='';
        Modulo_Invia_Spesa_Codice_Fiscale.disabled=true;
        //Modulo_Invia_Spesa_Partita_Iva.value='';
        Modulo_Invia_Spesa_Partita_Iva.disabled=true;
   
   }
   
   
}

function setPosition(IdDiv,margin_x,margin_y) {
      var d = document.getElementById(IdDiv)
      if (d) { 
          d.style.left=(document.body.clientWidth/2)-margin_x;
          d.style.top=(document.body.clientHeight/2)-margin_y;
      }
  } 
  
function setLabelButton(IdDiv,IdButton) {
     var d = document.getElementById(IdDiv)
     var b = document.getElementById(IdButton) 
     if (d && b) {
        if (d.innerHTML == '') b.value='Vedi i tuoi dati'; else b.value='Compila i tuoi dati';
     }
  }

function Validazione_Modulo_Cliente(Nome_Modulo) {
var Modulo = eval("document."+Nome_Modulo)

var PAT_USERID = /^[A-Za-z0-9_.-]{3,20}$/;
var PAT_PASSWORD = /^[A-Za-z0-9_.-]{6,20}$/;

var PAT_EMAIL = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+[.][A-Za-z]{2,6}$/;
var PAT_PHONE = /^[+\/.\-0-9 ]+$/;
var PAT_MOBILE = /^3[0-9]{8,9}/;

var PAT_CODICE_FISCALE = /^[A-Z]{6}[0-9]{2}[A-Z]{1}[0-9]{2}[A-Z]{1}[0-9]{3}[A-Z]{1}$/;
var PAT_PARTITA_IVA = /^[0-9]{11}$/;

Modulo_Invia_Spesa_Nome = document.getElementById('Modulo_Invia_Spesa_Nome')
Modulo_Invia_Spesa_Cognome = document.getElementById('Modulo_Invia_Spesa_Cognome')
Modulo_Invia_Spesa_Ente = document.getElementById('Modulo_Invia_Spesa_Ente')

Modulo_Invia_Spesa_Codice_Fiscale = document.getElementById('Modulo_Invia_Spesa_Codice_Fiscale')
Modulo_Invia_Spesa_Partita_Iva = document.getElementById('Modulo_Invia_Spesa_Partita_Iva')

Modulo_Invia_Spesa_Fattura = document.getElementById('Modulo_Invia_Spesa_Fattura')

Modulo_Invia_Spesa_Indirizzo = document.getElementById('Modulo_Invia_Spesa_Indirizzo')
Modulo_Invia_Spesa_Citta = document.getElementById('Modulo_Invia_Spesa_Citta')
Modulo_Invia_Spesa_Cap = document.getElementById('Modulo_Invia_Spesa_Cap')
Modulo_Invia_Spesa_Telefono = document.getElementById('Modulo_Invia_Spesa_Telefono')
Modulo_Invia_Spesa_Email = document.getElementById('Modulo_Invia_Spesa_Email')
    
        
if (Modulo_Invia_Spesa_Nome) {
    if (Modulo_Invia_Spesa_Nome.value.length == 0) {
            alert('Il campo NOME e\' richiesto.');
            Modulo_Invia_Spesa_Nome.focus();
            return false;
    }	
}

if (Modulo_Invia_Spesa_Cognome) {
    if (Modulo_Invia_Spesa_Cognome.value.length == 0) {
            alert('Il campo COGNOME e\' richiesto.');
            Modulo_Invia_Spesa_Cognome.focus();
            return false;
    }	
}

if (Modulo_Invia_Spesa_Ente) {
    if (Modulo_Invia_Spesa_Ente.value.length == 0) {
            alert('Il campo ENTE e\' richiesto.');
            Modulo_Invia_Spesa_Ente.focus();
            return false;
    }	
}


if (Modulo_Invia_Spesa_Fattura.value=='S') {

        if (Modulo_Invia_Spesa_Codice_Fiscale) {
            if (Modulo_Invia_Spesa_Codice_Fiscale.value.length > 0) {
                if (PAT_CODICE_FISCALE.test(Modulo_Invia_Spesa_Codice_Fiscale.value)==false) {
                    alert('Caratteri non consentiti o formato non corretto nel campo CODICE FISCALE');
                    Modulo_Invia_Spesa_Codice_Fiscale.focus();
                    return false;
                }
            } else {
                    alert('Il campo CODICE FISCALE e\' richiesto');
                    Modulo_Invia_Spesa_Codice_Fiscale.focus();
                    return false;
            }
        }

        if (Modulo_Invia_Spesa_Partita_Iva) {
            if (Modulo_Invia_Spesa_Partita_Iva.value.length > 0) {
                if (PAT_PARTITA_IVA.test(Modulo_Invia_Spesa_Partita_Iva.value)==false) {
                    alert('Caratteri non consentiti o formato non corretto nel campo PARTITA IVA');
                    Modulo_Invia_Spesa_Partita_Iva.focus();
                    return false;
                }
            } else {
                    alert('Il campo PARTITA IVA e\' richiesto');
                    Modulo_Invia_Spesa_Partita_Iva.focus();
                    return false;
            }
        }   
}

if (Modulo_Invia_Spesa_Indirizzo) {
    if (Modulo_Invia_Spesa_Indirizzo.value.length == 0) {
            alert('Il campo INDIRIZZO e\' richiesto.');
            Modulo_Invia_Spesa_Indirizzo.focus();
            return false;
    }	
}

if (Modulo_Invia_Spesa_Citta) {
    if (Modulo_Invia_Spesa_Citta.value.length == 0) {
            alert('Il campo CITTA\' e\' richiesto.');
            Modulo_Invia_Spesa_Citta.focus();
            return false;
    }	
}

if (Modulo_Invia_Spesa_Cap) {
    if (Modulo_Invia_Spesa_Cap.value.length == 0) {
            alert('Il campo CAP e\' richiesto.');
            Modulo_Invia_Spesa_Cap.focus();
            return false;
    }	
}

if (Modulo_Invia_Spesa_Telefono) {
    if (Modulo_Invia_Spesa_Telefono.value.length > 0) {
        if (PAT_PHONE.test(Modulo_Invia_Spesa_Telefono.value)==false) {
            alert('Caratteri non corretti nel campo TELEFONO');
            Modulo_Invia_Spesa_Telefono.focus();
            return false;
        }
    } else {
            alert('Il campo TELEFONO e\' richiesto');
            Modulo_Invia_Spesa_Telefono.focus();
            return false;
    }
}

if (Modulo_Invia_Spesa_Email) {
    if (Modulo_Invia_Spesa_Email.value.length > 0) {
        if (PAT_EMAIL.test(Modulo_Invia_Spesa_Email.value)==false) {
            alert('Caratteri non corretti nel campo EMAIL');
            Modulo_Invia_Spesa_Email.focus();
            return false;
        }
    } else {
            alert('Il campo EMAIL e\' richiesto');
            Modulo_Invia_Spesa_Email.focus();
            return false;
    }
}


 


  
        
return true;    
}
// -----------------------------------------------------------------------------------                   
// Fine - Cliente Acquisti
         
                    
                    
                    

