jQuery(document).ready(function(a) {
  var d = false, e = false;
  a("select").not(".normal").each(function() {
    var b = a(this), c = a(this).attr("width"), f = parseInt(c) + 2;
    a(this).hide();
    b.after('<span class="selectbox">' + a(this).children(":first-child").text() + '</span><span class="selectbox-wrapper"><ul class="replaceSelect" id="replace_' + b.attr("name") + '"></ul></span>');
    a(this).children("option").each(function() {
      a("#replace_" + b.attr("name")).append('<li id="option_' + a(this).val() + '">' + a(this).text() + "</li>")
    });
    a("#replace_" + b.attr("name")).parent().css("margin-left", "-" + f + "px");
    a("#replace_" + b.attr("name")).parent().css("width", c + "px").prev().css("width", c - 6 + "px");
    b.hasClass("float") && a("#replace_" + b.attr("name")).parent().prev().css("float", "left").css("margin-right", "10px")
  });
  a(".selectbox").click(function() {
    a(this).next().show();
    e = a(this);
    d = true
  }).mouseout(function() {
    if(d) {
      d = false;
      setTimeout(function() {
        d || e.next().hide()
      }, 100)
    }
  });
  a(".selectbox-wrapper").hover(function() {
    d = true
  }, function() {
    d = false;
    a(this).hide()
  });
  a(".replaceSelect li").click(function() {
    var b = a(this).parent().attr("id");
    b = b.substr(8);
    var c = a(this).attr("id");
    c = c.substr(7);
    a("select[name='" + b + "'] option[value='" + c + "']").attr("selected", "selected");
    a(this).parent().parent().prev().html(a(this).text()).next().hide()
  }).hover(function() {
    a(this).addClass("current")
  }, function() {
    a(this).removeClass("current")
  });
  a("#replace_aanleiding li").click(function() {
    var b = a(this).attr("id");
    b = b.substr(7);
    a(".extend_aanleiding").hide();
    a(".extend_aanleiding input").addClass("exclude");
    a("#" + b + " input").removeClass("exclude").parent().parent().show()
  });
  a("#replace_situatie li").click(function() {
    var b = a(this).attr("id");
    b = b.substr(7);
    a(".extend_situatie").hide();
    a(".extend_situatie input, .extend_situatie select").addClass("exclude");
    a("#" + b + " input, #" + b + " select").not(".checkbox").removeClass("exclude");
    a("#" + b).show()
  })
});
