function returnObjById(id) {
	if (document.getElementById)
		var returnVar = document.getElementById(id);
	else if (document.all)
		var returnVar = document.all[id];
	else if (document.layers)
		var returnVar = document.layers[id];
	return returnVar;
}

function ExecFunc01(cod) {
	new Ajax.Request('index.php', {
		method : 'post',
		parameters : {
			action : '3',
			func : '1',
			dist01 : cod
		},
		onSuccess : function(transport) {
			var response = transport.responseText || "no response text";
			if (response != "no response text") {
				returnObjById('SelConc01').innerHTML = response;
			}
		},
		onFailure : function() {
			return false;
		}
	});
}

function ExecFunc02(cod, ano) {
	new Ajax.Request(
			'index.php',
			{
				method : 'post',
				parameters : {
					action : '3',
					func : '2',
					marca01 : cod,
					anoMatric01 : ano
				},
				onSuccess : function(transport) {
					var response = transport.responseText || "no response text";
					if (response != "no response text") {
						returnObjById('SelModelo01').innerHTML = response;
						returnObjById('SelVersao01').innerHTML = '<select id="versao01" name="versao01"><option value="">[Seleccione]</option></select>';
					}
				},
				onFailure : function() {
					return false;
				}
			});
}

function ExecFunc03(cod1, cod2, ano) {
	new Ajax.Request('index.php', {
		method : 'post',
		parameters : {
			action : '3',
			func : '3',
			marca01 : cod1,
			modelo01 : cod2,
			anoMatric01 : ano
		},
		onSuccess : function(transport) {
			var response = transport.responseText || "no response text";
			if (response != "no response text") {
				returnObjById('SelVersao01').innerHTML = response;
			}
		},
		onFailure : function() {
			return false;
		}
	});
}

function ExecFunc04(cod1, cod2, cod3, dt) {
	new Ajax.Request('index.php', {
		method : 'post',
		parameters : {
			action : '3',
			func : '4',
			marca01 : cod1,
			modelo01 : cod2,
			versao01 : cod3,
			dtMatric01 : dt
		},
		onSuccess : function(transport) {
			var response = transport.responseText || "no response text";
			if (response != "no response text") {
				returnObjById('txtValorTotal').value = response;
				valTotalVeiculo();
			}
		},
		onFailure : function() {
			return false;
		}
	});
}

function ExecFunc05(ano) {
	new Ajax.Request(
			'index.php',
			{
				method : 'post',
				parameters : {
					action : '3',
					func : '5',
					anoMatric01 : ano
				},
				onSuccess : function(transport) {
					var response = transport.responseText || "no response text";
					if (response != "no response text") {
						returnObjById('SelMarca01').innerHTML = response;
						returnObjById('SelModelo01').innerHTML = '<select id="modelo01" name="modelo01"><option value="">[Seleccione]</option></select>';
						returnObjById('SelVersao01').innerHTML = '<select id="versao01" name="versao01"><option value="">[Seleccione]</option></select>';
					}
				},
				onFailure : function() {
					return false;
				}
			});
}

function ExecFunc06() {
	new Ajax.Request(
			'index.php',
			{
				method : 'post',
				parameters : {
					action : '3',
					func : '6'
				},
				onSuccess : function(transport) {
					var response = transport.responseText || "no response text";
					if (response != "no response text") {
						window.location=response;
					}
				},
				onFailure : function() {
					return false;
				}
			});
}
