﻿//调用方法              onkeypress="onlyNumber(event)"
function onlyNumber(e)
{
    var isIE = false;
    var isFF = false;
    var isSa = false;

    if ((navigator.userAgent.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) >=4))isIE = true;
    if(navigator.userAgent.indexOf("Firefox")>0)isFF = true;
    if(navigator.userAgent.indexOf("Safari")>0)isSa = true;

    var iKeyCode;
    iKeyCode = window.event?e.keyCode:e.which;
    if( !(((iKeyCode >= 48) && (iKeyCode <= 57)) || (iKeyCode == 13) || (iKeyCode == 46) || (iKeyCode == 45) || (iKeyCode == 37) || (iKeyCode == 39) || (iKeyCode == 8)))
    {   
        if (isIE)
        {
            e.returnValue=false;
        }
        else
        {
            e.preventDefault();
        }
    }

}



//设置所选择币种
function SetCurrency()
{
    var a = document.getElementsByName("sex");
    if(a.length == 0)
        return;    
    if(getCookie('rates') == '')
    {
        return;
    }
    switch(getMoneyType())
    {
        case "$":
            a[0].checked = true;
        break;
        case "€":
            a[1].checked = true;
        break;
        case "£":
            a[2].checked = true;
        break;
        case "A$":
            a[3].checked = true;
        break;
        case "C$":
            a[4].checked = true;
        break;
    }    
}

//获得xml文档对象
function getXmldoc(xml)
{
    try //Internet Explorer
        {
            xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async="false";
            xmlDoc.loadXML(xml);
        }  
        catch(e)
        {   
            try // Firefox, Mozilla, Opera, etc.
            {
                parser=new DOMParser();
                xmlDoc=parser.parseFromString(xml,"text/xml");
            }
            catch(e)
            {
                alert(e.message);
                return;
            }
        }
        return xmlDoc;
}
//联系在线客服
function clickImg()
{
    if(win == null)
        win = window.open('http://67.229.127.234:8080/login.aspx?web=ignah','newWindow','width=600,height=521,center=yes,alwaysRaised=yes,location=no,menubar=no,resizable=yes,scrollbars=no');
    else
    {
        if(win.closed)
            win = window.open('http://67.229.127.234:8080/login.aspx?web=ignah','newWindow','width=600,height=521,center=yes,alwaysRaised=yes,location=no,menubar=no,resizable=yes,scrollbars=no');
        else
            win.focus();
    }    
}

var win;

//获得contact消息
function ShowContact()
{
    var url = "ashx/contact.ashx";    
    var myAjax = new Ajax.Request(   
                                    url,   
                                    {
                                        method: "get",
                                        onComplete: getcontact
                                    }   
                                );  
}
//显示contact消息
function getcontact(xmlhttp)
{
    var temp = $('showMsg');
    temp.innerHTML = xmlhttp.responseText;
}

//获得about消息
function ShowAbout()
{
    var url = "ashx/about.ashx";    
    var myAjax = new Ajax.Request(   
                                    url,   
                                    {
                                        method: "get",
                                        onComplete: getAbout
                                    }   
                                );  
}
//显示about消息
function getAbout(xmlhttp)
{
    var temp = $('ShowAbout');
    temp.innerHTML = xmlhttp.responseText;
}
//设置每分钟获得一次当前时间
function StartShowTime()
{
    setvisit();
    ShowTime();
    setInterval('ShowTime()',60000);
}
//显示当前时间
function ShowTime()
{
    now=new Date();  
    $('showTime').innerHTML = now.toDateString() + ' ' + now.toTimeString().substring(0,5);
    


}

