/* define page id & image root */
var ogpid;
var imgRoot = "";

/*
 * variable menu scope
 */
var sIndex, eIndex, cIndex;
var mDep1

/*
 * function : define menu scope & init gnb menu
 */
function drawGNB() {
	var tmpDepth, tmpDep1="", tmpDep2, tmpSID, tmpType;
	var tmpStr = "";
	if (ogilvyMenu && ogpid) {
		tmpDepth = ogilvyMenu.getMenuID(ogpid);
		tmpType = tmpDepth.charAt(0);
		if (tmpDepth && tmpDepth.length > 9) {
			mDep1 = tmpDep1 = parseFloat(tmpDepth.substring(1,3));
			tmpDep2 = parseFloat(tmpDepth.substring(3,5));
		}
		tmpSID = tmpDepth.substring(0,3)+"000000a"; // 1Depth ÁöÁ¤
		for (var i = 0; i < ogilvyMenu.list.length; i++) {
			if (ogilvyMenu.list[i].mID == tmpSID) sIndex = i; // ½ÃÀÛ index ÁöÁ¤
			if (sIndex && ogilvyMenu.list[i].mID.substring(1,3) != tmpDep1) eIndex = i; // ¸¶Áö¸· index ÁöÁ¤
			if (ogilvyMenu.list[i].pID == ogpid) cIndex = i;
			if (eIndex) break; // ¹üÀ§ ÁöÁ¤ÈÄ Á¾·á
		}
		if (!eIndex) eIndex = ogilvyMenu.list.length - 1;
	}
	if (!isNaN(tmpDep1) && parseFloat(tmpDep1)  > 5) tmpDep1 = "";
	drawFlash("gnb", imgRoot+"/image/comm/layout/gnb.swf?dep1="+tmpDep1+"&dep2="+tmpDep2+"&", 657, 80, 1, null, null, 1);
}



/*
 * function : left menu action
 * @param mid(menu order number)
 */
var selMenu;
function selVMenu(mid) {
	var tmpDep, tmpDep1, tmpDep2, tmpDep3, tmpSub;
	var oldDep, oldDep1, oldDep2, oldDep3, oldSub;

	if (mid.length < 2) return;
	tmpDep = mid.substring(1).split("_");
	tmpDep[0] = tmpDep[0]; 
	tmpDep[0] = "" + tmpDep[0] + "";
	tmpDep[1] = tmpDep[1]; 
	tmpDep[1] = "" + tmpDep[1] + "";

	if (tmpDep[0]) {
		tmpDep1 = document.getElementById("m"+tmpDep[0]);
		tmpSub = document.getElementById("subB"+tmpDep[0]);
	}
	if (tmpDep[1]) tmpDep2 = document.getElementById("m"+tmpDep[0]+"_"+tmpDep[1]);

	/* ÀÌÀü ¸Þ´º·Î µÇµ¹¸®±â*/
	if (selMenu) {
		oldDep = selMenu.substring(1).split("_");
		oldDep[0] = oldDep[0]; 
		oldDep[1] = oldDep[1]; 

		if (oldDep[0]) {
			oldDep1 = document.getElementById("m"+oldDep[0]);
			oldSub = document.getElementById("subB"+oldDep[0]);
		}
		if (oldDep[1]) oldDep2 = document.getElementById("m"+oldDep[0]+"_"+oldDep[1]);
	}
	if (oldSub) oldSub.style.display = "none";
	if (oldDep2) mnuOut(oldDep2.id);
	if (oldDep1) oldDep1.className = "";
	if (oldDep1) mnuOut(oldDep1.id);

	if (tmpDep1) mnuOver(tmpDep1.id);
	if (tmpDep2) mnuOver(tmpDep2.id);
	if (tmpSub) tmpSub.style.display = "block";
	selMenu = mid;
	return false;
}

/*
 * function : left menu image actoin
 * @param tObj(menu object)
 */
