<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" session="true" %>
<%@ page import="kcg.imis.sec.LoginUserVO"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<% 
	LoginUserVO userVO = (LoginUserVO) session.getAttribute("userVO");
%>
<script type="text/javaScript" defer="defer">
	$(document).ready(function(){
		$.ajaxSetup({
			cache: false
		});
		
		$(window).resize(function(){
			var modalBack = $('#modalBack');
				modalBack.css({
					'width' : $(window).outerWidth(),
					'height' : $(window).outerHeight()
				});
		});
		
		// ContextMenu 방지 코드
		$(document).contextmenu(function(){
			return false;
		});
		
		// FancyBox 기본 설정
		$.extend($.fancybox.defaults, {
		    closeClick: true
		});
		
		// Jquery 달력 기본 설정
		$.datepicker.setDefaults({
			dateFormat: "yy-mm-dd",
			changeMonth: true,
			changeYear: true
		})
	});
	
	function showPwMenu(){
		$('#pwMenu').show();
		
		var modalBack = $('#modalBack');
		if (modalBack.length == 0) {
			modalBack = $('<div>')
			.show()
			.attr('id', 'modalBack')
			.css({
				//'background-color' : 'rgba(0,0,0 ,0.5)',
				'display' : 'none',
				'position' : 'absolute',
				'width' : $(window).outerWidth(),
				'height' : $(window).outerHeight(),
				'overflow' : 'hidden',
				'top' : '0px'
			});
			$('body').append(modalBack);
		}
		modalBack.show();
		
		
	}
	function hidePwMenu(){
		$('#pwMenu').hide();
		$('#modalBack').hide();
	}
	
	/* pagination 페이지 링크 function */
	function fn_changePw() {
		var form = document.forms['pwForm'];
		if (form.checkPwd.value == 'N') {
			alert('변경 비밀번호가 일치하지 않습니다.');
			return false;
		} else {
			$.ajax({
				'url': '/member/changePw.json',
				'type': 'post',
				'data': $(form).serialize(),
				'dataType': 'json', 
				'success': function(result){
					if (result.match == false) {
						alert('현재 비밀번호가 일치하지 않습니다.');
					} else if (result.result != '1') {
						alert('에러가 발생하였습니다. 다시 시도하세요.');
					} else {
						alert('비밀번호가 변경되었습니다.');
						hidePwMenu();
					}
				}
			});
		}
		
	}
	
	var Member = {
			checkPWD : function(_str){
				var form = document.forms['pwForm'];
				var passwd = form.npasswd.value;
				if(passwd == _str){
					$('#pwd_desc').html("<spring:message code="member.msg.match"/>");
					$('#pwd_desc').css('color', '#00f');
					form.checkPwd.value = 'Y'; 
				}else{
					$('#pwd_desc').html("<spring:message code="member.msg.dismatch"/>");
					$('#pwd_desc').css('color', '#f00');
					form.checkPwd.value = 'N'; 
				}
			}
		}
</script>

