document.write("<style>.formHelp{display:none;}</style>");
document.write("<style>.formValidator{display:none;}</style>");
jQuery.addMutator(function(ctx) {
 var links = jQuery("a.select_addedit", ctx);
 links.each(function() {
  var actionButton = jQuery(this);
  var fieldName = this.getAttribute("fieldName");
  var ptr = this.parentNode;
  while (ptr != null && ptr.nodeName != "FORM") ptr = ptr.parentNode;
  if (ptr == null) return;
  var selector = jQuery("select[@name='" + fieldName + "']", ptr);
  if (selector.length == 0) return;
  if (!selector.attr("changer_installed")) {
   selector.attr("changer_installed", true).change(function() {
    if (this.selectedIndex == 0) {
     actionButton
      .show()
      .empty()
      .append("<span>" + actionButton.attr("addTitle") + "</span>")
      .attr("wsWidgetName", actionButton.attr("addWidget"))
      .attr("wsTitle", actionButton.attr("addTitle"))
      .attr("href", actionButton.attr("addHref"));
    } else {
     actionButton
      .show()
      .empty()
      .append("<span>" + actionButton.attr("editTitle") + "</span>")
      .attr("wsWidgetName", actionButton.attr("editWidget"))
      .attr("wsTitle", actionButton.attr("editTitle"))
      .attr("href", actionButton.attr("editHref") + this.options[this.selectedIndex].value);
    }
    selector.WidgetSendResizeEvent();
   });
  }
  selector.change();
  actionButton.applyMutators();
 });
 jQuery.datePicker.setDateFormat('mdy','/');
 $('.date-picker', ctx).datePicker({startDate: "01/01/1970"}); //.bind("dpClosed", function() { alert("dpClosed"); jQuery(this).sendResizeEvent(); });;
 //jQuery("a.date-picker", ctx).click(function() { setTimeout(function() { jQuery(this).sendResizeEvent(); }, 1000); return false; });
 var s = jQuery(".formValidator", ctx).hide();
 jQuery(".formHelp:not(:empty)", ctx)
  .before("<a class='formHelpIcon' style='font-size: 120%; color: red;' href='#'>?</a>")
  .css("background-color", "#ffffff")
  .css("border", "1px solid black")
  .css("display", "none")
  .css("position", "absolute")
  .each(
   function() {
    var helpBox = jQuery(this);
    jQuery(this.previousSibling)
     .mousemove(
      function(e) {
       var xy = webslinger.fixMouseEvent(e);
       helpBox.css("top", xy[1] + 10).css("left", xy[0] + 10);
      }
     ).hover(
      function(e) {
       var xy = webslinger.fixMouseEvent(e);
       helpBox.css("top", xy[1] + 10).css("left", xy[0] + 10).show();
      },
      function(e) {
       helpBox.hide();
      }
     ).click(function() { return false; });
    jQuery("body").append(this);
   }
  );
 jQuery("input[@disabled], textarea[@disabled], select[@disabled]", ctx).addClass("disabled");
});

