<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
?>
<SCRIPT type="text/javascript">
function ShowHide(num) {
	var lay = eval("document.all.layer_" +num)
	if(lay.style.display == ""){ 
		lay.style.display = "none";
	}else{
		lay.style.display = "";
	}
}

function close(num) {
	var lay = eval("document.all.layer_" +num)
		lay.style.display = "none";
}
//-->
</SCRIPT>

<style>
#layer_main { position:relative; left:0px; top:0px; z-index:10; }
#layer_main2 { position:relative; left:0px; top:0px; z-index:20; }
#layer_main3 { position:relative; left:0px; top:0px; z-index:30; }
#layer_main_top { position:absolute; left:-163px; top:31px; width:602px; height:275px; z-index:11;}
#layer_main_top2 { position:absolute; left:-245px; top:31px; width:602px; height:275px; z-index:21;}
#layer_main_top3 { position:absolute; left:-315px; top:31px; width:602px; height:275px; z-index:231;}
html>body #layer_main_top { position:absolute; margin:0; left:-163px; top:31px; width:602px; height:273px; z-index:11;}
html>body #layer_main_top2 { position:absolute; margin:0; left:-245px; top:31px; width:602px; height:273px; z-index:21;}
html>body #layer_main_top3 { position:absolute; margin:0; left:-315px; top:31px; width:602px; height:273px; z-index:31;}
</style>
<!-- 화면을 중앙 고정 시작 -->
<table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td align="center" valign="top">
		<!-- 홈페이지 시작 -->
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td align="<?=$config[cf_home_align]?>" valign="top">				
				<table width="<?=$config[cf_home_width]?>" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td>						
						<table width='100%' cellpadding='0' cellspacing='0' border='0'>
							<tr height="20"><td></td></tr>
							<tr>
								<td align="center">
								<table cellspacing='0' cellpadding='0' border='0'>
								<form name='fsearchbox' method='get' action='javascript:fsearchbox_submit(document.fsearchbox);'>		
									<tr>
										<td><a href='<?=$g4['path']?>/'><img src='<?=$main_skin_path?>/img/logo_winter.gif' alt='Onuri' border='0'></a></td>
										<?if(!$sfl){?><input type='hidden' name='sfl' value='wr_subject||wr_content'><?}?>
										<input type='hidden' name='sop' value='and'>
										<td>
										<? 
										$text_stx = get_text(stripslashes($stx));
										?> 
										<?if($s_menu == "search"){?>
										<select id='gr_id' name='gr_id' class=select>
										<option value=''>통합검색</option>
										<?
										if($config[cf_home_ex_search_use] == 1) $home_ex_search = $config[cf_home_ex_search];
										else $home_ex_search = "''";
										
										$text_stx = get_text(stripslashes($stx));
										$excgr = "(".$home_ex_search.")";
										$sql = " SELECT a.gr_id, a.gr_subject, a.gr_use_access, a.gr_10, b.mb_id FROM $g4[group_table] AS a LEFT JOIN $g4[group_member_table] AS b ON a.gr_id = b.gr_id WHERE (b.mb_id = '$member[mb_id]' AND a.gr_use_access = '1' ) OR a.gr_use_access = '0' and a.gr_id not in " . $excgr . " ORDER BY a.gr_admin";
										$result = sql_query($sql);
										for ($i=0; $row=sql_fetch_array($result); $i++){
										?>
										<option value='<?=$row['gr_id']?>'><?=$row['gr_subject']?></option>
										<?}?>
										</select>
											<?=$group_select?> 
										</td>
										<td width='5'></td>
										<td>
										<select name=sfl>
											<option value='wr_subject||wr_content'>제목+내용</option>
											<option value='wr_subject'>제목</option>
											<option value='wr_content'>내용</option>
											<option value='wr_id'>아이디</option>
											<option value='wr_name'>이름</option>
										</select>
										</td>
										<?}?>
										<td width='5'></td>
										<td><INPUT name='stx' maxlength='100' style='<?if($s_menu == "index"){ echo "width:330px;";}else if($s_menu == "search"){ echo "width:210px;";}?>height:38;' tabIndex=1 trim value='<?=$text_stx?>' class='main_input'></td>
										<td width='5'></td>
										<td width='28' align='right'>
										<script type='text/javascript'>
										//document.fsearchbox.gr_id.value = "<?=$gr_id?>";
										//document.fsearchbox.sfl.value = "<?=$sfl?>";
										if (!fsearchbox.stx.value)
										{

											fsearchbox.stx.focus();

										}
										function fsearchbox_submit(f)
										{
											if (f.stx.value == '')
											{
												alert('검색어를 입력하세요.');
												f.stx.select();
												f.stx.focus();
												return;
											}
												/*
											// 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
											var cnt = 0;
											for (var i=0; i<f.stx.value.length; i++)
											{
												if (f.stx.value.charAt(i) == ' ')
												cnt++;
											}
											if (cnt > 1)
											{
												alert('빠른 검색을 위하여 검색어에 공백은 한개만 입력할 수 있습니다.');
												f.stx.select();
												f.stx.focus();
												return;
											}
											*/
												f.action = '<?=$g4[bbs_path]?>/search.php';
												f.submit();
											}
										</script>
										<input type=image src='<?=$main_skin_path?>/img/btn_search.gif' tabindex=3 style='width:52px;height:39px' title='검색' onmouseover=this.src='<?=$main_skin_path?>/img/btn_search.gif' onmouseout=this.src='<?=$main_skin_path?>/img/btn_search.gif' onmousedown=this.src='<?=$main_skin_path?>/img/btn_search.gif' alt='검색' onfocus='this.blur();'></td></tr>
										<tr><td></td></tr></form>
								</table>		
								</td>
							</tr>
							<tr>
								<td valign='top'>
								<table cellpadding='0' cellspacing='0' border='0'>
									<tr class='padding'>
										<td width='40' align='center'></td>
										<td width='278'></td>
										<td width='58'><img src='<?=$main_skin_path?>/img/f_menu.gif'></td>
										<td class='small'><a href='<?=$g4[bbs_path]?>/board.php?bo_table=06_2'>배너등록</a></td>
										<td class='small' width='1'>&nbsp;<span style="color:#dddddd;">|</span>&nbsp;</td>
										<td class='small'><a href='<?=$g4[path]?>/point_rule.php'>포인트</a></td>
										<td class='small' width='1'>&nbsp;<span style="color:#dddddd;">|</span>&nbsp;</td>
										<td class='small'><a href='<?=$g4[bbs_path]?>/email_certify1.php'>재인증</a></td>	
										<td width='15'></td>
										<td class=small style="color:#aaaaaa;"><a href="http://www.naver.com/" style="color:#aaaaaa;">네이버</a> · <a href="http://www.daum.co.kr/" style="color:#aaaaaa;">다음</a> · <a href="http://www.sir.co.kr" style="color:#aaaaaa;">그누보드</a></td>
									</tr>
								</table>
								</td>
							</tr>
							<tr height="5"><td></td></tr>
						</table>
							
						<table width='100%' cellpadding='0' cellspacing='0' border='0'>
							<tr>
								<td width='2'><img src='<?=$main_skin_path?>/img/box_left.gif' alt=''></td>
								<td background='<?=$main_skin_path?>/img/box_bg.gif' valign="bottom">		
								<table width='100%'cellpadding='0' cellspacing='0' border='0'>
									<tr>
										<td>
										<table cellpadding='0' cellspacing='0' border='0'>
											<tr height='32'>
												<td width='10'></td>
												<td valign='bottom'>
												<table height='28' cellpadding='0' cellspacing='0' border='0'>
													<tr>
														<td width='2' background='<?=$main_skin_path?>/img/box_over_left.gif'></td>
														<td background='<?=$main_skin_path?>/img/box_over_bg.gif' style='padding: 3 8 0 8;' style='cursor:pointer;'><span class='text1'><?=$config[cf_home_name]?></span></td>
														<td width='2' background='<?=$main_skin_path?>/img/box_over_right.gif'></td>
													</tr>
												</table>
												</td>
												<td style='padding: 0 10 2 10;'><img src='<?=$main_skin_path?>/img/box_bar.gif'></td>
												<td><a href="<?=$g4[path]?>/group/index.php" style='color:#FFFFFF;font-weight:none;'>내용목록</a></td>
												<td style='padding: 0 10 2 10;'><img src='<?=$main_skin_path?>/img/box_bar.gif'></td>
												<td>
												<div id="layer_main">
												<a href="javascript:ShowHide('main_top')" style='color:#FFFFFF;'>자세히보기</a>
												<div id="layer_main_top" style="display:none;">
												<table width="100%" height="100%" cellpadding='0' cellspacing='1' border='0' bgcolor='#d9d9d9'>
													<tr>
														<td bgcolor='#fafafa' valign='top'>
														<table width="100%" cellpadding='0' cellspacing='0' border='0'>
															<tr height="6"><td colspan="2"></td></tr>
															<tr>
																<td width='6'></td>
																<td valign='top'>
																<table cellpadding='0' cellspacing='0' border='0'>
																	<tr>
																	<?
																	if($config[cf_home_ex_main_use] == 1) $home_ex_main = $config[cf_home_ex_main];
																	else $home_ex_main = "''";

																	//접근가능그룹 여분필드 1 순서로 추출
																	$sql = " SELECT a.gr_id, a.gr_subject, a.gr_use_access, b.mb_id FROM $g4[group_table] AS a LEFT JOIN $g4[group_member_table] AS b ON a.gr_id = b.gr_id WHERE  (b.mb_id = '$member[mb_id]' AND a.gr_use_access = '1' ) OR a.gr_use_access = '0'  ORDER BY a.gr_1";
																		
																	$sql = " select * from $g4[group_table] where gr_id not in ($home_ex_main) order by gr_1";

																	//$sql = " select  gr_id, gr_subject from $g4[group_table] where gr_id not in ($except) order by gr_subject desc ";
																	$rst1 = sql_query($sql);

																	while ($row=sql_fetch_array($rst1)) {

																		echo "<td valign='top'><table cellpadding='0' cellspacing='0' border='0'><tr height='25'><td class='small'><a href='$g4[bbs_path]/group.php?gr_id=$row[gr_id]' style='padding:0 8 0 8;color:#339966;font-weight:bold;'>$row[gr_subject]</a></td></tr>";
																		
																		$sql2 = " select * from $g4[board_table] where gr_id = '$row[gr_id]' order by bo_order_search ";
																		$rst2 = sql_query($sql2);
																		$cells++;

																		while ($row2=sql_fetch_array($rst2)) {
																		$new_time = date("Y-m-d H:i:s", time()-3600*$row2[bo_new]);
																		$sql3 = " select count(*) as cnt from $g4[write_prefix]$row2[bo_table] where wr_datetime >= '$new_time' ";
																		$row3 = sql_fetch($sql3);
																			if ($row3[cnt] > 0)
																				$new = "&nbsp;<img src='$g4[path]/img/icon_new.gif'>"; // new 아이콘
																			else
																				$new = ""; //new 아이콘 없음
																		echo "<td class='small' height='20' style='padding:0 8 0 8;color:#777777;font-weight:none;'><a href='$g4[bbs_path]/board.php?bo_table=$row2[bo_table]' >$row2[bo_subject]</a>$new<br/></td></tr>";
																		}
																		echo "</table></td>";
																	}
																	?>
																	</tr>																
																</table>
																</td>
																<td valign='top' class='small'><a href="javascript:close('main_top')" style='padding: 0 5 0 0;'>x</a></td>
															</tr>
														</table>
														</td>
													</tr>
												</table>
												</div>	
												</div>																				
												</td>
												<td style='padding: 0 10 2 10;'><img src='<?=$main_skin_path?>/img/box_bar.gif'></td>
												<td>
												<div id="layer_main2">
												<a href="javascript:ShowHide('main_top2')" style='color:#FFFFFF;'>새글보기</a>
												<div id="layer_main_top2" style="display:none;">
												<table width="100%" height="100%" cellpadding='0' cellspacing='1' border='0' bgcolor='#d9d9d9'>
													<tr>
														<td bgcolor='#fafafa' valign='top'>
														<table width="100%" cellpadding='0' cellspacing='0' border='0'>
															<tr height="6"><td></td></tr>
															<tr height='25'>
																<td class='small' style='padding:0 8 0 15;'><?=newdata("basic2",10,24);?></td>
																<td align='right' valign='top' class='small'><a href="javascript:close('main_top2')" style='padding: 0 7 0 0;'>x</a></td>
															</tr>
														</table>
														</td>														
													</tr>
												</table>
												</div>
												</div>
												</td>
												<td style='padding: 0 10 2 10;'><img src='<?=$main_skin_path?>/img/box_bar.gif'></td>
												<td>
												<div id="layer_main3">
												<a href="javascript:ShowHide('main_top3')" style='color:#FFFFFF;'>기타</a>
												<div id="layer_main_top3" style="display:none;">
												<table width="100%" height="100%" cellpadding='0' cellspacing='1' border='0' bgcolor='#d9d9d9'>
													<tr>
														<td bgcolor='#fafafa' valign='top'>
														<table width="100%" cellpadding='0' cellspacing='0' border='0'>
															<tr height="6"><td></td></tr>
															<tr height='25'>
																<td class='small' style='padding:0 8 0 15;color:#336699;'></td>
																<td align='right' valign='top' class='small'><a href="javascript:close('main_top3')" style='padding: 0 7 0 0;'>x</a></td>
															</tr>
															<tr height="15"><td></td></tr>
															<tr><td><?=latest("banner", '06_5', 6)?></td></tr>
														</table>
														</td>														
													</tr>
												</table>
												</div>
												</div>
												</td>
											</tr>
										</table>
										</td>
										<td valign='bottom' width=90>
										<table height='28' cellpadding='0' cellspacing='0' border='0'>
											<tr>
												<td width='2' background='<?=$main_skin_path?>/img/box_over_left.gif'></td>
												<td background='<?=$main_skin_path?>/img/box_over_bg.gif' style='padding: 3 8 0 8;' style='cursor:pointer;'><span class='text1'>인기검색어</span></td>
												<td width='2' background='<?=$main_skin_path?>/img/box_over_right.gif'></td>
											</tr>
										</table>
										</td>
										<td align='right' width=150>
										<table cellspacing='0' cellpadding='0' border='0'>
											<tr><td width='5'></td><td colspan='2'><?=popular("scroll")?></td></tr>
										</table>
										</td>
										<td width='10'></td>
									</tr>
								</table>				
								</td>
								<td width='2'><img src='<?=$main_skin_path?>/img/box_right.gif' alt=''></td>
							</tr>
						</table>
						