if (!realDir) { //Real Dir 변수가 존재하지 않을경우 
	var realDir	= calRealDir(); 
}

if (addedDir) { //add Dir 변수가 존재할 경우 
	realDir	= caladdDir(); 
} else {
	var addedDir;
}

var naviArray	= realDir.split('/'); //directory명을 배열에 넣는다.parent메뉴를 구하기 위함
var naviDepth	= naviArray.length -1 ;// Menu Depth를 구한다.0,1,2 0부터 시작

function makeSWFVars (departDir) {
	switch (departDir) {
	case "assets" : 
		xml_url = 'http://www.everasset.com/images/assets/swf/flashxml.xml';
	break;
	case "energy" : 
		xml_url = 'http://www.everasset.com/images/energy/swf/flashxml.xml';
	break;
	case "estate" : 
		xml_url = 'http://www.everasset.com/images/estate/swf/flashxml.xml';
	break;
	case "el" : 
		xml_url = 'http://www.everasset.com/images/el/swf/flashxml.xml';
	break;
	default :
	break;	
	}
	swf_url = 'http://www.everland.com/images/'+departDir+'/swf/';
	xml_url = xml_url.replaceAll("&","%26");
	swf_url = swf_url.replaceAll("&","%26");

	switch (naviArray.length) {
		case 1 :
			preswfVars='numA='+naviArray[1];
			break;
		default :
			preswfVars='numA='+naviArray[1]+'&numB='+naviArray[2];
			break;
	}
	
	var swfVars	= preswfVars + '&xml_url='+xml_url+'&swf_url='+swf_url;

	return swfVars;
}

/********* 현재페이지 위치 구하기위한 함수 **********/ 
function calRealDir () {
	try {
		numFEndIndex= fullDir.indexOf(rootDir);
		realDir	= fullDir.substring (0,numFEndIndex) + fullDir.substring((numFEndIndex + rootDir.length),(fullDir.length -1));   // 전체적으로 full Dir 경로 - 홈 Dir 경로
		return realDir;
	}
	catch (noVal) {
		return realDir = '';
	}
} 
/********* realDir정보 추가 **********/ 
function caladdDir () {
	realDir += '/' + addedDir;
	return realDir;
}


function showSubMenu(smnID) {
	targetID = eval(smnID); // 크기변경할 DivID
	endHeight = eval(smnID+'_size').offsetHeight + 1; // 변경될 사이즈
	targetID.style.height = endHeight; // 크기변경
}

function hideSubMenu(smnID) {
	targetID = eval(smnID); // 크기변경할 DivID
	startHeight = eval(smnID+'_size').offsetHeight + 1; // 하부메뉴의 원래 사이즈
	("ssmn_"+naviArray[2]==smnID) ? endHeight = startHeight: endHeight = 1; // 변경될 사이즈 구하기
	targetID.style.height = endHeight; // 크기변경
}

String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/gi, "");
}

String.prototype.replaceAll = function(str1, str2) {
	var temp_str = "";
	if (this.trim() != "" && str1 != str2) {
	temp_str = this.trim();
		while (temp_str.indexOf(str1) > -1) {
			temp_str = temp_str.replace(str1, str2);
		}
	}
	return temp_str;
}


/**************** 메뉴 생성 Class************************/

