$(document).ready(function() {
		$.getJSON('findMyMake.php',
			{
				year: $('#select1').getSetSSValue()
			},
			function(j){
				$('#select2 options').remove();
				var curVal = $('#select2').val();
				var options = '<option value="">Make</option>';
				for (var i=0; i < j.length; i++)
				{
					options += '<option value="'+j[i].optionValue+'"';
					if (curVal == j[i].optionValue){ options += ' selected';}
					options +='>'+j[i].optionDisplay+'</option>';
				}
				$('#select2').html(options);
				$('#select2').resetSS();
			}
		);

		$.getJSON('findMyVeh.php',
			{
				year: $('#select1').getSetSSValue(),
				make: $('#select2').getSetSSValue()
			},
			function(j){
				$('#select3 options').remove();
				var curVal = $('#select3').val();
				var options = '<option value="">Model</option>';
				for (var i=0; i < j.length; i++)
				{
					options += '<option value="'+j[i].optionValue+'"';
					if (curVal == j[i].optionValue){ options += ' selected';}
					options +='>'+j[i].optionDisplay+'</option>';
				}
				$('#select3').html(options);
				$('#select3').resetSS();
			}
		);
		
		$.getJSON('findMyClass.php',
			{
				year: $('#select1').getSetSSValue(),
				make: $('#select2').getSetSSValue(),
				model: $('#select3').getSetSSValue()
			},
			function(j){
				$('#select4 options').remove();
				var curVal = $('#select4').val();
				var options = '<option value="">Part Line (optional)</option>';
				for (var i=0; i < j.length; i++)
				{
					options += '<option value="'+j[i].optionValue+'"';
					if (curVal == j[i].optionValue){ options += ' selected';}
					options +='>'+j[i].optionDisplay+'</option>';
				}
				$('#select4').html(options);
				$('#select4').resetSS();
			}
		);
});

$(document).ready(function() {
	$('#select1').change(function(){
		$.getJSON('findMyMake.php',
			{
				year: $('#select1').getSetSSValue()
			},
			function(j){
				$('#select2 options').remove();
				var curVal = $('#select2').val();
				var options = '<option value="">Make</option>';
				for (var i=0; i < j.length; i++)
				{
					options += '<option value="'+j[i].optionValue+'"';
					if (curVal == j[i].optionValue){ options += ' selected';}
					options +='>'+j[i].optionDisplay+'</option>';
				}
				$('#select2').html(options);
				$('#select2').resetSS();
			}
		);
	});

	$('#select2').change(function(){
		$.getJSON('findMyVeh.php',
			{
				year: $('#select1').getSetSSValue(),
				make: $('#select2').getSetSSValue()
			},
			function(j){
				$('#select3 options').remove();
				var curVal = $('#select3').val();
				var options = '<option value="">Model</option>';
				for (var i=0; i < j.length; i++)
				{
					options += '<option value="'+j[i].optionValue+'"';
					if (curVal == j[i].optionValue){ options += ' selected';}
					options +='>'+j[i].optionDisplay+'</option>';
				}
				$('#select3').html(options);
				$('#select3').resetSS();
			}
		);
	});
	$('#select3').change(function(){
		$.getJSON('findMyClass.php',
			{
				year: $('#select1').getSetSSValue(),
				make: $('#select2').getSetSSValue(),
				model: $('#select3').getSetSSValue()
			},
			function(j){
				$('#select4 options').remove();
				var curVal = $('#select4').val();
				var options = '<option value="">Part Line (optional)</option>';
				for (var i=0; i < j.length; i++)
				{
					options += '<option value="'+j[i].optionValue+'"';
					if (curVal == j[i].optionValue){ options += ' selected';}
					options +='>'+j[i].optionDisplay+'</option>';
				}
				$('#select4').html(options);
				$('#select4').resetSS();
			}
		);
	});
});