<%

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

nowpage_url = Request.ServerVariables("path_info")
%>
<!--#include virtual="/content/board/top.asp"-->

<!-- 리스트 -->
<div id="board" style="width:<%=a_width%>;">

	<div class="top">
		<div class="cal_top">
			<a class="sp sp_b_prev2" href='<%=nowpage_url%>?a_num=<%=a_num%>&amp;p_year=<%=(prevYear-1)%>&amp;p_month=<%=intThisMonth%>' onmouseover="this.className='sp sp_b_prev2_on'" onfocus="this.className='sp sp_b_prev2_on'" onmouseout="this.className='sp sp_b_prev2'" onblur="this.className='sp sp_b_prev2'"><span class="blind">이전 해</span></a>
			<a class="sp sp_b_prev" href='<%=nowpage_url%>?a_num=<%=a_num%>&amp;p_year=<%=prevYear%>&amp;p_month=<%=prevMonth%>' onmouseover="this.className='sp sp_b_prev_on'" onfocus="this.className='sp sp_b_prev_on'" onmouseout="this.className='sp sp_b_prev'" onblur="this.className='sp sp_b_prev'"><span class="blind">이전 달</span></a>

			<span class="sp sp_null"></span>
			<span class="sp sp_n<%= Mid(intThisYear, 1, 1)%>"><span class="blind"><%= Mid(intThisYear, 1, 1)%></span></span>
			<span class="sp sp_n<%= Mid(intThisYear, 2, 1)%>"><span class="blind"><%= Mid(intThisYear, 2, 1)%></span></span>
			<span class="sp sp_n<%= Mid(intThisYear, 3, 1)%>"><span class="blind"><%= Mid(intThisYear, 3, 1)%></span></span>
			<span class="sp sp_n<%= Mid(intThisYear, 4, 1)%>"><span class="blind"><%= Mid(intThisYear, 4, 1)%></span></span>
			<span class="sp sp_ndot"><span class="blind">.</span></span>
			<span class="sp sp_n<%=Mid(intThisMonth2,1, 1)%>"><span class="blind"><%=Mid(intThisMonth2,1, 1)%></span></span>
			<span class="sp sp_n<%=Mid(intThisMonth2,2, 1)%>"><span class="blind"><%=Mid(intThisMonth2,2, 1)%></span></span>
			<span class="sp sp_null"></span>

			<a class="sp sp_b_next" href='<%=nowpage_url%>?a_num=<%=a_num%>&amp;p_year=<%=nextYear%>&amp;p_month=<%=nextMonth%>' onmouseover="this.className='sp sp_b_next_on'" onfocus="this.className='sp sp_b_next_on'" onmouseout="this.className='sp sp_b_next'" onblur="this.className='sp sp_b_next'"><span class="blind">다음 달</span></a>
			<a class="sp sp_b_next2" href='<%=nowpage_url%>?a_num=<%=a_num%>&amp;p_year=<%=nextYear+1%>&amp;p_month=<%=intThisMonth%>' onmouseover="this.className='sp sp_b_next2_on'" onfocus="this.className='sp sp_b_next2_on'" onmouseout="this.className='sp sp_b_next2'" onblur="this.className='sp sp_b_next2'"><span class="blind">다음 해</span></a>

			<span class="sp sp_null"></span>
			<a class="sp sp_b_today" href='<%=nowpage_url%>?a_num=<%=a_num%>&amp;p_year=<%=Year(now)%>&amp;p_month=<%=Month(now)%>'><span class=""><input type="image" src="/sms_img/sub/btn_today.gif" alt="추가" /></span></a>
		</div>
		<div class="cal_right">
			<!-- #include virtual="/content/board/code.asp"--><!--분류-->
		</div>
	</div>

	
	<%If is_ad_cms = "Y" then%>
	<form id= "frm_list" action=""  method='post'>
	<div>
		<input type="hidden" name="status" />
		<input type="hidden" name="a_num" value="<%=a_num%>" />

		<input type="hidden" id="chk_all" name="chk_all" /><!-- 전체체크 사용하려구.. -->
	</div>
	<%End if%>



	<!-- 리스트 테이블 -->
	<div class="cal_blist">

			<table cellspacing="0" >
			<caption><%=replace( tit_name, " | ", "")%></caption>
				<colgroup>
				<col width="14%" />
				<col width="14%" />
				<col width="14%" />
				<col width="14%" />
				<col width="14%" />
				<col width="14%" />
				<col width="14%" />
				</colgroup>
			<thead>
				<tr>
					<th scope="col" class="sun">일요일</th>
					<th scope="col">월요일</th>
					<th scope="col">화요일</th>
					<th scope="col">수요일</th>
					<th scope="col">목요일</th>
					<th scope="col">금요일</th>
					<th scope="col" class="sat">토요일</th>
				</tr>
			</thead>



			<tbody>
				<%

				'cal		= CInt(a_width) / 7
				day1	= (-1 * datFirstDay)+2		'//날수1
				day2	= (-1 * datFirstDay)+2		'//날수2(내용할때)

				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

					%>
					<td class="day <%=tcolor%>" <%
					
					If cday <> "" Then
						If is_write = "Y" Then
							Response.write "title='일정등록' style='cursor:pointer;' onclick = ""location.href='write.asp?a_num=" & a_num & "&amp;b_sdate=" & dateserial(intThisYear, intThisMonth, cday) & "';"""
						End if
					End if
					
					%>>
						<%=cday%>
					<%
					If cday <> "" Then
						If is_write = "Y" Then
							Response.write "<img src='/sms_img/sub/icon_add.gif' align='right' style='vertical-align:bottom; padding:1px 4px 0 0;'/>"
						End If
					End if
					%>
					</td>
					<%
						day1 = day1 + 1
					next
					%>
				</tr>
				<!-- 내용 -->
				<tr>
					<%
						for c = 1 to 7

						'날짜계산
						If day2 > 0 and day2 <= intLastDay then
							cday2 = day2
						else
							cday2 = ""
						End if

						cday2 = Right( "00" & cday2, 2 )		'//1~9숫자 앞에 0붙이기

						If cday2 <> "00" then
							
							thisDate = DateSerial(intThisYear, intThisMonth, cday2)
						else
							thisDate = ""

						End if
					
					%>
					<td style="padding-left:2px;"><%today_list_new(thisDate)%></td>
					<%
						day2 = day2 + 1
					Next
					%>
				</tr>
				<%next%>

			</tbody>
			</table>

	</div>
	<!-- //리스트 테이블 -->

	<!-- 버튼 -->
	<div class="board_button">
		<div class="fr">
			<!-- <span class="bt"><a href="list.asp?a_num=<%=a_num%>" ><img src="/content/board/default_calendar/img/list_bt.gif" width="62" height="23" alt="목록" /></a></span> -->
			<%If is_write = "Y" then%>
			<!-- <span class="bt"><a href="write.asp?a_num=<%=a_num%>"><img src="/content/board/default_calendar/img/write_bt.gif" width="62" height="23" alt="쓰기" /></a></span> -->
			<%End if%>
		</div>

	</div>
	<!-- //버튼 -->


	<% If is_ad_cms = "Y" then%>
	</form>
	<% End if %>