function mnuOver(tObj) {
	if (tObj && selMenu != null && selMenu.indexOf(tObj) != -1) return;
	var mnuset = tObj.split("_");
	var tmpStr = "";
	for (var i = 0; i < mnuset.length; i++) {
		tmpStr += (i == 0)?mnuset[i]:"_"+mnuset[i];
		var tmpObj = document.getElementById(tmpStr);
		if (selMenu) {
			if (selMenu.indexOf(tmpStr) == -1 && tmpObj) imgOver(tmpObj);
		} else {
			if (tmpObj) imgOver(tmpObj);
		}
	}
}

function mnuOut(tObj) {
	if (tObj && selMenu != null && selMenu.indexOf(tObj) != -1) return;
	var mnuset = tObj.split("_");
	var tmpStr = "";
	for (var i = 0; i < mnuset.length; i++) {
		tmpStr += (i == 0)?mnuset[i]:"_"+mnuset[i];
		var tmpObj = document.getElementById(tmpStr);
		if (selMenu) {
			if (selMenu.indexOf(tmpStr) == -1 && tmpObj) imgOut(tmpObj);
		} else {
			if (tmpObj) imgOut(tmpObj);
		}
	}
}


function showSub(idx) {
	var tmpDep1 = document.getElementById("m"+idx);
	var tmpSub = document.getElementById("subB"+ idx);

	if (tmpDep1) tmpDep1.className = "sel";
	if (tmpSub) tmpSub.style.display = "block";
}

/*
 * function : draw left menu scope
 */
function drawLeft() {
	var tmpStr = "", j = 0, k = 0, initMenu, tmpCat;
	tmpStr += "<div id=\"snb\">\n";
	tmpStr += "	<div id=\"cmenu_menu\">\n";
	tmpStr += "		<h2><img src=\""+imgRoot+"/image/comm/layout/lmtop_0"+mDep1+".gif\" border=\"0\" alt=\"\" /></h2>\n";
	tmpStr += "		<div id=\"menu\">\n";
	tmpStr += "			<ul class=\"dep2\">\n";
	for (var i = sIndex; i <= eIndex; i++) {
		tmpCat = ogilvyMenu.list[i].pID.substring(1,ogilvyMenu.list[i].pID.length-1);

		if (ogilvyMenu.list[i].depth == 2) {
			if (k != 0) tmpStr += "				</ul>";
			if (j != 0) tmpStr += "</li>\n";

			tmpStr += "				<li><a href=\"" + ogilvyMenu.list[i].link + "\" onclick=\"javascript:goLink('"+ ogilvyMenu.list[i].pID + "'); return false;\"><img src=\""+imgRoot+"/image/comm/layout/left/lm"+ tmpCat + "x.gif\" id=\"m" + (j+1) + "\" onmouseover=\"mnuOver(\'m"+(j+1)+"\')\" onmouseout=\"mnuOut(\'m"+(j+1)+"\')\"  onclick=\"showSub(" +( j+1) + ")\" border=\"0\" align=\"absmiddle\" /></a>";

			k = 0; // 3depth ¼ø¼­ ÃÊ±âÈ­

			j++; // 2depth ¼ø¼­ Áõ°¡
			if (i == cIndex) initMenu = "m"+(j)
		}

		if (ogilvyMenu.list[i].depth == 3) {
			if (k == 0)  {
				tmpStr += "\n				<ul class=\"dep3\" id=\"subB" + (j) + "\" style=\"display:none\">\n";
				tmpStr += "						<li><a href=\"" +ogilvyMenu.list[i].link + "\"  onclick=\"javascript:goLink('"+ ogilvyMenu.list[i].pID + "'); return false;\"><img src=\""+imgRoot+"/image/comm/layout/left/lm"+ tmpCat + "x.gif\" id=\"m" + j + "_" + (k+1) + "\" onmouseover=\"mnuOver(\'m"+j+"_"+(k+1)+"\')\" onmouseout=\"mnuOut(\'m"+j+"_"+(k+1)+"\')\" border=\"0\" align=\"absmiddle\" /></a></li>\n";
			} else {
				tmpStr += "						<li><a href=\"" +ogilvyMenu.list[i].link + "\"  onclick=\"javascript:goLink('"+ ogilvyMenu.list[i].pID + "'); return false;\"><img src=\""+imgRoot+"/image/comm/layout/left/lm"+ tmpCat + "x.gif\" id=\"m" + j + "_"+ (k+1) + "\" onmouseover=\"mnuOver(\'m"+j+"_"+(k+1)+"\')\" onmouseout=\"mnuOut(\'m"+j+"_"+(k+1)+"\')\" border=\"0\" align=\"absmiddle\" /></a></li>\n";
			}
			k++; // 3depth ¼ø¼­ Áõ°¡
			if (i == cIndex) initMenu = "m"+ j +"_"+(k);
		}
	}
	if (j != 0) tmpStr += "</li>\n";
	tmpStr += "			</ul>\n";

	tmpStr += "		</div>\n";
	tmpStr += "	</div>";
	document.write(tmpStr);
	if (initMenu) selVMenu(initMenu);
//	viewObj(tmpStr);

	document.write("</div>");

}