<c:if test="${not empty userVO}">
	
	<div class="header_user">		
		<div class="top-gnb">		
			<ul id="menu1">
			<c:forEach var="menu" items="${topMenu}">
				<li><a href="${menu.uri}" target="_self">${menu.name}</a></li>
			</c:forEach>
			</ul>
			<ul class="gnb-menu-right">
				<li><a href="<c:url value='/member/update.do'/>">정보수정</a></li>
				<li class="logout"><a href="<c:url value='/j_spring_security_logout'/>"><spring:message code="login.msg.logout" /></a></li>
				<li><span>[<c:out value="${userVO.name}" /><spring:message code="login.msg.nim" /> <spring:message code="login.msg.welcom" /> ]</span></li>				
			</ul>
		</div>
	</div>
	
	<!-- <div class="logo">
		<h1><a href="/"><img src="/images/cmmn/logo02.png" alt="국제해양정보시스템"></a></h1>
	</div> -->
	
	<div class="logo">
		<h1><a href="/"><img src="/images/cmmn/logo02.png" alt="국제해양정보시스템"></a></h1>
		<div class="search">
			<form name="totalSearchForm" id="totalSearchForm" method="POST" action="/bbs/search.do">
				<input type="hidden" name="dumy" id="dumy" placeholder="내용을 입력해주세요."/>
				<input type="text" class="txt_total" name="searchKeyWord" id="searchKeyWord" placeholder="내용을 입력해주세요." value="${searchKeyWord}"/>
				<input type="image" class="Searchbtn" src="/images/new/btn_search_icon.png" alt="검색하기" onKeyDown="javascript:gosearch()"/>
			</form>
		</div><!--end of search-->
	</div>
	<script type="text/javaScript" defer="defer">
	function gosearch(){
		document.totalSearchForm.sumbit();
	}
	</script>
	<div id="menu2" class="header-gnb">
		<ul class="gnb-menu">
		<c:forEach var="depth1" items="${mainMenuList}">
		<li>
			<c:choose>
				<c:when test="${empty depth1.uri}"><a href="#" style="cursor:default;"><c:out value="${depth1.name}"></c:out> </a></c:when>
				<c:otherwise><a href="<c:url value="${depth1.uri}"></c:url>" style="cursor: hand;"><c:out value="${depth1.name}"></c:out> </a></c:otherwise>
			</c:choose>
			<c:if test="${not empty depth1.menuList}">
				<div class="submenu">
					<ul>
					<c:forEach var="depth2" items="${depth1.menuList}">
					<c:choose>
						<c:when test="${depth2.urlGroup eq 'board'}">
							<li>
								<a href="<c:url value="${depth2.uri}"></c:url>">
									<c:out value="${depth2.name}"></c:out>
								</a>
							</li>
						</c:when>
						<c:otherwise>
							<li>
								<a href="<c:url value="${depth2.uri}"></c:url>">
									<c:out value="${depth2.name}"></c:out>
								</a>
							</li>
						</c:otherwise>
					</c:choose>
						
					</c:forEach>
					</ul>
				</div>
			</c:if>
							
		</li>
		</c:forEach>
			<!-- <li>
				<a href="#" style="cursor:default;">게시판</a>
				<div class="submenu">
					<ul>
						<li><a href="javascript:alert('작업대기중입니다!');">공지사항</a></li>
						<li><a href="/bbs/list.do">정보요청</a></li>
					</ul>
				</div>				
			</li>
			<li>
				<a href="#" style="cursor:default;">세계해양분쟁</a>
				<div class="submenu">
					<ul>
						<li><a href="javascript:alert('작업대기중입니다!');">일본</a></li>
						<li><a href="javascript:alert('작업대기중입니다!');">중국</a></li>
						<li><a href="javascript:alert('작업대기중입니다!');">러시아</a></li>
					</ul>
				</div>				
			</li>
			<li>
				<a href="#" style="cursor:default;">현안보고</a>
				<div class="submenu">
					<ul>
						<li><a href="javascript:alert('작업대기중입니다!');">해양정세리포트</a></li>
						<li><a href="javascript:alert('작업대기중입니다!');">국제해양정세</a></li>
					</ul>
				</div>				
			</li>
			<li>
				<a href="#" style="cursor:default;">주변국 해양세력</a>
				<div class="submenu">
					<ul>
						<li><a href="javascript:alert('작업대기중입니다!');">일본해양세력</a></li>
						<li><a href="javascript:alert('작업대기중입니다!');">중국해양세력</a></li>
						<li><a href="javascript:alert('작업대기중입니다!');">국가별참고사이트</a></li>
					</ul>
				</div>				
			</li>
			<li>
				<a href="#" style="cursor:default;">국제회의</a>
			</li>
			<li>
				<a href="#" style="cursor:default;">자료실</a>
				<div class="submenu">
					<ul>
						<li><a href="javascript:alert('작업대기중입니다!');">독도/이어도</a></li>
						<li><a href="javascript:alert('작업대기중입니다!');">동영상</a></li>
						<li><a href="javascript:alert('작업대기중입니다!');">이미지</a></li>
					</ul>
				</div>				
			</li> -->
			<!-- <li>
				<a href="#" style="cursor:default;">해적,IMO등</a>
			</li>
			<li>
				<a href="#" style="cursor:default;">견문보고</a>
			</li> -->
		</ul>	
		<div class="all-menu">
			<a href="#" class="all-menu-view all-view-hiden"><img src="/images/cmmn/all-btn_2.png" alt="전체메뉴 보기" title="<spring:message code="menu.togglebtn.descript" />"></a>
		</div>
		<div id="menuBg" class="submenu_bg submenubg on"></div>				
	</div>
	
	<script type="text/javascript">
	
	//네비게이션
	    $(document).ready(function () {
	    	$(".all-menu").click(function () {
	            $(".submenu, #menuBg").toggle();
	            
	            $(".gnb-menu").mouseleave(function () {
	                $(".submenu, #menuBg").show();
	            });
	        });
	        $(".gnb-menu").mouseenter(function () {
	            $(".submenu, #menuBg").show();
	        });
	        $(".gnb-menu").mouseleave(function () {
	            $(".submenu, #menuBg").hide();
	        });
	    });   
	</script>		
	
</c:if>
<!-- //상단메뉴 -->
