$(document).ready(function() {
	$('.commandType').attr('disabled', false);
	$('.commandType').click(function(){
		var command = $(this);
		$('.commandType').attr('disabled', 'true');
		var commandType = $(this).prev().val();
		var rev = '';
		var logLength = 0;

		if (commandType == 'updateToRev') {
			rev = $('#rev').val();
		} else if (commandType == 'log') {
			logLength = $('#logLength').val();
		}

		$('#output').html('<div id="throbber" style="display:none" class="throbber"></div>');
		$('#throbber').fadeIn();

		$.ajax({
			url: 'hg.php',
			type: 'POST',
			data: ({commandType: commandType, rev: rev, logLength: logLength}),
			dataType: 'html',
			success: function(html) {
				if (html == '') {
					$('#output').html('No output');	
					$('.commandType').removeAttr('disabled');		
					return true;
				}

				$('#output').html(html);	
				$('.commandType').removeAttr('disabled');		
			}
		});
	});	
});