/* Copyright »ý¼º ÇÔ¼ö */
function drawCopyright() {
	var tmpStr = "";
/*
	tmpStr += "<span id=\"ogilvyone\" class=\"footer01\">";
	tmpStr += "	<div class=\"sel_st\" onmouseover=\"overDiv('sel1');\" onmouseout=\"outDiv('sel1');\"><img src=\""+imgRoot+"/image/comm/layout/footer_i01.gif\" alt=\"Ogilvy One Worldwide Korea\" /></div>";
	tmpStr += "	<div id=\"sel1\" class=\"ogilvyone\" onmouseover=\"overDiv('sel1');\" onmouseout=\"outDiv('sel1');\" style=\"display:none; position:absolute; left:0px; bottom:17px; z-index:100;\">";
	tmpStr += "		<ul class=\"ogilvyone_list\">";
	tmpStr += "			<li><a href=\"javascript:void(0);\" onclick=\"outDiv('sel1');\">OgilvyOne1</a></li>";
	tmpStr += "			<li><a href=\"javascript:void(0);\" onclick=\"outDiv('sel1');\">OgilvyOne2</a></li>";
	tmpStr += "			<li><a href=\"javascript:void(0);\" onclick=\"outDiv('sel1');\">OgilvyOne3</a></li>";
	tmpStr += "			<li><a href=\"javascript:void(0);\" onclick=\"outDiv('sel1');\">OgilvyOne4</a></li>";
	tmpStr += "			<li><a href=\"javascript:void(0);\" onclick=\"outDiv('sel1');\">OgilvyOne5</a></li>";
	tmpStr += "		</ul>";
	tmpStr += "	</div>";
	tmpStr += "</span>";
*/
	tmpStr += "<span class=\"footer02\"><img src=\""+imgRoot+"/image/comm/layout/footer_i02.gif\" alt=\"\" usemap=\"#footer\" class=\"nofocus\" /></span>";
	tmpStr += "<map name=\"footer\">";
	tmpStr += "	<area shape=\"rect\" coords=\"1,0,119,10\" href=\"/about/about.html\" alt=\"About Diamond Ogilvy Group\">";
	tmpStr += "	<area shape=\"rect\" coords=\"135,0,260,10\" href=\"/degree/360.html\" alt=\"360 Degree Brand Stewardship\">";
	tmpStr += "	<area shape=\"rect\" coords=\"274,0,294,10\" href=\"/press/news_list.html\" alt=\"Press\">";
	tmpStr += "	<area shape=\"rect\" coords=\"308,0,350,10\" href=\"/contact/contact.html\" alt=\"Contact us\">";
	tmpStr += "	<area shape=\"rect\" coords=\"364,0,393,10\" href=\"/recruit/public_list.html\" alt=\"Recruit\">";
	tmpStr += "	<area shape=\"rect\" coords=\"457,18,489,28\" href=\"http://www.ogilvy.com/\" target=\"_blank\" alt=\"English\">";
	tmpStr += "	<area shape=\"rect\" coords=\"510,18,550,28\" href=\"/sitemap/sitemap.html\" alt=\"SITEMAP\">";
	tmpStr += "</map>";
	document.write(tmpStr);
}