<form action="vote.manage.php" id="form_modi" name="form_modi" method="post" style="padding-bottom:20px">
	<input type="hidden" name="action" value="update" />
    <table class="from_table">
		<tr>
		  <th width="200" ><tpl> $langVoteLTitle </tpl>：</th>
			<td class="td1"><input name="txttitle" type="text" id="txttitle" class="txtinput" size="50" value="<tpl> $vote_array.vote_title </tpl>" />
			<label style="display:none" for="txttitle" class="wrong" metaDone="true" generated="true"></label>		  </td>
		</tr>
		<tr>
		  <th width="200" > <tpl> $langVoteOption </tpl>：<br /><br /><span class="btn_left" style="float:right"><input type="button" value="<tpl> $langVoteNewAddRow </tpl>" id="add_button" class="btn_submit"/></span></th>
		  <td width="580">
				<table width="100%" border="0" cellpadding="0" cellspacing="0" rules="none" class="tables_table">
				  	<tr>
					  <td><tpl> $langVoteDisGradation </tpl></td>
					  <td><tpl> $langVoteNum </tpl></td>
					  <td></td>
					  <td>&nbsp;</td>
					</tr>
				  <tbody id="aaaa">
				  	<tpl> foreach from=$vote_array.content key=key item=one </tpl>
				  		<tr>
							<td><input type="text" class="txtinput_short" size="10" name="vote_order[]" value="<tpl> $key </tpl>" /></td>
							<td><input type="text" class="txtinput_short" size="10" name="vote_content_num[]" value="<tpl> $one.num </tpl>" /></td>
							<td><input type="text" class="txtinput_short" size="30" name="vote_content[]" value="<tpl> $one.option </tpl>" /></td>
							<td><span class="btn_left"><input type='button' class="btn_submit" value='<tpl> $langVoteLDel </tpl>' onclick='deleteRow(this)' /></span></td>
						</tr>
					<tpl> /foreach </tpl>
				  </tbody>
		  </table>		  </td>
		</tr>
		<tr>
		  <th width="200"> <tpl> $langVoteLIfRepeat </tpl>：</th>
			<td width="580" class="td1">
				<input type="radio" name="txtrefresh" value="0" 
				
				
				<tpl> if $vote_array.vote_refresh eq '0' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langCNo </tpl>
		  <input type="radio" name="txtrefresh" value="1" <tpl> if $vote_array.vote_refresh eq '1' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langCYes </tpl>		  </td>
		</tr>
		<tr>
		  <th width="200"> <tpl> $langVoteLIfMemberCan </tpl>：</th>
			<td width="580" class="td1"><input type="radio" name="txtmember" value="0" 
			  
			  
			  <tpl> if $vote_array.vote_member eq '0' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langCNo </tpl>
		  <input type="radio" name="txtmember" value="1" <tpl> if $vote_array.vote_member eq '1' </tpl>checked="checked"<tpl> /if </tpl>/><tpl> $langCYes </tpl>		  </td>
		</tr>
		<tr>
		  <th width="200"> <tpl> $langVoteLIfManySelect </tpl>：</th>
			<td width="580" class="td1"><input type="radio" name="txtcheck" value="0" 
			  
			  
			  <tpl> if $vote_array.vote_check eq '0' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langCNo </tpl>
		  <input type="radio" name="txtcheck" value="1" <tpl> if $vote_array.vote_check eq '1' </tpl>checked="checked"<tpl> /if </tpl> /><tpl> $langCYes </tpl>		  </td>
		</tr>
		<tr>
		  <th width="200"><tpl> $langVoteLHomeDisTime </tpl>：</th><td width="580" class="td1"><input type="text" name="s_date" id="s_date" style="border:solid 1px #B0DF82;cursor:pointer; width:100px; background:url(../js/calendar/blue/cal_btn.gif) no-repeat right; height:18px; padding-right:19px;" readonly="readonly" value="<tpl> $vote_array.vote_start_date </tpl>" /> <tpl> $langVoteLTo </tpl>
  	    		<input type="text" name="e_date" id="e_date" style="border:solid 1px #B0DF82;cursor:pointer; width:100px; background:url(../js/calendar/blue/cal_btn.gif) no-repeat right; height:18px; padding-right:19px; " readonly="readonly" value="<tpl> $vote_array.vote_end_date </tpl>" />		  </td>
		</tr>
		<tr>
		  <th width="200" > <tpl> $langVoteLHomeDisPlace </tpl>：</th>
			<td width="580" class="td1">
				<tpl> foreach from=$show_name key=key item=one </tpl>
					<input name="show_name[]" type="checkbox" 
						<tpl> foreach from=$show_array key=key2 item=two </tpl>
							<tpl> if $two.show_name eq $key </tpl>
								checked="checked"
							<tpl> /if </tpl>
						<tpl> /foreach </tpl>
					value="<tpl> $key </tpl>" /><tpl> $one </tpl>
		  <tpl> /foreach </tpl>		  </td>
		</tr>
		<tr>
    		<td width="200">		  	  </td>
    	    <td width="580">
			  <span class="btn_left">
			  <input type="submit" name="Submit" class="btn_submit" value="<tpl> $langVoteLSub </tpl>" /></span>
			  <span class="btn_left"><input type="button" value="<tpl> $langVoteLRevert </tpl>" class="btn_submit" onclick="hideMessage();ShowDiv='result_content';getPageContent('vote.manage.php?action=modi&id='+<tpl> $vote_array.vote_id </tpl>);"/></span>
			  <span class="btn_left"><input type="button" value="<tpl> $langVoteLReturn </tpl>" class="btn_submit" onclick="hideMessage();ShowDiv='result_content';getPageContent('vote.manage.php?action=ajax_list');"/></span>
			  <input type="hidden" name="vote_num" id="vote_num"/>
			  <!-- <input type="button" value="显示列数" id="complete_button"/> -->
			  <input type="hidden" name="vote_id" value="<tpl> $vote_array.vote_id </tpl>" />
		</td>
		</tr>
  </table>
