<!-- $Id: category_info.htm 7561 2007-03-23 11:50:21Z paulgao $ -->
{include file="pageheader.htm"}
<!-- start add new category form -->
<div class="main-div">
  <form action="category.php" method="post" name="theForm" enctype="multipart/form-data" onsubmit="return validate()">

  <table width="100%" id="general-table">
      <tr>
        <td class="label">{$lang.cat_name}:</td>
        <td>
          <input type='text' name='cat_name' maxlength="20" value='{$cat_info.cat_name|escape:html}' size='27' /> <font color="red">*</font>
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.parent_id}:</td>
        <td>
          <select name="parent_id" onchange="catChanged()">
          <option value="0">{$lang.cat_top}</option>
            {$cat_select}
          </select>
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.is_leaf}:</td>
        <td>
          <input type="radio" name="is_leaf" value="1" {if $cat_info.is_leaf eq 1}checked="true"{/if} onClick="showunit(1)" >{$lang.isleaf}
          <input type="radio" name="is_leaf" value="0" {if $cat_info.is_leaf neq 1}checked="true"{/if} onClick="showunit(2)" >{$lang.noleaf}
        </td>
      </tr>

      <tr id="measure_unit" style="display:none">
        <td class="label">{$lang.measure_unit}:</td>
        <td>
          <input type="text" name='measure_unit' value='{$cat_info.measure_unit}' size="12" />
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.sort_order}:</td>
        <td>
          <input type="text" name='sort_order' {if $cat_info.sort_order}value='{$cat_info.sort_order}'{else} value="0"{/if} size="15" />
        </td>
      </tr>

      <tr>
        <td class="label">{$lang.keywords}:</td>
        <td><input type="text" name="keywords" value='{$cat_info.keywords}' size="60">
        </td>
      </tr>

      <tr>
        <td class="label">{$lang.cat_desc}:</td>
        <td>
          <textarea name='cat_desc' rows="7" cols="60">{$cat_info.cat_desc}</textarea>
        </td>
      </tr>
      <tr>
        <td class="label">{$lang.show_in_nav}:</td>
        <td>
          <input type="radio" name="show_in_nav" value="1" {if $cat_info.show_in_nav neq 0} checked="true"{/if}/> {$lang.yes}
          <input type="radio" name="show_in_nav" value="0" {if $cat_info.show_in_nav eq 0} checked="true"{/if} /> {$lang.no}
        </td>
      </tr>
      <tr>
      </table>
      <div class="button-div">
        <input type="submit" value="{$lang.button_submit}" />
        <input type="reset" value="{$lang.button_reset}" />
      </div>
    <input type="hidden" name="act" value="{$form_act}" />
    <input type="hidden" name="cat_id" value="{$cat_info.cat_id}" />
  </form>
</div>
{insert_scripts files="../js/utils.js,validator.js"}
{literal}
<script language="JavaScript">
<!--
document.forms['theForm'].elements['cat_name'].focus();
catChanged();
/**
 * 检查表单输入的数据
 */
function validate()
{
      validator = new Validator("theForm");
    validator.required("cat_name",      catname_empty);
    return validator.passed();
}
onload = function()
{
    {/literal}
        unit = '{$cat_info.is_leaf}';
    {literal}

    showunit(unit)

    // 开始检查订单
    startCheckOrder();
}

/**
 * 选取上级分类时判断选定的分类是不是底层分类
 */
function catChanged()
{
  var obj = document.forms['theForm'].elements['parent_id'];

    if (obj.selectedIndex > 0 && obj.options[obj.selectedIndex].className == "leafCat")
    {
      alert(is_leafcat);
      obj.selectedIndex = 0;

      return false;
    }

  return true;
}
/* 数量单位必须为底级时才填写 */
function gObj(obj)
{
    var theObj;
    if (document.getElementById)
    {
        if (typeof obj=="string")
        {
            return document.getElementById(obj);
        }else{
            return obj.style;
        }
    }
    return null;
}
function showunit(get_value)
{
    if (get_value == 1){
        gObj("measure_unit").style.display = "";
    }else{
        gObj("measure_unit").style.display = "none";
    }
}
//-->
</script>
{/literal}
{include file="pagefooter.htm"}