<form action="shop_pay.manage.php" id="form_add" name="form_add" method="post">
<input type="hidden" name="action" value="mode_save" />
<table width="680" border="0" cellpadding="0" cellspacing="0" class="from_table">
	<tr>
	  <th width="150"><tpl> $langSysShopPayModeName </tpl>:</th>
		<td width="480" class="td rowform"><input name="mode_name" class="txtinput" type="text" id="mode_name" maxlength="100" /></td>
		<td width="480" class="vtop tips2"><label style="display:none" for="mode_name" class="wrong" metaDone="true" generated="true"></label></td>
	</tr>
	<tr>
	  <th width="150"><tpl> $langSysShopPayModeType </tpl>:</th>
		<td width="480" class="td rowform">
			<input type="radio" name="mode_type" id="mode_type_0" value="0" checked="checked" onclick="$('#tr_shop_show_time').css('display','');$('#tr_product_number').css('display','none');" /><tpl> $langSysShopPayModeTypeTime </tpl><br />
			<input type="radio" name="mode_type" id="mode_type_1" value="1" onclick="$('#tr_shop_show_time').css('display','none');$('#tr_product_number').css('display','');" /><tpl> $langSysShopPayModeTypeNumber </tpl><br />
			<input type="radio" name="mode_type" id="mode_type_2" value="2" onclick="$('#tr_shop_show_time').css('display','');$('#tr_product_number').css('display','');" /><tpl> $langSysShopPayModeTypeAll </tpl>
	  </td>
		<td width="480" class="vtop tips2"></td>
	</tr>
	<tr id="tr_shop_show_time">
	  <th width="150"><tpl> $langSysShopPayModeShopTime </tpl>:</th>
		<td width="480" class="td rowform">
			<input name="mode_shop_show_time" class="txtinput" type="text" id="mode_shop_show_time" maxlength="10" />
	  </td>
		<td width="480" class="vtop tips2"><tpl> $langSysShopPayModeUnit </tpl>：<tpl> $langSysShopPayModeUnitDay </tpl><label style="display:none" for="mode_shop_show_time" class="wrong" metaDone="true" generated="true"></label></td>
	</tr>
	<tr id="tr_product_number" style="display:none">
	  <th width="150"><tpl> $langSysShopPayModeProductNumber </tpl>:</th>
		<td width="480" class="td rowform">
			<input name="mode_product_number" class="txtinput" type="text" id="mode_product_number" maxlength="10" />
	  </td>
		<td width="480" class="vtop tips2"><tpl> $langSysShopPayModeUnit </tpl>：<tpl> $langSysShopPayModeUnitGe </tpl><label style="display:none" for="mode_product_number" class="wrong" metaDone="true" generated="true"></label></td>
	</tr>
	
	<tr>
	  <th width="150"><tpl> $langSysShopPayModeMoney </tpl>:</th>
		<td width="480" class="td rowform">
			<input name="mode_money" class="txtinput" type="text" id="mode_money" maxlength="10" />
	  </td>
		<td width="480" class="vtop tips2"><tpl> $langSysShopPayModeUnit </tpl>：<tpl> $langSysShopPayModeUnitYuan </tpl><label style="display:none" for="mode_money" class="wrong" metaDone="true" generated="true"></label></td>
	</tr>
	<tr>
	  <th width="150"><tpl> $langSysShopPayModeRemark </tpl>:</th>
		<td width="480" class="td rowform">
			<textarea name="mode_remark" cols="50" rows="6" class="tarea" id="mode_remark"></textarea> 
	  </td>
		<td width="480" class="vtop tips2"></td>
	</tr>
	<tr>
		<td width="150"></td>
	    <td colspan="2"><div style="float:left; padding-left:20px">
			<span class="btn_left"><input type="submit" class="btn_submit" name="Submit" value="<tpl> $langSysShopPayModeSubmit </tpl>" /></span>
			</div>	</td>
    </tr>
</table>
</form>

<script>
$(document).ready(function() {
	var options = {
		beforeSubmit:  function(){showLoading(showSaveText);},
		success:       function(msg){
							hideLoading();
							showMessage(msg.message,msg.type);
							if(msg.type == '1'){
								ST(2,2);
								ShowDiv = "result_content";
								getPageContent("shop_pay.manage.php?action=mode_list");
							}
						},
		type:      'post',
		dataType:  'json'
	};
	
	//对表单做的验证定义
	$("#form_add").validate({
		errorClass: "wrong",
		rules: {
			mode_name: {required:true},
			mode_shop_show_time: {
				required:function(){
					if($('#mode_type_0').attr('checked') == true || $('#mode_type_2').attr('checked') == true){
						return true
					}else{
						return false;
					}
				},
				number:function(){
					if($('#mode_type_0').attr('checked') == true || $('#mode_type_2').attr('checked') == true){
						return true
					}else{
						return false;
					}
				},
				min:function(){
					if($('#mode_type_0').attr('checked') == true || $('#mode_type_2').attr('checked') == true){
						return 1;
					}else{
						return false;
					}
				}
			},
			mode_product_number: {required:function(){
					if($('#mode_type_1').attr('checked') == true || $('#mode_type_2').attr('checked') == true){
						return true
					}else{
						return false;
					}
				},
				number:function(){
					if($('#mode_type_1').attr('checked') == true || $('#mode_type_2').attr('checked') == true){
						return true
					}else{
						return false;
					}
				},
				min:function(){
					if($('#mode_type_1').attr('checked') == true || $('#mode_type_2').attr('checked') == true){
						return 1;
					}else{
						return false;
					}
				}
			},
			mode_money: {required:true,number:true}
		},
		messages: {
			mode_name: {required:"<tpl> $errSysShopPayModeNameIsEmpty </tpl>"},
			mode_shop_show_time: {required:"<tpl> $errSysShopPayModeShopTimeIsNotNumber </tpl>",number:"<tpl> $errSysShopPayModeShopTimeIsNotNumber </tpl>",min:"<tpl> $errSysShopPayModeShopTimeMinIs1 </tpl>"},
			mode_product_number: {required:"<tpl> $errSysShopPayModeProductNumberIsNotNumber </tpl>",number:"<tpl> $errSysShopPayModeProductNumberIsNotNumber </tpl>",min:"<tpl> $errSysShopPayModeProductNumberMinIs1 </tpl>"},
			mode_money: {required:"<tpl> $errSysShopPayModeProductNumberIsNotNumber </tpl>",number:"<tpl> $errSysShopPayModeProductNumberIsNotNumber </tpl>"}
		},
		submitHandler: function() {
			$('#form_add').ajaxSubmit(options);
		}
	});
});
</script>