<div id="agenda_date_range" style="display:none;">
	<label>From</label> <select name="start_month" class='input-small'>
	<% for i in 1..12 %>
		<% if i == @start_month %>
			<option value="<%= i %>" selected="selected"><%= Date::MONTHNAMES[i] %></option>
		<% else %>
			<option value="<%= i %>"><%= Date::MONTHNAMES[i] %></option>
		<% end %>
	<% end %>
	</select>
	<select name="start_year" class='input-small'>
	<% for i in 1..10 %>
		<% if (@d_s_year + i) == @start_year %>
			<option value="<%= @d_s_year + i %>" selected="selected"><%= @d_s_year + i %></option>
		<% else %>
			<option value="<%= @d_s_year + i %>"><%= @d_s_year + i %></option>
		<% end %>
	<% end %>
	</select>
	<label>To</label> <select name="end_month" class='input-small'>
	<% for i in 1..12 %>
		<% if i == @end_month %>
			<option value="<%= i %>" selected="selected"><%= Date::MONTHNAMES[i] %></option>
		<% else %>
			<option value="<%= i %>"><%= Date::MONTHNAMES[i] %></option>
		<% end %>
	<% end %>
	</select>
	<select name="end_year" class='input-small'>
	<% for i in 1..10 %>
		<% if (@d_s_year + i) == @end_year %>
			<option value="<%= @d_s_year + i %>" selected="selected"><%= @d_s_year + i %></option>
		<% elsif (@d_s_year + i) <= @start_year %>
			<option value="<%= @d_s_year + i %>" disabled='disabled'><%= @d_s_year + i %></option>
		<% else %>
			<option value="<%= @d_s_year + i %>"><%= @d_s_year + i %></option>
		<% end %>
	<% end %>
	</select>
	<button class="btn  bt-filter">Show Events</button>
</div>
<div id="calendar_agenda">
	<% @datesets.each_with_index do |dateset,i| %>
	<div class="row-fluid">
		<div class="span3">
			<h4><%= Date::MONTHNAMES[@calendartitle[i][0]] + " - " + @calendartitle[i][1].to_s %></h4>
			<div class="tiny_calendar">
				<table class="table">
					<tr>
						<th class="week_title">Sun</th>
						<th class="week_title">Mon</th>
						<th class="week_title">Tue</th>
						<th class="week_title">Wed</th>
						<th class="week_title">Thu</th>
						<th class="week_title">Fri</th>
						<th class="week_title">Sat</th>
					</tr>
					<% x = 0 %>
					<% dateset.each do |date| %>
						<% x = x + 1 %>
						<% if x == 1 %>
							<tr>
						<% end %>
						<td <%= (@calevents[i].index(date.to_i) != nil ? "class=has_event" : "") %> ><%= (date=="NaN"? "" : date ) %></td>
						<% if x == 7 %>
							<% x = 0 %>
							</tr>
						<% end %>
					<% end %>
						<!-- <td class="has_event">13</td> -->				
				</table>
			</div>
		</div>
		<div class="span9">
			<table class="table event_list">
				<thead>
					<tr height="0">
						<th class="span3"></th>
						<th class="span2"></th>
						<th class=""></th>
					</tr>
				</thead>
				<tbody>
					<% lastday = "" %>
					<% if @events[i].count > 0 %>
						<% @events[i].each do |event| %>
							<tr>
								<th>
									<% if event['display_date'] != lastday %>
										<%= event['display_date'] %>
									<% end %>
								</th>
								<td class="event_time"><%= event['display_time'] %></td>
								<td>
									<div class="event" link="<%= event['show_link'] %>" style="color: <%= event['color'] %>;"><%= event['title'] %></div>
								</td>
							</tr>
							<% lastday = event['display_date'] %>
						<% end %>
					<% else %>
						<tr>
							<td colspan='3'>No events for this month.</td>
						</tr>
					<% end %>
				</tbody>
			</table>
		</div>
	</div>
	<% end %>
</div>