/*
	 - FileName				: menu.js
	 - Author				: Kim dong-jun
	 - Last modified date	: 03/07/28
	 - modified contents	:
		 
		 
	 - Function list
			
		GoMenu			: ÇÃ·¡½¬¸Þ´º ¸µÅ©
		ChangeImage		: Å¬¸¯½Ã ÀÌ¹ÌÁö º¯°æÇÔ¼ö
		DisplayLayer	: layer Display
		LMenu			: ÁÂÃø ¼­ºê¸Þ´º DropDown view(ChangeImage, DisplayLayer »ç¿ë)
		PrintLmenu		: ÁÂÃø ¸Þ´º ºä
		ActiveLmenu		: ÇöÀç ¸Þ´º È°¼ºÈ­ ½ÃÅ´
		GoRemoteMenu	: ¿ìÃø ¸®¸ðÆ® ¸Þ´º ¸µÅ©
*/
	
var CURRENTMENU = InitMenu;
var CURRENTLMENU = null;
var STATUSLMENU = 0;		//active = 1, nonactive = 0
var ArrMenu = new Array();

ArrMenu[0] = new Array();
ArrMenu[0][0] = ["NEWS",100];
ArrMenu[0][1] = ["GAME INFO",200];
ArrMenu[0][2] = ["GAME GUIDE",300];
ArrMenu[0][3] = ["GAME DATA",400];
ArrMenu[0][4] = ["CONTACT US",500];
ArrMenu[0][5] = ["SITE-MAP",600];
ArrMenu[0][6] = ["BBS",700];	  	  	  	  
	  
ArrMenu[1] = new Array();
ArrMenu[1][0] = new Array();
ArrMenu[1][0][0] = [100,"News","/News/Notice.asp?ServiceUseID=63"];
  	ArrMenu[1][1] = new Array();
  	ArrMenu[1][1][0] = [110,"NOTICE","/News/Notice.asp?ServiceUseID=63"];  	
				  
ArrMenu[2] = new Array();
ArrMenu[2][0] = new Array();
ArrMenu[2][0][0] = [200,"Game Info","/gameinfo/story/legend.asp"];
  	ArrMenu[2][1] = new Array();
   	ArrMenu[2][1][0] = [210,"STORY","/gameinfo/story/legend.asp"];
   	ArrMenu[2][1][1] = [211,"LEGEND","/gameinfo/story/legend.asp"];
   	ArrMenu[2][1][2] = [212,"SCENARIO","/gameinfo/story/scenario.asp"];
   	ArrMenu[2][1][3] = [213,"NOVEL","/gameinfo/story/novel.asp"];			

   	ArrMenu[2][2] = new Array();
   	ArrMenu[2][2][0] = [220,"MOVIE","/gameinfo/movie/movie.asp"];
   	ArrMenu[2][2][1] = [221,"PR MOVIE","/gameinfo/movie/movie.asp#1"];
   	ArrMenu[2][2][2] = [222,"IN GAME MOVIE","/gameinfo/movie/movie.asp#2"];
   	ArrMenu[2][2][3] = [223,"MUSIC VIDEO","/gameinfo/movie/movie.asp#3"];
   	ArrMenu[2][2][4] = [224,"TV CF","/gameinfo/movie/movie.asp#4"];
   	ArrMenu[2][2][5] = [225,"TV PROGRAM","/gameinfo/movie/movie.asp#5"];
			
