// JavaScript Document

window.addEvent('domready', function(){

    
    
    if ($("RichiestaInfo")) {
        liveValidationUserForm();
    }
    
});



function liveValidationUserForm(){
	
    var wait = 1000;
    
	/*	var password = new LiveValidation('form[password]', {
        insertAfterWhatNode: $("hidden"),
        validMessage: "none",
        failureMessage: "",
        wait: wait
    });
    password.add(Validate.Presence, {
        failureMessage: ""
    });
    password.add(Validate.Length, {
        is: 6,
        wrongLengthMessage: ""
    });
    */
    var nome = new LiveValidation('nome', {
        insertAfterWhatNode: $("nome"),
        validMessage: "none",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
    nome.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });
   nome.add(Validate.Length, {
        minimum: 2,
        tooShortMessage: "campo obbligatorio"
    });
    
    var cognome = new LiveValidation('cognome', {
        insertAfterWhatNode: $("hidden"),
        validMessage: "none",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
    cognome.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });
     cognome.add(Validate.Length, {
        minimum: 2,
        tooShortMessage: "campo obbligatorio"
    });
    
 
 
  var via = new LiveValidation('via', {
        insertAfterWhatNode: $("via"),
        validMessage: "via",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
    via.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });
     via.add(Validate.Length, {
	minimum: 4,
        tooShortMessage: "indirizzo non valido"
    });



 var provincia = new LiveValidation('provincia', {
        insertAfterWhatNode: $("provincia"),
        validMessage: "none",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
    provincia.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });
    
    provincia.add(Validate.Length, {
	minimum: 2,
	tooShortMessage: "campo obligatorio",
        
    });
    
   
 
    var email = new LiveValidation('email', {
        insertAfterWhatNode: $("hidden"),
        validMessage: "none",
        failureMessage: "",
        wait: wait
    });
    email.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });
    email.add(Validate.Email, {
        failureMessage: "email non valida"
    });
    
   
    var cap = new LiveValidation('cap', {
        insertAfterWhatNode: $("hidden"),
        validMessage: "none",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
    cap.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });
    cap.add(Validate.Length, {
        maximum: 5,
        wrongLengthMessage: "cap non valido"
    });
    cap.add(Validate.Numericality, {
        onlyInteger: 1,
	tooShortMessage: "cap non valido",
	notANumberMessage: "cap non valido"
    });
    
    
    
    
    var citta = new LiveValidation('citta', {
        insertAfterWhatNode: $("hidden"),
        validMessage: "none",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
    citta.add(Validate.Presence, {
        failureMessage: "campo obligatorio"
    });
    citta.add(Validate.Length, {
        minimum: 2,
        tooShortMessage: "campo obbligatorio"
    });
   
    
    var telefono = new LiveValidation('telefono', {
        insertAfterWhatNode: $("hidden"),
        validMessage: "none",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
   /* telefono.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });*/
    telefono.add(Validate.Length, {
        minimum: 7,
         tooShortMessage: "min 7 cifre"
    });
    telefono.add(Validate.Numericality, {
        onlyInteger: 1,
	notANumberMessage: "campo numerico"
    });
    
    
    var cellulare = new LiveValidation('cellulare', {
        insertAfterWhatNode: $("hidden"),
        validMessage: "none",
        failureMessage: "campo obbligatorio",
        wait: wait
    });
    /*cellulare.add(Validate.Presence, {
        failureMessage: "campo obbligatorio"
    });*/
    cellulare.add(Validate.Length, {
        minimum: 7,
        tooShortMessage: "min 7 cifre"
    });
    cellulare.add(Validate.Numericality, {
        onlyInteger: 1,
	notANumberMessage: "campo numerico"
    });
    
    
    
   
}
