<%
/*==============================================================================================
* Project Title	: 한마음연수원
* File Name		: main.jsp
* Include		: 
				  
* Used DB Table	: notice
* Used Class	:
* Description	: 메인
* Programmer	: 강주용
* First Write	: 2010.05.10
* Last Update	:
==============================================================================================*/
%>

<%@ page contentType="text/html;charset=euc-kr" %>
<%@ include file="/include/in_Import.jsp" %>
<%@ include file="/include/in_Function.jsp" %>
<jsp:useBean id="sutil" class="kr.co.slight.jinhae.util.GYUtil" scope="page" />

<%
	int PageAuth = 1;
	String menuId	= request.getParameter("menuId");
	if(menuId == null || menuId.equals("")) menuId = "00";
%>

<%!
	static {
        try {
            new kr.co.slight.jinhae.pool.JDCConnectionDriver("org.postgresql.Driver","jdbc:postgresql:hanmaum","postgres","");
        } catch(Exception e) {
           	System.out.println("<br><br>JDCConnectionDriver Error : " + e.toString());
        }
	}

%>

<%

	Connection conn	= null;
	Statement stmt = null;
	ResultSet rs1 = null;
	ResultSet rs2 = null;

	try {
	    StringBuffer query1 = new StringBuffer();
		StringBuffer query2 = new StringBuffer();
			
		query1.append("select * from notice where state = '1' order by no desc limit 5 offset 0 ");
		query2.append("select * from notice where state = '2' order by no desc limit 5 offset 0 ");

		conn = DriverManager.getConnection("jdbc:jdc:jdcpool");
		stmt = conn.createStatement();

		rs1	= stmt.executeQuery(query1.toString());
		 
%>

<%@ page contentType="text/html;charset=euc-kr" %>
<jsp:include page="/hanmaum/mtop.jsp" flush="false"/>
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script language="javascript">
<!--

	function onGoPage(url) {
	
		if(url == "notice") {
			location.href = "Cs/csnot01.jsp?menuId=41";
		} else {
			location.href = "Cs/csqa01.jsp?menuId=42";
		}
	}
	
	function onSetPage(cmd) {

		if(cmd == "notice") {
			document.all.noticeTable.style.display = "";
			document.all.qandaTable.style.display = "none";

		} else {
			document.all.qandaTable.style.display = "";
			document.all.noticeTable.style.display = "none";
		}
	}

	function onViewPage(cmd, no) {
		if(cmd == "1") {
			location.href = "Cs/csnot02.jsp?menuId=41&no="+no;
		} else {
			location.href = "Cs/csqa02.jsp?menuId=42&no="+no;
		}
	}

//-->
</script>

<table width="940" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="940" height="360">
				<param name="movie" value="main.swf" />
				<param name="quality" value="high" />
				<param name="wmode" value="opaque" />
				<param name="swfversion" value="6.0.65.0" />
				<!-- 이 param 태그는 Flash Player 6.0 r65 이후 버전 사용자에게 최신 버전의 Flash Player를 다운로드하라는 메시지를 표시합니다. 사용자에게 이러한 메시지를 표시하지 	않으려면 이 태그를 삭제하십시오. -->
				<param name="expressinstall" value="Scripts/expressInstall.swf" />
				<!-- 다음 객체 태그는 IE 이외의 브라우저에 사용됩니다. IECC를 사용하여 IE에서 이 태그를 숨기십시오. -->
				<!--[if !IE]>-->
				<object type="application/x-shockwave-flash" data="main.swf" width="940" height="360">
				<!--<![endif]-->
					<param name="quality" value="high" />
					<param name="wmode" value="opaque" />
					<param name="swfversion" value="6.0.65.0" />
					<param name="expressinstall" value="Scripts/expressInstall.swf" />
					<!-- Flash Player 6.0 이전 버전 사용자의 브라우저에는 다음과 같은 대체 내용이 표시됩니다. -->
					<div>
						<h4>이 페이지의 내용을 보려면 최신 버전의 Adobe Flash Player가 필요합니다.</h4>
						<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Adobe Flash Player 내려받기" width="112" height="33" /></a></p>
					</div>
				<!--[if !IE]>-->
				</object>
			<!--<![endif]-->
			</object>
		</td>
	</tr>
</table>
<br />

<div name="noticeTable" id="noticeTable">
<table width="940" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="346" align="right" valign="top"><img src="Image/ma_con01.gif" alt="" width="326" height="141" border="0" usemap="#acc" /></td>
		<td width="390" align="center" valign="top">

			<table width="339" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="339">
						<img src="Image/ma_not01.gif" alt="" width="339" height="28" border="0" usemap="#nnot" />
					</td>
				</tr>
			</table>

			<table width="339" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td width="10">&nbsp;</td>
					<td width="259">&nbsp;</td>
					<td width="70">&nbsp;</td>
				</tr>
<%
	if (rs1 != null) {

		int no = 0;

		String subject = "";
		String regdate = "";

		while (rs1.next()) {			    
			no = rs1.getInt("no");
			subject	= rs1.getString("subject");								
			regdate	= rs1.getString("reg_dt").toString().substring(0, 10);

			subject = cutoffString(subject, 30);			
%>
				<tr>
					<td>&nbsp;</td>
					<td height="20" align="left">
						<a href="javascript:onViewPage('1','<%= no %>');">
							<%= subject %>
						</a>
					</td>
					<td align="right"><%= regdate %></td>
				</tr>
<%
		}
	} else {
%>
				<tr>
					<td colspan="3" align="center">등록된 게시물이 없습니다.</td>
				</tr>
<% 
	} 

	rs1.close();
	rs2	= stmt.executeQuery(query2.toString());

%>			
			</table>

		</td>
		<td width="204" valign="top"><img src="Image/ma_but03.gif" alt="" width="184" height="141" border="0" usemap="#Map" />
		</td>
	</tr>
</table>
</div>

<div name="qandaTable" id="qandaTable" style="display:none;">
<table width="940" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="346" align="right" valign="top"><img src="Image/ma_con01.gif" alt="" width="326" height="141" border="0" usemap="#acc" /></td>
		<td width="390" align="center" valign="top">

			<table width="339" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="339">
						<!--img src="Image/ma_not01.gif" alt="" width="339" height="28" border="0" usemap="#nnot" /-->
						<img src="Image/ma_not02.gif" alt="" width="339" height="28" border="0" usemap="#nqan" />
					</td>
				</tr>
			</table>

			<table width="339" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td width="10">&nbsp;</td>
					<td width="259">&nbsp;</td>
					<td width="70">&nbsp;</td>
				</tr>
<%
	if (rs2 != null) {

		int no = 0;

		String	subject = "";
		String	regdate = "";

		while (rs2.next()) {			    
			no = rs2.getInt("no");
			subject	= rs2.getString("subject");								
			regdate	= rs2.getString("reg_dt").toString().substring(0, 10);

			subject = cutoffString(subject, 30);			
%>
				<tr>
					<td>&nbsp;</td>
					<td height="20" align="left">
						<a href="javascript:onViewPage('2','<%= no %>');">
							<%= subject %>
						</a>
					</td>
					<td align="right"><%= regdate %></td>
				</tr>
<%
		}
	} else {
%>
				<tr>
					<td colspan="3" align="center">등록된 게시물이 없습니다.</td>
				</tr>
<% 
	} 
%>			
			</table>

		</td>
		<td width="204" valign="top">
			<a href="#">
				<img src="Image/ma_but01.gif" alt="" width="184" height="61" border="0" />
			</a>
			<a href="#">
				<img src="Image/ma_but02.gif" alt="" width="184" height="62" border="0" />
			</a>
		</td>
	</tr>
</table>
</div>

<map name="Map" id="nnot">
	<area shape="rect" coords="302,12,337,27" href="javascript:onGoPage('notice');" alt="더보기" />
	<!--area shape="rect" coords="1,2,83,28" href="#" alt="" /-->
	<area shape="rect" coords="83,2,166,27" href="javascript:onSetPage('qanda')" alt="" />
</map>

<map name="Map" id="nqan">
	<area shape="rect" coords="302,12,337,27" href="javascript:onGoPage('qanda');" alt="더보기" />
	<area shape="rect" coords="1,2,83,28" href="javascript:onSetPage('notice')" alt="" />
	<!--area shape="rect" coords="83,2,166,27" href="#" alt="" /-->
</map>

<map name="Map2" id="acc">
	<area shape="rect" coords="20,73,152,128" HREF="/hanmaum/Accou/accou01.jsp?menuId=31" target="viewframe" />
	<area shape="rect" coords="157,73,316,127" HREF="/hanmaum/Accou/accou04.jsp?menuId=34" target="viewframe" />
</map>
<%@ include file="/hanmaum/bottom1.jsp" %>

<%
		if ( rs1 != null ) rs1.close();
		if ( rs2 != null ) rs2.close();
		if ( stmt != null ) stmt.close();
		if ( conn != null ) conn.close();

	} catch (Exception e) {

		if ( rs1 != null ) rs1.close();
		if ( rs2 != null ) rs2.close();
		if ( stmt != null ) stmt.close();
		if ( conn != null ) conn.close();

		// 에러페이지로 이동............
		out.println("JSP >> Exception in /hanmaum/main.jsp : " + e.toString());
	}
%>
<map name="Map" id="Map">
  <area shape="rect" coords="59,79,113,99" href="#" alt="다운로드" />
  <area shape="rect" coords="115,77,178,99" href="#" alt="브로셔" />
  <area shape="rect" coords="4,3,181,42" href="#" alt="사용신청서 다운" />
  <area shape="rect" coords="4,106,180,139" href="#" alt="에코끼리링크" />
</map>
<script type="text/javascript">
<!--
	swfobject.registerObject("FlashID");
//-->
</script>