<form action="" id="form_module_shopclass" name="form_module_shopclass" method="post"  class="zhezhao_style"  style="background-color:#FBFDFC" onsubmit="return shopclass_submit_module();">

    <table border="0" cellpadding="0" cellspacing="0" class="from_table2" style="width:500px">
      <input type="hidden" name="action" id="action" value="shopclass_set_check_finish" />
		<tr>
		  <th width="100" class="td1"><tpl> $langChannelModuleId </tpl>:</th>
			<td class="td1" colspan="2" align="left">shopclass_module_<input type="text" name="shopclass_temp_name" id="shopclass_temp_name" class="txtinput" value="<tpl> $modi_array.temp_name </tpl>" />
			<p style="color:#FF0000">
			<tpl> $langChannelNoteModuleIdIs100EnglistOrNum </tpl>
			</p>			</td>
		</tr>
		<tr>
		  <th width="100" class="td1"><tpl> $langChannelTypeNameWordNum </tpl>:</th>
			<td class="td1" align="left"><input type="text" name="name_num" id="name_num" class="txtinput" value="<tpl> $modi_array.name_num </tpl>" />
			<p style="color:#FF0000">
			<tpl> $langChannelHomeDisSiz </tpl>
			</p>			</td>
		</tr>
		<tr>
		  <th width="100" class="td1"><tpl> $langChannelHomeDisType </tpl>:</th>
			<td class="td1" align="left">
			<input name="show_type" type="radio" <tpl> if $modi_array.show_type eq '0' || $modi_array.show_type eq '' </tpl>checked="checked"<tpl> /if </tpl> value="0" /><tpl> $langChannelLayer </tpl>
			<input name="show_type" type="radio" <tpl> if $modi_array.show_type eq '1' </tpl>checked="checked"<tpl> /if </tpl> value="1" /><tpl> $langChannelSingleness </tpl> 
			<input name="show_type" type="radio" <tpl> if $modi_array.show_type eq '2' </tpl>checked="checked"<tpl> /if </tpl> value="2" /><tpl> $langChannelMenu </tpl>
			&nbsp;&nbsp;
			<p  style="color:#FF0000">
			<tpl> $langChannelLayerDisTypeSinglenessNotClass </tpl>
			</p>			</td>
		</tr>
		<tr>
			<td height="30" align="center" valign="middle" class="td1">
									  </td>
		    <td height="30" align="center" valign="middle" class="td1"><span class="btn_left">
<input type="submit" value="<tpl> $langCEnsure </tpl>" class="btn_submit"  />
		  </span></td>
		</tr>
	<tr>
			<td colspan="2" align="left" style=" height:40px; line-height:40px;  font-size:14px; color:#007dc6 padding-top:10px">使用以下搜索功能，选取您所需要的本模块内容：</td>
		</tr>
		<tr>
			<td colspan="2" align="left" class="td1" style="color:#FF0000">
		  <tpl> $langChannelNeedDis2Class </tpl>			</td>
		</tr>
		<!-- 商品类别列表 -->
		<tpl> section name=listclass loop=$shop_class_array </tpl>
		<tr>
			<td align="left" colspan="2">
			<input <tpl> if $shop_class_array[listclass].is_check eq '1' </tpl>checked="checked"<tpl> /if </tpl> type="checkbox" name="check_id_<tpl> $shop_class_array[listclass].class_id </tpl>" id="check_id_<tpl> $shop_class_array[listclass].class_id </tpl>" onclick="shop_class_set_check(this.value);" value="<tpl> $shop_class_array[listclass].class_id </tpl>" />
			<a id="a_<tpl> $shop_class_array[listclass].class_id </tpl>" href="javascript:;" <tpl> if $shop_class_array[listclass].is_parent eq '1' </tpl> onclick="ajax_get_child_class('<tpl> $shop_class_array[listclass].class_id </tpl>');"<tpl> /if </tpl>>+</a>
			<tpl> $shop_class_array[listclass].class_name </tpl>　
			<tpl> $langCSort </tpl>：<input onblur="shop_class_set_check(<tpl> $shop_class_array[listclass].class_id </tpl>);" name="sort_<tpl> $shop_class_array[listclass].class_id </tpl>" id="sort_<tpl> $shop_class_array[listclass].class_id </tpl>" type="text" value="<tpl> $shop_class_array[listclass].sort_value|default:'0' </tpl>" size="5" maxlength="5" />			</td>
		</tr>
		<tr>
			<td align="left" colspan="2"><div style="display:none" id="div_<tpl> $shop_class_array[listclass].class_id </tpl>"></div></td>
		</tr>
		<tpl> /section </tpl><!-- 商品类别列表end -->
  </table>