ArrMenu[3] = new Array();
ArrMenu[3][0] = new Array();
ArrMenu[3][0][0] = [300,"GAME GUIDE","/gameguide/BeginnersGuide/BeginnersGuide.asp"];
	ArrMenu[3][1] = new Array();
   	ArrMenu[3][1][0] = [310,"BEGINNERS GUIDE","/gameguide/BeginnersGuide/BeginnersGuide.asp"];
   	
   	/*
   	ArrMenu[3][1][1] = [311,"INSTALL","/gameguide/BeginnersGuide/"];
   	ArrMenu[3][1][2] = [312,"CREATING CHARACTER","/gameguide/BeginnersGuide/"];
   	ArrMenu[3][1][3] = [313,"PLAYING A3","/gameguide/BeginnersGuide/"];
   				
   	ArrMenu[3][2] = new Array();
   	ArrMenu[3][2][0] = [320,"GAME SYSTEM","/Guide/Creation/default.asp"];
   	ArrMenu[3][2][1] = [321,"PARTY","/Guide/Creation/default.asp"];
   	ArrMenu[3][2][2] = [322,"QUEST","/Guide/Creation/createchar.asp"];
   	ArrMenu[3][2][3] = [323,"SHUE","/Guide/Creation/createchar.asp"];
   	ArrMenu[3][2][4] = [324,"PK","/Guide/Creation/createchar.asp"];
   	ArrMenu[3][2][5] = [325,"Item Convert","/Guide/Creation/createchar.asp"];
   	ArrMenu[3][2][6] = [326,"Converting Item","/Guide/Creation/createchar.asp"];
   	ArrMenu[3][2][7] = [327,"Item Combination","/Guide/Creation/createchar.asp"];
   	ArrMenu[3][2][8] = [328,"Chatting Macro","/Guide/Creation/createchar.asp"];
   	ArrMenu[3][2][9] = [329,"Gambling Rings / Amulets","/Guide/Creation/createchar.asp"];
	*/
			
   	ArrMenu[3][2] = new Array();
   	ArrMenu[3][2][0] = [320,"CHARACTERS","/gameguide/characters/warrior.asp"];
   	ArrMenu[3][2][1] = [321,"WARRIOR","/gameguide/characters/warrior.asp"];
   	ArrMenu[3][2][2] = [322,"SORCERESS","/gameguide/characters/sorceress.asp"];
   	ArrMenu[3][2][3] = [323,"KNIGHT","/gameguide/characters/knight.asp"];
   	ArrMenu[3][2][4] = [324,"ARCHER","/gameguide/characters/archer.asp"];
   	
	/*					
   	ArrMenu[3][4] = new Array();
   	ArrMenu[3][4][0] = [340,"ITEM","/Guide/Enjoygame/default.asp"];
   	ArrMenu[3][4][1] = [341,"WEAPONS","/Guide/Enjoygame/ring/default.asp"];
   	ArrMenu[3][4][2] = [342,"ARMOR","/Guide/Enjoygame/chatmacro/default.asp"];
   	ArrMenu[3][4][3] = [343,"GEM & STONES","/Guide/Enjoygame/pk/default.asp"];
   	ArrMenu[3][4][4] = [344,"RINGS & AMULETS","/Guide/Enjoygame/itemremodeling/default.asp"];
   	ArrMenu[3][4][5] = [345,"OTHERS","/Guide/Enjoygame/itemmixture/default.asp"];
   	ArrMenu[3][4][6] = [346,"ITEM OPTION","/Guide/Enjoygame/lottery/default.asp"];
						
   	ArrMenu[3][5] = new Array();
   	ArrMenu[3][5][0] = [350,"SKILL","/Guide/Item/default.asp"];
   	ArrMenu[3][5][1] = [351,"WARRIOR","/Guide/Item/Weapon.asp"];
   	ArrMenu[3][5][2] = [352,"SORCERESS","/Guide/Item/Defence.asp"];
   	ArrMenu[3][5][3] = [353,"KNIGHT","/Guide/Item/Jewel.asp"];

	*/		
   	ArrMenu[3][3] = new Array();
   	ArrMenu[3][3][0] = [330,"MAP INFO","/gameguide/mapinfo/temoz.asp"];
   	ArrMenu[3][3][1] = [331,"Temoz/Wolfreck","/gameguide/mapinfo/temoz.asp"];
   	ArrMenu[3][3][2] = [332,"Quanato/Elcanber","/gameguide/mapinfo/quanato.asp"];
   	ArrMenu[3][3][3] = [333,"Fellmod/Vemerden","/gameguide/mapinfo/fellmod.asp"];
   	ArrMenu[3][3][4] = [334,"Rangdel","/gameguide/mapinfo/rangdel.asp"];
   	ArrMenu[3][3][5] = [335,"Selvab","/gameguide/mapinfo/selvab.asp"];
   	ArrMenu[3][3][6] = [336,"Carod","/gameguide/mapinfo/carod.asp"];
   	ArrMenu[3][3][7] = [337,"Clab","/gameguide/mapinfo/clab.asp"];
				  