//调用方法             onkeypress="money(this.value)"
//钱
 function   money(str){   
          var   nc=event.keyCode; 
          var   s=str;
          if((nc>=48)   &&   (nc<=57)   )
          {   
            if(s.substring(0,1)=="0" && s.indexOf('.')< 0)
               {
                    event.keyCode=0;
                    return;
               }
            else
            { 

              if(s.indexOf('.')>0)
              {
              if( s.indexOf('.')<s.length-4)
              {
                event.keyCode=0;   return;   
              }
                }
              }
              }else   if(nc==46){   
                   if(s.length<1)
                   {
                 event.keyCode=0;   return;   
                     }
                  for(var   i=0;i<s.length;i++){   
                      if(s.charAt(i)=='.'){ 
                                  event.keyCode=0;   return;   
                      }   
                  }   
          }
          else{   
              event.keyCode=0;return;   
          }   
      }
      
  function   timeStyle(str){   
      var   nc=event.keyCode; 
      var   s=str;
      if((nc>=48)   &&   (nc<=57)   )
      {   
      if(s.indexOf('.')>0)
      {
      if( s.indexOf('.')<s.length-2)
      {
        event.keyCode=0;   return;   
      }

      }
      }else   if(nc==46){   
           if(s.length<1)
           {
         event.keyCode=0;   return;   
             }
          for(var   i=0;i<s.length;i++){   
              if(s.charAt(i)=='.'){ 
                          event.keyCode=0;   return;   
              }   
          }   
      }
      else{   
          event.keyCode=0;return;   
      }   
  }
      
//禁用字符
function charuse()
{
    if(event.keyCode==124)
    {
        event.returnValue=false;
    }
}

//textarea最大长度
function maxtextarea(tb, len)
{
    var tbvalue = tb.value;
    if(tbvalue.length >= len)
    {
         event.returnValue = false; 
         alert("Over max words!"); 
    }
}

//读COOKIE
function getCookie(cookiename)
{
    var result = '';
    var mycookie = document.cookie;
    var start2 = mycookie.indexOf(cookiename + "=");
    if(start2>-1)
    {
        start=mycookie.indexOf("=",start2)+1;
        var end = mycookie.indexOf(";",start);
        
        if (end == -1)
        {
            end = mycookie.length;
        }
        
        result = unescape(mycookie.substring(start,end));
        
    }
    return result;
}

//写入COOKIE
function setCookie(cookiename, cookievalue, hours)
{
    var date=new Date();
    date.setTime(date.getTime() + Number(hours)*3600*1000);
    temp = escape(cookievalue);
    document.cookie = cookiename + "=" + temp  +"; path=/;expires = " + date.toGMTString();
    ////var o = 0;
}

//已经计算了用户优惠率
function changeRate(moneyvalue)
{
    var rates = getCookie("rateValue");
    moneyvalue = Math.round(Number(moneyvalue)*getwebrate()*cusrate()*100)/100;
    
    if(rates == null || rates == "")
    {
        return moneyvalue;
    }
    var result ;
    result =  Math.round(Number(moneyvalue)*Number(rates)*100)/100;
    return result;
}

//没有计算用户优惠
function changeRate2(moneyvalue)
{
    var rates = getCookie("rateValue");
    
    moneyvalue = Math.round(Number(moneyvalue)*100)/100;
    
    if(rates == null || rates == "")
    {
        return moneyvalue;
    }
    return Math.round(Number(moneyvalue)*Number(rates)*100)/100;
}

//当所选币种改变时调用
function changemoney(imoneytype)
{
    var fuhao;        
    switch(imoneytype)
    {
        case "USD":
            fuhao = "$";
            break;
        case "EUR":
            fuhao = "€";
            break;
        case "GBP":
            fuhao = "£";
            break;
        case "AUD":
            fuhao = "A$";
            break;
        case "CAD":
            fuhao = "C$";
            break;
        default:
            break;
    }
    
    setCookie("moneyType",fuhao,1);
    var url = "ashx/moneytype.ashx?moneytype=" + imoneytype;
    
    var myAjax = new Ajax.Request(   
                                    url,   
                                    {
                                        method: "get",
                                        onComplete: getrateDo_lx
                                    }   
                                );  
}


