﻿if (document.all)    {n=0;ie=1;fShow="visible";fHide="hidden";}
if (document.layers) {n=1;ie=0;fShow="show";   fHide="hide";}

window.onerror=new Function("return true")
////////////////////////////////////////////////////////////////////////////
// Function Menu()                                                        //
////////////////////////////////////////////////////////////////////////////


// font size : 
rightX = 0;
firstMenuItem = true;

menuColor = " ";
menuHlColor = " ";
menuTextColor = " ";
menuTextHlColor = " ";

submenuColor =  " ";
submenuHlColor = " ";
submenuTextColor = " ";
submenuTextHlColor = " ";


function Menu(menuColor1, submenuColor1, submenuHlColor1)
{
	
	this.addItem    = addItem;
	this.showMenu   = showMenu;
	this.mainPaneBorder = 0;

	this.addSubItem = addSubItem;
	this.subMenuPaneBorder = 1;
	this.subMenuPaneWidth = 120;
	
	this.rootUrl = "";
	
	menuColor = "";
	menuHlColor = "#000099";//"#47487e"//"#0000ff";//"#ff8000";//submenuColor1;
	menuTextColor = menuHlColor ;//submenuHlColor1;
	menuTextHlColor = "#ffffff";//menuColor1;

	submenuColor = "";
	submenuHlColor = menuHlColor;//"#4d4dff";// menuTextColor;//submenuHlColor1;
	submenuTextColor = menuTextColor;//submenuHlColor;//menuTextColor;//"#ffffff";// menuColor1;
	submenuTextHlColor = menuTextHlColor;//menuColor1;

	
	
	submenuOn = false; 
	hasSubmenu = false;

	lastMenu = null;

	
	lastMenuStyle = null;
	rightY = 0;
	leftY = 0;
	leftX = 0;
	firstchk = 0;

	HTMLstr = "<table id='TopMenu' cellspacing='0' cellpadding='1' bgcolor='"+menuColor+"' border='"+this.mainPaneBorder+"'>\n";
	HTMLstr += "<tr height=33>";

	HTMLstr += "<!-- MAIN MENU STARTS -->\n";
	HTMLstr += "<!-- MAIN_MENU -->\n";
	HTMLstr += "<!-- MAIN MENU ENDS -->\n";

	HTMLstr += "</tr>\n";
	HTMLstr += "</table>\n";
	
	HTMLstr += "\n";
	HTMLstr += "<!-- SUB MENU STARTS -->\n";
	HTMLstr += "<!-- SUB_MENU -->\n";
	HTMLstr += "<!-- SUB MENU ENDS -->\n";
	HTMLstr += "\n";	

}
function addItem(idItem, text, hint, location)
{
	var Lookup = "<!-- ITEM "+idItem+" -->";
	if (HTMLstr.indexOf(Lookup) != -1)
	{
		alert(idParent + " already exist");
		return;
	}
	var MENUitem = "";
	MENUitem += "\n<!-- ITEM "+idItem+" -->\n";
	

	// add deliminator between menu items
//	if(firstMenuItem)
//	{
//		firstMenuItem = false;
//	}
//	else
//	{
	//	MENUitem +="<td style='font-family:굴림;font-size: 14;font-weight: bold'>|</td>\n";
//		MENUitem +="<td style='font-family:굴림;font-size: 14;font-weight: bold;";
//		MENUitem += " color:" + menuColor + "'>|</td>\n";
//	}

	MENUitem += "<td id='" + idItem + "' nowrap=true class='font2' valign='bottom'";
	if (location != null)
		MENUitem += "href='"+this.rootUrl+"/"+location+"' ";
	else
		MENUitem += "href='.' ";
	
	if (hint != null) MENUitem += "title='"+hint+"' ";

//	MENUitem += "onmouseOver=\"displaySubMenu('"+idItem+"')\" ";
	MENUitem += "onmouseEnter=\"displaySubMenu('"+idItem+"')\"  ";
	MENUitem += "onclick=\"_openPage(this.href)\" ";
	MENUitem += " style='position:relative;font-family: 굴림;font-size: 14;font-weight: bold;cursor:pointer;padding-left:12;padding-right:12; border-bottom:0px solid #bf0000;  ";
	MENUitem += " color:" + menuTextColor + "'>";
	MENUitem += text;

	MENUitem += "</td>\n";

	MENUitem += "<!-- END OF ITEM "+idItem+" -->\n\n";
	MENUitem += "<!-- MAIN_MENU -->\n";
	
	HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);
}

