<script type="text/javascript" src="<{$mod_url}>/index.php?page=module_header&src=jquery.js"></script>
<script type="text/javascript" src="<{$mod_url}>/index.php?page=module_header&src=d3downloads.js"></script>
<h2><{$smarty.const._MD_D3DOWNLOADS_H2CATEGORYMANAGER}></h2>
<{if $iserror}>
	<div style="color: #CC0000;font-size:100%;font-weight:bold;margin:5px;padding:5px;border-width:1px;border-style:solid;border-color:#808080;">
		<{$error_message}>
	</div>
<{/if}>
<form name="categorymanager" id="categorymanager" action="<{$mod_url}>/admin/index.php?page=<{$page}>" method="post">
<{$gticket_hidden}>
<div style="text-align:right;color:inherit;border: 1px inset #CCC;padding: 3px;with: 80%;font-size: small;">
	[<a href="<{$mod_url}>/admin/index.php?page=categoryedit&amp;cid=0"><{$smarty.const._MD_D3DOWNLOADS_NEWCATEGORYEDITTITLE}></a>]&nbsp;
	<{$smarty.const._MD_D3DOWNLOADS_LABEL_PERPAGE}>&nbsp;
	<select name="perpage" onchange="submit();">
		<{html_options options=$perpage selected=$select_perpage}>
	</select>
</div>
<table class="outer">
	<tr>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_TH_ID}>
		</th>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_TH_TITLE}>
		</th>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_TH_WEIGHT}>
		</th>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_FILES_SUM}>
		</th>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_SUBCATEGORY_SUM}>
		</th>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_MAINCATEGORY}>
		</th>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_CATEGORYIMG}>
		</th>
		<th style="text-align:center;">
			<{$smarty.const._MD_D3DOWNLOADS_TH_CONTENTSACTIONS}>
			<input type="checkbox" onclick="col_check_on_off( this, 'col_action_' )">
		</th>
	</tr>
	<{foreach from=$category item="mycategory"}>
		<tr class="<{cycle values="even,odd"}>">
			<td style="text-align:center;">
				<{$mycategory.cid}>
			</td>
			<td nowrap="nowrap">
				<input type="text" size="35" maxlength="255" name="title[<{$mycategory.cid}>]" id="col_title_<{$mycategory.cid}>" value="<{$mycategory.title}>" />
				<div id="title_info_<{$mycategory.cid}>" style="display:none;color: #CC0000;font-size:100%;font-weight:bold;margin:2px;padding:2px;"></div>
			</td>
			<td align="center">
				<input type="text" size="3" name="weights[<{$mycategory.cid}>]" id="col_weight_<{$mycategory.cid}>" value="<{$mycategory.cat_weight}>" style="text-align:right;" />
			</td>
			<td align="center">
				<{$mycategory.files}>
			</td>
			<td align="center">
				<{$mycategory.subcategory}>
			</td>
			<td align="center">
				<{if $mycategory.parentid}>
					<a href="<{$mod_url}>/admin/index.php?page=categoryedit&amp;cid=<{$mycategory.parentid}>"><{$mycategory.parent_cat}></a>
				<{else}>
					<div alighn="center">-----------------</div>
				<{/if}>
			</td>
			<td align="center">
				<{if $mycategory.imgurl != ""}>
					<img src="<{$mycategory.imgurl}>" width="70" style="margin: 5 2px 3px;padding: 5px;border: 2px solid #CCC;background:#FFF;color:inherit;" align="middle" />
				<{else}>
					<img src="<{$mod_url}>/images/folder.gif" width="18" height="14" border="0" align="middle" />
				<{/if}>
			</td>
			<td nowrap="nowrap" style="text-align:center;">
				<a href="<{$mod_url}>/index.php?cid=<{$mycategory.cid}>"><{$smarty.const._MD_D3DOWNLOADS_VISIBLE}></a> |
				<a href="<{$mod_url}>/admin/index.php?page=categoryedit&amp;cid=<{$mycategory.cid}>"><{$smarty.const._EDIT}></a> |
				<input type="checkbox" name="action_selects[<{$mycategory.cid}>]" id="col_action_<{$mycategory.cid}>" value="1" /><br />
				<span style="font-size: small;"><a href="<{$mod_url}>/admin/index.php?page=categoryedit&amp;cid=0&amp;pid=<{$mycategory.cid}>"><{$smarty.const._MD_D3DOWNLOADS_MAKESUBCATEGORY}></a></span>
			</td>
		</tr>
	<{/foreach}>
	<tr>
		<td colspan="9" align="center" class="head">
			<input type="submit" name="category_update" id="category_update" value="<{$smarty.const._SUBMIT}>" tabindex="0" />
		</td>
	</tr>
	<tr>
		<th colspan="9" style="text-align:right;">
			<{$smarty.const._MD_D3DOWNLOADS_LABEL_CATEGORYCHECKED}>
			<input type="submit" name="delete" id="delete" value="<{$smarty.const._MD_D3DOWNLOADS_BTN_DELETE}>" /> | 
			<input type="submit" name="category_top_move" id="category_top_move" value="<{$smarty.const._MD_D3DOWNLOADS_CATEGORY_TOP_MOVE}>" /> | 
			<input type="submit" name="category_move" id="category_move" value="<{$smarty.const._MD_D3DOWNLOADS_CATEGORY_MOVE}>" /> 
			<{$smarty.const._MD_D3DOWNLOADS_SEL_CATEGORY}>
			<select name="move_select" id="move_select">
			<{html_options options=$moveselect}>
			</select><br />
		</th>
	</tr>
	<tr>
		<td colspan="9" align="right">
			<div style="color:inherit;border: 1px inset #CCC;padding: 3px;font-size: small;">
				<{$smarty.const._MD_D3DOWNLOADS_CATEGORY_CHECK}>
				<input type="submit" name="category_check" value="<{$smarty.const._SUBMIT}>" />
			</div>
		</td>
	</tr>