function getrateDo_lx(xmlhttp)
{
    var r = xmlhttp.responseText;
    if(isNaN(r)) 
    {
        return;
    }
    setCookie("rateValue",r,1);
    try{
    SetCurrency();
    }catch(e)
    {}
    try{
    GetShopInfo();
    }catch(e)
    {}
    try{
    GetItemsList();
    }catch(e)
    {}
    try
    {
    getBuyInfo();
    }catch(e)
    {}
    try{
     GetHotList(305);GetHotList(102);GetHotList(96);GetHotList(103);GetHotList(104);GetHotList(105);GetHotList(83);GetHotList(106);
    }
    catch(e){}
}

//change moneytype
function getMoneyType()
{
    var moneyType = getCookie("moneyType");
    if(moneyType == '')
        changemoney("USD");
    return moneyType;
}

//getorderserial
function getserial()
{
    var md = new Date();
    var year = md.getYear();
    year = year.toString();
    year = year.substring(2,4);
    
    if(year.length == 1)
    {
        year = "0" + year;
    }
    
    var month = md.getMonth() + 1;
    if(month < 10)
    {
        month = "0" + month;
    }
    
    var day = md.getDate();
    if(day < 10)
    {
        day = "0" + day;
    }
    
    var s = "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";
    var arr = s.split(" ");
     var sn4 = "";
    while(sn4.length <=3)
    {
        sn4 += arr[Math.round(Math.random()*100)%36];
    }       
   // return "IG9" + year + month + day + arr[Math.round(Math.random()*100)%36] + arr[Math.round(Math.random()*100)%36] + arr[Math.round(Math.random()*100)%36] + arr[Math.round(Math.random()*100)%36];
    return "IG3" + year + month + day + sn4;
}

function getserialpot()
{
    var md = new Date();
    var year = md.getYear();
    year = year.toString();
    year = year.substring(2,4);
    
    if(year.length == 1)
    {
        year = "0" + year;
    }
    
    var month = md.getMonth() + 1;
    if(month < 10)
    {
        month = "0" + month;
    }
    
    var day = md.getDate();
    if(day < 10)
    {
        day = "0" + day;
    }
    
    var s = "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";
    var arr = s.split(" ");
     
     var sn4 = "";
    while(sn4.length <=3)
    {
        sn4 += arr[Math.round(Math.random()*100)%36];
    }     
   // return "IG9" + year + month + day + arr[Math.round(Math.random()*100)%36] + arr[Math.round(Math.random()*100)%36] + arr[Math.round(Math.random()*100)%36] + arr[Math.round(Math.random()*100)%36] + "POT";
    return "IG3" + year + month + day + sn4+"POT";
}
//web language
function getwebrate()
{
    
    try
    {
        var language = "";
        
        if(document.all)
        {
            language = navigator.systemLanguage;
        }
        else
        {
            language = navigator.language;
        }
        
        if(language.toLowerCase() == "zh-cn")
        {
            //return 1.17;
            return 1;
        }
        else
        {
            return 1;
        }
    }
    catch(err)
    {
        return 1;
    }
}

//log rate
function cusrate()
{
    var uinfo = getCookie("customerinfo");
    
    var rate = 1;
    try
    {
        if(uinfo != null && uinfo != '')
        {
            var arr = uinfo.split("|||");
            var r = parseFloat(arr[8])/100.0;
            
            rate = rate - r;
        }
    }
    catch(err)
    {
        
    }
    
    return rate;
}
function getmoneytype2()
{
    var tp = getMoneyType();
    
    var result = "USD";
    
    if(tp == "$")
    {
        result = "USD";
    }
    
    if(tp == "€")
    {
        result = "EUR";
    }
    
    if(tp == "£")
    {
        result = "GBP";
    }
    
    if(tp == "A$")
    {
        result = "AUD";
    }
    
    if(tp == "C$")
    {
        result = "CAD";
    }
    return result;
}

