<!-- 商铺选择部分 -->
<form action="" id="form_module_shop" name="form_module_shop"  class="zhezhao_style"  method="post" style="background-color:#FBFDFC" onsubmit="return shop_submit_module();">
    <table width="744" border="0" cellpadding="0" cellspacing="0"  class="from_table2" style="width:500px" >
		<tr>
		  <th width="25%" class="td1"><tpl> $langChannelModuleId </tpl>:</th>
			<td width="560" colspan="2" align="left" class="td1">shop_module_
			  <input type="text" name="shop_temp_name" id="shop_temp_name"  class="txtinput" value="<tpl> $modi_array.temp_name </tpl>" />
			<p style="color:#FF0000">
			<tpl> $langChannelNoteModuleIdIs100EnglistOrNum </tpl>
			</p>		  </td>
		</tr>
		<tr>
		  <th width="25%" class="td1"><tpl> $langChannelShopNameNum </tpl>:</th>
			<td class="td1" colspan="2" align="left"><input type="text" name="name_num"  class="txtinput"id="name_num" value="<tpl> $modi_array.name_num </tpl>" />
			<p style="color:#FF0000">
			<tpl> $langChannelHomeDisSiz </tpl>
			</p>			</td>
		</tr>
		<tr>
		  <th width="25%" class="td1"><tpl> $langChannelShopDisType </tpl>:</th>
			<td class="td1" align="left">
				<input type="radio" name="show_type" value="0" <tpl> if $modi_array.show_type eq '0' || $modi_array.show_type eq '' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langChannelWord </tpl>
				<input type="radio" name="show_type" value="1" <tpl> if $modi_array.show_type eq '1' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langChannelImage </tpl>
				<input type="radio" name="show_type" value="2" <tpl> if $modi_array.show_type eq '2' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langChannelNewAddShop </tpl>			</td>
		</tr>
		<tr>
			<td class="td1" colspan="2">
				<table width="100%" border="0" cellpadding="0" cellspacing="0" id="shop_list" class="noborder" style="border:1px dashed #0099CC;">
				<tr style=" background-color:#EFF8FC">
				  <td colspan="2" align="left" valign="middle">&nbsp;<tpl> $langChannelShopName </tpl></td>
				  <td width="21%" align="left" valign="middle"><tpl> $langCSort </tpl></td>
				  <td width="32%" align="left" valign="middle"><tpl> $langCOperation </tpl></td>
				</tr>
				<tpl> if $modi_array.shop_id[0].shop_id neq "" </tpl>
					<tpl> foreach from=$modi_array.shop_id item=one key=key </tpl>
					<tr>
					  
					  <td colspan="2"   align="left" ><tpl> $one.shop_name </tpl></td>
					  <td align="left" valign="middle"><input type="text" size="4" name="shop_sort[<tpl> $one.shop_id </tpl>]" id="shop_sort_<tpl> $one.shop_id </tpl>" value="<tpl> $modi_array.sort_value[$key] </tpl>" /><input type="hidden" name="shop_id[<tpl> $one.shop_id </tpl>]" id="shop_id_<tpl> $one.shop_id </tpl>" value="<tpl> $one.shop_id </tpl>" /></td>
						<td align="left" valign="middle"><a href="javascript:;" onclick="var row=$(this).parent().parent();row.fadeOut('normal', function(){row.remove();});" title="<tpl> $langCdele </tpl>" class="del_a_pic">
					  </a></td>
					</tr>
					<tpl> /foreach </tpl>
				<tpl> /if </tpl>
			  </table>			</td>
		</tr>
		<tr>
			<td colspan="2" class="td1"  style=" padding-left:210px; padding-top:10px"><span class="btn_left">
				<input type="submit" value="<tpl> $langChannelConfirm </tpl>" class="btn_submit" />
		  </span>		</td>
		    <td class="td1">&nbsp;</td>
		</tr>		<tr>
			<td colspan="2" align="left" style=" height:40px; line-height:40px; padding-top:10px;  font-size:14px; color:#007dc6">使用以下搜索功能，选取您所需要的本模块内容：</td>
		</tr>
		<tr>
			<td class="td1" colspan="3">
				<!-- 商铺列表搜索 -->
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="noborder">
				   <tr>
					<th width="25%" class="td1"><tpl> $langChannelType </tpl>： </th><td align="left">
					<select name="slcShopClass" id="slcShopClass">
						<option value=""><tpl> $langChannelAll </tpl></option>
						<tpl> foreach from=$category_array item=one key=key </tpl>
							<option value="<tpl> $key </tpl>"><tpl> $one </tpl></option>
						<tpl> /foreach </tpl>
					</select>
					<tpl> $shop_select_category </tpl>					</td>
				  </tr>
				   <tr>
					<th width="25%" class="td1">
					 <tpl> $langChannelStoreName </tpl>：</th><td align="left"> <input type="text" id="txtShopName" class="txtinput" name="txtShopName" />
						&nbsp;&nbsp;
						  <span class="btn_left">
						<input value="<tpl> $langChannelseach </tpl>" type="button" class="btn_submit" onclick="shop_submit_search();" /></span></td>
				   </tr>
			  </table>
			<!-- 商铺列表搜索end --></td>
		</tr>
		<tr>
			<td class="td1" colspan="2">
				<div id="shop_search_list" style="padding-left:130px;*padding-left:110px;_padding-left:110px"><!-- shop_search_list条件筛选出来的商铺列表 --></div>			</td>
		</tr>
  </table>
