
var LOTTE_HOST = "www.lotteshopping.com";
var LOTTE_ROOT = "http://" + LOTTE_HOST;

/*
** Menu Contoller
*****************************/
var kidoMenu = {
	Version : "1.2",
	vars : {
		  limitDirLength : 3
		, subMenuPaddingTop : 8
		, subMenuPaddingBottom : 6
		, menuHeight : 26
		, subMenuHeight : 18
		, rootPath : "/english"
	},
	menu : new Object,
	currentMenuId : "",
	focusedMenuId : "",
	prevMenuId : "",
	defaultCheckedMenuId : "",
	leftMenuAreaHeight : 0,
	dir : new Array,
	
	getDir : function(_pathName) {
		while(_pathName.indexOf("//")>-1) {
			_pathName = _pathName.replace("//","/");
		}
		if (_pathName.indexOf(this.vars.rootPath)==0) {
			_pathName = _pathName.replace(this.vars.rootPath,"");
		}
		if (_pathName.indexOf("/")==0) {
			_pathName = _pathName.substring(1,_pathName.lastIndexOf("/"));
		}
		return _pathName.split("/", this.vars.limitDirLength);
	},
	
	addMenu : function(_id, _title, _url) {
		this.menu[_id] = {
			  title : _title
			, url : _url
		}
	},
	
	goToThisMenu : function(_menuId) {
		var depth = _menuId.split("_");
		var menuUrl = "";
		try {
			menuUrl = this.menu[_menuId].url;
		} catch(e) {
			
		}
		if (menuUrl!="") {
			location.href = menuUrl;
		} else {
			alert("No URL");
		}
	},
	
	getLeftMenuHTML : function() {
		var depth1Id = this.dir[0];
		var leftMenu = new Array;
		var index = 0;
		for (prop in this.menu) {
			var menuId = ""+prop;
			if ((menuId).indexOf(depth1Id+"_")==0) {
				if (menuId.split("_").length<3) {
					index = leftMenu.length;
					leftMenu[index] = {
						id : prop + ""
						, title : this.menu[prop].title
						, url : this.menu[prop].url
						, hasSubMenu : false
						, subMenu : new Array
					}
				} else {
					var subIndex = leftMenu[index].subMenu.length;
					leftMenu[index].hasSubMenu = true;
					leftMenu[index].subMenu[subIndex] = {
						id : prop + ""
						, title : this.menu[prop].title
						, url : this.menu[prop].url
					}
				}
			}
		}
		
		var s = '';
		s += '<img src="' + IMAGE_ROOT + this.vars.rootPath + '/images/common/left/title/'+depth1Id+'.jpg" align="absmiddle"><br>\n';
		s += '<div style="width:168px; background:url(' + IMAGE_ROOT + this.vars.rootPath + '/images/common/etc/menu_bg.gif) repeat-y; padding-left:5px;">\n';
		for (var i=0; i<leftMenu.length; i++) {
			var id = leftMenu[i].id;
			var menuAreaMaxHeight = this.vars.menuHeight;
			if (leftMenu[i].hasSubMenu) {
				menuAreaMaxHeight += this.vars.subMenuPaddingTop;
				menuAreaMaxHeight += this.vars.subMenuHeight * leftMenu[i].subMenu.length;
				menuAreaMaxHeight += this.vars.subMenuPaddingBottom;
			}
			s += '<div leftMenuId="' + id + '" id="'+id+'-menuArea" maxHeight="' + menuAreaMaxHeight + '" style="width:158px;height:' + this.vars.menuHeight + 'px;overflow:hidden;">\n';
			s += '	<div style="cursor:pointer;" onClick="goPage(\'' + id + '\');">\n';
			s += '		<div id="'+id+'-on" style="position:absolute;z-index:50;display:none;"><img leftMenuId="' + id + '" src="' + IMAGE_ROOT + this.vars.rootPath + '/images/common/left/menu/' + id + '-on.gif" align="absmiddle"></div>\n';
			s += '		<div><img leftMenuId="' + id + '" src="' + IMAGE_ROOT + this.vars.rootPath + '/images/common/left/menu/' + id + '-off.gif" width="158" height="' + this.vars.menuHeight + '" align="absmiddle"></div>\n';
			s += '	</div>\n';
			if (leftMenu[i].hasSubMenu) {
				s += '	<div leftMenuId="' + id + '" style="background:url(' + IMAGE_ROOT + this.vars.rootPath + '/images/common/etc/menu_line.gif) no-repeat; padding:'+this.vars.subMenuPaddingTop+'px 0px '+this.vars.subMenuPaddingBottom+'px 0px;">\n';
				for (var j=0; j<leftMenu[i].subMenu.length; j++) {
					var subMenuId = leftMenu[i].subMenu[j].id;
					s += '		<div leftMenuId="' + id + '">\n';
					s += '			<table style="position:absolute;z-index:40;" cellpadding="0" cellspacing="0" border="0" width="158" height="' + this.vars.subMenuHeight + '">';
					s += '			<tr><td leftMenuId="' + id + '" style="cursor:pointer;" ';
					if (subMenuId!=this.currentMenuId) {
						s += '			 onMouseOver="kidoMenu.fadeInLeftMenu(\'' + subMenuId + '-on\');" ';
						s += '			 onMouseOut="kidoMenu.fadeOutLeftMenu(\'' + subMenuId + '-on\');" ';
					}
					s += '			 onClick="goPage(\'' + subMenuId + '\');" ';
					s += '			></td></tr>\n';
					s += '			</table>\n';
					s += '			<div id="'+subMenuId+'-on" style="position:absolute;z-index:30;display:';
					if (subMenuId!=this.currentMenuId) {
						s += '			none';
					}
					s += '			"><img leftMenuId="' + id + '" src="' + IMAGE_ROOT + this.vars.rootPath + '/images/common/left/menu/' + subMenuId + '-on.gif" align="absmiddle"></div>\n';
					s += '			<div><img leftMenuId="' + id + '" src="' + IMAGE_ROOT + this.vars.rootPath + '/images/common/left/menu/' + subMenuId + '-off.gif" align="absmiddle"></div>\n';
					s += '		</div>\n';
				}
				s += '	</div>\n';
			}
			s += '</div>\n';
		}
		if (leftMenu.length==0) {
			s += '<style>#Menu_Bottom{display:none;}</style>\n';
		}
		s += '</div>\n';
		return s;
	},
	
	writeLeftMenuHTML : function() {
		document.write(this.getLeftMenuHTML());
		this.setLeftMenu();
		setInterval("kidoMenu.resizeContentsArea()",50);
	},
	
	resizeContentsArea : function() {
		try {
			if (document.getElementById("Left_Menu")) {
				var newHeight = document.getElementById("Left_Menu").offsetHeight;
				if (this.leftMenuAreaHeight!=newHeight) {
					if (document.getElementById("Contents_Area")) {
						document.getElementById("Contents_Area").style.height = parseInt(newHeight,10) + "px";
					}
				}
			}
		} catch(e) {
			
		}
	},
	
	focusLeftMenu : function(_id) {
		if (_id==null||_id==undefined) _id = $E.event.srcElement.getAttribute("leftMenuId");
		this.blurLeftMenu(this.prevMenuId);
		if (_id!=""&&_id!=undefined&&_id!=this.defaultCheckedMenuId) {
			if (_id!=this.focusedMenuId) {
				try {
					var menuOnId = _id + "-on";
					var menuArea = _id + "-menuArea";
					var maxHeight = parseInt($(menuArea).getAttribute("maxHeight"),10);
					$(menuOnId).setStyle("display", true);
					$(menuOnId).setFadeIn(1, 15);
					clearTimeout($TIMER.resizeTo[menuArea]);
					$(menuArea).setAttribute("resizeStatus","");
					$(menuArea).resizeTo(null, maxHeight, null, 10);
					this.prevMenuId = this.focusedMenuId;
					this.focusedMenuId = _id;
				} catch(e) {
					
				}
			}
		} else {
			this.resetLeftMenu();
		}
	},
	
	blurLeftMenu : function(_id) {
		if (_id!=""&&_id!=undefined) {
			if (_id!=this.focusedMenuId) {
				this._blurLeftMenu(_id);
			}
		}
	},
	
	_blurLeftMenu : function(_id) {
		try {
			if (_id!=this.defaultCheckedMenuId) {
				var menuOnId = _id + "-on";
				var menuArea = _id + "-menuArea";
				$(menuOnId).setFadeOut(0, 40, '$("'+menuOnId+'").setStyle("display", false)');
				clearTimeout($TIMER.resizeTo[menuArea]);
				$(menuArea).setAttribute("resizeStatus","");
				$(menuArea).resizeTo(null, this.vars.menuHeight, null, 10);
			}
		} catch(e) {
		
		}
	},
	
	resetLeftMenu : function() {
		if (this.focusedMenuId!="") {
			this._blurLeftMenu(this.focusedMenuId);
			this.focusedMenuId = "";
			this.prevMenuId = "";
		}
	},
	
	setLeftMenu : function() {
		var depth2Id = this.dir[0] + "_" + this.dir[1];
		this.focusLeftMenu(depth2Id);
		this.defaultCheckedMenuId = depth2Id;
	},
	
	fadeInLeftMenu : function(_menuId) {
		$(_menuId).setStyle("display", true);
		$(_menuId).setFadeIn(1, 15);
	},
	
	fadeOutLeftMenu : function(_menuId) {
		$(_menuId).setFadeOut(0, null, '$("'+_menuId+'").setStyle("display", false)');
	},
	
	initialize : function(_pathName) {
		var pathName = (_pathName==null) ? location.pathname : _pathName;
		this.dir = this.getDir(pathName);
		this.currentMenuId = this.dir.join("_");
	}
};

