var last_id = 0;

function onAjaxSuccess(data)
{
	$('#results').html(data);
}

function selAnswer(this_el, this_id, next_id) {
	if (this_el.value != 0) {
		if (next_id != 0) {
			$('div#question'+next_id).animate({height: 'show'}, 300);
		}
		else {
			last_id = this_id;
		}

		if (last_id != 0) {

			var i=0, answers = new Array();
			$('div > select').each(
			  function()  {
					answers[i++] = this.value;
			  }
			);

			$.post('ajax-search-results.php',
			  {
				'answers[]': answers,
			  },
			  onAjaxSuccess
			);
		}

	}
	else {
		$('div:has(select):gt('+$('div:has(select)').index($('div#question'+this_id)[0])+')').animate({height: 'hide'}, 300);
	}
}