function mgmtMenu () {
	var menuColor	= new String; // bg color 정보
	var departName	= new String; // 메뉴 Directory 정보 / 리조트, 운영시간, 교통, 티켓, 가이드맵
	var menuDirName	= new String; // 메뉴 별 정보 / 소개, 영역, 고객 ... ...
	var menuType	= new String; // 대 메뉴 소 메뉴 표시 LMN / SMN
	var menuHTML	= new String; // 메뉴 HTML 소스
	var imgOnSRC	= new String; // 이미지 ON URL 정보
	var menuStyle	= new String; // TAB / DIY 구분정보를 가지고 있음 
	var parentID	= new String; // 소메뉴에서만 쓰이느 대메뉴의 ID

	var cntHTML					= new Array();
		cntHTML['DIY']			= new Array();
		cntHTML['DIY']['INIT']	= '<div id="menu"><ul>';
		cntHTML['DIY']['ADD']	= '<li><a href="{%PAGEURL%}"><img src="{%IMGSRC%}"></a></li>';
		cntHTML['DIY']['END']	= '</ul></div>';
		cntHTML['TAB']			= new Array();
		cntHTML['TAB']['INIT']	= '<div class="tab"><ul>';
		cntHTML['TAB']['ADD']	= '<li><a href="{%PAGEURL%}"><img src="{%IMGSRC%}"></a></li>';
		cntHTML['TAB']['END']	= '</ul></div>';
		cntHTML['SMN']			= new Array();
		cntHTML['SMN']['INIT']	= '<div id="wrap_left"><div id="leftmenu"><img src="http://www.everland.com/MultiLanguage/japanese/images/{%DIRNAME%}/left_title.gif"><div class="lefttop"></div><div class="leftbg"><ul>';
		cntHTML['SMN']['ADD']			= new Array();
		cntHTML['SMN']['ADD']['LMN']	= '<li class="{%ISHERE%}"><a href="{%PAGEURL%}" >{%MENUNAME%}</a></li>';
		cntHTML['SMN']['END']	= '</ul></div><div class="leftbottom"></div></div></div>';
	this.initMenu		= initMenu;
	this.setMenu		= setMenu;
	this.addMenu		= addMenu;
	this.menuInterval	= menuInterval;
	this.endMenu		= endMenu;
	this.showMenu		= showMenu;
	this.changeOnImg	= changeOnImg;
	this.testMenu		= testMenu;

	function initMenu (dName,DirName,mnStyle) {
		departName 	= dName;
		menuDirName = DirName;
		menuStyle	= mnStyle;
		
		tmpString	= cntHTML[menuStyle]['INIT'];
		tmpString	= tmpString.replaceAll("{%DIRNAME%}",menuDirName);
		
		menuHTML	= tmpString;
	}

	function setMenu () {
		menuColor = bgcolorTAB[menuDirName] ;
	}

	function changeOnImg (imgSRC) {
		oldImgSrc	=imgSRC;  // 이미지 경로 찾아냄

		splitOldSrc	= oldImgSrc.split("/");
		numFileName	= splitOldSrc.length - 1;

		fileName	= splitOldSrc[numFileName].split(".");  
		fileName[0]	= fileName[0] + "_on" ; // 파일명 찾아서 _on을 붙임(자기위치 표시)

		splitOldSrc[numFileName] = fileName.join(".");

		imgOnURL	= splitOldSrc.join("/"); // 새로운 경로를 생성(_on 붙인 경로명)
		return imgOnURL
	}

	function addMenu (mnType, imgID, imgSRC, pageURL, prtID, imgOnURL,menuName) {
		menuType 	= mnType;
		parentID	= prtID;
		var isHere = 'other';
		if (imgOnURL) {
			imgOnSRC = imgOnURL;
		} else {
			imgOnSRC = this.changeOnImg (imgSRC);
		}
		tmpString	= (menuStyle=='SMN') ? cntHTML[menuStyle]['ADD'][menuType] : cntHTML[menuStyle]['ADD'];
		tmpString	= tmpString.replaceAll("{%PARENTID%}",parentID);
		tmpString	= tmpString.replaceAll("{%DEPARTNAME%}",departName);
		tmpString	= tmpString.replaceAll("{%DIRNAME%}",menuDirName);
		tmpString	= tmpString.replaceAll("{%MENUNAME%}",menuName);
		tmpString	= tmpString.replaceAll("{%PAGEURL%}",pageURL);
		tmpString	= tmpString.replaceAll("{%IMGID%}",imgID);
		tmpString	= tmpString.replaceAll("{%IMGONSRC%}",imgOnSRC);
		tmpString	= tmpString.replaceAll("{%IMGSRC%}",imgSRC);
		tmpString	= tmpString.replaceAll("{%ISHERE%}",isHere);
		for (imgDepth = 0; imgDepth <= naviDepth; imgDepth++) { // 현재페이지일 경우 미리 온 표시 해놓음
			if(mnType=='LMN'){
				if (naviArray[imgDepth]==prtID ){
						var classcode = 'here';
						tmpString = tmpString.replaceAll(isHere,'here');
					}
			}else{
				if (naviArray[imgDepth]==imgID ) {
						tmpString = tmpString.replaceAll(imgSRC,imgOnSRC);
					}
			}
		}

		menuHTML	+= tmpString;
	}
	function menuInterval (htmlCode) {
		menuHTML += htmlCode;
	}

	function endMenu () {
		tmpString	= cntHTML[menuStyle]['END'];
		tmpString	= tmpString.replaceAll("{%DEPARTNAME%}",departName);		
		tmpString	= tmpString.replaceAll("{%DIRNAME%}",menuDirName);
		menuHTML	+= tmpString;

	}
	
	function showMenu () {
		this.endMenu ();
		document.write (menuHTML);
		if (menuStyle=='SMN')  window.onload = function () {try{ showSubMenu("ssmn_"+opensubMenuID);} catch (noError) {}}// 현재페이지일 경우 메뉴을 열어놓기 위함
	}
	function testMenu () {
		this.endMenu ();
		alert(menuHTML);

	}
}


/********* 정황정보 표시 함수 **********/ 
function pathInfo (showName, Url) {
	switch (showName) {
		case "cms" :
			pathCnt = Url;
			var showPath = document.getElementById('state');
			showPath.innerHTML = pathCnt;
		break;
		case "nopath" :
			pathSection.style.display = "none";
		break;		
		default :
			pathCnt += (Url) ? '&gt; <a href="'+Url+'"><b>'+showName+'</b></a> ' : '&gt; '+showName+'</b></a> ';
			var showPath = document.getElementById('state');
			showPath.innerHTML = pathCnt;
		}
}

