function getRocznik(_select) {
	var eid = _select.options[_select.selectedIndex].value;
	if (eid == 0) return false;

	var emarka = $('#a')[0].options[$('#a')[0].selectedIndex].value;
	if (emarka == 0) return false;
	
	$('#c')[0].disabled = true;
	$('#c')[0].html = '';
	$('#c')[0].options[0] = new Option("Ladowanie...", 1);
		
	$.ajax({
		url: 'ajax-motor-select.html',
		type: 'GET',
		data: ({ marka: emarka, model: eid }),
		success: function(htmlData) {
			$('#c').html(htmlData);
			$('#c')[0].disabled = false;
			
			return true;
		}
	});
	return false;
}

function getModel(_select) {
	var eid = _select.options[_select.selectedIndex].value;
	if (eid == 0) return false;

	$('#b')[0].disabled = true;
	$('#b')[0].html = '';
	$('#b')[0].options[0] = new Option("Ladowanie...", 1);

	$.ajax({
		url: 'ajax-motor-select.html',
		type: 'GET',
		data: ({ marka: eid }),
		success: function(htmlData) {
			$('#b').html(htmlData);
			$('#b')[0].disabled = false;

			$('#c')[0].html = '';
			$('#c')[0].options[0] = new Option("-- rocznik --", 1);
			$('#c')[0].disabled = true;
			return true;
		}
	});
	return false;
}

function getItem(id) {
	if(
		$('#a')[0].selectedIndex != 0 &&
		$('#b')[0].selectedIndex != 0 &&
		$('#c')[0].selectedIndex != 0
	)
	{
		var emarka = $('#a')[0].options[$('#a')[0].selectedIndex].value;
		var emodel = $('#b')[0].options[$('#b')[0].selectedIndex].value;
		var eid = $('#c')[0].options[$('#c')[0].selectedIndex].value;

		var url = "produkty,-1," + seo(eid) + ",1,czesci-" + seo(emarka) + "-" + seo(emodel) + ".html";
		window.location = url;
	}
}

function getRocznikMotodata(_select) {
	var eid = _select.options[_select.selectedIndex].value;
	if (eid == 0) return false;

	var emarka = $('#a_motodata')[0].options[$('#a_motodata')[0].selectedIndex].value;
	if (emarka == 0) return false;

	$('#c_motodata')[0].disabled = true;
	$('#c_motodata')[0].html = '';
	$('#c_motodata')[0].options[0] = new Option("Ladowanie...", 1);

	$.ajax({
		url: 'ajax-motor-select.html',
		type: 'GET',
		data: ({ marka: emarka, model: eid, motodata: 1 }),
		success: function(htmlData) {
			$('#c_motodata').html(htmlData);
			$('#c_motodata')[0].disabled = false;

			return true;
		}
	});
	return false;
}


function getModelMotodata(_select) {
	var eid = _select.options[_select.selectedIndex].value;
	if (eid == 0) return false;

	$('#b_motodata')[0].disabled = true;
	$('#b_motodata')[0].html = '';
	$('#b_motodata')[0].options[0] = new Option("Ladowanie...", 1);

	$.ajax({
		url: 'ajax-motor-select.html',
		type: 'GET',
		data: ({ marka: eid, motodata: 1 }),
		success: function(htmlData) {
			$('#b_motodata').html(htmlData);
			$('#b_motodata')[0].disabled = false;

			$('#c_motodata')[0].html = '';
			$('#c_motodata')[0].options[0] = new Option("-- rocznik --", 1);
			$('#c_motodata')[0].disabled = true;
			return true;
		}
	});
	return false;
}


function getItemMotodata(id) {
	if(
		$('#a_motodata')[0].selectedIndex != 0 &&
		$('#b_motodata')[0].selectedIndex != 0 &&
		$('#c_motodata')[0].selectedIndex != 0
	)
	{
		var emarka = $('#a_motodata')[0].options[$('#a_motodata')[0].selectedIndex].value;
		var emodel = $('#b_motodata')[0].options[$('#b_motodata')[0].selectedIndex].value;
		var eid = $('#c_motodata')[0].options[$('#c_motodata')[0].selectedIndex].value;

		var url = 'motodata,' + seo(eid) + "," + seo(emarka) + "-" + seo(emodel) + ".html";
		window.location = url;
	}
}
