// Top Menu
function initNavigation(seq) {
	nav = document.getElementById("topmenu");
	nav.menu = new Array();
	nav.current = null;
	nav.menuseq = 0;
	navLen = nav.childNodes.length; 
		
	allA = nav.getElementsByTagName("li")

	for(k = 0; k < allA.length; k++) {
		allA.item(k).onmouseover = allA.item(k).onfocus = function () {
			nav.isOver = true;
		}
		allA.item(k).onmouseout = allA.item(k).onblur = function () {
			nav.isOver = false;
			setTimeout(function () {
				if (nav.isOver == false) {
					if (nav.menu[seq])
						nav.menu[seq].onmouseover();
					else if(nav.current) {
						menuImg = nav.current.childNodes.item(0);
						menuImg.src = menuImg.src.replace("none");
						if (nav.current.submenu)
							nav.current.submenu.style.display = "none";
						nav.current = null;
					}
				}
			}, 0);
		}
	}

	for (i = 0; i < navLen; i++) {
		navItem = nav.childNodes.item(i);
		if (navItem.tagName != "LI")
			continue;

		navAnchor = navItem.getElementsByTagName("a").item(0);
		navAnchor.submenu = navItem.getElementsByTagName("ul").item(0);
		
		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				menuImg = nav.current.childNodes.item(0);
				menuImg.src = menuImg.src.replace("none");
				if (nav.current.submenu)
					nav.current.submenu.style.display = "none";
				nav.current = null;
			}
			if (nav.current != this) {
				menuImg = this.childNodes.item(0);
				menuImg.src = menuImg.src.replace("none");
				if (this.submenu)
					this.submenu.style.display = "block";
				nav.current = this;
			}
			nav.isOver = true;
		}
		nav.menuseq++;
		nav.menu[nav.menuseq] = navAnchor;
	}
	if (nav.menu[seq])
		nav.menu[seq].onmouseover();
}

// Adjust Layout
window.onload = function() {
	window.setInterval(function() {
		bodyEl = document.getElementById("body");
		subEl = document.getElementById("sub");
		if (!bodyEl || !subEl)
			return;
		if (bodyEl.offsetHeight < subEl.offsetHeight +  25) {
			bodyEl.style.height = subEl.offsetHeight + "px";
		}
	}, 2000);
}

function initBoardList() {
	boardPager = document.getElementById("board-pager");
	if (boardPager)
		boardPager.getElementsByTagName("li").item(2).style.borderStyle = "none";
}
function initBoardViewPhoto() {
	imageContainer = document.getElementById("attach-photo");
	if (imageContainer) {
		imgEl = imageContainer.getElementsByTagName("img");
		for (i = 0; i < imgEl.length; i++) {
			if (imageContainer.offsetWidth < imgEl.item(i).offsetWidth) {
				imgEl.item(i).style.width = imageContainer.offsetWidth;
			}
		}
	}
}



function searchinctype(form){
		form.submit();
}

function moveList(f) {
	
	var check = false;
	var tmp = document.getElementsByName('list[]');

	for(i=0; i<tmp.length; i++) {
		if(tmp[i].checked == true) check = true;
	}
	
	if(check) {
		window.open('','moveWin','width=100,height=100,height=50,width=50');
		f.method = "post";
		f.target = "moveWin";
		f.action = "bd_alter_list.html";
		f.submit();
	} else {
		alert("변경할 게시물을 선택해 주세요.");
		return false;
	}
}


//글자크기 
//ex) onclick="setFontSize(+1);"	 onclick="setFontSize(-1);"
function wdSetFontSize(a) {
	window.clearInterval(document.getElementById("quick").move);
	
	var defaultFontSize = 1;//em
	var minFontSize = 1;//em
	var maxFontSize = 2;//em
	obj = document.getElementById("wrap");
	var objFontSize = obj.style.fontSize;
	if (!objFontSize) { objFontSize = parseFloat(defaultFontSize)+"em"; }
	var checkFontSize = (Math.round(12*parseFloat(objFontSize))+(a*2))/12;
	if (checkFontSize >= maxFontSize) { checkFontSize = maxFontSize; obj.style.fontSize = checkFontSize+"em"; alert("더이상 늘릴 수 없습니다."); }
	else if (checkFontSize <= minFontSize) { checkFontSize = minFontSize; obj.style.fontSize = checkFontSize+"em"; alert("더이상 줄일 수 없습니다."); }
	else { obj.style.fontSize = checkFontSize+"em"; }
	var array = document.getElementById("quick").style.top.split("px");
	document.getElementById("quick").style.top = (array[0]-275)+"px";
	initMoving(document.getElementById("quick"),275,66,250);
}

