$(function() {
  var default_settings = {
    buttonImage:     g.root_url + "/global/images/clock.png",
    showOn:          "both",
    buttonImageOnly: true
  }
  $(".cf_timepicker").each(function() {
    var field_name = $(this).attr("name");
    var settings = default_settings;
    if ($("#" + field_name + "_id").length) {
      var settings_list = $("#" + field_name + "_id").val().split("|");
      if (settings_list.length > 0) {
        settings.timeFormat = settings_list[0];
        for (var i=1; i<settings_list.length; i++) {
          var parts = settings_list[i].split("`");
          if (parts[1] === "true") {
            parts[1] = true;
          } else if (parts[1] === "false") {
            parts[1] = false;
          }
          settings[parts[0]] = parts[1];
        }
      }
    }
    $(this).timepicker(settings);
  });
});