 function output(obj, val) {	
        }
        
        var msgErrNorma = 'Devi prima accettare le condizioni del trattamento dei dati personali';
        $(document).ready(function(){
          $("#wait").hide();
	  $("#error").hide();
	  $("#success").hide();
          $("input:checkbox").each( function() {
            (this.checked) ? $("#fake"+this.id).addClass('fakechecked') : $("#fake"+this.id).removeClass('fakechecked');
            $(this).css({
		'visibility' : 'hidden',
		'position' : 'absolute'
		});
          });
          $(".fakecheck").click(function(){
            ($(this).hasClass('fakechecked')) ? $(this).removeClass('fakechecked') : $(this).addClass('fakechecked');
            $(this.hash).trigger("click");
    		    
            return false;
          });	    	    	    
          
          var name = $("#txtNome"),
            email = $("#txtEmail"),
            tel = $("#txtTelefono"),
            note = $("#txtNote"),
            norma = $("#chkNorma"),
            allFields = $([]).add(name).add(email).add(tel).add(note).add(norma),
            tips = $("#validateTips");
            allFields.tipsy({
		trigger: 'manual', 
		gravity: 'sw'
	});
            
            
          allFields.focus(function() {
            $(this).addClass('ui-state-highlight');
          });  
          
          allFields.blur(function() {
            $(this).removeClass('ui-state-highlight');
          });  
                    
          function updateTips(t, o, parent) {
            if (!parent) {
              o.attr('original-title', t).tipsy('show');
              o.addClass('ui-state-error');
            }else{
              o.attr('original-title', t).tipsy('show');              
            }            
          }

          function checkLength(o,n,min,max) {
            if ( o.val().length > max || o.val().length < min ) {
              updateTips('La lunghezza del ' + n + ' deve essere tra ' +min+" e "+max+".", o, false);
              return false;
            } else {
              return true;
            }
          }
          
          function checkLengthNoMsg(o,min,max) {
            if ( o.val().length > max || o.val().length < min ) {	              
              return false;
            } else {
              return true;	              
            }
          }

          function checkSelectOrNo(o) {
            if (o.is(':checked')) {
              return true;
            } else {
              updateTips(msgErrNorma, o, true);
              return false;			              
            }
          }
          
          function checkEqual(o, u, n) {              
            if (o.val() == u.val()) {
              return true;
            } else {
              updateTips(n, o, false);
              return false;			              
            }
          }

          function checkSelectVal(o,n,min,max) {
		        if ( o.val().length > max || o.val().length < min ) {
			        updateTips('Devi selezionare un valore valido per il ' + n + ".",o,true);
			        return false;
		        } else {
			        return true;
		        }
	        }

          function checkRegexp(o,regexp,n) {
            if ( !( regexp.test( o.val() ) ) ) {
              updateTips(n, o, false);
              return false;
            } else {
              return true;
            }
          }

          if ($.browser.msie) {
            $("#watchPrivacy").css({ 
		'cursor' : 'hand' 
		});
          }else{
            $("#watchPrivacy").css({ 
		'cursor' : 'pointer' 
		});
          }
          
          $("#watchPrivacy").colorbox({ href:'privacy.htm',iframe:true, innerWidth:'700', innerHeight:'600' });
          
          $('#ButtonSpedisci').click(function() {
            return checkData();
          })
          .hover(
            function(){ 
	            //$(this).addClass("ui-state-hover"); 
            },
            function(){ 
	            //$(this).removeClass("ui-state-hover"); 
            }
          ).mousedown(function(){
            //$(this).addClass("ui-state-active"); 
          })
          .mouseup(function(){
	           // $(this).removeClass("ui-state-active");
          });
          
          var myTimer = {};
          
          function checkData() {  
            var bValid = true;
            
            allFields.removeClass('ui-state-error');
            name.tipsy('hide');
            email.tipsy('hide');
            tel.tipsy('hide');
            note.tipsy('hide');
            norma.tipsy('hide');
            
            bValid = bValid && checkLength(name,'campo Nome',1,100);            
            bValid = bValid && checkRegexp(name,/^(.+$)/,'campo Nome accetta solo : a-z A-Z 0-9');
            bValid = bValid && checkLength(email,'campo EMail',5,250);
            bValid = bValid && checkRegexp(email,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{ \| }~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{ \| }~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,'campo E-Mail non è valido, esempio: mail@caffezamboni.it');            
	    bValid = bValid && checkLength(note,'campo Note',1,1000);   
	    if (checkLengthNoMsg(note,1,1000)) {
		bValid = bValid && checkRegexp(note,/^([a-zA-Z0-9_\.\-\s\'\"\?\!\+\*\à?\è\à?\ù\ò\ì\;\:\,\/])+$/,"Campo note non accetta caratteri speciali");
	    }
            bValid = bValid && checkLength(tel,'campo Telefono',1,50);
            bValid = bValid && checkRegexp(tel,/^([+]39)?([0-9]*\-?\ ?\/?[0-9]*)$/,'campo Telefono accetta solo : 0-9');
                        
            bValid = bValid && checkSelectOrNo(norma);
            if (bValid) {
	      $('#wait').show();
	      $.ajax({
                    type: "post",
                    url: "/send.php",
                    data: "name=" + name.val() + "&email=" + email.val() + "&comment=" + note.val() + "&tel=" + tel.val(),
                    error: function() {
		         $('#wait').hide();
                        $('#error').show();
						$('#success').hide();
                    },
                    success: function () {
                        $('#wait').hide();
			$('#error').hide();
                        $('#success').show();
                        $('#MessageForm').hide();
						$('#privacybox').hide();
                    }
                });  
                   
            }
            return false;
          }	              	             
        });    
	  //]]> 