kidoMenu.initialize();
try {
	$E.addAction("onMouseOver", "menuControl", "kidoMenu.focusLeftMenu()");
} catch(e) {

}


with(kidoMenu) {

addMenu("lotte", "COMPANY", "/english/lotte/index.jsp");
addMenu("lotte_about", "ABOUT US", "/english/lotte/about/overview/overview.jsp");
addMenu("lotte_about_overview", "Overview", "/english/lotte/about/overview/overview.jsp");
addMenu("lotte_about_ceo", "CEO's Message", "/english/lotte/about/ceo/ceo.jsp");
addMenu("lotte_about_history", "History", "/english/lotte/about/history/history01.jsp");
addMenu("lotte_about_manage", "Management Philosophy", "/english/lotte/about/manage/manage.jsp");
addMenu("lotte_about_sustainability", "Sustainability Management", "/english/lotte/about/sustainability/sustainability.jsp");
addMenu("lotte_about_award", "Award", "/english/lotte/about/award/award.jsp");
addMenu("lotte_about_ci", "CI Introduction", "/english/lotte/about/ci/ci.jsp");

addMenu("lotte_branch", "Branch Network", "/english/lotte/branch/001/branch_001_overview.jsp");
addMenu("lotte_branch_001", "Main", "/english/lotte/branch/001/branch_001_overview.jsp");
addMenu("lotte_branch_002", "Jamsil", "/english/lotte/branch/002/branch_002_overview.jsp");
addMenu("lotte_branch_003", "Youngdengpo", "/english/lotte/branch/003/branch_003_overview.jsp");
addMenu("lotte_branch_004", "Cheongyangni", "/english/lotte/branch/004/branch_004_overview.jsp");
addMenu("lotte_branch_005", "Gwanak", "/english/lotte/branch/005/branch_005_overview.jsp");
addMenu("lotte_branch_006", "Gangnam", "/english/lotte/branch/006/branch_006_overview.jsp");
addMenu("lotte_branch_007", "Nowon", "/english/lotte/branch/007/branch_007_overview.jsp");
addMenu("lotte_branch_008", "Bundang", "/english/lotte/branch/008/branch_008_overview.jsp");
addMenu("lotte_branch_009", "Bupyeong", "/english/lotte/branch/009/branch_009_overview.jsp");
addMenu("lotte_branch_010", "Ilsan", "/english/lotte/branch/010/branch_010_overview.jsp");
addMenu("lotte_branch_011", "Anyang", "/english/lotte/branch/011/branch_011_overview.jsp");
addMenu("lotte_branch_012", "Incheon", "/english/lotte/branch/012/branch_012_overview.jsp");
addMenu("lotte_branch_013", "Busan Main", "/english/lotte/branch/013/branch_013_overview.jsp");
addMenu("lotte_branch_014", "Daegu", "/english/lotte/branch/014/branch_014_overview.jsp");
addMenu("lotte_branch_015", "Daejeon", "/english/lotte/branch/015/branch_015_overview.jsp");
addMenu("lotte_branch_016", "Gwangju", "/english/lotte/branch/016/branch_016_overview.jsp");
addMenu("lotte_branch_017", "Dongnae", "/english/lotte/branch/017/branch_017_overview.jsp");
addMenu("lotte_branch_018", "Pohang", "/english/lotte/branch/018/branch_018_overview.jsp");
addMenu("lotte_branch_019", "ChangWon", "/english/lotte/branch/019/branch_019_overview.jsp");
addMenu("lotte_branch_020", "Ulsan", "/english/lotte/branch/020/branch_020_overview.jsp");
addMenu("lotte_branch_021", "Young Plaza", "/english/lotte/branch/021/branch_021_overview.jsp");
addMenu("lotte_branch_022", "Sangin", "/english/lotte/branch/022/branch_022_overview.jsp");
addMenu("lotte_branch_023", "Jeonju", "/english/lotte/branch/023/branch_023_overview.jsp");
addMenu("lotte_branch_024", "Mia", "/english/lotte/branch/024/branch_024_overview.jsp");
addMenu("lotte_branch_025", "Y.Plaza-Cheongju", "/english/lotte/branch/025/branch_025_overview.jsp");
addMenu("lotte_branch_026", "Y.Plaza-Daegu", "/english/lotte/branch/026/branch_026_overview.jsp");
addMenu("lotte_branch_027", "Centumsity", "/english/lotte/branch/027/branch_027_overview.jsp");
addMenu("lotte_branch_028", "Starcity", "/english/lotte/branch/028/branch_028_overview.jsp");
addMenu("lotte_branch_029", "Gwangbok", "/english/lotte/branch/029/branch_029_overview.jsp");
addMenu("lotte_branch_030", "Jungdong", "/english/lotte/branch/030/branch_030_overview.jsp");
addMenu("lotte_branch_031", "Guri", "/english/lotte/branch/031/branch_031_overview.jsp");
addMenu("lotte_branch_032", "Ansan", "/english/lotte/branch/032/branch_032_overview.jsp");


}

function goPage(_menuId) {
	kidoMenu.goToThisMenu(_menuId);
}

function goHome() {
	location.href = "/";
}

function winOpen(_url, _target, _option) {
	if (_target==null||_target=="") _target = "_blank";
	if (_option==null) _option = "";
	open(_url, _target, _option);
}

