var mmenu = new Array(); // Data를 담을 배열

// 2차배열을 만들기 위한 function
function addData(sseq,uupperSeq,ttile,uurl,ttarget, ssubYn, eengTitle){
	mmenu[sseq] = new Array();
	mmenu[sseq][0] = uupperSeq; // 상위seq
	mmenu[sseq][1] = ttile;     // 메뉴 제목
	mmenu[sseq][2] = uurl;      // URL
	mmenu[sseq][3] = ttarget;   // URL의 Target
	mmenu[sseq][4] = ssubYn;    // 하위메뉴 존재여부
	mmenu[sseq][5] = eengTitle; // 메뉴 영문제목
	return;
}

// 메뉴의 제목을 페이지에 작성하는 function
function getTitle(sseq){
	document.write(mmenu[sseq][1]);
	return;
}

// 서브페이지의 큰 제목표시 function
function getTitleWithSpace(sseq) {
	var temp = mmenu[sseq][1];
	var result = '';

	for (var i=0; i<temp.length; i++) {
		result = result + temp.charAt(i);
		if (i < (temp.length-1)) {
			result = result + "&nbsp;";
		}
	}

	document.write(result);
	return;
}

// history를 구성하기 위한 function
function historyWrite(sseq){
	var HistoryTmp  = "";
	var seqTmp      = sseq;
	var upperSeqTmp = -1;

	// 무한반복을 막기위해 for문이용 1000번으로 제한
	for(i=0; i<1000 && seqTmp!=upperSeqTmp; i++){
		if(HistoryTmp=="")
			HistoryTmp  = " / " + "<a href=\""+mmenu[seqTmp][2]+"\" target=\""+mmenu[seqTmp][3]+"\" style=\"font-family:Arial;font-size:8pt; FONT-WEIGHT:bold;color:#777777;text-decoration:none;\">"+mmenu[seqTmp][1]+"</a>" + HistoryTmp;
		else
			HistoryTmp  = " / " + "<a href=\""+mmenu[seqTmp][2]+"\" target=\""+mmenu[seqTmp][3]+"\" style=\"font-family:Arial;font-size:8pt;color:#777777;text-decoration:none;\">"+mmenu[seqTmp][1]+"</a>" + HistoryTmp;

		seqTmp      = mmenu[seqTmp][0];
		upperSeqTmp = mmenu[seqTmp][0];
	}
	if(sseq!=0)
	HistoryTmp = " / <a href=\"/info_tech/\" target=\"_top\" style=\"font-family:Arial;font-size:8pt;color:#777777;text-decoration:none;\">정보기술원</a>"+HistoryTmp;

	document.write(HistoryTmp);
	return;
}

