	<script type="text/javascript" src="../javascript/jquery/plugins/ajax.file.upload.js"></script>
	<script type="text/javascript" src="../javascript/jquery/plugins/interface.js"></script>
	<script type="text/javascript" src="../javascript/jquery/plugins/inestedsortable.js"></script>
<script type="text/javascript">

		var updatingSortables = false;
		var updateTimeout = null;
		function CreateSortableList() {
			$('#CategoryList').NestedSortable(
				{
					accept: 'SortableRow',
					noNestingClass: "no-nesting",
					opacity: .8,
					helperclass: 'SortableRowHelper',
					onChange: function(serialized) {
						updatingSortables = true;
						if(updateTimeout != null) window.clearTimeout(updateTimeout);
						
						$.ajax({
							url: '%%GLOBAL_pathToKB%%/admin/remote.php?type=sortcategories',
							type: 'POST',
							dataType: 'xml',
							data: serialized[0].hash,
							success: function(response) {
								display_success('Message', '%%LNG_CategoryOrdersUpdated%%');
								
								if(document.all) {
									// IE has problems here - it breaks on sortable lists so for now we just
									// refresh the current page
									window.location.reload();
								}
							}
						});

					},
					onStop: function() {
						if(document.all && updatingSortables == false) {
							// IE has problems here - it breaks on sortable lists so for now we just
							// refresh the current page
							updateTimeout = window.setTimeout(function() { window.location.reload(); }, 100);
						}
					},
					autoScroll: true,
					handle: '.sort-handle'
				}
			);
		}
		
		function display_success(id,message,timeout){
			if($('#'+id+' .MessageBox').get() != "") {
				$('#'+id).fadeOut('slow');
				$('#'+id).html('<div class="MessageBox MessageBoxSuccess">'+message+'</div>').fadeIn('slow');
			} else {
				$('#'+id).hide().html('<div class="MessageBox MessageBoxSuccess">'+message+'</div>').show('slow');
			}
			if(timeout > 0) {
				window.setTimeout(function() { $('#'+id).hide('slow'); }, timeout);
			}
		}
		
		
		$(document).ready(function()
		{
			CreateSortableList();
		});
</script>
<p class="InfoTip">%%LNG_CategoryOrdersInfo%%</p>
<div class="BodyContainer" >

<form method="post" name="fmUser" action="%%GLOBAL_FormAction%%">
<input type="hidden" value="" name="bulkaction">
<table class="OuterPanel" id="outerpanel" cellspacing="0" cellpadding="0" border="0">
<tr>
	<td class="Heading1">%%LNG_ManageCategories%%</td>
	</tr>
	<tr>
	<td>
		<!--<div class="Heading1">%%LNG_ManageCategories%%</div>-->
		<div class="Intro" style="margin-bottom:0px;margin-top:10px;">%%LNG_ManageCatMessage%%</div> 
		<div id="Message">%%GLOBAL_Message%%</div>
<br />
<div class="Intro" style="margin-bottom:20px;">
						<span style="display: %%GLOBAL_ShowCreateButton%%">
							<input type="button" onClick="document.location.href='index.php?ToDo=createCategory'" name="createNewCategory" value="%%LNG_CreateCategory%%" class="Button">
						</span>
						<span style="display: %%GLOBAL_ShowDeleteButton%%">
							<input type="button" value="%%LNG_Delete%% %%LNG_Selected%%" class="Button" onclick="BulkAction(this, 'delete', '%%LNG_BulkDeleteCategoryFailure%%', '%%LNG_BulkDeleteCategoryConfirm%%')">
						</span>
		</div>
	</td>
</tr>
</table>
		<table border=0 cellspacing="0" cellpadding="0" width="100%" class=text>
			<tr class="Heading3">
				<td width="1">
					<input type="checkbox" name="toggle" onclick="javascript: toggleAllCheckboxes(this);">
				</td>
				<td align="left">
					%%LNG_CategoryName%%
				</td>
				<td align="center" width="80">
					%%LNG_CategoryQuestions%%
				</td>
				<td align="center" width="80">
					%%LNG_CategorySecurity%%
				</td>
				<td width="100">
					%%LNG_Action%%
				</td>
			</tr>
		</table>

	%%GLOBAL_CategoryGrid%%
</form>

</div>