$(function() {
	$('#cyear').change(function() {
		updMake();
	});
	$('#cmake').change(function() {
		updModel();
	});
	$('#cmodel').change(function() {
		updOption();
	});
	var $_GET = {};
	var $cmake = '';
	var $cmodel = '';
	var $coption = '';
	document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
		function decode(s) {
			return decodeURIComponent(s.split("+").join(" "));
		}
		$_GET[decode(arguments[1])] = decode(arguments[2]);
	});
	if ($_GET['cmodel']) {
		$cmake = '&cmake=' + $_GET['cmake'];
	}
	if ($_GET['cmodel']) {
		$cmodel = '&cmodel=' + $_GET['cmodel'];
	}
	if ($_GET['coption']) {
		$coption = '&coption=' + $_GET['coption'];
	}
	updMake();
	updModel();
	updOption();
	function updMake() {
		$.ajax( {
			url : '/?m=products&event=modelhtml&action=make'+$cmake,
			type : 'POST',
			data : 'cyear=' + $('#cyear option:selected').val(),
			dataType : 'html',
			success : function(data) {
				$('#cmake').empty().html(data);
				updModel();
				updOption();
			}
		});
	}
	function updModel() {
		$.ajax( {
			url : '/?m=products&event=modelhtml&action=model'+$cmodel,
			type : 'POST',
			data : 'cyear=' + $('#cyear option:selected').val() + '&cmake='
					+ $('#cmake option:selected').val(),
			dataType : 'html',
			success : function(data) {
				$('#cmodel').empty().html(data);
				updOption();
			}
		});
	}
	function updOption() {
		$.ajax( {
			url : '/?m=products&event=modelhtml&action=option'+$coption,
			type : 'POST',
			data : 'cyear=' + $('#cyear option:selected').val() + '&cmake='
					+ $('#cmake option:selected').val() + '&cmodel='
					+ $('#cmodel option:selected').val(),
			dataType : 'html',
			success : function(data) {
				$('#coption').empty().html(data);
			}
		});
	}
});
$(function() {
	$('#cyear2').change(function() {
		updMake2();
	});
	$('#cmake2').change(function() {
		updModel2();
	});
	$('#cmodel2').change(function() {
		updOption2();
	});
	var $_GET = {};
	var $cmake = '';
	var $cmodel = '';
	var $coption = '';
	document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
		function decode(s) {
			return decodeURIComponent(s.split("+").join(" "));
		}
		$_GET[decode(arguments[1])] = decode(arguments[2]);
	});
	if ($_GET['cmodel']) {
		$cmake = '&cmake=' + $_GET['cmake'];
	}
	if ($_GET['cmodel']) {
		$cmodel = '&cmodel=' + $_GET['cmodel'];
	}
	if ($_GET['coption']) {
		$coption = '&coption=' + $_GET['coption'];
	}
	updMake2();
	updModel2();
	updOption2();
	function updMake2() {
		$.ajax( {
			url : '/?m=products&event=modelhtml&action=make' + $cmake,
			type : 'POST',
			data : 'cyear=' + $('#cyear2 option:selected').val(),
			dataType : 'html',
			success : function(data) {
				$('#cmake2').empty().html(data);
				updModel2();
				updOption2();
			}
		});
	}
	function updModel2() {
		$.ajax( {
			url : '/?m=products&event=modelhtml&action=model' + $cmodel,
			type : 'POST',
			data : 'cyear=' + $('#cyear2 option:selected').val() + '&cmake='
					+ $('#cmake2 option:selected').val(),
			dataType : 'html',
			success : function(data) {
				$('#cmodel2').empty().html(data);
				updOption2();
			}
		});
	}
	function updOption2() {
		$.ajax( {
			url : '/?m=products&event=modelhtml&action=option' + $coption,
			type : 'POST',
			data : 'cyear=' + $('#cyear2 option:selected').val() + '&cmake='
					+ $('#cmake2 option:selected').val() + '&cmodel='
					+ $('#cmodel2 option:selected').val(),
			dataType : 'html',
			success : function(data) {
				$('#coption2').empty().html(data);
			}
		});
	}
});