ArrMenu[4] = new Array();
ArrMenu[4][0] = new Array();
ArrMenu[4][0][0] = [400,"Game Data","/gamedata/download/a3client.asp"];
   	ArrMenu[4][1] = new Array();
   	ArrMenu[4][1][0] = [410,"DOWNLOAD","/gamedata/download/a3client.asp"];
   	ArrMenu[4][1][1] = [411,"A3 CLIENT","/gamedata/download/a3client.asp"];
   	ArrMenu[4][1][2] = [412,"GRAPHIC CARD DRIVER","/gamedata/download/driver.asp"];
   	ArrMenu[4][1][3] = [413,"MANUAL","/gamedata/download/manual.asp"];
   	
   	ArrMenu[4][2] = new Array();
   	ArrMenu[4][2][0] = [420,"WALLPAPER","/gamedata/wallpaper/default.asp"];
   	
   	ArrMenu[4][3] = new Array();
   	ArrMenu[4][3][0] = [430,"ARTWORK","/gamedata/artwork/default.asp"];
   	
   	ArrMenu[4][4] = new Array();
   	ArrMenu[4][4][0] = [440,"OST","/gamedata/ost/default.asp"];
						
ArrMenu[5] = new Array();
ArrMenu[5][0] = new Array();
ArrMenu[5][0][0] = [500,"CONTACT US","/general/contactus.asp"];

ArrMenu[6] = new Array();
ArrMenu[6][0] = new Array();
ArrMenu[6][0][0] = [600,"SITE-MAP","/general/sitemap.asp"];

ArrMenu[7] = new Array();
ArrMenu[7][0] = new Array();
ArrMenu[7][0][0] = [700,"BBS","/board/list.asp?ServiceUseID=65"];
  	ArrMenu[7][1] = new Array();
  	ArrMenu[7][1][0] = [710,"BBS","/board/list.asp?ServiceUseID=65"];  	
	  
function goMenu(no)
{
	var TopMenu = no.substring(0,1);
	var SubMenu = no.substring(1,2);
	var DetailMenu = no.substring(2,no.length);
	
	// change number.....
	if ((TopMenu == 3) && (SubMenu == 3))
		SubMenu = 2
	if ((TopMenu == 3) && (SubMenu == 6))
		SubMenu = 3
	
	// change number.....
	
	document.location.href = ArrMenu[TopMenu][SubMenu][DetailMenu][2];	
}
	     
function ChangeImage(str, num, MenuIdx, func)							//func=1 : str + "_over.gif", func=0 : str + ".gif"
{
	/*var CImage = document.getElementById(str + num);
	if (func==1)
	{
		if (CImage != null) {
			CImage.src = "/a/img/menu/" + str + MenuIdx + "_over.gif";*/
			STATUSLMENU = 1;
			CURRENTLMENU = num;
/*		}
	} else {
		CImage.src = "/a/img/menu/" + str + ((Math.floor(MenuIdx/100)*100)+(num*10)) + ".gif";
	}*/
}
      
function DisplayLayer(num, func)	//func=1 : display=visible, func=0 display=none
{
	var DLayer = document.getElementById("LMENU" + num)
	if (DLayer != null)
		if(func==1)
			DLayer.style.display="";
		else
			DLayer.style.display="none";	
}
      
function LMenu(num, MenuIdx)
{
	if (STATUSLMENU==0)
		CURRENTLMENU = null;
	else
	{
		ChangeImage("lmenu_",CURRENTLMENU, MenuIdx, 0);
		DisplayLayer(CURRENTLMENU, 0);
		if (CURRENTLMENU==num)
		{
			STATUSLMENU = 0;
			CURRENTLMENU = null;
			return;
		}
		else
		{
				STATUSLMENU = 0;
				CURRENTLMENU = null;
		}
	}
	ChangeImage("lmenu_",num, MenuIdx, 1);
	DisplayLayer(num, 1);
}
      
