
function choiceText(j) {
	var text;
	switch(j)
	{
		case '6':
			text = 'N/A';
			break;
		case '1':
			text = 'Strongly Disagree';
			break;
		case '2':
			text = 'Disagree';
			break;
		case '3':
			text = 'Neither agree nor disagree';
			break;
		case '4':
			text = 'Agree';
			break;
		case '5':
			text = 'Strongly Agree';
			break;
	}
	return text;
}

$(document).ready(function(){

	$('.choice-button').hover(
      function () {
         if ($(this).hasClass('choice-button-selected') == false)
		{
			$(this).css('background-position', 'center 0px');
		}
		 if ($(this).parent().parent().parent().parent().find('td.choice-text').hasClass('choice-selected') == false)
		 {
		 	 var choice_value = $(this).parent().attr("class");
			 choice_value = choice_value.split('choice-');
			 choice_value = choice_value[1];
			 $(this).parent().parent().parent().parent().find('td.choice-text').html('<span class="choice-faded">' + choiceText(choice_value) + '</span>');
		 }
      },
      function () {
        if ($(this).hasClass('choice-button-selected') == false)
		{
			$(this).css('background-position', 'center 30px');
		}
		if ($(this).parent().parent().parent().parent().find('td.choice-text').hasClass('choice-selected') == false)
		 {
		 	 $(this).parent().parent().parent().parent().find('td.choice-text').html('<span class="choice-faded">' + click_rating + '</span>');
		 }
      }
    );

	$('.choice-button').click(function () {
      $(this).parent().parent().find('li div').each(function () {
		if ($(this).hasClass('choice-button-selected') == true)
		{
			$(this).addClass('choice-button');
	  		$(this).removeClass('choice-button-selected');
			$(this).css('background-position', 'center 30px');
		}
		});
		$(this).addClass('choice-button-selected');
		$(this).removeClass('choice-button');
		$(this).css('background-position', 'center 69px');
		var choice_value = $(this).parent().attr("class");
		choice_value = choice_value.split('choice-');
		choice_value = choice_value[1];
	  // set input value
	  $(this).parent().parent().parent().find('input').attr('value', choice_value);
	  // set text
	  $(this).parent().parent().parent().parent().find('td.choice-text').addClass('choice-selected').html(choiceText(choice_value));
    });


	$('.choice-button-selected').click(function () {

      $(this).parent().parent().find('li div').each(function () {
		if ($(this).hasClass('choice-button-selected') == true)
		{
			$(this).addClass('choice-button');
	  		$(this).removeClass('choice-button-selected');
			$(this).css('background-position', 'center 30px');
		}
		});
	  $(this).addClass('choice-button-selected');
	  $(this).removeClass('choice-button');
	  $(this).css('background-position', 'center 69px');
	  var choice_value = $(this).parent().attr("class");
	  choice_value = choice_value.split('choice-');
		choice_value = choice_value[1];
	  // set input value
	  $(this).parent().parent().parent().find('input').attr('value', choice_value);
	  // set text
	  $(this).parent().parent().parent().parent().find('td.choice-text').addClass('choice-selected').html(choiceText(choice_value));
    });


});
