function loadSubcat() {
	if ($('#cat_id').val() > 0) {
		$.ajax({
			url: '/ajax/?module=wiki&action=subcats&parent=' + $('#cat_id').val(),
			type: 'GET',
			dataType: 'xml',
			timeout: 1000,
			error: function(){
				alert('Error loading XML document');
			},
			success: function(xml){ 
				var stype = $('type',xml).text();
				var stotal = $('total',xml).text();
				if (stype == 'Error') {
				   alert ('Error loading your rquest: wiki-' + stotal);
				} else {

				options = '<option value="0" selected="selected">Select Sub-Category</option>';
				$(xml).find('item').each(
					function(){ 
						options += '<option value="' + $(this).find('id').text() + '">' + $(this).find('text').text() + '</option>';
					}
				);
				$('select#subcat_id').html(options);
				$('option:first', 'select#subcat_id').attr('selected','selected');

				}
			}
		});
	} else {
		$('select#subcat_id').html('<option value="0" selected="selected">Select Sub-Category</option>');
	}
}

function submitWiki() {
var stitle = $.trim($('#p_title').val());
var stext = $.trim($('#p_text').val());
var serror = 0;
var serror_text = '';

if (stitle == '') {
	serror = 1;
} else if (stext == '') {
	serror = 2;
} else if ($('#cat_id').val() == 0) {
	serror = 3;
} else if ($('#subcat_id').val() == 0) {
	serror = 4;
}

if (serror == 0) {

$('input#sbsubmit').attr('disabled','disabled');
$('form#r_form').submit();

} else {

if (serror == 1) { 
serror_text = 'You must have a title in order to submit.';
} else if (serror == 2) {
serror_text = 'You must have text in order to submit.';
} else if (serror == 3) {
serror_text = 'You must select a category in order to submit.';
} else if (serror == 4) {
serror_text = 'You must select a sub-category in order to submit.';
}
$('div#report').html('<p class="report-warning">' + serror_text + '</p>');
return false;

}

}