function activatePlaceholders() {
    var inputs = document.getElementsByTagName("input");
    for (var i=0; i < inputs.length; i++) {
        if (inputs[i].getAttribute("type") == "text") {
            if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
                inputs[i].onfocus = function() {
                    if (this.value == this.getAttribute("placeholder")) {
                        this.value = "";
                        this.setAttribute("class", "");
                        this.setAttribute("className", "");
                    }
                    return false;
                }

                inputs[i].onblur = function() {
                    if (this.value.length < 1) {
                        this.value = this.getAttribute("placeholder");
                        this.setAttribute("class", "placeholder");
                        this.setAttribute("className", "placeholder");
                    }
                }

                inputs[i].onblur();
            }
        }
    }
}

window.onload = function() {
    activatePlaceholders();
}

"use strict";
var ProgramsUI = {
  selectors: {
    use_position_limits_checkbox: '#use_position_limits',
    ask_about_team_checkbox: '#ask_team',
  },

  init: function () {
      $(ProgramsUI.selectors.use_position_limits_checkbox).bind('change', function () {
          var checked = $(this).attr('checked');

          if (checked) {
              $('input.position_limit').parent().parent().show();
              $('span input[name="max_campers"]').parent().hide();
          } else {
              $('input.position_limit').parent().parent().hide();
              $('span input[name="max_campers"]').parent().show();
          }
      });

      $(ProgramsUI.selectors.ask_about_team_checkbox).bind('change', function () {
          var checked = $(this).attr('checked');

          if (checked) {
              $('select[name="team_group_id"]').parent().parent().show();
          } else {
              $('select[name="team_group_id"]').parent().parent().hide();
          }
      });

  }

};

$(document).ready(function () {
    ProgramsUI.init();
});

