<?php defined('PHPNEW_STATIC_TPL') === false && exit(URL_HOST);?>
<style type="text/css">
    #contents{}
    #contents table{}
    #contents td{ width: 20%;}
    .addcat{display: none;}
    input,textarea{color: gray;}
    #dialog {width:490px;height:auto;border:3px solid silver;text-align:center;display:none;position:absolute;z-index:10;background-color: #EAEFE0;}
    .hideid{display: none;}
    .catid_news{background-color: #76AEED;}
</style>
<script type="text/javascript">
var jsondata = ($json_array);
var c_asc , c_name, c_tags, deles,c_tpl, i=0;
var catid = readom = 0;
$(function (){
    $('.d1').click(function (){
          if(readom == 0){
            catid = $(this).attr('title');
            if(catid == 'dele')
                return false;
            if($('input[name="catid"]').val() != catid){
                if(jsondata[catid]){
                    $('input[name="icat"]').val(jsondata[catid]['c_name']);
                    $('input[name="iasc"]').val(jsondata[catid]['c_asc']);
                    $('.c_tpl_all option[value="'+jsondata[catid]['c_tpl']+'"]').attr('selected','selected');
                    $('textarea[name="tags"]').val(jsondata[catid]['c_tags']);
                }else{
                    $('.c_tpl_all option[value="0"]').attr('selected','selected');
                }
                 $('#dialog').hide('fast'); 
                 dialog('dialog');
                 $('input[name="catid"]').val(catid);
            }else{
                $('#dialog').hide('fast'); 
                $('input[name="catid"]').val(0);
            }
          }
    })
})
function ajax_cats(ids){
    i ++;
    c_asc = encodeURIComponent($('.c_asc_'+ids).val());
    c_name = encodeURIComponent($('.c_name_'+ids).val());
    c_tags = encodeURIComponent($('.c_tags_'+ids).val());
    c_tpl  = encodeURIComponent($('.c_tpl_'+ids).val());
    deles = 0;
    if($('.dele_'+ids).attr("checked")){
        deles = 1;
    }
    $.get('./index.php?admincp=cats&type=ajax&c_name='+c_name+'&c_tags='+c_tags+'&c_asc='+c_asc+'&deles='+deles+'&c_id='+ids+'&c_tpl='+c_tpl+'&rand='+i,function(data){
        if(data != 1){
            alert('更新失败,请返回....');
            js_header('{ADM_GET_URL}');
        }
    });
}
function all_update(){
    $('.all_num').each(function(){
        ajax_cats($(this).val());
    })
    alert('栏目信息更新成功');
    js_header('{ADM_GET_URL}');
}
function dialog(container){
	showDiv($("#"+container));
	$("#shut").click(function(){//关闭弹窗
		$('#dialog').hide('fast'); 
        $('input[name="catid"]').val(0);
	});
}
function showDiv(obj){
    center(obj);
 $(obj).show('fast',function (){
    
     $(window).scroll(function(){
        center(obj);
     });
     $(window).resize(function(){
       center(obj);
     }); 
 });

}

function center(obj){
     var windowWidth = document.documentElement.clientWidth;   
     var windowHeight = document.documentElement.clientHeight;   
     var popupHeight = $(obj).height();   
     var popupWidth = $(obj).width();
     $(obj).css({   
      "position": "absolute",
      'top':((windowHeight-popupHeight)/2 + $(document).scrollTop()) +'px',
      'left':(windowWidth-popupWidth)/2 +'px'
     });   
}

function readoms(){
    if(readom === 0){
      readom = 1; 
    }else{
       readom = 0; 
    }
}

function catspost(obj){
    $.post($(obj).attr('action'), $(obj).serializeArray(), function (data){
        if(data.s == 'dele'){
            alert('删除栏目成功');
        }
        
        if(data.s == 'up'){
            alert('共更新'+data.count+'条记录');
        }
        
        if(data.s == 'news'){
            alert('创建新栏目成功');
        }
        if(data.s == 'none'){
            alert('异常操作!');
        }
        js_header('./index.php?admincp=cats.html');
    },'json');
    return false;
}
</script>
<div id="contents">
<table class="tab" style=" width: 100%; background-color: white;">
    <tr class="admin_list">
        <th colspan="5">栏目列表　<input type="checkbox" style="vertical-align: middle;" onclick="readoms();" /> 只读</th>
    </tr>
<!--{loop $cat_array $narr}-->
<tr class="listtr">
    <!--{loop $narr $val}-->
    <td>
        <div style="margin: 5px;background-color: #FF8040;  border: 1px solid #EBF9BF;">
            <div class="d1 catid_{$val[c_id]}" title="{$val[c_id]}" style="height: 48px;text-align: center; line-height: 48px; color: white;">{$val[c_name]}</div>
            <div style="text-align: center; color: #F9F9F9; height: 22px; line-height: 22px; background-color: #7D949F;">序: {$val[c_asc]}　篇: {$val[counts]}　附: {$val[attcount]}</div>
        </div>
    </td>
    <!--{/loop}-->
</tr>
<!--{/loop}-->

    <tr>
    <td colspan="5" style="line-height: 20px; padding-left: 6px; border-top: 1px solid silver;"><strong>说明</strong>: <br />
    　1:　栏目描述支持html,SEO作用<br />
    　2:　排序将影响导航的顺序, 倒序算法<br />
    　3:　描述中输入类似格式: link:http://www.fenanr.com 为纯粹跳转链接,仅在顶部导航中显示.
    </td>
    </tr>
</table>

<br /><br />
<div id="dialog">
    <form onsubmit="return catspost(this);" action="{GET_URL}">
    <ul style="list-style:none; line-height: 20px; text-align: left; margin: 0; padding: 0;">
    <li style=" overflow: hidden;">
    <input name="catid" type="hidden" value="0" />
    <input name="randge" type="hidden" value="0" />
    <span style="display: block; margin: 3px; font-weight: bolder; float: left; width: 60%;">栏目编辑: </span>
    <input style="float: right; margin: 3px; cursor: pointer;" type="button" value="关闭弹出窗" id="shut" />
    </li>
    <li class="order_mess" style="margin: 3px; height: auto; text-align: center; background-color: white;"><br />
    <div style="text-align: left; line-height: 2em; margin-left: 6px; margin-top: 6px;">
        栏目名称: <input type="text" style="width: 380px;" name="icat" />　<br />
        栏目风格: <select name="istyle" class="c_tpl_all">
            <option value="0">默认风格</option>
            <option value="gen">宫格风格</option>
            <option value="show">销售风格</option>
        </select>　排序: <input style="width: 30px;" type="text" name="iasc" value="0" /><br />
        栏目描述: <textarea style="width: 380px; height: 120px; border: 1px solid silver;" name="tags"></textarea><br />
        <span style="margin-left: 56px; color: #FF8040;"> * 规则格式: link:{URL_HOST} 为纯粹跳转链接</span><br />
        <input style="margin-left: 56px;" type="submit" value=" 编 辑 " /> <input style="margin-left: 30px;" type="checkbox" name="deles" value="1" /> <span style="color: red;">删除</span>
        <br /><br />
    </div>
    </li>
    </ul>
    </form>
</div>

</div>