function addSubItem(idParent, text, hint, location)
{
	var MENUitem = "";

	Lookup = "<!-- ITEM "+idParent+" -->";
	if (HTMLstr.indexOf(Lookup) == -1)
	{
		alert(idParent + " not found");
		return;
	}

	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
	
	var firstItem = false;
	if (HTMLstr.indexOf(Lookup) == -1)
	{
		MENUitem += "\n";
		MENUitem += "<div id='"+idParent+"submenu' style='position:absolute; visibility: hidden;'>\n";

		MENUitem += "<table bgcolor='"+submenuColor+"' cellpadding='6' cellspacing='0'>\n";

		MENUitem += "<tr>\n<td nowrap=true onmouseover=\"highlightSubmenu(this, true)\" onmouseout=\"highlightSubmenu(this, false)\" ";
		if (location != null)
			MENUitem += "href='"+this.rootUrl+"/"+location+"' ";
		else
			MENUitem += "href='.' ";
		MENUitem += "onClick=\"_openPage(this.href)\" " ;
//		MENUitem += "style='position:relative;font-family: 굴림; font-size: 12; font-weight: bold;cursor:pointer;  "
		MENUitem += "style='position:relative;font-family: 굴림; font-size: 12; font-weight: normal;cursor:pointer;"
		MENUitem += "color:"+submenuTextColor+"'> \n";
			
		MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
		MENUitem += "</td>\n</tr>\n" ;
		MENUitem += "</table>\n";
		MENUitem += "</div>\n";
		MENUitem += "\n";
	

		MENUitem += "<!-- SUB_MENU -->\n";
		HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
		
		firstItem = true;
	}

	Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";

	MENUitem = "";
	if(!firstItem)
	{
//		MENUitem = "|</td>\n<td  nowrap=true onmouseover=\"highlightSubmenu(this, true)\" onmouseout=\"highlightSubmenu(this, false)\">\n";
		MENUitem = "</td>\n<td  nowrap=true onmouseEnter=\"highlightSubmenu(this, true)\" onmouseLeave=\"highlightSubmenu(this, false)\" "
		if (location != null)
			MENUitem += "href='"+this.rootUrl+"/"+location+"' ";
		else
			MENUitem += "href='.' ";
		MENUitem += "onClick=\"_openPage(this.href)\" ";
		MENUitem += "style='position:relative;font-family: 굴림; font-size: 12; font-weight: normal;cursor:pointer; "
//		MENUitem += "style='position:relative;font-family: 굴림; font-size: 12; font-weight: bold;cursor:pointer; "
		MENUitem += "color:"+submenuTextColor+"'> \n";
	}

	MENUitem += text;

	MENUitem += Lookup;
	HTMLstr = HTMLstr.replace(Lookup, MENUitem);
}

function showMenu()
{	
	document.writeln(HTMLstr);
}

////////////////////////////////////////////////////////////////////////////
// Private declaration


function getSubMenuItems(idMainMenu)
{
	var	submenu = eval(idMainMenu+"submenu");
	
	// submenu <div>의 <table>에 들어 있는 모든 cell Array를 구함 
	var cells = submenu.firstChild.cells;

	// get true submenu items excluding deliminator '|' 
	var i;
	var j;
	var items = new Array();	
	for(i = 0, j = 0; i < cells.length; i++)
	{
//		if(i % 2 > 0) continue;
		// collect text of the link in current cell
		items[j] = cells[i].firstChild;
		j++;
	}	

	return items;
}

function getMenuID(pos)
{
	var menuTable = eval("TopMenu");
	
	return menuTable.cells[pos].firstChild.id;
}

