<?exit?>
{htmltemplate header}

<div id="rightwrap">
<div id="rtitle">
	<p id="titlenav">{lang category}&nbsp;&raquo;&nbsp;{lang cate_manage}</p>
</div>
<div id="rmain" >

	<div class="ml5" >
			<a class="btnart" id="addcate" href="javascript:void(0);" ><cite >{lang cate_add}</cite></a>
			
	</div>
	<div class="mt10"></div>
 <form  method="POST" action="" >
 <input type="hidden" name="arthash" value="{ART_HASH}" />
	    <table  class="tblist tbmsutil" id="catelist" >
        <!--{if $categorys}-->
        <thead>
        <tr>
            <th class="first"  class="w25"><input id="checkall_1" type="checkbox" class="checkall" onclick="checkAll(this)" /></th>
            <th >{lang cate_name}</th>
            <th width="35">{lang sort_order}</th>
            <th width="35" style="display:none">{lang if_show}</th>
            <th width="80">{lang handler}</th>
        </tr>
        </thead>
        <!--{/if}-->
        
        <tbody>
        <!--{loopif $categorys $category}-->  
        <tr class="{$category.layer}">
            <td  class="w25" ><input type="checkbox" class="select" name="selects[]" value="{$category.cid}" /></td>
            <td style="padding-left:{$category.layer}em" valign="middle">{if $category.childcount}<a href="javascript:;" onclick="rowToggle(this)" class="treeiclo"></a>{else}<a href="javascript:;" class="treeiitem"></a>{/if}<span class="node_name editable" title="{lang editable}">{$category.name|escape}</span></td>
            <td align="center"><span class="editable" title="{lang editable}">{$category.displaysort}</span></td>
            <td align="center" style="display:none" ><!--{if $category.status}--><img src="{ATHEME_IMG}ienabled.gif"  title="{lang editable}"/><!--{else}--><img src="{ATHEME_IMG}idisabled.gif" title="{lang editable}"/><!--{/if}--></td>
            <td class="handler">
            <span><a href="index.php?wskm=category&amp;act=edit&amp;id={$category.cid}">{lang edit}</a>&nbsp;|&nbsp;<a href="javascript:if(confirm('{lang cate_delconfirm}'))window.location = 'index.php?wskm=category&amp;act=drop&amp;id={$category.cid}';">{lang drop}</a></span>
                </td>
        </tr>
        <!--{loopelse}-->
        <tr class="no_data">
            <td colspan="5">{lang no_data}</td>
        </tr>  
        <!--{/loopelse}--> 
        </tbody>
        <tfoot>
            <tr class="tr_pt10">  
            <!--{if $category} -->
                <td colspan="5" class="align_center">
                	<div class="fleft mt5">
                		<input id="checkall_2"  type="checkbox" class="checkall" onclick="checkAll(this)">&nbsp;{lang checkall}&nbsp;&nbsp;
					</div>	
                	<div class="btncright mt5">
						<input class="btncommon" type="submit" value="{lang drop}"  />            
					</div>
                </td>
            <!--{/if}-->
            </tr>
        </tfoot>
    </table>
    
</form>


<div id="addcate_menu" style="display:none" class="float_div" >
<script type="text/javascript" src="{ART_URL}includes/js/plugin/validate.js"></script>
<script type="text/javascript">
$(function(){
    $('#category_info').validate({
        errorPlacement: function(error, element){ 
        	$(element).next('.field_notice').hide();
            $(element).after(error);
        },
        success       : function(label){       
            label.addClass('right').text('OK!');
        },
        onfocusout : false,
        onkeyup    : false,
        rules : {
            name : {
                required : true,
                remote   : {                
                url :'index.php?wskm=category&act=check_category',
                type:'get',
                data:{
                    name : function(){
                        return $('#name').val();
                    },
                    parentid : function() {
                        return $('#parentid').val();
                    },
                    id : '$category.cid'
                  }
                }
            },
            displaysort : {
                number   : true
            }
        },
        messages : {
            name : {
                required : '{lang cate_name_empty}',
                remote   : '{lang name_exist}'
            },
            displaysort  : {
                number   : '{lang number_only}'
            }
        }
    });
});
</script>
    <form method="post" class="jqvalid" action="index.php?wskm=category&act=add&addcatepost=1" enctype="multipart/form-data" id="category_info">
    <input type="hidden" name="arthash" value="{ART_HASH}" />
        <table class="tablecommon float_border" >
            <tr>
                <td >
                    {lang cate_name}:</th>
                <td >
                    <input class="infoTableInput2" maxlength="15" size="15" maxlength="15" id="name" type="text" name="name" value="" /> <label class="field_notice"></label>               </td>
            </tr>
            <tr>
                <td >
                    <label for="parent_id">{lang parent_id}:</label></th>
                <td >
                    <select id="parentid"   name="parentid"><option value="0">{lang top_cate}</option>{$categorys_selectoption}</select> <label class="field_notice"></label>               </td>
            </tr>
            <tr>
                <td >
                    {lang sort_order}:</th>
                <td >
                    <input class="sort_order" size="2" maxlength="2" id="displaysort" type="text" name="displaysort" value="99" />  <label class="field_notice"></label>              </td>
            </tr>
            <tr style="display:none">
              <td >{lang if_show}:</th>
              <td ><p>
                <label>
                  <input type="radio" name="status" value="1" checked="checked" />
                  {lang yes}</label>
                <label>
                  <input type="radio" name="status" value="0"/>
                  {lang no}</label>
              </p></td>
            </tr>

          <tr>
            <th></th>
            <td >
            			<div class="btncright ">
			            <input class="btncommon" type="submit" value="{lang submit}" name="addcatepost"/>            
			            </div>
			            <div class="btncright ">
			            <input class="btncommon" type="button" " onclick="$('#addcate_menu').hide()" value="{lang cancel}" name="ss"/>
			            </div>
        	</tr>
        </table>
    </form>
</div>

<script type="text/javascript">
jQuery(function(){
	 table_hover('tbmsutil');	
	 displayMenu('addcate','click'); 
});

function rowToggle(obj)
{
	obj = obj.parentNode.parentNode;
	var caterows= document.getElementById("catelist");
	var parentlayer = parseInt(obj.className);
	var isbreak = false;
	var rowlength=caterows.rows.length;
	for (i = 0; i < rowlength; i++)
	{
		var row = caterows.rows[i];
		if (caterows.rows[i] == obj){
			isbreak = true;
		}
		else if (isbreak == true){
			var nextlayer = parseInt(row.className);
			if (nextlayer > parentlayer)
			{				
				if(obj.cells[1].childNodes[0].className == 'treeiclo'){
					row.style.display ='none';
				}else{
					row.style.display = (row.style.display != 'none') ? 'none' : ($.browser.msie ) ? 'block' : 'table-row';
				}
				if(row.cells[1].childNodes[0].className=='treeiexp')row.cells[1].childNodes[0].className ='treeiclo';
			}
			else
			{
				isbreak = false;
				break;
			}
		}
	}

	for (i = 0; i < obj.cells[1].childNodes.length; i++)
	{
		var imgObj = obj.cells[1].childNodes[i];
		if (imgObj.tagName == "A")
		{
			imgObj.className = imgObj.className =='treeiexp'?'treeiclo':'treeiexp';
		}
	}
}

</script>
</div>



{htmltemplate footer}