<%
Set ST = New SelectTable

if v_year = "" then
	intThisYear = Year(now)
else
	intThisYear = v_year
End if

if v_month = "" then
	intThisMonth = Right( "0" & Month(now), 2 )
else
	intThisMonth = Right( "0" & v_month, 2 )
End if

intThisMonth2 = intThisMonth	'//1~9숫자 앞에 0붙이기

gday			= Right("0"&Day(now), 2)	'//오늘날짜
datFirstDay		= Weekday( DateSerial( intThisYear, intThisMonth, 1 ) )		'//요일 구하기 (num)
intLastDay		= Day( DateSerial( intThisYear, intThisMonth+1, 1-1 ) )		'//마지막날 구하기
jucnt			= Round( ( ( datFirstDay + intLastDay) / 7 ) + 0.5, 0 )

'response.write jucnt

'// 이전, 다음 만들기
If CInt( intThisMonth ) = 1 Then
	prevYear = intThisYear - 1
Else
	prevYear = intThisYear
End if

If CInt( intThisMonth ) = 1 Then
	prevMonth = 12
Else
	prevMonth = CInt(intThisMonth) - 1
End if

If intThisMonth = 12 Then
	nextYear = intThisYear + 1
Else
	nextYear = intThisYear
End if

If intThisMonth = 12 Then
	nextMonth = 1
Else
	nextMonth = intThisMonth + 1
End if

%>
		<div class="calen">
		<form id="frm_search" name="frm_search" method="get" action="01_01.asp">
			<ul class="sl_area">
				<li>
					<select id="p_year" name="p_year" class="select_basic" style="width:120px;" onchange="this.form.submit();">
<%
For i = 2010 To year(now)+1
%>
						<option value="<%=i%>" <%=chkSelect(intThisYear, i)%>><%=i%>년</option>
<%
next
%>
					</select>
				</li>
				<li>
					<select id="p_month" name="p_month" class="select_basic" style="width:80px;" onchange="this.form.submit();">
<%
For i = 1 To 12
	i_value = Right("0"&i, 2)
%>
						<option value="<%=i_value%>" <%=chkSelect(intThisMonth, i_value)%>><%=i_value%>월</option>
<%
next
%>
					</select>
				</li>
			</ul>
		</form>
			<table class="table1">
				<colgroup>
					<col width="15%" />
					<col width="14%" />
					<col width="14%" />
					<col width="14%" />
					<col width="14%" />
					<col width="14%" />
					<col width="15%" />
				</colgroup>
				<thead>
					<tr>
						<th scope="col">일</th>
						<th scope="col">월</th>
						<th scope="col">화</th>
						<th scope="col">수</th>
						<th scope="col">목</th>
						<th scope="col">금</th>
						<th scope="col">토</th>
					</tr>
				</thead>
				<tbody>
<%

				'cal		= CInt(a_width) / 7
				day1	= (-1 * datFirstDay)+2		'//날수1

				For ju = 1 to jucnt						'//주간 7개 돌리공..
%>

					<tr>
<%
					for i = 1 to 7
						'//글자색

						Select Case i
							Case 1 : tcolor="sun"
							Case 7 : tcolor="sat"
							Case Else
								tcolor = ""
						End select

						'//날짜계산
						If day1 > 0 and day1 <= intLastDay then
							cday = day1
						else
							cday = ""
						End If
						
						day_class = ""

						If cday <> "" Then
							thisdate = dateserial(intThisYear, intThisMonth, cday)
							If Date() = thisdate Then
								day_class = "today "	'sch_on
								cday = "TODAY"
							End If
							
							cnt = todaySchedule( thisdate )
							If cnt <> "0" Then
								day_class = day_class & "sch_on"
							End if
						End If
%>
						<td><a href="#day" class="<%=day_class%>"><%=cday%></a></td>
<%
						day1 = day1 + 1
					next
					%>
					</tr>

				<%next%>

				</tbody>
			</table>
		</div>
<%
function todaySchedule( thisdate )
	
	Dim ST
	Dim sql, cnt
	Set ST = New SelectTable

	where_query = " where b_sdate <= '" & thisdate & "' AND b_edate >='" & thisdate & "' and b_id = '" & SESSION("ss_m_id") & "' "
	sql = "select count(*) as cnt from " & tablename & where_query
	cnt = ST.selectQueryColumn( sql )

	todaySchedule = cnt

End function
%>