if(!g_arrTreeIndex)
{

	var g_bInitialize		= false;
//	Àü¿ªº¯¼ö
	var g_arrTreeIndex		= new Array;
	var g_nTreeCount		= 0;
	var g_nLastOpenIndex	= 0;

	var g_szIconImagPath	= "/_Images/";
	
	var g_nRootLevel		= 0;
	var g_pStartNode		= null;
	var g_pStartNodeParent	= null;
	
	var g_strNowPathLink		= "";
	var g_strDocumentTitle		= "";
	
	var g_dwNowNode			= null;
	
	var g_strNowPathDir		= "";
	
	

	var g_strSiteName		= 'Danyang-gun English Homepage ';

	var g_strOverColor		= "#78C844";
	var g_strOutColor		= "#000000";


// (STRUCT)	µð·ºÅä¸® ¹× ÆÄÀÏ struct

	function scTree(dwSeq, dwThread, nDepth, strCode, strCategoryName, bType, strPath, strTop, strBottom, dwInCount)
	{
		// ±¸Á¶Ã¼ º¯¼ö
		this._dwSeq				= dwSeq;
		this._dwThread			= dwThread;
		this._nDepth			= nDepth;
		this._strCode			= strCode;
		this._strCategoryName	= strCategoryName;
		this._bType				= bType;
		this._strPath			= strPath;
		this._strTop			= strTop;
		this._strBottom			= strBottom;
		this._dwInCount			= dwInCount;
		
		this._nId			= -1;
		this._arrChildren	= new Array;
		this._nChildren		= 0;
		this._bIsLastNode	= false;
		this._bIsOpen		= false;
		this._blsShow		= false;
		this._szExtImage	= '';
		this._blsPath		= false;
		
		// »ý¼ºÀÚ
		this.CreateIndex	= CreateIndex;
		
		// ±¸Á¶Ã¼ ÇÔ¼ö
		this.Initialize		= Initialize;
		this.AddChild		= AddChild;
		this.TagPrint		= TagPrint;
		this.ShowTree		= ShowTree;
		this.HiddenTree		= HiddenTree;
		this.ClickNode		= ClickNode;
		
		
		this._objTable		= null;			//	Tree_~
		this._objTdNode		= null;			//	TreeNode_~
	}




















/***********************************************************
	STRUCT FUNCTION
***********************************************************/

//	(S)	ÀÎµ¦½º »ý¼º
//		: »õ·Î »ý¼ºµÈ ±¸Á¶Ã¼ÀÇ ÀÎµ¦½º¸¦ Á¤ÀÇ ÇÏ¸ç Àü¿ª¹è¿­Çü º¯¼ö³»¿¡ ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ°ªÀ» ÀúÀå
	function CreateIndex()
	{
		this._nId	= g_nTreeCount;
		g_arrTreeIndex[g_nTreeCount]	= this;
		g_nTreeCount++;
	}
	


//	(S)	±¸Á¶Ã¼³»ÀÇ Initialize ÇÔ¼ö
//		: 
	function Initialize(bIsLastNode)
	{
		this.CreateIndex();
		
		if(this._nChildren > 0)
		{
			for(var i=0; i<this._nChildren; i++)
			{
				if(i == (this._nChildren - 1))
					this._arrChildren[i].Initialize(true);
				else
					this._arrChildren[i].Initialize(false);
			}
		}
		
		this._bIsLastNode	= bIsLastNode;
	}



//	(S)	±¸Á¶Ã¼³» ÀÚ½ÄÃß°¡ ÇÔ¼ö		(return ptChildrenNod)
//		: ÇöÀç ±¸Á¶Ã¼³»ÀÇ ÀÚ½Ä³ëµå Ãß°¡
	function AddChild(ptChildrenNod)
	{
		this._arrChildren[this._nChildren]	= ptChildrenNod;
		this._nChildren++;
		
		return	ptChildrenNod;
	}


//	(S) ÇØ´ç ³ëµåÀÇ Ãâ·Â¿ë Å×±×¸¦ ÀÛ¼º ÈÄ Ãâ·Â
	function TagPrint()
	{
		var strTag	= "";
		//var strNameClickEvent	= " onclick=\"Event_onClick_Name(" + this._nId + ");Goto_Link(" + this._nId + ");\" onmouseover=\"Event_onMouseOver_Name(" + this._nId + ");\" onmouseout=\"Event_onMouseOut_Name(" + this._nId + ");\"";
		var strNameClickEvent	= " onclick=\"Event_onClick_Name(" + this._nId + ");Goto_Link(" + this._nId + ");\" onmouseover=\"Event_onMouseOver_Name(" + this._nId + ");\" onmouseout=\"Event_onMouseOut_Name(" + this._nId + ");\"";
		
		if(this._nDepth - g_nRootLevel >= 0)

		{

			// ÃÖ»óÀ§ ¼­ºê¸Þ´º
			if(this._nDepth - g_nRootLevel == 1)
			{
				strTag	=	'<table border="0" width="166" cellpadding="0" style="border-collapse: collapse" id="Table_'+ this._nId +'" style="display:block;"><tr><td width="23" align="center" height="30"><img border="0" src="';
				strTag	+=	g_szIconImagPath + 'bl_submenu.gif" width="11" height="11"></td><td height="30" id="Td_'+ this._nId +'" '+ strNameClickEvent +' style="font-weight: bold;">';
				strTag	+=	this._strCategoryName + '</td></tr><tr><td height="3" align="center" background="'+ g_szIconImagPath +'bg_menuline.gif" colspan="2"></td></tr></table>';
				
				this._blsShow		= true;
			}
			// µÎ¹øÀç ¼­ºê¸Þ´º
			else if(this._nDepth - g_nRootLevel == 2)
			{
				strTag	=	'<table border="0" width="166" cellspacing="0" cellpadding="0" height="26" id="Table_'+ this._nId +'" style="display:none;"><tr><td width="23"></td><td id="Td_'+ this._nId +'" '+ strNameClickEvent +'>&#8226; ';
				strTag	+=	this._strCategoryName + '</td></tr><tr><td colspan="2" background="'+ g_szIconImagPath +'bg_menuline1.gif" height="1"></td></tr></table>';
			}
			//	¼¼¹øÀç ¼­ºê
			else if(this._nDepth - g_nRootLevel == 3)
			{
				strTag	=	'<table border="0" width="166" cellspacing="0" cellpadding="0" height="21" id="Table_'+ this._nId +'" style="display:none;"><tr><td width="46"></td><td id="Td_'+ this._nId +'" '+ strNameClickEvent +'> ';
				strTag	+=	this._strCategoryName + '</td></tr></table>';
			}
			else
			{
				strTag	= "";
			}
			
			document.write(strTag);
		}
		
		try
		{
			this._objTable		= document.getElementById("Table_"+ this._nId);
		}
		catch(e)
		{
			this._objTable		= null;
		}
		
		try
		{
			this._objTdNode		= document.getElementById("Td_"+ this._nId);
		}
		catch(e)
		{
			this._objTdNode		= null;
		}
		
		
		if(this._nChildren > 0)
		{
			for(var i=0; i<this._nChildren; i++)
			{
				if(i == (this._nChildren - 1))
					this._arrChildren[i].TagPrint();
				else
					this._arrChildren[i].TagPrint();
			}
		}
	}
		
		
	
//	(S)	ÀÚ±â ÀÚ½Å º¸ÀÌ±â
	function ShowTree()
	{
		this._objTable.style.display	= "block";
		this._blsShow	= true;
	}
		
	
	
//	(S)	ÀÚ±â ÀÚ½Å ¼û±â±â
	function HiddenTree()
	{
		for(var i=0; i<this._nChildren; i++)
		{
			this._arrChildren[i].HiddenTree();
			
			if(this._arrChildren[i]._bIsOpen)
				this._arrChildren[i].ClickNode();
		}
		this._objTable.style.display	= "none";
		this._blsShow	= false;
	}



//	(S)	ÇØ´ç ³ëµåÅ¬¸¯½Ã ÀÌº¥Æ®
	function ClickNode()
	{
		// ÇØ´ç ÆäÀÌÁö·Î ÀÌµ¿
		if(this._nChildren > 0)
		{
			if(this._bIsOpen)
			{
				for(var i=0; i<this._nChildren; i++)
				{
					this._arrChildren[i].HiddenTree();
					
					if(this._arrChildren[i]._bIsOpen)
						this._arrChildren[i].ClickNode();
				}
				
				this._bIsOpen		= false;
				g_nLastOpenIndex	= null;
			}
			else
			{
				for(var i=0; i<this._nChildren;i++)
				{
					this._arrChildren[i].ShowTree();
					this._bIsOpen		= true;
				}
				
				this._bIsOpen		= true;
				g_nLastOpenIndex	= this._nId;
			}
		}
		else
		{
			this._bIsOpen		= true;
			g_nLastOpenIndex	= this._nId;
		}
	}
	
	
/***********************************************************
	GLOBAL FUNCTION
***********************************************************/

//	(G)	ÀÚ½Ä Ãß°¡					(return ptChildrenNod)

	function g_AddChild(ptParentNod, ptChildrenNod)
	{
		return ptParentNod.AddChild(ptChildrenNod);
	}
	

//	(G)	»õ·Î¿î Æ®¸®Ãß°¡				(return ptChildrenNod);
	function g_addList(dwSeq, dwThread, nDepth, strCode, strCategoryName, bType, strPath, strTop, strBottom, dwInCount)
	{
		var List	= new scTree(dwSeq, dwThread, nDepth, strCode, strCategoryName, bType, strPath, strTop, strBottom, dwInCount);
		return List;
	}
	
	

//	(G)	½ÇÁ¦ ½ÇÇàÇÔ¼ö
	function KnTree_Progress()
	{
		if(!g_bInitialize)
		{
			objList0.Initialize(false);
			g_bInitialize	= true;
		}
	}

//	(G) È­¸é Ãâ·Â
	function KnTree_Print()
	{
		if(g_pStartNode == null)
			return;
			
		// ºÎ¸ð ³ëµå ºÒ·¯¿À±â
		Set_StartNode_ParentNode();
		
		// Å×±× È­¸éÃâ·Â
		g_pStartNodeParent.TagPrint();
	}


//	(G)	Ã³À½ º¸¿©ÁÙ ³ëµå¼³Á¤
//	** ¼öÁ¤....
	function Set_ShowNode(nNode)
	{
		if(nNode == "" || nNode == null)
			nNode	= 1;
			
		for(var i=0;i<g_nTreeCount;i++)
		{
			if(g_arrTreeIndex[i]._nLevel <= nNode)
				g_arrTreeIndex[i].ShowTree();
		}
	}
	
//	(G)	Ã³À½ º¸ÀÏ ·çÆ® ¼³Á¤
	function Set_RootNode_Code(strCode)
	{
		for(var i=0; i<g_nTreeCount; i++)
		{
			if(g_arrTreeIndex[i]._strCode == strCode)
			{
				g_pStartNode	= g_arrTreeIndex[i];
				break;
			}
		}
		
		g_nRootLevel	= g_nStartNode._nDepth;
	}

	function Set_RootNode_CategoryName(strCategoryName)
	{
		if(strCategoryName == null || strCategoryName == "")
		{
			for(var i=0; i<g_nTreeCount; i++)
			{
				if(g_arrTreeIndex[i]._nDepth == 0)
				{
					pNowNode	= g_arrTreeIndex[i];
					break;
				}
			}
			return;
		}
		
		var arrCategoryName	= strCategoryName.split(">");
		var nCategoryNameLength	= arrCategoryName.length;

		var nMaxNode	= nCategoryNameLength;
		var pNowNode	= objList0;
		
		for(var i=0; i< nMaxNode; i++)
		{
			if(pNowNode._nChildren > 0)
			{
				for(var j=0; j<pNowNode._nChildren; j++)
				{
					if(pNowNode._arrChildren[j]._strCategoryName == arrCategoryName[i])
					{
						pNowNode	= pNowNode._arrChildren[j];
						break;
					}
				}
			}
		}
		
		if(pNowNode != null)
		{
			g_dwNowNode	= pNowNode._nId;
			g_pStartNode	= pNowNode;
			g_nRootLevel	= pNowNode._nDepth;
		}
	}
	
	
	function Set_StartNode_ParentNode()
	{
		if(g_pStartNode == null)
			return;
		
		var nNowDepth	= g_pStartNode._nDepth;
		var nNowId		= g_pStartNode._nId;

		if(nNowDepth == 1)
		{
			g_pStartNodeParent	= g_pStartNode;
		}
		else if(nNowDepth > 1)
		{
			for(var i=nNowId; i>0; i--)
			{
				if(g_arrTreeIndex[i]._nDepth == nNowDepth - 1)
				{
					g_pStartNodeParent	= g_arrTreeIndex[i];
					break;
				}
			}
		}
	}
	
	
	function Set_First_ShowNode_Code(strCode)
	{
		for(var i=0; i<g_nTreeCount; i++)
		{
			if(g_arrTreeIndex[i]._strCode == strCode)
			{
				g_arrTreeIndex[i].ClickNode();
				
				for(var j=g_arrTreeIndex[i]._nDepth; j>0; j--)
				{
					if(g_arrTreeIndex[j]._nDepth == g_arrTreeIndex[i]._nDepth - 1)
					{
						Set_First_ShowNode_Code(g_arrTreeIndex[j]._strCode);
					}
					break;
				}
			}
		}
	}
	
	

	function Set_First_ShowNode_CategoryName(strCategoryName)
	{
		if(strCategoryName == null || strCategoryName == "")
		{
		/*
			for(var i=0; i<g_nTreeCount; i++)
			{
				if(g_arrTreeIndex[i]._nDepth == 0)
				{
					pNowNode	= g_arrTreeIndex[i];
					break;
				}
			}
		*/
			return;
		}
		
		var arrCategoryName	= strCategoryName.split(">");
		var nCategoryNameLength	= arrCategoryName.length;

		var nMaxNode	= nCategoryNameLength;
		var pNowNode	= objList0;
		
		g_strNowPathLink	= "<a href=\"#\" onclick=\"Goto_Code_Link('"+ objList0._strCode +"');\">Home</a>";
		g_strDocumentTitle	= g_strSiteName;
		
		for(var i=0; i< nMaxNode; i++)
		{
			if(pNowNode._nChildren > 0)
			{
				for(var j=0; j<pNowNode._nChildren; j++)
				{
					if(pNowNode._arrChildren[j]._strCategoryName == arrCategoryName[i])
					{
						pNowNode			= pNowNode._arrChildren[j];
						pNowNode._blsPath	= true;
						pNowNode.ClickNode();
						
						g_strNowPathLink	+= " &gt; <a href=\"#\" onclick=\"Goto_Code_Link('"+ pNowNode._strCode +"');\">"+ pNowNode._strCategoryName +"</a>";
						g_strDocumentTitle	+= ">"+ pNowNode._strCategoryName;
						
						if(pNowNode._blsPath && pNowNode._objTdNode)
						{
							pNowNode._objTdNode.style.color	= g_strOverColor;
						}
						break;
					}
				}
			}
		}
		
		g_strNowPathLink	+= "&nbsp;&nbsp;&nbsp;&nbsp;"
		
		g_dwNowNode		= pNowNode;
	}
	
	
	function Get_ParentNodeId(nId)
	{
		if(g_nTreeCount > nId && nId > 0)
		{
			if(g_arrTreeIndex[nId]._nDepth > g_nRootLevel)
			{
				for(var i=nId - 1; i>=0; i--)
				{
					if(g_arrTreeIndex[nId]._nDepth == g_arrTreeIndex[i]._nDepth + 1)
					{
						return i;
					}
				}
			}
		}
		else
		{
			return 0;
		}
	}
	
	
	function Goto_Link(nId)
	{
		if(g_arrTreeIndex[nId]._nChildren == 0)
		{
			if(!g_arrTreeIndex[nId]._blsPath)
				location.href	= g_arrTreeIndex[nId]._strPath;
		}
	}
	
	
	function Goto_Code_Link(strCode, strQuery)
	{
		var pObj	= null;
		
		for(var i=0; i<g_nTreeCount; i++)
		{
			if(g_arrTreeIndex[i]._strCode == strCode)
			{
				pObj	= g_arrTreeIndex[i];
				break;
			}
		}
		
		if(!strQuery)
			strQuery	= '';
		
		if(pObj)
			location.href	= pObj._strPath + strQuery;
	}
	
	
	function Goto_Category_Link(strCategoryName, strQuery)
	{
		if(strCategoryName == null || strCategoryName == "")
		{
			return;
		}
		
		var arrCategoryName	= strCategoryName.split(">");
		var nCategoryNameLength	= arrCategoryName.length;

		var nMaxNode	= nCategoryNameLength;
		var pNowNode	= objList0;
		
		for(var i=0; i< nMaxNode; i++)
		{
			if(pNowNode._nChildren > 0)
			{
				for(var j=0; j<pNowNode._nChildren; j++)
				{
					if(pNowNode._arrChildren[j]._strCategoryName == arrCategoryName[i])
					{
						pNowNode	= pNowNode._arrChildren[j];
						break;
					}
				}
			}
		}
		
		if(!strQuery)
			strQuery	= '';
			
		location.href	= pNowNode._strPath + strQuery;
	}



	function Get_Category_Path_Print()
	{
		PrintTitle();
		document.write(g_strNowPathLink);
	}


	function Goto_Thread_Link(dwThread, strQuery)
	{
		var pObj	= null;
		
		for(var i=0; i<g_nTreeCount; i++)
		{
			if(g_arrTreeIndex[i]._dwThread == dwThread)
			{
				pObj	= g_arrTreeIndex[i];
				break;
			}
		}
		
		if(!strQuery)
			strQuery	= '';
				
		location.href	= pObj._strPath + strQuery;	
	}


	function Get_CategoryName_Object(strCategoryName)
	{
		var pObj	= null;
		
		for(var i=0; i<g_nTreeCount; i++)
		{
			if(g_arrTreeIndex[i]._strCategoryName == strCategoryName)
			{
				pObj	= g_arrTreeIndex[i];
				break;
			}
		}
		
		return pObj;
	}



	function PrintTitle()
	{
		top.document.title	= g_strSiteName;//g_strDocumentTitle;
	}
	
	
	function GetNowNode()
	{
		return (g_dwNowNode);
	}
	
	
	// °æ·Î¸¦ ÀÚµ¿À¸·Î Ã¼Å©ÇÏ¿© ÇöÀç ÃÖ»óÀ§ Ä«Å×°í¸®¸¦ ¾Ë¾Æ³½´Ù.
	function Set_Search_RootNode()
	{
		var strLocation	= document.location.toString();
		
		strLocation	= strLocation.replace(/http:\/\/.*?\//i, "");
		strLocation	= strLocation.substring(0, strLocation.search(/\//i));
		
		g_strNowPathDir	= strLocation;
		
		strLocation	= eval("/" + strLocation + "/i");
		
		strLocationName	= "";
		
		for(var i=0; i<g_nTreeCount; i++)
		{
			var objNode	= g_arrTreeIndex[i];
			
			if(objNode._nDepth == 1 && objNode._strPath.search(strLocation) > 0)
			{
				strLocationName	= objNode._strCategoryName;
				break;
			}
		}
		
		if(strLocationName != '')
			Set_RootNode_CategoryName(strLocationName);
	}
	
	// ÆäÀÌÁö¸¦ ÀÚµ¿À¸·Î °Ë»öÇÏ¿© ÇöÀç Ä«Å×°í¸® À§Ä¡Á¤º¸(¸µÅ©)¸¦ Ç¥½Ã
	function Get_Auto_NowPathInfomation()
	{
		var strLocation	= document.location.toString();
	
		strLocation	= strLocation.replace(/http:\/\/.*?\//i, "/");

// xxx Ãß°¡ xxx
		if(strLocation.search(/\?|\#/gi) > 0)
			strLocation	 = strLocation.substring(0, strLocation.search(/\?|\#/gi));
// xxx Ãß°¡ xxx

		if(strLocation.search(/\?/i) > 0)
			strLocation	= strLocation.substring(0, strLocation.search(/\?/i)).toLowerCase();
		else
			strLocation	= strLocation.toLowerCase();
		
		strLocation	= eval("/" + strLocation.replace(/\//gi, '\\\/') + "/i");
		
		var pSetNode	= null;
		
		for(var i=(g_nTreeCount - 1); i>0; i--)
		{
			var objNode	= g_arrTreeIndex[i];
			
			if(objNode._strPath.search(strLocation) >= 0)
			{
				pSetNode	= objNode;

				//
					pSetNode._blsPath	= true;
					pSetNode.ClickNode();

					if(pSetNode._blsPath && pSetNode._objTdNode)
					{
						pSetNode._objTdNode.style.color	= g_strOverColor;
					}
				//
				break;
			}
		}
		
		if(pSetNode == null)
		{
			pSetNode	= g_arrTreeIndex[g_dwNowNode];
		}
		
		if(pSetNode != null)
		{
			var nId		= pSetNode._nId;
			var nDepth	= pSetNode._nDepth;
			
			g_strNowPathLink	= " &gt; <a href=\"#\" onclick=\"Goto_Code_Link('"+ pSetNode._strCode +"');\">"+ pSetNode._strCategoryName +"</a>";
			g_strDocumentTitle	= pSetNode._strCategoryName;
			
			if(g_nTreeCount > nId && nId > 0)
			{
				for(var i=nDepth; i > 0; i--)
				{
					nId		= pSetNode._nId;
					for(var j=nId - 1; j>0; j--)
					{
						if(g_arrTreeIndex[nId]._nDepth == g_arrTreeIndex[j]._nDepth + 1)
						{
							pSetNode	= g_arrTreeIndex[j];

							//
								pSetNode._blsPath	= true;
								pSetNode.ClickNode();

								if(pSetNode._blsPath && pSetNode._objTdNode)
								{
									pSetNode._objTdNode.style.color	= g_strOverColor;
								}
							//
							
							g_strNowPathLink	= " &gt; <a href=\"#\" onclick=\"Goto_Code_Link('"+ pSetNode._strCode +"');\">"+ pSetNode._strCategoryName +"</a>" + g_strNowPathLink;
							
							if(g_strDocumentTitle == '')
								g_strDocumentTitle	== pSetNode._strCategoryName;
							else
								g_strDocumentTitle	= pSetNode._strCategoryName +'>'+ g_strDocumentTitle;
							break;
						}
					}
				}
			}
			
			g_strNowPathLink	= "<a href=\"#\" onclick=\"Goto_Code_Link('"+ g_arrTreeIndex[0]._strCode +"');\">Home</a>" + g_strNowPathLink;
			g_strDocumentTitle	= g_strSiteName + '   ¢Æ '+ g_strDocumentTitle;
		}
	}

/***********************************************************
	GLOBAL EVENT FUNCTION
***********************************************************/


//	(G)	ÀÌ¸§ ¸¶¿ì½º Å¬¸¯½Ã ÀÌº¥Æ®
	function Event_onClick_Name(nId)
	{
		var objTree		= g_arrTreeIndex[nId];
		objTree.ClickNode();
	}


//	(G)	ÀÌ¸§ ¸¶¿ì½º ¿À¹ö½Ã ÀÌº¥Æ®
	function Event_onMouseOver_Name(nId)
	{
		var objTree		= g_arrTreeIndex[nId];
		var objTdNode	= objTree._objTdNode;
		
		objTdNode.style.cursor			= "pointer";
		objTdNode.style.color			= g_strOverColor;
	}


//	(G)	ÀÌ¸§ ¸¶¿ì½º ¾Æ¿ô½Ã ÀÌº¥Æ®
	function Event_onMouseOut_Name(nId)
	{
		var objTree		= g_arrTreeIndex[nId];
		var objTdNode	= objTree._objTdNode;
		
		objTdNode.style.cursor			= "arrow";
		
		if(!objTree._blsPath)
			objTdNode.style.color			= g_strOutColor;
	}

}
