﻿//添加火狐对innerText属性的支持
function isIE(){ //ie?
   if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1)
    return true;
   else
    return false;
}
if(!isIE()){ //firefox innerText define
   HTMLElement.prototype.__defineGetter__(     "innerText",
    function(){
     var anyString = "";
     var childS = this.childNodes;
     for(var i=0; i<childS.length; i++) {
      if(childS[i].nodeType==1)
       anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
      else if(childS[i].nodeType==3)
       anyString += childS[i].nodeValue;
     }
     return anyString;
    }
   );
   HTMLElement.prototype.__defineSetter__("innerText",
    function(sText){
     this.textContent=sText;
    }
   );
} 

var $$ =function(ID){return document.getElementById(ID);};
var IsRootDir=false;
var OpenCloseFlag="0";
function getQueryString(key)
{
	var locString = location.search;
	var reg = new RegExp("(\\?|\\&)" + key + "=([^\\&]*)(\\&?)","i").exec(locString);
	return RegExp.$2;
}
function BindHotList()
{   
    if(IsRootDir)
    {   
        //Gold
        $$("divHotList").innerHTML=aion.ajax.common.GetHotList("AION","26","0").value;
        //PowerLevel
        $$("divHotList1").innerHTML=aion.ajax.common.GetHotList("AION","27","0").value;
    }
    else
    {   
        //Gold
        $$("divHotList").innerHTML=aion.ajax.common.GetHotList("AION","26","1").value;
        //PowerLevel
        $$("divHotList1").innerHTML=aion.ajax.common.GetHotList("AION","27","1").value;
    }
}
//右边热卖区域切换
function ChangeHotList(hottype)
{
    if(hottype=="0")
    {   
        $("#divhotGold").removeClass("current");
        $("#divhotGold").addClass("current3");
        $("#divhotPL").removeClass("current");
        $("#divhotPL").addClass("current2");
        $$("divHotList1").style.display="none";
        $$("divHotList").style.display="";
    }
    else
    {   
        $("#divhotPL").removeClass("current2");
        $("#divhotGold").removeClass("current3");
        $("#divhotGold").addClass("current");
        $$("divHotList1").style.display="";
        $$("divHotList").style.display="none";
    }
}

function CheckOut1(name,moneycode,price,webtime,startlevel,endlevel,leveltype,choosetype)
{   
	//Main("CheckOut");
	var hidGameName=$$("hidGameName").value;
	var result = aion.ajax.PowerLevel.SaveForm1(hidGameName,name,price,webtime,startlevel,endlevel,leveltype,choosetype);
	window.location="../powerlevel/powerlevel1.html";
}
//焦点进入
function ClearText(me,text)
{   
    if(me.value==""||me.value==text)
    me.value="";
}
//焦点离开
function GetText(me,text)
{   
    if(me.value=="")
    {   
        me.value=text;
    }
    
    if(me==$$("txtRegEmail")&&text!=me.value)
    {
        CheckEmail(me);
    }
    if(me==$$("txtUserID")&&text!=me.value)
    {
        CheckID(me);
    }
}
BindHotList();
InitLoginLayer();
/*
function WebRefresh()
{
	RefreshInfo();
}
var MyInterval=setInterval("WebRefresh()",1000*60*5);
*/
//用户登录
function CustomerLogin()
{
        
}
//打开登录的层
function OpenLoginLayer()
{   
    if(OpenCloseFlag=="0")
    {
	    $$("divPopLogin").style.display="";
	    OpenCloseFlag="1";
	}
	else
	{
	    $$("divPopLogin").style.display="none";
	    OpenCloseFlag="0";
	}
}
//关闭登录的层
function CloseLoginLayer()
{
	$$("divBG").style.display="none";
	$$("divPopLogin").style.display="none";
	OpenCloseFlag="0";
}
//初始化登陆框显示位置
function InitLoginLayer()
{   
    if($$("divPopLogin")!=null&&$$("divBG")!=null)
    {
	    LayerPosition("divPopLogin","home1");	
	    $$("divBG").style.width=document.body.scrollWidth+"px";
	    $$("divBG").style.height=document.body.scrollHeight+"px";
	}
}
//计算位置
function LayerPosition(divId1,divId2)
{
	var tbMenu=document.getElementById(divId1);
	var tdId=document.getElementById(divId2);
	var MenuStyle =tbMenu.style; 
	var MeTop = tdId.offsetTop;
	var MeLeft = tdId.offsetLeft;
	while (tdId = tdId.offsetParent)
	{
		MeTop+=tdId.offsetTop;
		MeLeft+=tdId.offsetLeft;
	} 
	MenuStyle.top=Number(MeTop-170)+"px";
	MenuStyle.left = Number(MeLeft+155)+"px"; 
}
//登录
function CustomerLogin()
{
	var txtEmail1=$$("txtLoginUserName");
	var txtPassword=$$("txtLoginPwd");
	if(txtEmail1.value=="")
	{
		alert("UserName can't be empty.");
		return;
	}
	if(txtPassword.value=="")
	{
		alert("Password can't be empty.");
		return;
	}	
	var result=aion.ajax.common.Login(txtEmail1.value,txtPassword.value).value;
	if(result!="")
	{   
	
	    $$("divBG").style.display="none";
	    $$("divPopLogin").style.display="none";
	    $$("divIsLogin").style.display="";
	    $$("divNotLogin").style.display="none";
		$$("divIsLogin").innerHTML=result;
	}
	else
	{
		alert("UserName or Password Error.");
	}
	txtEmail1.value="";
	txtPassword.value="";
}
//注销
function Logout()
{
	var result=aion.ajax.common.Logout().value;
	//中间显示信息处要更改
	$$("divIsLogin").style.display="none";
	$$("divNotLogin").style.display="";
	if(OpenCloseFlag=="0")
	{
	    OpenCloseFlag="1";
	}
	else
	{
	    OpenCloseFlag="0";
	}
}
//检查是否登录
function CheckLogin()
{
	var result=aion.ajax.common.CheckLogin().value;
	if($$("divIsLogin")!=null&&$$("divNotLogin")!=null)
	{
	    if(result!="")
	    {   
		    $$("divIsLogin").style.display="";
		    $$("divNotLogin").style.display="none";
		    $$("divIsLogin").innerHTML=result;
	    }
	    else
	    {
		    //$$("divIsLogin").style.display="none";
		    $$("divNotLogin").style.display="";
	    }
	}
}
CheckLogin();
//enter event
function checkenter(evt,para,option)
{
	evt = evt ? evt : (window.event ? window.event : null);	
	if(evt.keyCode == 13)
	{
		switch(para)
		{
			case 0:
				var option=document.getElementById(option);
				option.focus();
				break;
			case 1:
				setTimeout(option,100)
				break;
		}
		return false;
	}
}

