<table align="center" border="0" rules="none" cellpadding="0" cellspacing="0">
<%
  tab_width = 160
  begin 
    if @mode == :browse
      all = @enquete_db.num_of_enquetes
      num = @enquete_db.normalize_num(@num)
      enq = @enquete_db[num]
%>
<tr class="enquete-div-question">
<td width="tab_width" colspan="3">
<p><small>Q <%= num %>: <%= enq.question %></small></p>
</td>
</tr>
<tr class="enquete-div-chart">
<%
      if enq.all == 0
        yes_ratio = no_ratio = 0
        yes_width = no_width = tab_width * 0.5
      else
        yes_ratio = enq.percent.to_i
        no_ratio = 100 - yes_ratio
        yes_width = (tab_width * yes_ratio * 0.01).to_i
	yes_width = 1 if yes_width <= 0
        no_width = tab_width - yes_width
      end
      yes_bg = (yes_ratio == 0) ? "#ffffff" : "#cc3333"
      no_bg = (no_ratio == 0) ? "#ffffff" : "#bbbbbb"
%>
<td width="<%=yes_width%>" bgcolor="<%=yes_bg%>">&nbsp;</td>
<td width="<%=no_width%>" bgcolor="<%=no_bg%>">&nbsp;</td>
</tr>
<tr class="enquete-div-vote">
<td width="tab_width" colspan="2">
<small>
<div align="center" class="enquete-div-vote-yes">
<%=a('vote_yes', {'num' => num}, context)%>[Yes]</a>
<%= enq.yes %>(<%= yes_ratio %> %)
</div>
<div align="center" class="enquete-div-vote-no">
<%=a('vote_no', {'num' => num}, context)%>[No]</a>
<%= enq.no %>(<%= no_ratio %> %)
</div>
</small>
</td>
</tr>
<tr class="enquete-div-nav">
<td width="tab_width" colspan="2">
<small>
<div align="center">
[<%=a('browse', {'num' => 1}, context) %><%= h('<<') %></a>]
[<%=a('browse', {'num' => @enquete_db.normalize_num(num-1)}, context) %><%= h('<') %></a>]
[<%=a('browse', {'num' => @enquete_db.normalize_num(num+1)}, context) %><%= h('>') %></a>]
[<%=a('browse', {'num' => nil}, context) %><%= h('>>') %></a>]
[<%=a('edit', {}, context) %>New</a>]
</div>
</small>
</td>
</tr>
<%
    else
      # @mode == :edit
%>
<%=form('add', context) %>
<tr class="enquete-div-edit-title">
<td width="tab_width" colspan="2">
<p>New Enquete:</p>
</td>
</tr>
<tr class="enquete-div-edit-field">
<td width="tab_width" colspan="2">
<input type="text" name="question" value="" />
</td>
</tr>
<tr class="enquete-div-edit-button">
<td width="tab_width" colspan="2">
<div align="right">
<input type="submit" value="add" />
</div>
</td>
</tr>
</form>
<tr class="enquete-div-edit-return">
<td width="tab_width" colspan="2">
<div align="center">
[<%=a('browse', {num => nil}, context) %>Browse</a>]
</div>
</td>
</tr>
<%
    end
  rescue EnqueteDB::NoEnqueteException
    @mode = :edit
    retry
  end
%>
</table>
