<style>
.e{
	background-color: eeeeee; 
	border: thin solid black;
}

td {
 vertical-align:top;
}

.time {
	border-bottom:1px dashed black;
	padding-right:10px;
	text-align: right;
}
</style>

Events (this week):
<% 

#now, we want to go through events, putting them into place in the day
#structure

#starting this week:

#as a test, we'll show just This Week
today = Time.new
#figure out what day sunday is in the crazy system
today_handle = controller.make_handle (today)
sunday_handle = today_handle - today.wday
%>

<table cellpadding=0 cellspacing=0 width="100%" style="border-collapse: collapse; table-layout: fixed;">
	<tr><th>&nbsp;</th>
	<% for day in 0...7 %>

	<th width="13%"><%= ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"][day] %></th>

	<% end %>
	<% for halfhour in 0...48 %>

               <tr><td class="time"><b><%=
                       "#{((halfhour / 2) % 12 < 10 && (halfhour / 2) % 12 != 0) ? '0' : ''}" +
                       "#{(halfhour / 2) % 12 == 0 ? '12' : (halfhour / 2) % 12}" +
                       ":" +
                       "#{halfhour % 2 == 0 ? '00' : '30'}" +
                         " " +
                       "#{halfhour < 24 ? 'AM' : 'PM'}" %></td>

	<% for day in 0...7 %>
		<% tday = sunday_handle + day
		if @daylist[tday] 
			if @daylist[tday][halfhour] != 0  %>
				<%= controller.render_ev @daylist[tday][halfhour] %>
			<% end %>
		<% else %>
			<td class="e"></td>
		<% end %>
	<% end %>
	</tr>
	<% end %>
</table>


<p>Future events:</p>

<table width="100%">
  <tr>
    <th>Start</th>
    <th>End</th>
    <th>Name</th>
    <th>Location</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>

  </tr>
  
<% 
next_sunday = today - today.wday * 24 * 60 * 60 - today.hour * 60 * 60 - today.min * 60 - today.sec + 7*24*60*60
for event in @events 
if event.start > next_sunday %>
  <tr>
    <td><%= event ["start"].strftime "%a %b %d %I:%M %p" %></td>
    <td><%= event ["end"].strftime "%I:%M %p" %></td>
    <td><%=h event ["title"] %></td>
    <td><%=h event ["location"] %></td>

    <td><%= link_to 'Show', :action => 'show', :id => event.id %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => event.id %></td>
    <td><%= link_to 'Destroy', {:action => 'destroy', :id => event.id}, :confirm => 'Are you sure you want to delete this event?' %></td>
  </tr>
<% end
end %>
</table>

<br />

<%= link_to 'New event', :action => 'new' %>
