function getyears() {
  $("#year option:first").text("Loading choices...");
	var model = $("#model").val();
	$.ajax({
		type: "GET",
		url: "inc/getYears.php?model="+model+"&r="+Math.floor(Math.random()*10001),
		dataType: "text",
		success: function(data){
	    var y_list = document.getElementById("year");
			for(j = y_list.options.length; j >= 1; j--) { y_list.options[(j - 1)] = null; } //remove all options
			$('#year').append('<option value="">Choose</option>');

			var results = data.split("|");
			$(results).each(function(i) {
				$('#year').append('<option value="'+results[i]+'">'+results[i]+'</option>');
			});
			$('#year').removeAttr("disabled");
			document.getElementById("trim").selectedIndex = 0;
			$('#trim').attr("disabled","disabled");
	   }
	 });
}
function gettrims() {
	$("#trim option:first").text("Loading choices...");
	var model = $("#model").val();
	var year = $("#year").val();
	$.ajax({
		type: "GET",
		url: "inc/getTrims.php?model="+model+"&year="+year+"&r="+Math.floor(Math.random()*10001),
		dataType: "text",
		success: function(data){
	     	var y_list = document.getElementById("trim");
			for(j = y_list.options.length; j >= 1; j--) { y_list.options[(j - 1)] = null; } //remove all options
			$('#trim').append('<option value="">Choose</option>');

			var results = data.split("|");
			$(results).each(function(i) {
				var sp = results[i].split("~");
				$('#trim').append('<option value="'+sp[0]+'">'+sp[1]+'</option>');
			});
			$('#trim').removeAttr("disabled");
	   }
	 });
}
function getnavi() {
  var trim = $("#trim").val();
  $.ajax({
		type: "GET",
		url: "inc/checkModule.php?trim="+trim+"&r="+Math.floor(Math.random()*10001),
		dataType: "text",
		success: function(data){
		  if(data == 225) {
		    $("#selectVehicleTable tr:eq(2)").after("<tr><td>Navigation System:</td><td><select name=\"n\" id=\"n\"><option value=\"1\">My vehicle has a navigation system</option><option value=\"0\">My vehicle does NOT have a navigation system</option></select></td></tr>");
		  }
	  }
  });
}
