﻿var $$=function(ID){return document.getElementById(ID);};
_ServerList_Selected_Game="AION";
_ServerList_Current_Page="Home";

function ShowServerList(Page,Area)
{
    _ServerList_Current_Page=Page;
	_ServerList_Selected_Game=Area;
	
	if(Area.toLowerCase()=="aion")
	{
		$$("USLI").className="biangeng";
	}
	else
	{
		$$("USLI").className="nobiangeng";
	}
	if(Area.toLowerCase()=="euaion")
	{
		$$("EULI").className="biangeng";
	}
	else
	{
		$$("EULI").className="nobiangeng";
	}
	
	
	SearchServer("ALL");
}

function regreplace(str,searchtxt,replacetxt)
{
	var kk=new RegExp(searchtxt,"gi");
	str=str.replace(kk,replacetxt);
	return str;
}

function SearchServer(firstletter)
{
 var str="";
 str=str+"<div class=\"zm\" align=\"center\">";
 str=str+"<ul>"; 
 for(c=0;c<26;c++)
 {
	var cc=String.fromCharCode(65+c);
	str=str+"<li><a href=\"#\" onclick=\"SearchServer('"+cc+"');return false;\">"+cc+"</a></li>\r\n";
 }
 str=str+"<ul>";
 str=str+"</div>";
 
 //firstletter 默认值是 ALL 之后都是26个字母
 str=str+"<div class=\"fwq_2\">";
 //循环取服务器
 var oldServer=""; 
 var ServerY=ServerArray[_ServerList_Selected_Game];
 for(var i=0;i<ServerY.length;)
 {	
	var str2="";
	str2=str2+"<div>";
	if(firstletter=="ALL")
	{	
		//str2=str2+"<div align=\"center\" class=\"f_1\"><strong>"+ServerY[i].substring(0,1).toUpperCase()+" (Elyos)</strong></div>";
		str2=str2+"<div align=\"center\" class=\"f_1\"><strong>Elyos</strong></div>";
	}
	else
	{
		//str2=str2+"<div align=\"center\" class=\"f_1\"><strong>"+firstletter+" (Elyos)</strong></div>";
		str2=str2+"<div align=\"center\" class=\"f_1\"><strong>Elyos</strong></div>";
	}
	str2=str2+"<div align=\"center\" class=\"f_2\">";
	str2=str2+"<ul>";
	var str3="";
	str3=str3+"<div>";
	if(firstletter=="ALL")
	{
		//str3=str3+"<div align=\"center\" class=\"f_1\"><strong>"+ServerY[i].substring(0,1).toUpperCase()+" (Asmodians)</strong></div>";
		str3=str3+"<div align=\"center\" class=\"f_1\"><strong>Asmodians</strong></div>";
	}
	else
	{
		//str3=str3+"<div align=\"center\" class=\"f_1\"><strong>"+firstletter+" (Asmodians)</strong></div>";
		str3=str3+"<div align=\"center\" class=\"f_1\"><strong>Asmodians</strong></div>";
	}
	str3=str3+"<div align=\"center\" class=\"f_2\">";
	str3=str3+"<ul>";
	for(var j=0;j<200 && i<ServerY.length;i++)
	{
		var newServer=ServerY[i].substring(0,ServerY[i].lastIndexOf("-"));
		var svletter=ServerY[i].substring(0,1).toUpperCase();
		if(newServer!=oldServer && (firstletter==svletter || firstletter=="ALL"))
		{
			if(_ServerList_Current_Page=="Home")
			{
				str2=str2+"<li><a href=\""+_ServerList_Selected_Game+"-Kinah/"+regreplace(regreplace(newServer," ","-"),"'","")+"-Elyos.Html#list\">"+newServer+"</a></li>";
			}
			else
			{
				str2=str2+"<li><a href=\"../"+_ServerList_Selected_Game+"-Kinah/"+regreplace(regreplace(newServer," ","-"),"'","")+"-Elyos.Html#list\">"+newServer+"</a></li>";
			}
		
			if(_ServerList_Current_Page=="Home")
			{
				str3=str3+"<li><a href=\""+_ServerList_Selected_Game+"-Kinah/"+regreplace(regreplace(newServer," ","-"),"'","")+"-Asmodians.Html#list\">"+newServer+"</a></li>";
			}
			else
			{
				str3=str3+"<li><a href=\"../"+_ServerList_Selected_Game+"-Kinah/"+regreplace(regreplace(newServer," ","-"),"'","")+"-Asmodians.Html#list\">"+newServer+"</a></li>";
			}
			j++;
		}
		oldServer=ServerY[i].substring(0,ServerY[i].lastIndexOf("-"));		
	}
	if(str2!="<div>"+"<div align=\"center\" class=\"f_1\"><strong>"+firstletter+" (Elyos)</strong></div>"+"<div align=\"center\" class=\"f_2\">"+"<ul>")
	{
	str2=str2+"</ul><div style=\"clear:both\"></div></div>";
	str2=str2+"</div>";
	str3=str3+"</ul><div style=\"clear:both\"></div></div>";
	str3=str3+"</div>";
	str=str+str2+str3;
	}
 }
 //循环结束 
 str=str+"</div>";
 document.getElementById("ServerList").innerHTML=str;
}




function ShowNewsDescript()
{
	var NewsDescription=document.getElementById("NewsDescription");
	var NewsList=document.getElementById("NewsList");
	if(NewsDescription.style.display=="none")
	{
		NewsList.style.display="none";
		NewsDescription.style.display="";
	}
	$$("ND").className="biangeng";
	$$("NS").className="nobiangeng";
}

function ShowNewsList()
{
	var NewsDescription=document.getElementById("NewsDescription");
	var NewsList=document.getElementById("NewsList");
	
	if(NewsList.style.display=="none")
	{
		NewsList.style.display="";
		NewsDescription.style.display="none";
		
	}
	$$("ND").className="nobiangeng";
	$$("NS").className="biangeng";
}
