//<script>//
<!--//
$(document).ready(function () {
	$('#select-topic').live('change', function () {
		if ($(this).val() == 0) { return true; }
		$('.feedback-loading').fadeIn();
		$('#select-topic').attr('disabled', true);
		$.ajax({
			type: 'GET',
			url: 'inc/feedback.php',
			data: 'topic=' + $('#select-topic').val(),
			success: function (res) {
				if (res == '') {
					$('#feedback-from').submit();
				} else {
					$('.be-dynamic').html(res);
					$('#select-topic').attr('disabled', false);
				}
				$('.feedback-loading').fadeOut();
			},
			error: function () {
				$('#feedback-from').submit();
			}
		});
	});
	
	$('#select-subtopic').live('change', function () {
		if ($(this).val() == 0) { return true; }
		$('.feedback-loading').fadeIn();
		$('#select-topic').attr('disabled', true);
		$('#select-subtopic').attr('disabled', true);
		$.ajax({
			type: 'GET',
			url: 'inc/feedback.php',
			data: 'topic=' + $('#select-topic').val() + '&subtopic=' + $('#select-subtopic').val(),
			success: function (res) {
				if (res == '') {
					$('#feedback-from').submit();
				} else {
					$('.be-dynamic').html(res);
					$('#select-topic').attr('disabled', false);
					$('#select-subtopic').attr('disabled', false);
				}
				$('.feedback-loading').fadeOut();
			},
			error: function () {
				$('#feedback-from').submit();
			}
		});
	});
	$('.biz-search .psf').live('keypress', function (e) {
		if (e.keyCode == 13) {
			search_public(yp)
			return false;
		}
	})
});

function search_public(extra) {
	$('#pub_selected').html('<center><img src="t/template/img/loading.gif" width="35" height="35" alt="Loading" /> Searching...</center>');
	$.ajax({
			type: 'GET',
			url: 'inc/get_business.php',
			data: 'bn=' + $('#pub_bn').val() + '&near=' + $('#pub_near').val() + '&yp=' + extra,
			success: function (msg) {
				$('#pub_selected').hide().html(msg).slideDown();
				if (extra == 'all') { $('#pub_search').slideUp(); }
			}
	});
}

function select_business(id) {
	$('#biz_id').val(id);
	$('#pub_search').slideUp();
	$('#pub_selected').html($('#business_' + id).html() + '<br/><div style="float: right"><a style="cursor: pointer" onclick="select_another()">Select another</a></div>');
}
					
function select_another() {
	$('#biz_id').val(0);
	$('#pub_search').slideDown();
	$('#pub_selected').html('');
}
//-->