// 메뉴를 구성하는 function
function menuWrite(sseq){
	var sseq2 = -100; // 실제 메뉴를 보여주게 될 seq를 담을 변수 코드의 메뉴가 하위메뉴를 갖느냐 안갖느냐에 달려있다.
	if(mmenu[sseq][4]=='N') sseq2=mmenu[sseq][0]; // sseq의 메뉴가 하위메뉴가 없을때는 그것의 상위 메뉴가 보여진다.
	else                    sseq2=sseq;           // sseq의 메뉴가 하위메뉴가 있을때는 해당 메뉴가 보여진다.

	document.write("<table width=\"160\" bgcolor=\"#E5E5E5\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("<tr>");
	document.write("<td height=\"58\" bgcolor=\"#CCCCCC\" style=\"PADDING-TOP:2px;BORDER-BOTTOM:2px solid #999999;\">");
	document.write("<table width=\"145\" cellspacing=\"0\" cellpadding=\"0\" style=\"COLOR:#777777;FILTER:blur(add=1,direction=90,strength=2);\">");
	document.write("<tr>");
	document.write("<td align=\"right\" style=\"FONT-FAMILY:바탕;FONT-SIZE:16px;FONT-WEIGHT:bold;\">");
	document.write(mmenu[sseq2][1]);
	document.write("</td>");
	document.write("</tr>");
	//document.write("<tr>");
	//document.write("<td align=\"right\" style=\"FONT-FAMILY:굴림;FONT-SIZE:12px;\">");
	//document.write(mmenu[sseq2][5]);
	//document.write("</td>");
	//document.write("</tr>");
	document.write("</table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td align=\"center\">");
	document.write("<table width=\"145\" cellspacing=\"0\" cellpadding=\"0\" style=\"FONT-FAMILY:굴림; FONT-SIZE:12px; FILTER: blur(add=1,direction=90, strength=2);\">");

	for(i=0; i<mmenu.length; i++){
		if(mmenu[i]!=null&&mmenu[i][0]==sseq2&&i!=0){
			document.write("<tr>");
			document.write("<td align=\"right\" height=\"29\"style=\"border-bottom:1px dashed #999999;PADDING-TOP:4px;\">");
			document.write("<a href=\""+mmenu[i][2]+"\" target=\""+mmenu[i][3]+"\" style=\"color:#777777;text-decoration:none;\">");
			document.write(mmenu[i][1]);
			document.write("</a>");
			document.write("</td>");
			document.write("</tr>");
		}
	}

	document.write("</table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
	document.write("<div id=\"ttop\" style=\"position:absolute;left:0px;top:0px;\"></div>");
	return;
}


// top 버튼을 위한 스크립트 ===========================

var Hoffset=810; // 화면의 왼쪽   여백
var Voffset=25;  // 화면의 아래쪽 여백


var ie_ccheck   = document.all && navigator.userAgent.indexOf("Opera") == -1; // 브라우저 종류확인
var written_obj ; // html을 쓰기위한 객체
var dsocleft    ; // 스크롤된 x좌표

function write_html(){
	var htmlString = "<table cellspacing='0' cellpadding='0' width='35' bgcolor='#FFFFFF'>";
	htmlString    += "<tr>";
	htmlString    += "<td align='center'>";
	htmlString    += "<a href='javascript:window.scroll(0,0)' style='font-family:Arial;font-size:12px;color:#666666;text-decoration:none;'><img src='/image/button_gotop.gif' border='0'></a>";
	htmlString    += "</td>";
	htmlString    += "</tr>";
	htmlString    += "</table>";
	if(written_obj!=null){
		if (ie_ccheck||document.getElementById){
			written_obj.innerHTML=htmlString;
		}
		else if (document.layers){
			written_obj.document.write(htmlString);
			written_obj.document.close();
		}
	}
}

function position_init(){
	written_obj = ie_ccheck? document.all.ttop : document.getElementById? document.getElementById("ttop") : document.ttop
	dsocleft = ie_ccheck ? document.body.scrollLeft : pageXOffset;

	var dsoctop  = ie_ccheck ? document.body.scrollTop  : pageYOffset;
	var window_height = ie_ccheck ? document.body.clientHeight : window.innerHeight;

	if(written_obj!=null){
		if (ie_ccheck || document.getElementById){
			written_obj.style.left = Hoffset;
			written_obj.style.top  = parseInt(dsoctop) + parseInt(window_height) - Voffset;
		}
		else if (document.layers){
			written_obj.left = Hoffset;
			written_obj.top  = dsoctop + window_height - Voffset;
		}
	}
}

function beingwatermark(){
	position_init();
	setInterval("position_init()",500);
	write_html();
}

if (ie_ccheck||document.getElementById||document.layers) window.onload=beingwatermark;

// 사이트맵 구성을 위한 스크립트 ===========================
/* 컬러지정
 * width - 테이블너비
 * color1 - 큰제목 배경색
 * color2 - 큰제목 글자색, 하위메뉴 글자색, 점선색
 * color3 - 하위메뉴 배경색
 * color4 - 하위의 하위메뉴 글자색
 * color5 - 하위의 하위메뉴 배경색
 * color6 - 공백색
*/
function sitemapWrite(sseq, width, color1, color2, color3, color4, color5, color6){

	document.write("<table width=\""+width+"\" height=\"100%\" bgcolor=\""+color6+"\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("<tr>");
	document.write("<td height=\"58\" bgcolor=\""+color1+"\" style=\"PADDING-TOP:2px;BORDER-BOTTOM:2px solid #6A9FAF;\">");
	document.write("<table width=\""+(width-6)+"\" cellspacing=\"0\" cellpadding=\"0\" style=\"COLOR:"+color2+";FILTER:blur(add=1,direction=90,strength=2);\">");
	document.write("<tr>");
	document.write("<td align=\"left\" style=\"FONT-FAMILY:바탕;FONT-SIZE:16px;FONT-WEIGHT:bold;PADDING-LEFT:10px\">");
	document.write(mmenu[sseq][1]);
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td align=\"left\" style=\"FONT-FAMILY:굴림;FONT-SIZE:12px;PADDING-LEFT:10px\">");
	document.write(mmenu[sseq][5]);
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td align=\"center\" valign=\"top\">");
	document.write("<table width=\""+width+"\" cellspacing=\"0\" cellpadding=\"0\" style=\"FONT-FAMILY:굴림; FONT-SIZE:12px; FILTER: blur(add=1,direction=90, strength=2);\">");

	for(i=0; i<mmenu.length; i++){
		if(mmenu[i]!=null&&mmenu[i][0]==sseq){
			document.write("<tr>");
			document.write("<td align=\"right\" height=\"29\"style=\"border-bottom:1px dashed "+color2+";PADDING-TOP:4px;PADDING-RIGHT:10px;\" bgcolor=\""+color3+"\">");
			document.write("<a href=\""+mmenu[i][2]+"\" target=\""+mmenu[i][3]+"\" style=\"color:"+color2+";text-decoration:none;\">"+mmenu[i][1]+"</a> <img src=\"/image/sub_history_01.gif\">");
			document.write("</td>");
			document.write("</tr>");

			if(mmenu[i][4] == 'Y'){
				for(j=0; j<mmenu.length; j++){
					if(mmenu[j]!=null&&mmenu[j][0]==i){
						document.write("<tr bgcolor=\"#"+color5+"\">");
						document.write("<td align=\"right\" height=\"29\"style=\"border-bottom:1px dashed "+color2+";PADDING-TOP:4px;PADDING-RIGHT:20px;\" bgcolor=\""+color5+"\">");
						document.write("<a href=\""+mmenu[j][2]+"\" target=\""+mmenu[j][3]+"\" style=\"color:"+color4+";text-decoration:none;\">"+mmenu[j][1]+"</a>");
						document.write("</td>");
						document.write("</tr>");
					}
				}
			}
		}
	}

	document.write("</table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr><td bgcolor=\""+color6+"\">&nbsp;</td></tr>");
	document.write("</table>");
	return;
}
