$(document).ready(function(){
		  handleNbQuestions();
});

function handleNbQuestions(){
  var globalDiv = $("div#nb_question");
  $("input.Plus").click(function(){
	var globalValue = parseInt(globalDiv.html());

	if (globalValue > 0) {
		var input = $(this);
		var name = input.attr('id').substr(4);
		var currentInput = $("input[name=nbQuestion" + name + "]");
		var currentValue = parseInt(currentInput.val());
		globalDiv.html(globalValue - 1);
		currentInput.val(currentValue + 1);
	}
  });
  $("input.Minus").click(function(){
	var input = $(this);
	var name = input.attr('id').substr(5);
	var currentInput = $("input[name=nbQuestion" + name + "]");
	var currentValue = parseInt(currentInput.val());
	if (currentValue > 0) {
		var globalValue = parseInt(globalDiv.html());
		globalDiv.html(globalValue + 1);
		currentInput.val(currentValue - 1);
	}
  });
}

