<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/validator.js"></script>
<script type="text/javascript">
<tpl>$time_calendar</tpl>
</script>
<body>
<h1>
<span class="action-span"><a href="?ctl=vote&act=vote_manage"><tpl>$vote_list</tpl><!--投票列表--></a></span>
<span class="action-span1"><a href="?ctl=index&act=admin_main"><tpl>$common_admin_index</tpl><!--管理首页--></a> >> <tpl>if $vote_info['vote_id'] != ''</tpl><tpl>$vote_edit</tpl><!--编辑投票--><tpl>else</tpl><tpl>$vote_add</tpl><!--添加投票--><tpl>/if</tpl></span>
<div style="clear:both"></div>
</h1>
<div class="main-div">
<form action="index.php?ctl=vote&act=vote_save" method="post" name="theForm" enctype="multipart/form-data" onSubmit="return validate();">
<table width="100%" id="general-table">
  <tr>
    <td class="label"><tpl>$vote_add_title</tpl><!--投票标题-->：</td>
    <td>
      <input type='text' name='vote_title' value='<tpl>$vote_info['vote_title']</tpl>' size='40' />    </td>
  </tr>
  <tr>
    <td class="label"><tpl>$vote_add_start</tpl><!--开始时间-->：</td>
    <td>
      <input name="vote_start_time" type="text" id="vote_start_time" size="22" value="<tpl>$vote_info['vote_start_time']</tpl>" readonly="readonly" /><input name="selbtn1" type="button" id="selbtn1" onClick="return showCalendar('vote_start_time', '%Y-%m-%d', false, false, 'selbtn1');" value="<tpl>$vote_add_select</tpl>" class="button"/>    </td>
  </tr>
  <tr>
    <td class="label"><tpl>$vote_add_end</tpl><!--结束时间-->：</td>
    <td>
      <input name="vote_end_time" type="text" id="vote_end_time" size="22" value="<tpl>$vote_info['vote_end_time']</tpl>" readonly="readonly" /><input name="selbtn2" type="button" id="selbtn2" onClick="return showCalendar('vote_end_time', '%Y-%m-%d', false, false, 'selbtn2');" value="<tpl>$vote_add_select</tpl>" class="button"/>    </td>
  </tr>
  <tr>
    <td class="label"><tpl>$vote_add_type</tpl><!--投票类型-->：</td>
    <td><tpl>$vote_type</tpl></td>
  </tr>
  <tr>
    <td class="label"><tpl>$vote_add_body</tpl><!--投票内容-->：</td>
    <td><label>
      <input type="button" name="add_vote_button" onClick="add_vote();"  class="button" value="<tpl>$vote_add_option</tpl>">&nbsp;&nbsp;
	  <tpl>if $vote_option_count <=0</tpl>
      <input type="button" name="reset_vote_button" onClick="reset_vote();" class="button" value="<tpl>$vote_add_option_reset</tpl>">
	  <tpl>/if</tpl>
    </label></td>
  </tr>
  <tr>
    <td class="label">&nbsp;</td>
    <td>
	<div id="input_vote_id">
	<tpl>if $vote_option_count >0</tpl>
	<tpl>foreach $vote_info['vote_body'] as $val</tpl>
	<tpl>$vote_add_one_option</tpl><!--选项--><tpl>$val['vote_key']</tpl>：<input name="vote_body[]" type="text" value="<tpl>$val['vote_option']</tpl>" size="35">&nbsp;&nbsp;&nbsp;<tpl>$vote_add_num</tpl><!--票数-->：<input name="vote_num[]" type="text" value="<tpl>$val['vote_num']</tpl>" size="5"><br />
	<tpl>/foreach</tpl>
	<tpl>else</tpl>
	<tpl>$vote_add_one_option</tpl><!--选项-->1：<input name="vote_body[]" type="text" size="35">&nbsp;&nbsp;&nbsp;<tpl>$vote_add_num</tpl><!--票数-->：<input name="vote_num[]" type="text" size="5">
	<tpl>/if</tpl>
	  </div>
	  <br></td>
  </tr>
  <tr>
    <td class="label">&nbsp;</td>
    <td>
	  <input type="hidden" name="vote_id" value="<tpl>$vote_info['vote_id']</tpl>" />
      <input type="submit" value="<tpl>$vote_add_save</tpl>" class="button" />
      <input type="reset" value="<tpl>$vote_add_reset</tpl>" class="button" />    </td>
  </tr>
</table>
</form>
</div>
<div id="footer">
<tpl>$common_copyright</tpl>
</div>
<script type="text/javascript">
  /**
   * 检查输入的内容
   */
  function validate()
  {
    var validator = new Validator('theForm');
    validator.required('vote_title','<tpl>$vote_add_title_error</tpl>');
    return validator.passed();
  }
  
/*添加投票项js代码*/
<tpl>if $vote_option_count >0</tpl>
var i=<tpl>$vote_option_count</tpl>;
<tpl>else</tpl>
var i=1;
<tpl>/if</tpl>

function add_vote() {
	i++;
	if(i>30) {
		alert('<tpl>$vote_add_max_option</tpl>');
		return false;
	}
	document.getElementById('input_vote_id').innerHTML +=  '<br /><tpl>$vote_add_one_option</tpl>'+i+'：<input name="vote_body[]" type="text" size="35">&nbsp;&nbsp;&nbsp;<tpl>$vote_add_num</tpl>：<input name=vote_num[]" type="text" size="5">';
}

/*重置投票项js代码*/
function reset_vote() {
	i = 1;
	document.getElementById('input_vote_id').innerHTML =  '<tpl>$vote_add_one_option</tpl>1：<input name="vote_body[]" type="text" size="35">&nbsp;&nbsp;&nbsp;<tpl>$vote_add_num</tpl>：<input name=vote_num[]" type="text" size="5">';
}
</script>
</body>