<script type="text/javascript">
  
  // Requires 'jQuery UI - Core Modules' from: 
  // Page JavaScript/CSS Code > Included Javascript Library.
  
  // This is the DOM Name/Value of the field we'll apply the datepicker to.
  // Rename date to match the Name/Value of your field
  var dp = 'date';
  
  // This is the foarmat of the date shown to the user.
  // http://docs.jquery.com/UI/Datepicker/formatDate
  var ui_format = 'dd-M-yy';
  
  // !IMPORTANT!
  // We can access the MySQL TIMESTAMP value of this field in SQL+ 
  // by using the name of the field + _ts. 
  
  
  
  // -- DO NOT EDIT BELOW THIS LINE --
  
  $().ready(function(){
    
    // create our hidden items
    $(function(){
      if ($('#' + dp).length > 0){
        var hiddenInput_ts = $('<input/>',{type:'hidden',id:dp + '_ts'});
        hiddenInput_ts.appendTo('#fb_fld-' + dp);
      }
    }),
    
    // create the datepicker
    $(function() {
      $('#' + dp).datepicker({
        
        // the format of our date object
        dateFormat: ui_format,
        
        // this is the Name of the hidden field we'll write the SQL format to. 
        altField: "#" + dp + '_ts',
        altFormat: "yy-mm-dd 00:00:00",
        
        onClose: function() {
          // validate code
          validators[this.id].check();
          
        }
      });
    });
    
  }); // ready

  
</script>