/*
盛大超级玩家活动
装载游戏编号及对应的区服
伍德祥
2006-7-9
*/
var oXmlGames,GameID,oXmlAreas;
var sXmlSourceSrc="XML/";
//初始化
function InitGameAreas(sXmlSource,sPath)
{
	if(sXmlSource==null||sXmlSource=="")
	{
		sXmlSource="Games.xml";
	}
	if(sPath==null)
	{
		sPath="";
	}
	oXmlGames=new ActiveXObject("Msxml2.FreeThreadedDomDocument");
	oXmlGames.async=false;
	oXmlGames.load(sPath+sXmlSourceSrc+sXmlSource);
}
//装载游戏列表
function LoadGames(sSelectID)
{
	if(oXmlGames==null)
	{
		InitGameAreas();
	}
	if(sSelectID==null||sSelectID=="")
	{
		sSelectID="sltGames";
	}
	var oSelect=document.getElementById(sSelectID);
	if(!oSelect)
	{
		window.alert("无法找到游戏分类信息容器");
		return;
	}
	while(oSelect.options.length>1)
	{
		oSelect.remove(1);
	}
	try
	{
		var bTest=bEnableAll;
	}
	catch(err)
	{
		bEnableAll=true;
	}
	var oGames;
	if(bEnableAll==true)
	{
		oGames=oXmlGames.selectNodes("/Games/Game");
	}
	else
	{
		oGames=oXmlGames.selectNodes("/Games/Game[@Disabled='0']");
	}
	for(var iCount=0;iCount<oGames.length;iCount++)
	{
		var oOption=document.createElement("option");
		oOption.value=oGames[iCount].getAttribute("GameID");
		oOption.text=oGames[iCount].selectSingleNode("Name").text;
		oSelect.add(oOption);
	}
}
//装载区服列表
function LoadAreas(vGameIDOrXml,sSelectID)
{
	if(sSelectID==null||sSelectID=="")
	{
		sSelectID="sltAreas";
	}
	GameID=vGameIDOrXml;
	var oSelect=document.getElementById(sSelectID);
	if(!oSelect)
	{
		window.alert("无法找到区服信息容器");
		return;
	}
	while(oSelect.options.length>0)
	{
		oSelect.remove(0);
	}
	var oOption=document.createElement("option");
	oOption.value="";
	oOption.text="请选择";
	oSelect.add(oOption);
	oOption.selected=true;
	var sXmlUrl="";
	if(oXmlGames==null)
	{
		sXmlUrl=vGameIDOrXml;
	}
	else
	{
		var oGame=oXmlGames.selectSingleNode("/Games/Game[@GameID='"+vGameIDOrXml+"']");
		if(oGame==null)
		{
			return;
		}
		sXmlUrl=sXmlSourceSrc+oGame.getAttribute("Areas");
	}
	oXmlAreas=new ActiveXObject("Msxml2.FreeThreadedDomDocument");
	oXmlAreas.async=false;
	oXmlAreas.load(sXmlUrl);
	var oAreas=oXmlAreas.selectNodes("/Areas/Area");
	for(var iCount=0;iCount<oAreas.length;iCount++)
	{
		oOption=document.createElement("option");
		oOption.value=oAreas[iCount].getAttribute("AreaID");
		oOption.text=oAreas[iCount].getAttribute("AreaName");
		oSelect.add(oOption);
	}
}
function LoadServers(iAreaID,sSelectID)
{
	if(sSelectID==null||sSelectID=="")
	{
		sSelectID="sltServers";
	}
	var oSelect=document.getElementById(sSelectID);
	if(!oSelect)
	{
		window.alert("无法找到区服信息容器");
		return;
	}
	while(oSelect.options.length>0)
	{
		oSelect.remove(0);
	}
	var oOption=document.createElement("option");
	oOption.value="";
	oOption.text="请选择";
	oSelect.add(oOption);
	oOption.selected=true;
	var oAreas=oXmlAreas.selectNodes("/Areas/Area[@AreaID='"+iAreaID+"']/Server");
	for(var iCount=0;iCount<oAreas.length;iCount++)
	{
		oOption=document.createElement("option");
		oOption.value=oAreas[iCount].getAttribute("ServerID");
		oOption.text=oAreas[iCount].getAttribute("ServerName");
		oSelect.add(oOption);
	}
	if(iCount==0)
	{
		oSelect.runtimeStyle.display="none";
	}
	else
	{
		oSelect.runtimeStyle.display="inline";
	}
}