</table>
</form>

<div align="right"><{$pagenav}></div>

<{if $sitemap}>
	<h2><{$smarty.const._MD_D3DOWNLOADS_CATEGORY_TREE}></h2>
	<div style="color:inherit;border: 1px inset #CCC;padding: 6px;font-size: small;">
		<table border="0" width="100%" cellspacing="10" cellpadding="10" align="center">
			<tr>
			    <{foreach from=$sitemap.parent item="parent" key="count"}>
		    	    <td valign="top" width="33%">
						<div style="border:dotted 1px #c0c0c0;padding:2px">
							<div style="border:dotted 1px #808080;padding:10px">
								<div>
									<img src="<{$mod_url}>/images/folder.gif" width="18" height="14" border="0" />
									&nbsp;<a href="<{$mod_url}>/<{$parent.url}>"><{$parent.title}></a>
									&nbsp;<span style="font-size:smaller;">( <{$parent.files}> )</span>
								</div>
								<{foreach from=$parent.child item="child"}>
									<div>
										&nbsp;<a href="<{$mod_url}>/<{$child.url}>"><{$child.title}></a>
										&nbsp;<span style="font-size:smaller;">( <{$child.files}> )</span>
									</div>
								<{/foreach}>
								<div style="font-size:smaller;">
									( <{$smarty.const._MD_D3DOWNLOADS_BCAT_TOTAL}><{$parent.total_files}> )
								</div>
							</div>
						</div>
					</td>
			<{if ($count+1) is div by 3}>
					</tr>
				<tr>
			<{/if}>
			  <{/foreach}>
			</tr>
		</table>
	</div>
<{/if}>
<br />

<div style="color:inherit;border: 1px inset #CCC;padding: 6px;with: 80%;font-size: small;">
	<{$smarty.const._MD_D3DOWNLOADS_HELP_CATEGORY_DEL}>
</div>

<script type="text/javascript">
<!--//
jQuery( function($){
	$( '#category_update' ).click( function(){
		validate_error = 0 ;
		$.each( $id_filter( 'col_title_' , '^=' ), function(){
			var targetId = this.id ;
			var info = 'title_info_' + targetId.slice( 10 ) ;
			var message = '<{$smarty.const._MD_D3DOWNLOADS_SUBJECT|string_format:$smarty.const._FORM_ENTER}>' ;
			validate_error += form_validate_contentform( targetId, info, message ) ;
		});
		return ( validate_error == 0 ) ? true : false ;
    });

    $( '#delete' ).click( function(){
		infoDom_initialize() ;
		col_action_check( 'col_action_' ) ;
		if( validate_checked > 0 ){
			return confirm('<{$smarty.const._MD_D3DOWNLOADS_CONFIRM_CATEGORY_DEL}>') ;
		} else {
			popup_info( '<{$smarty.const._MD_D3DOWNLOADS_ERROR_SEL_CATEGORY}>' )
			return false ;
		}
    });

    $( '#category_top_move' ).click( function(){
		infoDom_initialize() ;
		col_action_check( 'col_action_' ) ;
		if( validate_checked > 0 ){
			return confirm('<{$smarty.const._MD_D3DOWNLOADS_CONFIRMCATEGORY_TOP_MOVE}>') ;
		} else {
			popup_info( '<{$smarty.const._MD_D3DOWNLOADS_ERROR_SEL_CATEGORY}>' )
			return false ;
		}
    });

    $( '#category_move' ).click( function(){
		infoDom_initialize() ;
		col_action_check( 'col_action_' ) ;
		select_check( 'move_select' ) ;
		if( validate_checked > 0 && validate_selected > 0 ){
			return confirm('<{$smarty.const._MD_D3DOWNLOADS_CONFIRMCATEGORY_MOVE}>') ;
		} else {
			popup_info( '<{$smarty.const._MD_D3DOWNLOADS_ERROR_SEL_CATEGORY}>' )
			return false ;
		}
    });
});
//-->
</script>