
jQuery(function($) {

	$('#thread-order-form input').hide();

	$('#thread-order-form select').change(function() {

		if ( $(this).hasClass('paged') )
			return $('#thread-order-form').submit();

		if ( $(this).hasClass('logged_in') ) {
			$.post(wpListL10n.url, {
				action      : 'save_thread_order',
				order       : $('#thread-order-form select[name=order]').val(),
				_ajax_nonce : $('#thread-order-form input[name=_wpnonce]').val()
			});
		}

		$('#thread').fadeTo('normal', 0, function(){
			$('#thread li').each(function() {
				$(this).prependTo( $(this).parent() );
			});
			$('#thread').fadeTo('normal', 1);
		});

	});

});