function sideMenuInfo()
{
	
	this.title = "none";
	this.selected = -1;
	
	var curLocation = String(document.location).toLocaleLowerCase();

	var isZeroboard = (curLocation.search(RegExp("id=")) > 0) ? true : false;
	
	var menuTable = eval("TopMenu");
	

	for(var i = 0; i < menuTable.cells.length; i++)
	{
		var submenu = eval(menuTable.cells[i].id + "submenu");
		
		var cells = submenu.firstChild.cells;

		for(var j = 0; j < cells.length; j++)
		{			
		    var href = String(cells[j].href).toLocaleLowerCase();
		    var found = false;
			if(isZeroboard)
			{
				// RegExp의 parameter내에 "?"가 포함된경우 문제를 피함
				var pos = href.search(RegExp("id="));
				if(pos >= 0)
				{
					href = href.substr(pos, href.length - pos);
					if(curLocation.match(href)) found = true;
				}
			}
			else 
			{
				if(curLocation == href) found = true;
			}
			if(found) 
			{
				this.title = menuTable.cells[i].innerText;
				this.curItemId = j;
				this.items = new Array();
				for(var k = 0; k < cells.length; k++)
				{
					this.items[k] = cells[k];
				}
				
				break;
			}
		}
		if(this.submenuId >= 0) break;
	}

	
	return this;			
}	

function displaySubMenu(idMainMenu)
{
	
	var menu;
	var submenu;
	var submenuStyle;

	menu = eval(idMainMenu);
	
	// highlight current menu item	
	// color로 강조
//	menu.bgColor = menuHlColor;
//	menu.style.color = menuTextHlColor;
	// bottom line으로 강조
	menu.style.borderBottomWidth = "3px";

	// submenu가 없는 경우를 체크
	try
	{
		submenu = eval(idMainMenu+"submenu");
	
		submenuStyle = eval(idMainMenu+"submenu.style");
	
	}
	catch(err)
	{
		if (lastMenuStyle != null && lastMenuStyle != submenuStyle) hideAll();
		lastMenu = menu;
		lastMenuStyle = null;
		submenuOn = false;
		hasSubmenu = false;
		return;
	}

	hasSubmenu = true;
	submenuStyle.left = calculateSumOffset(menu, 'offsetLeft');
	submenuStyle.top  = calculateSumOffset(menu, 'offsetTop') + menu.offsetHeight;
		
	/*
		// align submenu left to current menu left	
		x = parseInt(submenuStyle.left, 10) + menu.offsetWidth * 0.5 - submenu.clientWidth * 0.5;
		submenuStyle.left = x+"px";
	*/
	
	// align submenu left to current menu table left 
	// If submenu right goes over menu table right, align submenu right to menu table right
/*
	var menuTable = eval("TopMenu").parentElement;
	var right = menuTable.offsetLeft + menuTable.offsetWidth;
	if(parseInt(submenuStyle.left, 10) + submenu.clientWidth > right)
	{ 	
		submenuStyle.left = (right - submenu.clientWidth) + "px";
	}

*/
//	submenu.top  = menu.style.top+40;
	submenuStyle.visibility = fShow;

	if (lastMenuStyle != null && lastMenuStyle != submenuStyle) hideAll();

	leftX  = document.all[idMainMenu+"submenu"].style.posLeft;
	rightX = leftX + document.all[idMainMenu+"submenu"].offsetWidth;
	leftY  = document.all[idMainMenu+"submenu"].style.posTop + document.all[idMainMenu+"submenu"].offsetHeight;
	rightY = leftY;
		

	lastMenuStyle = submenuStyle;
	lastMenu = menu;
	
	submenuOn = true;
}

function hideSubMenu(idmainMenu)
{
	submenuStyle = eval(idMainMenu+"submenu.style");
	submenuStyle.visibility = fHide;
	eval(idMainMenu).style.cursor = "auto";
			
}


function hideAll()
{
	if (lastMenuStyle != null) 
	{
		lastMenuStyle.visibility = fHide;
		lastMenuStyle.left = 0;

		lastMenuStyle = null;

	}
	if(lastMenu != null)
	{
//		window.status = lastMenu.id;
//		lastMenu.bgColor = menuColor;
//		lastMenu.style.color = menuTextColor;
		lastMenu.style.borderBottomWidth = "0px";
//		lastMenu = null;
	}
//	window.status = " ";
	submenuOn = false;
}

function calculateSumOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = eval('idItem');
	do
	{
		totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}