</form>
<script>
$(document).ready(function() {	
});

//添加模块，以模块标识符号
function shopclass_submit_module(){

	var temp_name = "";//模块标识符
	var patrn=/^[a-zA-Z0-9]{1,100}$/; //正则匹配.
	var patrn_num=/^[0-9]{1,1000}$/; //正则数字匹配.
	var sort_value = "";//排序的序号拼成的字符串，值之间的顺序为选中的商铺类别的顺序
	var name_num = "";//商铺类别名称字数
	
	//验证模块标识符是否存在，不存在则返回错误
	temp_name = $("#shopclass_temp_name").val();
	if (!patrn.exec(temp_name)){
		alert("<tpl> $langChannelModuleIdIs100EnglistOrNum </tpl>");
		return false;
	}
	//验证类别名称长度
	name_num = $("#name_num").val();
	if (!patrn_num.exec(name_num)){
		alert("<tpl> $langChannelTypeNameLengthIsNum </tpl>");
		return false;
	}
	
	temp_name = "shopclass_module_"+temp_name//给模块标识符添加前缀
	
	if(checkRepeatModuleName(temp_name) == false){return false;}//验证是否与已有名称或者表单名重复 
	
	/* 取表单参数 */var queryString=$("#form_module_shopclass").formSerialize();
	$.ajax({
		url: "channel.manage.php",
		data: queryString,
		type:'post',
		dataType:"html",
		success: function(msg){
			//添加模块标签
			$("#add_module_sign").append("<tr><td><span class='btn_left'><input type='button' class='btn_submit' style='width:250px' value='"+temp_name+"' onclick='modi_module(\""+temp_name+"\");deleteRow(this);set_module_style(\"disabled\");'/></span><input type='hidden' name='"+temp_name+"' id='"+temp_name+"' value='"+msg+"'/><a href=\"javascript:;\" onclick=\"javascript: copyToClipboard('"+temp_name+"')\" title='<tpl> $langChannelCopyModuleName </tpl>' class='copy_a_pic'></a><a href='javascript:;' onclick='if($(\"#add_module\")[0].disabled != true){deleteProhibitionElements(\""+temp_name+"\");deleteRow(this);}else{alert(\"<tpl> $langModuleDelWrong </tpl>\");}' title='<tpl> $langChannelDelThisModule </tpl>' class='del_a_pic'></a></td></tr>");
			
			$("#body_module").html("");//替换为模块标识符，隐藏域为拼的字符串
			
			$("#add_module").attr("disabled","");//开放增加按钮
			
			set_module_style('no_disabled');//将模块区域中的按钮还原成no_disabled
			
			$.unblockUI();//去除遮罩
	
			$("#module_block").html('');//去除遮罩中的内容
			
		}
	});
	return false;
}

//向服务器端提交类别ID，用来记录选中的类别
function shop_class_set_check(id){
	str = $("#sort_"+id).val();
	if($("#check_id_"+id).attr('checked')){/* 如果是没选中的话，则清空session中的该值 */$.ajax({
			url: "channel.manage.php",
			data: "action=shopclass_set_check&class_id="+id+"&sort="+str,
			type:'post',
			dataType:"html"
		});
	}else{/*  */$.ajax({
			url: "channel.manage.php",
			data: "action=shopclass_set_clean_check&class_id="+id,
			type:'post',
			dataType:"html"
		});
	}
	
	return false;
}

//取类别下的子类别
function ajax_get_child_class(id){

	var str = $("#div_"+id).html();
	
	if($("#div_"+id).css('display') != 'block'){
		if(str == ''){
			$("#div_"+id).css('display','');
			
			$.ajax({
				url: "channel.manage.php",
				data: "action=shopclass_child_list&id="+id+"&channel_read_param="+$('#channel_read_param').val()+"&module_name=<tpl> $modi_array.temp_name </tpl>&txtid="+$('#txtid').val(),
				type:'post',
				dataType:"html",
				success: function(msg){
					$("#div_"+id).html(msg);
				}
			});
			$("#a_"+id).text('-');
		}else{
			$("#a_"+id).text('-');
			$("#div_"+id).css('display','');
		}	
	}else{
		$("#a_"+id).text('+');
		$("#div_"+id).css('display','none');
	}
	return false;
}
</script>