function PrintLmenu(num)
{
	var strHtml="";
	var TopMenu = num.substring(0,1);
	var SubMenu = num.substring(1,2);
	var DetailMenu = num.substring(2,num.length);
	
	strHtml += "<tr><td width=174px height=31px align=center style=background:url('/a/img/bg_LmenuTop.jpg');color:#F2DEC7;><b>" + ArrMenu[0][TopMenu-1][0] + "</td></tr>";
	strHtml += "<tr><td width=174px height=447px valign=top style=background:url('/a/img/bg_LMenu" + trim(ArrMenu[0][TopMenu-1][0]) + ".jpg');padding:21px;>";
	
	for (var i=1; i < ArrMenu[TopMenu].length;i++)
	{					
		if (ArrMenu[TopMenu][i].length > 1) 
			strHtml += "<table cellpadding='0' cellspacing='0' border='0'><tr><td><a href='javascript:LMenu(" + i + "," + ArrMenu[TopMenu][i][0][0] + ");' onfocus='this.blur();'><div id='lmenu_" + i + "' style='color:#998675;' onMouseOut=this.style.color='#998675' onMouseOver=this.style.color='#F2DEC7'><b>+" + ArrMenu[TopMenu][i][0][1] + "</div></a></td></tr>";
		else
			strHtml += "<table cellpadding='0' cellspacing='0' border='0'><tr><td><a href='" + ArrMenu[TopMenu][i][0][2] + "' onfocus='this.blur();'><div id='lmenu_" + i + "' style='color:#998675;' onMouseOut=this.style.color='#998675' onMouseOver=this.style.color='#F2DEC7'><b>+" + ArrMenu[TopMenu][i][0][1] + "</div></a></td></tr>";		
		
		strHtml += "</table>";
				
		if (ArrMenu[TopMenu][i].length > 1)
		{			
			strHtml += "				<div id='LMENU" + i + "' style='display:none;padding-left:0px' align='left' width='100%'>";
			strHtml += "				<table cellpadding='0' cellspacing='0' border='0' width='100%' style='border-top:1px solid #57493C; border-bottom:1px solid #57493C;'>";
			strHtml += "				<tr><td colspan='3' height='4'></td></tr>";
						
			for (var j=1;j < ArrMenu[TopMenu][i].length;j++)
			{
				strHtml += "			<tr height='18'>";
				strHtml += "				<td width='5'></td>"
				strHtml += "				<td style='padding-top:6px' align='left'><a href='" + ArrMenu[TopMenu][i][j][2] + "' onfocus='this.blur();'></a></td>";
				strHtml += "				<td align='left' style='padding-left:3px'><a href='" + ArrMenu[TopMenu][i][j][2] + "' onfocus='this.blur();' style='color:#736357;' onMouseOver=this.style.color='#998675' onMouseOut=this.style.color='#736357'><b>" + ArrMenu[TopMenu][i][j][1] + "</a></td>";
				strHtml += "			</tr>";							
			}						
			strHtml += "				<tr><td colspan='3' height='4'></td></tr>";
			strHtml += "				</table>";
			strHtml += "				</div>";							
		}
	}
	document.write (strHtml);
}
            
function ActiveLmenu(num)
{		
	var TopMenu = num.substring(0,1);
	var SubMenu = num.substring(1,2);
	var DetailMenu = num.substring(2,num.length);
			
	if (ArrMenu[TopMenu][SubMenu].length > 1)
	  LMenu(SubMenu, (TopMenu*100)+(SubMenu*10));
	else
	  ChangeImage("lmenu_",SubMenu, (TopMenu*100)+(SubMenu*10), 1);
}

// trim
function trim(tmp)
{
	var i, tmp2, tmp3;
	tmp3 = "";
	tmp2 = tmp.split(" ");
	for (i = 0; i < tmp2.length; i++)
		tmp3 += tmp2[i]
	
	return tmp3;	
}