//showrep
function showrep()
{
    if($("rad1").checked == true)
    {
        $("repddl").style.display = "none";
    }
    
    if($("rad2").checked == true)
    {
        $("repddl").style.display = "";
    }
}

//getuid
function getuid()
{
    var uid = 0;
    
    var uinfo = getCookie("customerinfo");
    
    if(uinfo != null)
    {
        var arr = uinfo.split("|||");
        uid = arr[0];
    }
    
    uid = parseInt(uid);
    
    if(uid == null || isNaN(uid))
    {
        uid = 0;
    }
    uid = parseInt(uid);
    
    if(isNaN(uid))
    {
        uid = 0;
    }
    return uid;
}

//huang hang
function hh()
{
    var D=document; 
    F(D.body); 
    function F(n)
    {
        var u,r,c,x; 
        if(n.nodeType==3)
        { 
            u=n.data.search(/\S{10}/); 
            if(u>=0) 
                { 
                    r=n.splitText(u+10); 
                    n.parentNode.insertBefore(D.createElement("WBR"),r); 
                } 
        }
        else if(n.tagName!="STYLE" && n.tagName!="SCRIPT")
        {
            for(c=0;x=n.childNodes[c];++c)
            {
                F(x);
            }
        } 
    } 
}

//
function witerlivechat(xmlhttp)
{ 

     var result = xmlhttp.responseText;

    if(result!=null && result.length>=1)
    {
             window.open(""+result+"");
    }
}

function openLiveChat(obj,mess)
{
      var url = "ashx/getlivechat.ashx";
      var myAjax = new Ajax.Request(   
                    url,   
                    {
                      method: "get",onComplete: witerlivechat
                    }   
      );  
}




//get current url 
function getpagetype()
{
    var cpage = window.location.href;
    var arr = cpage.split(".");
    var hz;
    if(arr.length == 0)
    {
        return "";
    }
    else
    {
        hz = arr[arr.length - 1].toLowerCase();
    }
    
    if(hz.indexOf("aspx") > 0)
    {
        return "aspx";
    }
    
    if(hz.indexOf("htm") > 0 && hz.indexOf("html") < 0)
    {
        return "htm";
    }
    
    if(hz.indexOf("html") > 0)
    {
        return "html";
    }
}
//open complaint page
function opencp()
{
    var curl = "customer_complaint" + "." + getpagetype();
    curl = "customer_complaint.html"
    window.open(curl,"_self")
}

//customer points
function upoints()
{
    var jifen = 0;
    
        var url = "ashx/jifen.ashx?cid=" + getuid();
        
        var myAjax = new Ajax.Request(   
                                        url,   
                                        {
                                            method: "get", 
                                            onComplete: getponitsdo0
                                        }   
                                   ); 
}

function getponitsdo0(xmlhttp)
{
    var jifen = xmlhttp.responseText;

    $("spjifen").innerHTML = jifen; 
    
    if($("spjifen2") != null)
    {
        $("spjifen2").innerHTML = jifen;
    }
}

//ws 2
function ws2(sz)
{
    return Math.round(parseFloat(sz)*100)/100;
}

//jude login
function islogin()
{
    if(getuid() == 0)
    {
        window.location.href = "index.html";
    }
}


//jude login
function checklogin()
{
    if(getuid() == 0)
    {
       if($("checklogin")!=null)
       {
           $("checklogin").style.display="";
           $("spbody").style.display="none";
           if($("k2serverlist")!=null)
           {
               $("k2serverlist").style.display="none";
           }
       }
    }else{
       if($("checklogin")!=null)
       {
           $("checklogin").style.display="none";
           $("spbody").style.display="";
             if($("k2serverlist")!=null)
           {
               $("k2serverlist").style.display="";
           }
       }  
    }
}

