$(document).ready ->
  #activeCount must be at 4 to enable button
  activeCount = 4
  #set all inputs
  $('input[type="checkbox"]').prop('checked', true)

  #Checkbox set
  $('.checkBox').click ->
    if !($(this).hasClass('active'))
      activeCount++
      switch $(this).val()
        when "1" then $('input#id_trust').prop('checked', true)
        when "2" then $('input#id_protection').prop('checked', true)
        when "3" then $('input#id_monitoring').prop('checked', true)
        when "4" then $('input#id_feedback').prop('checked', true)
      if activeCount == 4
        $('input[type="submit"]').prop('disabled', false)
    else 
      $(this).addClass("deselected")
      $('input[type="submit"]').prop('disabled', true)
      activeCount--
      switch $(this).val()
        when "1" then $('input#id_trust').prop('checked', false)
        when "2" then $('input#id_protection').prop('checked', false)
        when "3" then $('input#id_monitoring').prop('checked', false)
        when "4" then $('input#id_feedback').prop('checked', false)
    $(this).toggleClass('active')

  #remove Deselected State 
  $(".checkBox").mouseleave ->
    $(this).removeClass("deselected")