function wdSetRESize() {
	window.clearInterval(document.getElementById("quick").move);
	obj = document.getElementById("wrap");
	obj.style.fontSize = "1em";
	var array = document.getElementById("quick").style.top.split("px");
	document.getElementById("quick").style.top = (array[0]-275)+"px";
	initMoving(document.getElementById("quick"),275,66,250);
}

/* contents print*/
function fnPrint(){
	var width = 700;
	var height = 700;
	var popw = (screen.width - width) / 2;
	var poph = (screen.height - height) / 2;
	 p = contents.innerHTML; 
	ypwindow = window.open("", "Order_print", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width="+width+",height="+height+",top="+poph+",left="+popw);
	ypwindow.document.open();
	ypwindow.document.write("<html><head><title>경기도 파주교육청 콘텐츠화면인쇄 </title>");
	ypwindow.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/design/default/css/contents.css\" />");
	ypwindow.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/design/default/css/print.css\" />");
	ypwindow.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/design/default/css/board.css\" />");
	ypwindow.document.write("<script>window.print();</script>");
	ypwindow.document.write("</head>");
	ypwindow.document.write("<body>");
	ypwindow.document.write("<div id=\"printarea\">");
	ypwindow.document.write(p);
	ypwindow.document.write("</div>");
	ypwindow.document.write("</body>");
	ypwindow.document.write("</html>");
	ypwindow.document.close(); 
}


function openCBBWindow(id,skin){ 
	window.open("/G-PIN/Sample-AuthRequest.php?id="+id+"&skin="+skin,'CbaWindow', 'width=410, height=450, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=300, top=200' );
}

function openCBBWindow2(id, bbskind, skin){ 
	window.open("/G-PIN/Sample-AuthRequest.php?id="+id+"&bbskind="+bbskind+"&skin="+skin,'CbaWindow', 'width=410, height=450, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=300, top=200' );
}
/*유관기관사이트이동*/
function wjLink_go()
{
	var link_url = document.getElementById("select1").value;
	if(link_url) window.open(link_url);
	else alert("시/도교육청을 선택해 주세요");
}
function wjLink_go01()
{
	var link_url = document.getElementById("select2").value;
	if(link_url) window.open(link_url);
	else alert("지역교육청을 선택해 주세요");
}
function wjLink_go02()
{
	var link_url = document.getElementById("select3").value;
	if(link_url) window.open(link_url);
	else alert("교육관련사이트를 선택해 주세요");
}


var CBA_window; 

    function openCBAWindow(){ 
        CBA_window = window.open('', 'CbaV2Window_test', 'width=410, height=450, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=300, top=200' );

        if(CBA_window == null){ 
			 alert(" ※ 윈도우 XP SP2 또는 인터넷 익스플로러 7 사용자일 경우에는 \n    화면 상단에 있는 팝업 차단 알림줄을 클릭하여 팝업을 허용해 주시기 바랍니다. \n\n※ MSN,야후,구글 팝업 차단 툴바가 설치된 경우 팝업허용을 해주시기 바랍니다.");
        }

        document.reqCBAForm.action = 'https://name.siren24.com/vname/jsp/vname_j10.jsp';
        document.reqCBAForm.target = 'CbaV2Window_test';
    }


//글자크기 
//ex) onclick="setFontSize(+1);"	 onclick="setFontSize(-1);"
function wdSetFontSize(a) {
	window.clearInterval(document.getElementById("quick").move);
	
	var defaultFontSize = 1;//em
	var minFontSize = 1;//em
	var maxFontSize = 2;//em
	obj = document.getElementById("wrap");
	var objFontSize = obj.style.fontSize;
	if (!objFontSize) { objFontSize = parseFloat(defaultFontSize)+"em"; }
	var checkFontSize = (Math.round(12*parseFloat(objFontSize))+(a*2))/12;
	if (checkFontSize >= maxFontSize) { checkFontSize = maxFontSize; obj.style.fontSize = checkFontSize+"em"; alert("더이상 늘릴 수 없습니다."); }
	else if (checkFontSize <= minFontSize) { checkFontSize = minFontSize; obj.style.fontSize = checkFontSize+"em"; alert("더이상 줄일 수 없습니다."); }
	else { obj.style.fontSize = checkFontSize+"em"; }
	var array = document.getElementById("quick").style.top.split("px");
	document.getElementById("quick").style.top = (array[0]-275)+"px";
	initMoving(document.getElementById("quick"),275,66,250);
}

function wdSetRESize() {
	window.clearInterval(document.getElementById("quick").move);
	obj = document.getElementById("wrap");
	obj.style.fontSize = "1em";
	var array = document.getElementById("quick").style.top.split("px");
	document.getElementById("quick").style.top = (array[0]-275)+"px";
	initMoving(document.getElementById("quick"),275,66,250);
}

//png 
function setPng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =
	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src=''; 
	return '';
}