function Product()
{
    this.pid = "";
    this.pname = "";
    this.pLevel = "-1";
    this.pbeizhu = "";
    this.purl = "";
    this.ptid = "";
    this.productserial = "";
    this.tid = "";
    this.productGames = "0";
    this.productServer = "0";
    this.productstock = "0";
    this.productPrice = "0";
    this.productTaskid = "0";
    this.cid = "0";
    this.sid = "0";
    this.beizhu = ""; 
    this.productDelivery = "";   
    this.number = "0";
    
}

Array.prototype.remove=function(dx)
  {
    if(isNaN(dx)||dx>this.length){return false;}
    for(var i=0,n=0;i<this.length;i++)
    {
        if(this[i]!=this[dx])
        {
            this[n++]=this[i]
        }
    }
    this.length-=1
  }

function GetObjPos(ATarget)
{
    var target = ATarget;
    var pos = new CPos(target.offsetLeft, target.offsetTop);
    
    var target = target.offsetParent;
    while (target)
    {
        pos.x += target.offsetLeft;
        pos.y += target.offsetTop;
        
        target = target.offsetParent
    }
    
    return pos;
} 
function CPos(x, y)
{
    this.x = x;
    this.y = y;
}
function showdiv(divtran,img)
{ 
    var proc=GetObjPos(img);

    
    if(document.all)
    {
        divtran.style.top = proc.y;  
        divtran.style.left = proc.x + 38;
    }
    else
    {
        divtran.style.top = proc.y + "px";  
        divtran.style.left = (proc.x) + 38 + "px";
    }
}

function kkserverlistadd(xmlhttp)
{
   var result = xmlhttp.responseXML; 
   var getserverdll = $("drpServer");
   if(xmlhttp.responseText != "<NewDataSet />")
    { 
        var pricelist = result.getElementsByTagName("Table");
        for(var i = 0; i < pricelist.length; i++)
        {
            var op = document.createElement("option"); 
            op.id = "sop" + i;
            var sname = pricelist[i].getElementsByTagName("serverName")[0].childNodes[0].nodeValue;
            var optext = sname;
            op.appendChild(document.createTextNode(optext));            
            getserverdll.appendChild(op);            
        }
        getSelectOption();
    }    
}

//game gold
function gamegold(gameid)
{
   var url = "ashx/getgamelist.ashx?gameid=" + gameid;
   
   
   var myAjax = new Ajax.Request(
                                    url,
                                    {
                                        method: "get",
                                        onComplete: kkserverlistadd
                                    }
                                );
}

function getpid()
{    
    var pid = getCookie("pid");
    
    if(pid == null || pid == "" || isNaN(pid))
    {
        pid = "0";
	setCookie("pid","0",2.0);
    }        
    return pid;
}

function setvisit()
{
    var pid = getpid();
    var uid = getuid();
    var refurl = document.referrer;
    var cururl = document.URL;
    
    if(refurl == null)
    {
        refurl = "";
    }
    
    var url = "ashx/visit.ashx?pid=" + pid + "&uid=" + uid + "&refurl=" + refurl + "&cururl=" + cururl;
        
    var myAjax = new Ajax.Request(   
                                    url,   
                                    {
                                        method: "get", 
                                        onComplete: setvisitdo
                                    }   
                               ); 
}
function setvisitdo(xmlhttp)
{
    var result = xmlhttp.responseText;
	
    if(getpid() == "0")
    {
        setCookie("pid",result,2.0);
    }
}

function setlb(text)
{
    $("TextBox4").value=text;
   
}


function ontop(obj)
{
    for(var i = 1; i < 6; i++)
    {
        $("w"+i).className = "fl b1";
    }
    $("w"+obj).className="fl b2";
}

//headnavblack
//headnavleft
function onhead(test)
{
    for(var i = 1; i < 8; i++)
    {
        $("h"+i).className = "headnavleft";
    }
    $("h"+test).className="headnavblack";
}