</form>
<script>
$(document).ready(function() {
	hideLoading();
	
	//增加一列
	$('#add_button').click(function(e){
		var num = $('#aaaa').children('tr').length;
		$('#aaaa').append("<tr>" + 

			"<td><input type='text' class='txtinput_short' size='10' name='vote_order["+num+"]' /></td>" + 
			"<td><input type='text' class='txtinput_short' size='10' name='vote_content_num["+num+"]' value='0' /></td>" + 
			"<td><input type='text' class='txtinput_short' size='30' name='vote_content["+num+"]' /></td>" +
			"<td><span class='btn_left'><input type='button' class='btn_submit' value='<tpl> $langVoteLDel </tpl>' onclick='deleteRow(this)' /><span></td></tr>");

		
		//记录信息条数
		numRow();
	});
	
	$('#complete_button').click(function(e) {
	  alert("<tpl> $langVoteLAggregatelyHave </tpl> "+ 
		$('#aaaa').children('tr').length +
		" <tpl> $langVoteLRowData </tpl>");
	});
	
	//添加
	var options = {
		beforeSubmit:  function(){showLoading(showSaveText);},
		success:       function(msg){
							hideLoading();
							showMessage(msg.message,msg.type);
							if(msg.type == '1'){
								ShowDiv	= 'result_content';
								getPageContent("vote.manage.php?action=ajax_list");
							}
						},
		type:      'post',
		dataType:  'json'
	};
	
	//对添加表单做的验证定义
	$("#form_modi").validate({
		errorClass: "wrong",
		rules: {
		},
		messages: {
		},
		submitHandler: function() {
			$('#form_modi').ajaxSubmit(options);
		}
	});
});
//删除
function deleteRow(elem) {
  // 先抓到是哪一個 tr
  var row = $(elem).parent().parent().parent();
  // 移除它
  row.fadeOut('normal', function() {
    row.remove();
  });
}

//时间
$(function(){
   $("#s_date").datepicker();
   $("#e_date").datepicker();
})

//计算有多少列信息
function numRow(){
	var num = $('#aaaa').children('tr').length;
	$('#vote_num').val(num);
}

numRow();
</script>