﻿/* URL Information */
var __bLocal		= (location.href.indexOf("http://lc")==0);
var __bNewWWW		= (location.href.indexOf("http://new")==0);
var __urlPrefix		= __bLocal ? "lc-":(__bNewWWW ? "new-":"");
var __urlWWW		= "http://"+__urlPrefix+"www.webzen.com/";
var __urlMEMBER		= "http://"+__urlPrefix+"member.webzen.com/";
var __urlFORUM		= "http://"+__urlPrefix+"forum.webzen.com/";
var __urlMU			= "http://"+__urlPrefix+"muonline.webzen.com/";
var __urlSUN		= "http://"+__urlPrefix+"sunonline.webzen.com/";
var __urlARCHLORD	= "http://"+__urlPrefix+"archlord.webzen.com/";
var __urlPayment	= "http://"+__urlPrefix+"payment.webzen.com/";

/* KeyWord */
var word_GAMES, word_FORUMS, word_VIDEOFORUM, word_WEBZENFORUM, word_WCOIN;
var word_DOWNLOAD, word_SUPPORT, word_MYACCOUNT, word_SIGNUP, word_LOGIN, word_LOGOUT;
var _selectedLang = fnGetCookie('CurrentCulture');
if (_selectedLang == "fr")
{
	word_GAMES = "JEUX";
	word_FORUMS = "FORUMS";
	word_VIDEOFORUM = "VIDÉO FORUM";
	word_WEBZENFORUM = "WZ FORUM";
	word_WCOIN = "W COIN";
	word_DOWNLOAD = "TÉLÉCHARGER";
	word_SUPPORT = "SOUTIEN";
	word_MYACCOUNT = "MON COMPTE";
	word_SIGNUP = "INSCRIVEZ-VOUS";
	word_LOGIN = "CONNECTEZ-VOUS";
	word_LOGOUT = "LOG OUT";
}
else if (_selectedLang == "de")
{
	word_GAMES = "SPIELE";
	word_FORUMS = "FOREN";
	word_VIDEOFORUM = "VIDEO FORUM";
	word_WEBZENFORUM = "WZ FORUM";
	word_WCOIN = "W COIN";
	word_DOWNLOAD = "DOWNLOAD";
	word_SUPPORT = "SUPPORT";
	word_MYACCOUNT = "MEIN KONTO";
	word_SIGNUP = "NEU ANMELDEN";
	word_LOGIN = "EINLOGGEN";
	word_LOGOUT = "ABMELDEN";
}
else
{
	word_GAMES		= "GAMES";
	word_FORUMS		= "FORUMS";
	word_VIDEOFORUM = "VIDEO FORUMS";
	word_WEBZENFORUM = "WEBZEN FORUM";
	word_WCOIN		= "W COIN";
	word_DOWNLOAD	= "DOWNLOAD";
	word_SUPPORT	= "SUPPORT";
	word_MYACCOUNT	= "MY ACCOUNT";
	word_SIGNUP		= "SIGN UP";
	word_LOGIN		= "LOG IN";
	word_LOGOUT		= "LOG OUT";
}

