// JavaScript Document
$(document).ready(function()
{
	$('input[type="checkbox"]').attr('checked', false);
	
	$('.actieknop').click(function()
	{
		// welke checkbox moet veranderd worden?
		var id = "#checkbox_" + $(this).attr('checkbox');
		
		// welk vinkje moet verkleuren?
		var kies = "#kies_" + $(this).attr('checkbox');

		// welk tekstje moet verkleuren?
		var list = "#listitem_" + $(this).attr('checkbox');

		// is de checkbox aan of uit?
		var tog = $(id).attr('checked');

		// is het vinkje grijs of groen?
		var src = $(kies).attr('src');
		
		// is het tekstje grijs of zwart?
		var textcolor = $(list).css('color');
		
		// zet de checkbox aan/uit
		$(id).attr('checked', !tog);
		
		// zet het vinkje grijs/groen
		if(src == '/colors/templates/toscani_colors/images/stories/kies.png')
		{
			$(kies).attr('src', '/colors/templates/toscani_colors/images/stories/kies_2.png');
		}
		else
		{
			$(kies).attr('src', '/colors/templates/toscani_colors/images/stories/kies.png');
		}
		
		// zet het tekstje grijs/zwart
		if(textcolor == 'rgb(204, 204, 204)')
		{
			$(list).css('color', 'rgb(51, 51, 51)');
			$(list).css('font-weight','bold');
		}
		else
		{
			$(list).css('color', 'rgb(204, 204, 204)');
			$(list).css('font-weight','normal');
			
		}
		
		// verstuur het formulier
		var values = $('#form_modules').serialize();
		$.ajax(
		{
			type: "POST",
			url:  "/colors/templates/toscani_colors/xhr/progress.php",
			data: values,
			success: function(aantal_punten)
			{
				// zet de progressbar goed
				$('#progress').css('background-position', '0px ' +(-19*aantal_punten)+ 'px');
				
				// zet de prijswaarde goed
				if(aantal_punten <= 2) $('#prijswaarde').html('1.950');
				else if(aantal_punten <= 12) $('#prijswaarde').html('2.950');
				else if(aantal_punten <= 22) $('#prijswaarde').html('3.950');
				else $('#prijswaarde').html('5.950');
				
				// zet de labelbox goed
				if(aantal_punten <= 2) $('#labelbox').attr('src', '/colors/templates/toscani_colors/images/stories/red_box.png');
				else if(aantal_punten <= 12) $('#labelbox').attr('src', '/colors/templates/toscani_colors/images/stories/green_box.png');
				else if(aantal_punten <= 22) $('#labelbox').attr('src', '/colors/templates/toscani_colors/images/stories/blue_box.png');
				else $('#labelbox').attr('src', '/colors/templates/toscani_colors/images/stories/yellow_box.png');
			}
		});
	});	
});
