
	$(document).ready(function(){
		step = "step" + $("#step").val();
		if ($("#"+step).val() != "") {
			field = $("#"+step).val();
			$("#"+field).addClass("fitguideCheckboxOn");
			$(".nextLink").removeClass("linkOff");
		}
	});
	 
	$("div.checkbox").click (
		function () {
			if (!$(this).hasClass("fitguideCheckboxOn")) {
				field = $(this).attr("id");
				field_value = $(this).attr("value");
				field_title = $(this).attr("title");
				fields = $("#fields").val();
				step = "step" + $("#step").val();
				$("#"+step).val(field);
				$("#"+step+"_id").val(field_value);
				$("#"+step+"_title").val(field_title);
				$(this).toggleClass("fitguideCheckboxOn");
				xx = fields.split(",");
				for (n=0; n<xx.length;n++) {
					if (xx[n] != field) {
						$("#"+xx[n]).removeClass("fitguideCheckboxOn");
					}
				}
				$(".nextLink").removeClass("linkOff");
			}
		}
	)

	$("#next").click(
		function (){
			step = $("#step").val();
			nextStep = parseInt(step) + 1;
			if (step == 4) {
				if ($("#step1").val() == "standup") {
					nextStep = 6;
				}
			}
			if (step == 7) {
				if ($("#step1").val() == "whitewater") {
					nextStep = 9;
				}
				if ($("#step1").val() == "standup") {
					nextStep = 9;
				}
			}
			$("form[name='fitguide_form']").attr("action","step" + nextStep + "X.php");
			$("form[name='fitguide_form']").submit();
			return false;
		}
	)
	$("#previous").click(
		function (){
			step = $("#step").val();
			prevStep = parseInt(step) - 1;
			if (step == 6) {
				if ($("#step1").val() == "standup") {
					prevStep = 4;
				}
			}
			if (step == 9) {
				if ($("#step1").val() == "whitewater") {
					prevStep = 7;
				}
				if ($("#step1").val() == "standup") {
					prevStep = 7;
				}
			}			
			$("form[name='fitguide_form']").attr("action","step" + prevStep + "X.php");
			$("form[name='fitguide_form']").submit();
			return false;
		}
	)	