function fnDisplayGNB(strGameCode, strAccountID, blnLogin)
{
	/* GNB Printing */
	document.write("<div id=\"global_gnb\">\n");
	document.write("<div id=\"global_header\">\n");
	document.write("	<table>\n");
	document.write("	<tbody>\n");
	document.write("	<tr>\n");
	document.write("		<td width=\"440\" nowrap=\"nowrap\">\n");
	document.write("		<h1><a href=\""+__urlWWW+"\"><img src=\"http://image.webzen.com/Global/Games/common/nav_logo.gif\" alt=\"\" /></a></h1>\n");
	document.write("		<ul id=\"global_nav_menu\">\n");
	document.write("			<li onmouseover=\"gnb.over(this);\">\n");
	document.write("				<p class=\"depth1\">"+word_GAMES+"</p>\n");
	document.write("				<div id=\"global_nav_gamebox\">\n");
	document.write("				<ul>\n");
	document.write("					<li><a href=\""+__urlMU+"\">MUONLINE</a></li>\n");
	document.write("					<li><a href=\""+__urlARCHLORD+"\">ARCHLORD</a></li>\n");
	document.write("					<li><a href=\""+__urlSUN+"\">S.U.N</a></li>\n");
	//document.write("					<li><a href=\"#\">R2</a></li>\n");
	document.write("				</ul>\n");
	document.write("				<div class=\"nav_pngbg\"></div>\n");
	document.write("				</div>\n");
	document.write("			</li>\n");
	document.write("			<li onmouseover=\"gnb.over(this);\">\n");
	document.write("				<p class=\"depth1\">"+word_FORUMS+"</p>\n");
	document.write("				<div id=\"global_nav_forumsbox\">\n");
	document.write("				<ul>\n");
	document.write("					<li><a href=\""+__urlFORUM+"VideoForum/\">"+word_VIDEOFORUM+"</a></li>\n");
	document.write("					<li><a href=\""+__urlFORUM+"\">"+word_WEBZENFORUM+"</a></li>\n");
	document.write("				</ul>\n");
	document.write("				<div class=\"nav_pngbg\"></div>\n");
	document.write("				</div>\n");
	document.write("			</li>\n");
	if (blnLogin == "True")
	{	// login
		document.write("			<li><a href=\""+__urlPayment+"Main/Main_GB_C.asp\" class=\"depth1\">W COIN</a></li>\n");
	} 
	else 
	{	// before login
		document.write("			<li><a href=\""+__urlMEMBER+"Login/Default.aspx?sGC=102&sRU="+__urlPayment+"/Main/Main_GB_C.asp\" class=\"depth1\">"+word_WCOIN+"</a></li>\n");
	}
	document.write("			<li class=\"bdnone\"><a href=\""+__urlWWW+"_HTML/Download.aspx\" class=\"depth1\">"+word_DOWNLOAD+"</a></li>\n");
	document.write("		</ul>\n");
	document.write("		</td>\n");
	document.write("		<td nowrap=\"nowrap\">\n");
	document.write("		<table>\n");
	document.write("		<tbody>\n");
	document.write("		<tr>\n");
	document.write("			<td>\n");
	document.write("			<ul id=\"global_nav_register\">\n");
	if (blnLogin == "True")
	{	// login
		document.write("				<li class=\"username\"><span title=\"Your user ID\">"+strAccountID+"</span></li>\n");
	}
	document.write("				<li id=\"global_nav_language\">\n");
	document.write("				<div id=\"languageGlobalSelect\" onclick=\"selectGlobalFunc.action(this,0);\">\n");
	document.write("					<p><a href=\"#\" class=\"default\" onclick=\"return false;\">English</a></p>\n");
	document.write("					<ul>\n");
	document.write("						<li><a href=\"#\" name=\"en\">English</a></li>\n");
	document.write("						<li><a href=\"#\" name=\"fr\">Français</a></li>\n");
	document.write("						<li><a href=\"#\" name=\"de\">Deutsch</a></li>\n");
	document.write("					</ul>\n");
	document.write("				</div>\n");
	document.write("				</li>\n");
	document.write("				<li class=\"bdnone_support\"><a href=\""+__urlWWW+"Support/FAQ.aspx\">"+word_SUPPORT+"</a></li>\n");
	document.write("				<li><a href=\""+__urlMEMBER+"MyPage/ModifyProfile/\">"+word_MYACCOUNT+"</a></li>\n");
	if (blnLogin == "True")
	{	// login
		document.write("				<li class=\"bdnone\"><a href=\""+__urlMEMBER+"Login/LogOut.aspx?sGC="+strGameCode+"\">"+word_LOGOUT+"</a></li>\n");
	}
	else
	{	// before login
		document.write("				<li><a href=\""+__urlMEMBER+"Login/default.aspx?sGC="+strGameCode+"&amp;sRU="+ document.URL+"\">"+word_LOGIN+"</a></li>\n");
		document.write("				<li class=\"bdnone\"><a href=\""+__urlMEMBER+"Account/Join/registAccount.aspx\">"+word_SIGNUP+"</a></li>\n");
	}
	document.write("			</ul>\n");
	document.write("			</td>\n");
	document.write("		</tr>\n");
	document.write("		</tbody>\n");
	document.write("		</table>\n");
	document.write("		</td>\n");
	document.write("	</tr>\n");
	document.write("	</tbody>\n");
	document.write("	</table>\n");
	document.write("</div>\n");
	document.write("</div>\n");
}

function fnGetCookie( name ) {
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie = document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

/* GNB Layer */
var gnb = {
	over : function(el){
		depth = el.getElementsByTagName("div")[0];
		depth_list = depth.getElementsByTagName("li");
		depth_link = depth.getElementsByTagName("a");
		depth.style.display = "block";
		el.onmouseout = depth.onmouseout = function(){
			depth.style.display = "none";
		}
		for(var i=0; i<depth_list.length; i++){
			depth_list[i].onmouseover = function(){ gnb.rollover(this); }
			depth_list[i].onmouseout = function(){ gnb.rollout(this); }
			depth_link[i].onfocus = function(){ this.blur(); }
			depth_link[i].onclick = function(){ depth.style.display = "none"; }
		}
	},
	rollover : function(el){
		el.getElementsByTagName("a")[0].className = "on";
	},
	rollout : function(el){
		el.getElementsByTagName("a")[0].className = "";
	}
};

var selectGlobalFunc = {
	language : function(el){
		var SelectElement = document.getElementById(el);
		var ActionElement = SelectElement.getElementsByTagName("a");
		for(var i = 1; i < ActionElement.length; i++){
			if(ActionElement[i].getAttribute("name") == fnGetCookie('CurrentCulture')){
				ActionElement[0].innerHTML = ActionElement[i].innerHTML;
			}
		}
	},
	action: function(el, state)
	{
		// state = 0 or 1
		var SelectElement = document.getElementById(el.id);
		var ListElement = SelectElement.getElementsByTagName("ul")[0];
		var ActionElement = ListElement.getElementsByTagName("a");
		if (ListElement.style.display == "block")
		{
			selectGlobalFunc.close(ListElement);
			return false;
		} else
		{
			ListElement.style.display = "block";
		}

		var strSelected = SelectElement.getElementsByTagName("a")[0];
		strSelected.focus();
		for (var i = 0; i < ActionElement.length; i++)
		{
			if (strSelected.firstChild.nodeValue == ActionElement[i].firstChild.nodeValue)
			{
				selectGlobalFunc.elementClass = ActionElement[i];
				SelectElement.getElementsByTagName("li")[i].style.display = "none";
			} else
			{
				SelectElement.getElementsByTagName("li")[i].style.display = "block";
				ActionElement[i].onclick = function()
				{
					fnSetDomainCookie('CurrentCulture', this.name, 365);
					location.reload();
					return false;
				}
			}
			ActionElement[i].onmouseover = function()
			{
				selectGlobalFunc.elementClass.className = "";
				this.className = "selected";
				selectGlobalFunc.elementClass = this;
			}
		}

		SelectElement.onmouseover = function() { strSelected.onblur = function() { } }
		SelectElement.onmouseout = function() { strSelected.onblur = function() { selectGlobalFunc.close(ListElement); } }
	},
	close: function(el)
	{
		selectGlobalFunc.elementClass.className = "";
		el.style.display = "none";
		return false;
	}
};