function updateBody(e)
{

	if(submenuOn == true)
	{
		var x = window.event.clientX;
		var y = window.event.clientY;
		if (x > rightX || x < leftX) 
			hideAll();
		else if(y > rightY) 
			hideAll();
				
		if(lastMenu)
		{
			 var top = calculateSumOffset(lastMenu, 'offsetTop');
			// When cursor is over menu item bottom
			 if(y < top + lastMenu.offsetHeight)
			{
				if(y < calculateSumOffset(lastMenu, 'offsetTop') ) hideAll();
				var left = calculateSumOffset(lastMenu, 'offsetLeft');
				if(x < left) hideAll();
				if(x > left + lastMenu.offsetWidth) hideAll();
//				window.status = lastMenu.href;
	
			}
		}

	}
}
function updateTitleBar(e)
{
	if(submenuOn == true)
	{
		var x = window.event.clientX;
		var y = window.event.clientY;
		if (x > rightX || x < leftX) 
			hideAll();
		else if(y > rightY) 
			hideAll();
				
		if(lastMenu)
		{
			 var top = calculateSumOffset(lastMenu, 'offsetTop');
			// When cursor is over menu item bottom
			 if(y < top + lastMenu.offsetHeight)
			{
				if(y < calculateSumOffset(lastMenu, 'offsetTop') ) hideAll();
				var left = calculateSumOffset(lastMenu, 'offsetLeft');
				if(x < left) hideAll();
				if(x > left + lastMenu.offsetWidth) hideAll();
//				window.status = lastMenu.href;
	
			}
		}

	}
}

function highlightSubmenu(submenu, highlight)
{
	if(highlight == true)
	{
//		submenu.bgColor = submenuHlColor;
//		submenu.style.color = submenuTextHlColor;
		submenu.style.fontWeight = "bold";
//		submenu.style.fontSize = "14";
		window.status = submenu.href;
	}
	else
	{
//		submenu.bgColor = submenuColor;
//		submenu.style.color = submenuTextColor;
		submenu.style.fontWeight = "normal";
//		submenu.style.fontSize = "12";
		window.status = " ";
	}
}


function highlightMenu(menu, highlight)
{
	if(highlight == false)
	{
		menu.bgColor = menuColor;
		menu.style.color = menuTextColor;
		menu.style.borderBottomWidth = "10px";
		window.status = " ";
	}
	else
	{
		menu.bgColor = menuHlColor;
		menu.style.color = menuTextHlColor;
		menu.style.borderBottomWidth = "0px";
	}
}

function highlightSidemenu(sidemenu, highlight)
{
	if(highlight == true)
	{
	//	sidemenu.parentElement.bgColor = submenuHlColor;
//		sidemenu.style.textDecoration = "underline";
		sidemenu.style.fontWeight = "bold";
		sidemenu.style.cursor = "hand";
		
	}
	else
	{
	//	sidemenu.parentElement.bgColor = submenuColor;
//		sidemenu.style.textDecoration = "none";
		sidemenu.style.fontWeight = "normal";
		sidemenu.style.cursor = "auto";
	}
}
	
function onLoad()
{
//	window.status = "loaded";
//	document.getElementById("menuTable").onmousemove=updateTitleBar;
	var menuTable = eval("TopMenu").parentElement;
	menuTable.onmousemove=updateTitleBar;

//window.status = document.getElementById("titleBar").id;

}

if (document.all)
{
	document.body.onclick=hideAll;
	document.body.onscroll=hideAll;
	document.body.onmousemove=updateBody;
//	document.body.onload = onLoad;	

}