</form>
<!-- 商品选择部分end -->
<script>
$(document).ready(function() {
});

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

	var temp_name = "";//模块标识符
	var patrn=/^[a-zA-Z0-9]{1,100}$/; //正则匹配
	var patrn_num=/^[0-9]{1,1000}$/; //正则数字匹配
	var sort_value = "";//排序的序号拼成的字符串，值之间的顺序为选中的商铺的顺序
	var param_array = new Array();
	var name_num = "";
	var shop_str = "";//选中的商铺 字符串
	var sort_sign = true; //排序的序号是否正确的标识
	
	//验证模块标识符是否存在，不存在则返回错误
	temp_name = $("#shop_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> $langChannelShopNameLengthIsNum </tpl>");
		return false;
	}
	
	//商品列表，取选中的项
	$('#shop_list input[@type=hidden]').each(function(){
		if(this.value != ""){
			shop_str += "shop_id:"+this.value+"|||";//选中字符串
			sort_value += "sort_value:"+$("#shop_sort_"+this.value).val()+"|||";//排序字符串
			if (!patrn_num.exec($("#shop_sort_"+this.value).val())){
				sort_sign=false;
			}
		}
	});
	
	//验证右侧是否有值
	if(shop_str == ""){
		alert("<tpl> $langChannelAddShopInfoNotNull </tpl>");
		return false;
	}
	//验证排序的序号是否正确
	if(sort_sign == false){
		alert("<tpl> $langChannelCompositorNumIsNumber </tpl>");
		return false;
	}
	
	//取表单的参数信息，以后如果继续添加参数，则以"|||"分割，参数标识：参数值 的形式衔接
	param_array[0] = "temp_name:"+temp_name+"|||";//模块标识符
	param_array[1] = "name_num:"+name_num+"|||";//商铺名称字数
	param_array[2] = shop_str;//选中商铺标识
	param_array[3] = sort_value;//排序字段
	param_array[4] = "show_type:"+$("input[@name=show_type][@checked]").val();//展现形式
	
	//循环 param_array 拼成字符串存入隐藏域中
	var str = "";
	for(i=0;i<param_array.length;i++){
		str += param_array[i];
	}
	
	temp_name = "shop_module_"+temp_name//给模块标识符添加前缀
	
	if(checkRepeatModuleName(temp_name) == false){return false;}//验证是否与已有名称或者表单名重复 

	
	//添加模块标签
	$("#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='"+str+"'/><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>\");}' class='del_a_pic' title='<tpl> $langChannelDelThisModule </tpl>'></a></td></tr>");
	
	$("#body_module").html("");//替换为模块标识符，隐藏域为拼的字符串
	
  	$("#add_module").attr("disabled","");//开放增加按钮
	
	set_module_style('no_disabled');//将模块区域中的按钮还原成no_disabled
	
	$.unblockUI();//去除遮罩
	
	$("#module_block").html('');//去除遮罩中的内容
	
	return false;
}

/* 通过检索条件，在左边菜单中列出商品列表 */function shop_submit_search(){
	ShowDiv = 'shop_search_list';
	var search_shop_keyword = escape($("#txtShopName").val());
	$.ajax({
		url: "channel.manage.php",
		data: "action=shop_search&slcShopClass="+$("#slcShopClass").val()+"&txtShopName="+search_shop_keyword,
		type:'get',
		dataType:"html",
		beforeSubmit:  showLoading(showText),// 提交之前执行的方法
		success: function(msg){
			hideLoading();
			if(msg != ""){
				$("#shop_search_list").html(msg);
			}else{
				alert("<tpl> $langChannelThisTypeNotShop </tpl>");
			}
		}
	});
	return false;
}
</script>