// OnLoad
jQuery(document).ready(function($) {
  // Attach to all select elements
  $("#location-switcher select").change(function() {
    select_element = this;
    var class_string = $(select_element).attr("class");
    var id_string = $(select_element).attr("id");
    var id_string2 = $("#" + id_string + " option:selected").attr("id");
    
    //Hide and disable all selects
    $("." + class_string + " select").hide();
    $("." + class_string + " select").each(function() {
      this.disabled = true;
    });
    
    // Show and enable select
    $("#select-" + id_string2).show();
    $("#select-" + id_string2).each(function() {
      this.disabled = false;
    });
    
    // show placeholder if nothing selected
    $(".select-group").each(function() {
      select_group = this
      var id_string = $(select_group).attr("id");
      var visible_selects = $("#" + id_string + " select:visible");
      if (visible_selects.length == 0) {
        $("#" + id_string + " .placeholder").show();
      }
    });
  }); 
})
