$(document).ready(function () {

// Initial toggling

	$(".contents").hide();
	$("#male-size").hide();
	$("#gender .contents").show();
	$("gender").toggle();
	
//Default Case Debug
	
	$("#genderSelection").val('dash');
	$("#formSizeMale").val('dash');
	$("#formSizeFemale").val('dash');
	
	$("#attrcode").val('1000');

	$('#submitButton').click (function(){
		if ($("#attrcode").val() == "1000") {
			location.reload();
			alert("Were sorry. Please try that again.");
			return false;
		}
	});

// Toggle Scripts
	
	$("#gender a").toggle(
		function () {
			$("#gender a").removeClass();
			$("#gender a").addClass("openQuestionBar");
			$("#gender .contents").show();
		},
		function () {
			$("#gender a").removeClass();
			$("#gender a").addClass("questionBar");
			$("#gender .contents").hide();
		}
	);
	
	$("#male-size a").toggle(
		function () {
			$("#male-size a").removeClass();
			$("#male-size a").addClass("openQuestionBar");
			$("#male-size .contents").show();
		},
		function () {
			$("#male-size a").removeClass();
			$("#male-size a").addClass("questionBar");
			$("#male-size .contents").hide();
		}
	);
	
	$("#female-size a").toggle(
		function () {
			$("#female-size a").removeClass();
			$("#female-size a").addClass("openQuestionBar");
			$("#female-size .contents").show();
		},
		function () {
			$("#female-size a").removeClass();
			$("#female-size a").addClass("questionBar");
			$("#female-size .contents").hide();
		}
	);
	
	$("#options a").toggle(
		function () {
			$("#options a").removeClass();
			$("#options a").addClass("openQuestionBar");
			$("#options .contents").show();
		},
		function () {
			$("#options a").removeClass();
			$("#options a").addClass("questionBar");
			$("#options .contents").hide();
		}
	);
	
	
	$("#genderSelection").change(function() {
		switch ($('#genderSelection :selected').text()) {  
   		
   		case '--':
			$("#female-size").hide();
			$("#male-size").hide();
			$("#options .contents").hide();
			$("#attrcode").val('1000');
		break;
   		
   		case 'Male':
			$("#female-size").hide();
			$("#male-size").show();
			$("#male-size .contents").show();
		break;  

		case 'Female':  
			$("#male-size").hide();
			$("#female-size").show();
			$("#female-size .contents").show();
		break;
		}  
	})
	
	$("#formSizeFemale,#formSizeMale").change(function() {
		$("#options a").removeClass();
		$("#options a").addClass("openQuestionBar");
		$("#options .contents").show();
	});
	
// Happy Feet Selector-izor

	$("#formSizeMale").change(function() {
		switch ($('#formSizeMale').val()) {  
   		
   		case 'dash':
			$("#attrcode").val('1000');
		break;
   		
   		case 'ms':
			$('#attrcode option[value="1044"]').attr('selected','selected');
		break;
		
		case 'ms2':  
			$('#attrcode option[value="1045"]').attr('selected','selected');
		break;
		
		case 'mm':  
			$('#attrcode option[value="1046"]').attr('selected','selected');
		break;
		
		case 'ml':  
			$('#attrcode option[value="1048"]').attr('selected','selected');
		break;
		
		case 'ml2':  
			$('#attrcode option[value="1049"]').attr('selected','selected');
		break;
		
		case 'mm2':  
			$('#attrcode option[value="1047"]').attr('selected','selected');
		break;
		
		case 'mxl':  
			$('#attrcode option[value="1050"]').attr('selected','selected');
		break;
		
		case 'mxx':  
			$('#attrcode option[value="1051"]').attr('selected','selected');
		break;		
		}
	})
	
	$("#formSizeFemale").change(function() {
		switch ($('#formSizeFemale').val()) {  
   		
   		case 'dash':
			$("#attrcode").val('1000');
		break;
   		
   		case 'wxs':
			$('#attrcode option[value="1038"]').attr('selected','selected');
		break; 

		case 'ws':
			$('#attrcode option[value="1039"]').attr('selected','selected');
		break; 
		
		case 'ws2':
			$('#attrcode option[value="1040"]').attr('selected','selected');
		break; 

		case 'wm':  
			$('#attrcode option[value="1041"]').attr('selected','selected');
		break;
		
		case 'wm2':  
			$('#attrcode option[value="1042"]').attr('selected','selected');
		break;
		
		case 'wl2':  
			$('#attrcode option[value="1043"]').attr('selected','selected');
		break;		
		}
	})
	
	$("#thongSelector:unchecked").click(function (){
	if ($("#thongSelector").attr('checked')) {
		switch ($('#attrcode').val()) {
		
		case '1038':  
			$('#attrcode option[value="1052"]').attr('selected','selected');
		break;
		
		case '1039':  
			$('#attrcode option[value="1053"]').attr('selected','selected');
		break;
		
		case '1040':  
			$('#attrcode option[value="1054"]').attr('selected','selected');
		break;
		
		case '1041':  
			$('#attrcode option[value="1055"]').attr('selected','selected');
		break;
		
		case '1042':  
			$('#attrcode option[value="1056"]').attr('selected','selected');
		break;
		
		case '1043':  
			$('#attrcode option[value="1057"]').attr('selected','selected');
		break;
		
		case '1044':  
			$('#attrcode option[value="1058"]').attr('selected','selected');
		break;
		
		case '1045':  
			$('#attrcode option[value="1059"]').attr('selected','selected');
		break;
		
		case '1046':  
			$('#attrcode option[value="1060"]').attr('selected','selected');
		break;
		
		case '1047':  
			$('#attrcode option[value="1061"]').attr('selected','selected');
		break;
		
		case '1048':  
			$('#attrcode option[value="1062"]').attr('selected','selected');
		break;
		
		case '1049':  
			$('#attrcode option[value="1063"]').attr('selected','selected');
		break;
		
		case '1050':  
			$('#attrcode option[value="1064"]').attr('selected','selected');
		break;
		
		case '1051':  
			$('#attrcode option[value="1065"]').attr('selected','selected');
		break;
		}

	} else {

		switch ($('#attrcode').val()) {
		
		case '1052':  
			$('#attrcode option[value="1038"]').attr('selected','selected');
		break;
		
		case '1053':  
			$('#attrcode option[value="1039"]').attr('selected','selected');
		break;
		
		case '1054':  
			$('#attrcode option[value="1040"]').attr('selected','selected');
		break;
		
		case '1055':  
			$('#attrcode option[value="1041"]').attr('selected','selected');
		break;
		
		case '1056':  
			$('#attrcode option[value="1042"]').attr('selected','selected');
		break;
		
		case '1057':  
			$('#attrcode option[value="1043"]').attr('selected','selected');
		break;
		
		case '1058':  
			$('#attrcode option[value="1044"]').attr('selected','selected');
		break;
		
		case '1059':  
			$('#attrcode option[value="1045"]').attr('selected','selected');
		break;
		
		case '1060':  
			$('#attrcode option[value="1046"]').attr('selected','selected');
		break;
		
		case '1061':  
			$('#attrcode option[value="1047"]').attr('selected','selected');
		break;
		
		case '1048':  
			$('#attrcode option[value="1062"]').attr('selected','selected');
		break;
		
		case '1063':  
			$('#attrcode option[value="1049"]').attr('selected','selected');
		break;
		
		case '1064':  
			$('#attrcode option[value="1050"]').attr('selected','selected');
		break;
		
		case '1065':  
			$('#attrcode option[value="1051"]').attr('selected','selected');
		break;
		}
	}
});
})