// linemap
function contentstitle()
{
	var pos, pos2, lTitle, rLocation, tmp;
	pos = CURRENTMENU;
	pos2 = pos.split("");
	tmp = "&nbsp;&gt;&nbsp;";
	
	lTitle = ArrMenu[pos2[0]][pos2[1]][0][1];
	rLocation = "<a href=/main.asp onFocus=this.blur();>home</a>" + tmp;	// home
	rLocation += "<a href=" + ArrMenu[pos2[0]][0][0][2] + " onFocus=this.blur();>" + convert(ArrMenu[pos2[0]][0][0][1]) + "</a>";

	if (pos2[1] != 0)
	{
		rLocation += tmp;
		rLocation += "<a href=" + ArrMenu[pos2[0]][pos2[1]][0][2] + " onFocus=this.blur();>" + convert(ArrMenu[pos2[0]][pos2[1]][0][1]) + "</a>";
	}
	if (pos2[2] != 0)
	{
		rLocation += tmp;
		rLocation += "<a href=" + ArrMenu[pos2[0]][pos2[1]][pos2[2]][2] + " onFocus=this.blur();>" + convert(ArrMenu[pos2[0]][pos2[1]][pos2[2]][1]) + "</a>";
	}
	
	subtitle.innerHTML = lTitle;
	linemap.innerHTML = rLocation;	
}

// upper case
function convert(tmp)
{
	var tmp2;
	tmp = tmp.toLowerCase();
	tmp2 = tmp.substr(0,1);
		
	if (tmp != "bbs")
		return tmp2.toUpperCase() + tmp.substr(1);
	else
		return "BBS";
}

function GoRemoteMenu(no)
{
   switch (parseInt(no)) {
   	case 1 :
   		fullScreen('main');
   		break;
   	case 2 :
   		document.location.href="/gameinfo/movie/movie.asp#4";
   		break;
   	case 3 :
   		openloveletter();
   		break;
   	case 4 :
   		document.location.href="/gameinfo/movie/movie.asp";
   		break;
   	case 5 :
   		document.location.href="/gameinfo/movie/movie.asp#3";
   		break;
   	case 6 :
   		document.location.href="/gameinfo/movie/movie.asp#5";
   		break;
   	case 7 :
   		openpreview();
   		break;

   	case 8 :
   		openpreview();
   		break;
   		
   	case 9 :
   		viewmovie();
   		break;
   		
   	case 10 :
   		downfile();
   		break;   		   		



   }
}
      
function fullScreen(menuid)		// casting_char page control
{
	var Pop;
	var tmpUrl="http://ftp.gameto.com/webteam/WebA3/intro/new_casting_char_english/" + menuid + ".html";
	
		if (self.screen) { 
	        sw = screen.width;
	        sh = screen.height;
			w = sw - 10;
			h = sh - 70;
			cx = 0;
			cy = 0;

			var  sml = 'toolbar=0,location=0,fullscreen=1,directories=0,status=0,menubar=0,scrollbars=0,resizable=0';
			var  mid = 'width='+w+','+'height='+h+',' + 'screenX=' +cx+','+'screenY='+cy+','+'left='+cx+','+'top='+cy+',fullscreen=1,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0';
			var  big = 'width='+w+','+'height='+h+',' + 'screenX=' +cx+','+'screenY='+cy+','+'left='+cx+','+'top='+cy+',fullscreen=1,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0';


	
			if (screen.width < 900)
			{
				Pop=window.open(tmpUrl,"casting_char",sml);
			}
			else if (screen.width < 1030)
			{
				Pop=window.open(tmpUrl,"casting_char",mid);   
			}
			else
			{
					
				Pop=window.open(tmpUrl,"casting_char",big);   
			}
	}
}

function openloveletter()		// love letter popup
{
	popmovie=window.open("/etc/loveletter/default.htm","loveletter", "toobar=no,scrollbars=no,status=no, resize=no, width=720, height=300");
	popmovie.focus();
}
	
function viewmovie()		// flash movie popup 
{
	popmovie=window.open("http://ftp.gameto.com/opteam/A3/www/clan_swf/main.html","popmovie1", "toobar=no,scrollbars=no,status=no, resize=no, width=720, height=390");
	popmovie.focus();
}

function openpreview()		// age of sovereign popup
{
	poppre=window.open("/a3clan/popup/menu1.asp","poppreview", "toobar=no,scrollbars=no,status=no, resize=no, width=700, height=600");
	poppre.focus();
}

function downfile()			// age of sovereign popup flash
{
	location.href = "ftp://ftp.gameto.com/opteam/A3/www/clan_swf/pop_movie.zip";
}

function GoMain()
{
	location.href="/main.asp";
}