$(function() {
  /*RFP JS*/
  $('.nhwcheck').removeAttr('checked');
  $('.nhwcheck').click(function(){
    this_nhw = $(this).next().text();
    container_contents = $('#nhwcontainer').attr("value");
    $('#nhwcontainer').attr("value", container_contents + ', ' + this_nhw);
  });
  
  $('#addNewSkill').click(function(){
    newSkill = $('#newSkill').attr('value');
    
    if (newSkill == ''){
      $('#skillsList > .error').show();
    } else {
      $('#newSkill').before('<li><input type="checkbox" checked="checked" class="nhwcheck" /> <label>' + newSkill + '</label></li>')
      $(this).prev().attr('value', '');
      $('#skillsList > .error').hide();
      
      container_contents = $('#nhwcontainer').attr("value");
      $('#nhwcontainer').attr("value", container_contents + ', ' + newSkill);
    }
  });
  

  //Count the words in the desc
  var remaining = 250 - $('.countMe').val().split(/\s/).length;
  $('.remaining').html(remaining);
  $('.countMe').bind('keyup', function(){
    var remaining = 250 - $(this).val().split(/\s/).length;
    
    if (remaining < 0){
      var limitedWords = $(this).val().substring(0, 249);
      $(this).val(limitedWords);
    }
    
    $('.remaining').html(remaining);
  });
  
  
});