</div>
<!-- //리스트 -->
<!--#include virtual="/content/board/bottom.asp"-->
<%
function today_list_new(thisDate2)

	'global $b_subject, $a_tablename, $board_skin1_url, $a_cate, $v_cate, $a_num, $b_num, $page_info, $a_type, $b_cate_str;

	Dim R_Fields_code, order_by_code, thisDate3, sql_opt1, sql_opt2, sql_opt3, sql

	R_Fields_code	= "b_num, b_subject, b_content, b_catename, b_open, b_sbjclr, b_cate"
	order_by_code	= " ORDER BY b_sdate asc, b_edate asc"
	thisDate3		= thisDate2



	'//검색 옵션-------------------------------------------------------
	sql_opt1	= " AND b_sdate <= '" & thisDate3 & "' AND b_edate >='" & thisDate3 & "'"


	sql_opt2 = " AND  b_id = '" & SESSION("ss_m_id") & "'"



	'//분류기능 사용시..
	If a_cate = "Y" and v_cate <> "" then
		sql_opt3 = " AND  b_cate = " & v_cate
	End if
	'//----------------------------------------------------------------


	SQL = "Select " & R_Fields_code & " FROM " & a_tablename & " WHERE b_num <> '0'"
	SQL = SQL & sql_opt1 & sql_opt2 & sql_opt3
	SQL = SQL & order_by_code
	'response.write sql
	'response.end
	Set rs_tdy = dbcon.execute( sql )

	If Not( rs_tdy.bof Or rs_tdy.eof ) then
		
		'//$zul = 1;
		Do Until rs_tdy.eof

			b_num		= rs_tdy("b_num")
			b_subject	= rs_tdy("b_subject")
			b_content	= rs_tdy("b_content")
			b_catename	= rs_tdy("b_catename")
			b_open		= rs_tdy("b_open")

			b_sbjclr	= rs_tdy("b_sbjclr")
			b_cate		= rs_tdy("b_cate")

			b_subject_str = StringToHTML( b_subject, 6, false)
'//			$b_subject_str = remove_tags($b_subject);
'//			$b_subject_str = StringToHTML($b_subject_str, 18, false );

'			//$_SESSOIN[$zul."_"."b_num"] = $b_num;

			'//공개/비공개
			If a_type = "Y" Or a_type = "T" then		'//사용하면, or 전체 비공개이면

				If b_open = "N" Or a_type = "T" then	'//비공개이면

					b_open_str = "<img src='/content/board/default_calendar/img/icon_key.gif' width='17' height='12' alt='비밀글' />"
				else		'//공개이면
					b_open_str = ""
				End if

			Else
				b_open_str = ""
			End if
			
%>

		<a href="view.asp?a_num=<%=a_num%>&amp;b_num=<%=b_num%>&amp;<%=page_info%>" style="color:#6B6B6B;">·<%If a_cate = "Y" Then response.write b_cate_str(b_cate)%><%=b_subject_str%></a><%=b_open_str%><br />

<%
		
		'//$_SESSOIN["zul_".$zul] = "";
		'//$zul = $zul + 1;

			rs_tdy.movenext
		loop
	End if
	Set rs_tdy = nothing

End function
%>
