$(document).ready(function() {
	var $mainMenu = $('#menu');
	var $sideMenu = $('#side-menu');
	var $sideMenuTopItems = $sideMenu.find('>ul>li');
	
	$sideMenuTopItems
		.filter('.current').addClass('expanded').end()
		.filter(':not(.current)').find('>ul').addClass('hidden');
	$sideMenuTopItems.find('>span')
		.wrapInner('<a href="#"></a>')
		.click(function() {
			$(this).parent().toggleClass('expanded').find('>ul').toggleClass('hidden');
			return false;
		});

/*인물시작*/
	$(".accordion h4:first").addClass("active");
	$(".accordion p:not(:first)").hide();

	$(".accordion h4").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h4").removeClass("active");
	});
/*인물끝*/

	

	/*$mainMenu.find('>ul>li').bind('mouseenter', function() {
			$(this).siblings().andSelf().find('>ul').removeAttr('style');
			var img = $(this).find('>a>img')[0];
			if (img)
				img.src = img.src.replace(/-off/, '-on');
		})
		.not('.current')
		.bind('mouseleave', function() {
			var img = $(this).find('>a>img')[0];
			if (img)
				img.src = img.src.replace(/-on/, '-off');
		});*/

	// --> accessibility -_-
	/*$mainMenu.find('>ul>li>a')
		.focus(function() {
			$(this).parent()
				.siblings().find('>ul').removeAttr('style')
				.end().end()
				.find('>ul').css( {'display':'block', 'z-index':'100' });
		});	*/
	// <-- accessibility

	$mainMenu.find('>ul').superfish({
		delay: 400,
		speed: 'fast',
		autoArrows: false,
		onBeforeShow: function() {
			$mainMenu.find('img').each(function() {
				this.src = this.src.replace(/-on/, '-off');
			})
			.parents('li.sfHover').find('img').each(function() {
				this.src = this.src.replace(/-off/, '-on');
			});
		},
		onHide: function() {
			$mainMenu.find('img').each(function() {
				this.src = this.src.replace(/-on/, '-off');
			})
			.parents('li.sfHover').find('img').each(function() {
				this.src = this.src.replace(/-off/, '-on');
			});
		}
	});

	$(document).keydown(function(event) {
		var link = null;

		var keycode = event.keyCode ? event.keyCode : event.which;
		if (event.ctrlKey) {
			if (keycode == 37) {
				link=$("a.prev").attr("href");
			}
			else if (keycode == 39) {
				link=$("a.next").attr("href");
			}
		}

		if (link) document.location=link;
	});

	var $boardDivisions = $('#board-divisions');
	$boardDivisions.find('>li>span').click(function() {
		var $li = $(this).parent();
		if ($li.hasClass('expanded'))
			$li.removeClass('expanded');
		else {
			$li.siblings().removeClass('expanded');
			$li.addClass('expanded');
		}
	});

	var $filesDiv = $('#content-main div.record-files');
	$filesDiv.find('span.header').attr('style','line-height:'+$filesDiv.height()+'px;height:'+$filesDiv.height()+'px');
});

function portal_popup_windowOpen_scroll(url, popupwidth, popupheight)
 {
  Top = (window.screen.height - popupheight) / 3;
  Left = (window.screen.width - popupwidth) / 2;
  if (Top < 0) Top = 0;
  if (Left < 0) Left = 0;
  Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=" + Left + ",top=" + Top + ",width=" + popupwidth + ",height=" + popupheight;
  PopUpWindow = window.open(url, "PopUpWindow", Future)
  PopUpWindow.focus();
 }
//팝업창함수
function notice_getCookie( name ){
			var nameOfCookie = name + "=";
			var x = 0;
			while ( x <= document.cookie.length ){
				var y = (x+nameOfCookie.length);
				if ( document.cookie.substring( x, y ) == nameOfCookie ) {
					if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
						endOfCookie = document.cookie.length;
					return unescape( document.cookie.substring( y, endOfCookie ) );
				}
				x = document.cookie.indexOf( " ", x ) + 1;
				if ( x == 0 )
					break;
			}
			return "";
		}
		//Popup Close
function closeWin()     {    window.close();	}