// for side menu
function _openPage(href)
{
	document.location = href;
}
function blurLink(link)
{
	link.blur();
}
function SideMenu()
{
	var info = new sideMenuInfo();
	
	var str;
	
	// make table for side menu
	str = "<table id='SideMenu' width ='100%' cellspacing='3' cellpadding='0' bgcolor='' border='0'>\n"	
	
	
	// make title cell
	titleColor = eval("TopMenu").parentElement.bgColor;
	str += "<tr height = '40' > <td bgColor='" + titleColor + "' ";
	str += "style='font-family: 굴림; font-size:18; font-weight: bold; color:#000000; padding-left: 0px; padding-top: 20px;'>\n";
//	str += info.title +"&nbsp;&nbsp;<img src='/bbs/downArrow.gif' height='4' align='center'>"+ "</td>\n";
	if(info.title != "none") 
	{
		str += info.title + "</td>\n";
		
	
		// make submenu cells
		for(var i = 0; i < info.items.length; i++)
		{
			str += "<tr height ='20'> \n";
		    str += "<td bgColor='' style='padding-left:0px;'>";
			if(i == info.curItemId)
			{
				str += "<a href='" +  info.items[i].href + "' style='font-family:굴림; font-size:14; font-weight:bold;text-decoration:none;";
				str += "color:"+menuTextColor+"'";
				str += "onFocus=\"blurLink(this)\" >\n" ;
				str += info.items[i].innerText + "</a>"+"&nbsp;&nbsp;&nbsp;<img src='/bbs/rightArrow.gif'  width='4' align='center'>"+"</td></tr>\n";
			}
			else
			{
				str += "<a href='" +  info.items[i].href + "' style='font-family:굴림; font-size:14; font-weight:normal;text-decoration:none;";
				str += "color:"+menuTextColor+"'";
				str += "onmouseEnter=\"highlightSidemenu(this, true)\" onmouseLeave=\"highlightSidemenu(this, false)\" onFocus=\"blurLink(this)\" >\n" ;
			str += info.items[i].innerText + "</a></td></tr>\n";
			}
				   
		}
		
	}
	else
	{
		str += "</td>\n";
	}


	// 위/경도 찾기,게시판 이외의 페이지의 경우에 사이드 메뉴에 인쇄 기능 추가
//	url = String(document.location);
	if(String(document.location).search(RegExp("latLng.php")) < 0 && String(document.location).search(RegExp("id=")) < 0)
	{
		if(info.title != "none")
		{
			str += "<tr height ='20'><td bgColor='' style='padding-left:0px;font-family:굴림; font-size:14; font-weight:normal;";
//			str += "text-decoration:none;color:"+menuTextColor+";'>------------"+"</td></tr>\n";
			str += "text-decoration:none;color:"+menuTextColor+";'>――――――――――――"+"</td></tr>\n";
		}

		str += "<tr height ='20'><td bgColor='' style='padding-left:0px;font-family:굴림; font-size:14; font-weight:normal;";
		str += "text-decoration:none;color:"+menuTextColor+";'";
/*
		str += "onmouseEnter=\"highlightSidemenu(this, true)\" onmouseLeave=\"highlightSidemenu(this, false)\" onFocus=\"blurLink(this)\"  onClick=\"printContents()\">내용 인쇄</td></tr>\n";
*/	
		/*	str += "onmouseEnter=\"highlightSidemenu(this, true)\" onmouseLeave=\"highlightSidemenu(this, false)\" onFocus=\"blurLink(this)\"  onClick=\"window.open('/bbs/printContents.htm')\">내용 인쇄</td></tr>\n";
		*/
			str += "onmouseEnter=\"highlightSidemenu(this, true)\" onmouseLeave=\"highlightSidemenu(this, false)\" onFocus=\"blurLink(this)\"  onClick=\"if(eval('iframe')=='[object]'){iframe.focus();iframe.print();/*history.go(1);*/}else{ printContents();}\">내용 인쇄</td></tr>\n";
		
	}
	
	// add information
	for(i = 0; i < 5; i++)
	{
		str += "<tr height = '20'> <td bgColor='' style='padding-left:0px;'>  </td></tr>\n"; // 빈 줄
	}
	str += "<tr height = '20'> <td bgColor='' ";
	str += "style='font-family: 굴림; font-size:18; font-weight: bold; color:#484848; padding-left: 0px;'>전화문의</td></tr>\n";
	str += "<tr height = '20'> <td bgColor='' ";
	str += "style='font-family: 굴림; font-size:14; font-weight: bold; color:#484848; padding-left: 0px;'><font color='#808080'>상호</font>&nbsp;&nbsp;씨쓰데브</td></tr>\n";
	str += "<tr height = '20'> <td bgColor='' ";
	str += "style='font-family: 굴림; font-size:14; font-weight: bold; color:#484848; padding-left: 0px;'><font color='#808080'>전화</font>&nbsp;&nbsp;02-6237-1981</td></tr>\n";
	str += "<tr height = '20'> <td bgColor='' ";
	str += "style='font-family: 굴림; font-size:14; font-weight: bold; color:#484848; padding-left: 0px;'>";
	str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;010-4753-1981</td></tr>\n";

	str += "</table>\n";
	
	document.write(str);	
	
	return this;
}