function onthtml(html)
{
    //window.location="index.aspx";
    if(html=="1")
    {
         window.location="account.html";
        return;
    }
    if(html=="2")
    {
        window.location="jianshe.html";
        return;
    }
    if(html=="3")
    {
        window.location="accountsetup.html";
        return;
    }
       if(html=="4")
    {
        window.location="updatepwd.html";
        return;
    }
       if(html=="5")
    {
        //window.location="accountsell.html";
        return;
    }
    
}


function AddFavorite(sURL, sTitle)
    {
        try
        {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e)
        {
            try
            {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            catch (e)
            {
                alert("加入收藏失败，请使用Ctrl+D进行添加");
            }
        }
    }
function SetHome(obj,vrl)
{
    try
    {
            obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
    }
    catch(e){
            if(window.netscape) {
                    try {
                            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                    } 
                    catch (e) { 
                            alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                    }
                    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                    prefs.setCharPref('browser.startup.homepage',vrl);
             }
    }
}


//function divcenter()
//{
//    alert("a");
//    var divId=document.getElementById('divshow');
//     divId.style.display="block";
//    //var divId=document.getElementById('divshow');
//     
//    divId.style.left=(document.body.clientWidth-divId.clientWidth)/2+document.body.scrollLeft;
//    divId.style.top=(document.body.clientHeight-divId.clientHeight)/2+document.body.scrollTop;
//}

function parsefloatclass() 
{ 
     var rs =  parseFloat(20.1576200) + parseFloat(5.7423030);
     alert(rs);
     rs=Math.round(rs,4);
     
     alert(rs);
 } 

////全选/取消
//function funcheck(Gname,check)
//{
//        
//        var aa=$(Gname);
//            for(var a=1;a<aa.rows.length-1;a++)
//            {
//                  aa.rows[a].cells[0].getElementsByTagName("input")[0].checked=check.checked;
//            }      
//}

function newshow()
{
    alert("新闻正在更新中!");
    return;
}

function ClearAllTextBox()   
{   
var obj=window.document.forms[0];   
for(i=0;i<obj.elements.length; i++)   
{   
var elem=obj.elements[i];   
if(elem)   
{   
if(elem.type=="text")   
{   
elem.value="";   
}   
}   
}   
}  

function timelook()
{
      //myDate.getYear();        //获取当前年份(2位) 
//     myDate.getFullYear();    //获取完整的年份(4位,1970-????) 
//    myDate.getMonth();       //获取当前月份(0-11,0代表1月) 
//    myDate.getDate();        //获取当前日(1-31) 
//    myDate.getDay();         //获取当前星期X(0-6,0代表星期天) 
//    myDate.getTime();        //获取当前时间(从1970.1.1开始的毫秒数) 
    //alert("a");
//    var myDate = new Date(); 
//  
//    $("shijian1").value=myDate.getFullYear()+"-"+myDate.getMonth()+"-"+ myDate.getDate();
//    
//    $("shijian2").value=myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+ myDate.getDate();
//    1，3，5，7，8，10，12 大月
//4，6，9，11 小月

    var date = new Date();
    var d   = date.getDate();
    var day = (d < 10) ? '0' + d : d;
    
    var m = date.getMonth() + 1;
    var nextmonth =0;
    if(m==1)
    {
         nextmonth = parseInt(m);
    }
    else
    {
         nextmonth = parseInt(m-1);
    }
    var month = (m < 10) ? '0' + m : m;
    nextmonth = (nextmonth < 10) ? '0' + nextmonth : nextmonth;
    var yy = date.getYear();
    var year = (yy < 1000) ? yy + 1900 : yy;    
    $("shijian1").value=year + "-" + nextmonth + "-" + "01";
    $("shijian2").value=year + "-" + month + "-" + day;

    
}

function closeLayer(){
   document.getElementById("divImg").style.display = "none";
}

function queren()
{
    $("queren").style.display="";
    $("querenbt").style.display="none";
    $("querenbt2").style.display="";
}

function queren2()
{
    $("queren").style.display="none";
    $("querenbt2").style.display="none";
    $("querenbt").style.display="";
}
