$(function() {
  $(".option").hide();

  // Hide Specify Other fields
  $(".source-other").hide();
  $("form #source").change(function() {
      $("dd.mandatory").remove(); /* Remove any existing warnings */

      /* If "other" is selected, show and require text field */
      if ("other" == $(this).val()) {
        $(".source-other").show();
        $(".source-other :input").addClass("required");
      /* Otherwise, hide text field and make it optional again*/
      } else {
        $(".source-other").hide();
        $(".source-other :input").removeClass("required");
      }
  });
});
function changeContactType(ele) {
  var form = $(ele).parents("form");
  $(".option", form).hide();  /* Hide options */
  $("dd.mandatory").remove(); /* Remove any existing warnings */

  /* Unrequire optional fields */
  $(".if-require :input", form).removeClass("required");
  $("label[for='telephone']").css("padding-left", "0.65em");
  $("label[for='telephone']").siblings("span").remove();
  $("#telephone").removeClass("required");

  /* Show options for this type and require as necessary */
  $("." + ele.value, form).show();
  $("." + ele.value + ".if-require :input", form).addClass("required");

  if (/^(?:appointment|estimate|promo)$/.test(ele.value)) {
    /* Require telephone */
    var html = "<span class='required'>*</span> <label for='telephone'>Telephone</label>";
    $("label[for='telephone']").parents("dt").html(html);
    $("label[for='telephone']").css("padding-left", "0");
    $("#telephone").addClass("required");
  }

  if ("promo" == ele.value) {
    $("h1").text("Registration Form");
  } else {
    $("h1").text("Contact Us");
  }

  $("form #source").change();
}