$(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;
		});

	//$('a[href^=http]:not(.open-local)')
		//.add($('a.open-new'))
		//.attr('title', '새창')
		//.click(function() {
			//window.open(this.href);
			//return false;
		//});

	$mainMenu.find('ul>li')
		.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')
		.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':'21' });
		});	
	// <-- accessibility



	$(document).bind('keydown','Ctrl+left',function(event){
		link=$("a.prev").attr("href");
		if (link) document.location=link;
	});

	$(document).bind('keydown','Ctrl+right',function(event){
		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();	}