﻿
var xmlHttp; //全局Ajax变量
var method = true;
var minicart_total_cost = ""
var minicart_total_items = "";
var option1html = '';
var option1htm2 = '';

function findAuthor(file) {
    var divid = "snapframe";
    file = "snap/" + file + ".html";
    var xmlObj = null;
    try {
        xmlObj = new XMLHttpRequest();
    } catch (trymicrosoft) {
        try {
            xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (othermicrosoft) {
            try {
                xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (failed) {
                xmlObj = false;
            }
        }
    }
    xmlObj.onreadystatechange = function() {
        if (xmlObj.readyState == 4) {
            if (xmlObj.responseText.indexOf('404 Page') == -1) {
                document.getElementById(divid).innerHTML = xmlObj.responseText;
            }
            else
                document.getElementById(divid).innerHTML = 'No Snap Shot goes here.';


        }
    }
    xmlObj.open('GET', file, true);
    xmlObj.send('');

}


function GetId(divid)//使用较多，先定义下
{
    return document.getElementById(divid);
}
function CreateXMLHttpRequest()//创建Ajax函数
{
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else {
        xmlHttp = new XMLHttpRequest();
    }
}
function chkpass(pass1value, divid) {
    if (pass1value.length < 6 && pass1value.length != 0) {
        document.getElementById(divid).innerHTML = "<span>error password</span>";
    } else {
        document.getElementById(divid).innerHTML = "";
    }

}

function chkemailsubmit(email) {
    b_return = false;
    if (!VerifyEmail(email) && email.length != 0) {
        b_return = true;
    }
    return b_return
}


function checkpass2(pass1value, pass2value, divid) {
    if ((pass1value.length < 6 || pass1value != pass2value) && pass2value.length != 0) {
        document.getElementById(divid).innerHTML = "<span>error Confirm Password </span>";
    } else {
        document.getElementById(divid).innerHTML = "";
    }

}
function chkemail(email, divid) {

    if (!VerifyEmail(email) && email.length != 0) {
        document.getElementById(divid).innerHTML = "<span>error email</span>";
    } else {
        document.getElementById(divid).innerHTML = "";
    }

}


function VerifyEmail(email) {
    var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    if (!reg.test(email)) {
        return false;
    }
    return true;
}
function GetWebBrowser()//返回ie类型
{
    if (window.ActiveXObject) {
        return 0;
    }
    else {
        return 1;
    }
    return 0;
}

function ShowTip(divid, id, sku) //显示属性函数，核心功能
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'trunpage.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            var divH = GetId(divid).offsetHeight;
            var divW = GetId(divid).offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    // alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;
                    //alert($("#" + divid).offset().top);
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    //GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
                    ShowTip(divid, id, sku);
                }
            }
            else {
                GetId(divid).innerHTML = "<div class='my_table'><img src=\"/skin1/newsale/images/loading.gif\" border=0></div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'equipments_id=' + id + '&l_type=100&SKU=' + sku;
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}

function Showlist(divid, race, player_class, gender, role_ori, l_type, page, faction) //显示账号列表
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    //GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
                    Showlist(divid, race, player_class, gender, role_ori, l_type, page, faction);
                }
            }
            else {
                GetId(divid).innerHTML = "<div><img src=\"/skin1/newsale/images/loading.gif\" border=0></div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'race=' + race + '&player_class=' + player_class + '&gender=' + gender + '&l_type=' + l_type + '&role_ori=' + role_ori + '&page=' + page + '&faction=' + faction;
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}

function ResTest(divid)//同步方式下的获得返回结果的时间句柄
{
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            //alert(xmlHttp.responseText);
            GetId(divid).innerHTML = xmlHttp.responseText;
            // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
        }
        else {
            //GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
            TrunPage(divid, Level, Gender, Class, Race, Role_ori, Price, Faction, Order, Page, Talent, l_type, OrderMethod, PageSize);
        }
    }
    else {
        GetId(divid).innerHTML = "<div class=\"accmessage\"><img src=\"/skin1/newsale/images/accloading.gif\" /></div>";
    }
}

function TrunPage(divid, Level, Itemlevel, Gender, Class, Race, Role_ori, Price, Faction, Order, Page, Talent, l_type, OrderMethod, PageSize) //显示账号列表
{

    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        if (GetWebBrowser() == 1) {
            xmlHttp.onreadystatechange = ResTest(divid);
            if (document.getElementById("toplocation").getElementsByTagName("a")[1].innerHTML.indexOf("us accounts") == -1)
                xmlHttp.open('POST', '/world-of-warcraft-eu-accounts/trunpage.php', false);
            else
                xmlHttp.open('POST', '/world-of-warcraft-us-accounts/trunpage.php', false);
        }
        else {
            if (document.getElementById("toplocation").getElementsByTagName("a")[1].innerHTML.indexOf("us accounts") == -1)
                xmlHttp.open('POST', '/world-of-warcraft-eu-accounts/trunpage.php', method);
            else
                xmlHttp.open('POST', '/world-of-warcraft-us-accounts/trunpage.php', method);
            xmlHttp.onreadystatechange = function() //同步方式下的获得返回结果的时间句柄
            {
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        //alert(xmlHttp.responseText);
                        GetId(divid).innerHTML = xmlHttp.responseText;
                        // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                    }
                    else {
                        //GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
                        TrunPage(divid, Level, Itemlevel, Gender, Class, Race, Role_ori, Price, Faction, Order, Page, Talent, l_type, OrderMethod, PageSize);
                        //GetId(divid).innerHTML="<div><img src=\"/skin1/newsale/images/loading.gif\" border=0></div>";
                    }
                }
                else {
                    GetId(divid).innerHTML = "<div class=\"accmessage\"><img src=\"/skin1/newsale/images/accloading.gif\" /></div>";
                }
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'divid=' + divid + '&Level=' + Level +'&Itemlevel='+Itemlevel+ '&Gender=' + Gender + '&Class=' + Class + '&Race=' + Race + '&Role_ori=' + Role_ori + '&Price=' + Price + '&Faction=' + Faction + '&Order=' + Order + '&Page=' + Page + '&Talent=' + Talent + '&l_type=' + l_type + '&OrderMethod=' + OrderMethod + '&PageSize=' + PageSize;
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
    if (GetWebBrowser() == 1)
        xmlHttp.onreadystatechange = ResTest(divid);
}

function Showlevellist(divid, l_type, page, player_level) //显示账号列表
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    //GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
                    Showlevellist(divid, l_type, page, player_level);
                }
            }
            else {
                GetId(divid).innerHTML = "<div><img src=\"/skin1/newsale/images/loading.gif\" border=0></div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'player_level=' + player_level + '&l_type=' + l_type + '&page=' + page;
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}


function ShowORI(divid, ORI) //显示相同角色定位
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    GetId(divid).innerHTML = "ERROR:" + xmlHttp.statusText;
                }
            }
            else {
                GetId(divid).innerHTML = "<div>&nbsp;Data accessing</div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'ROLE_ORI=' + ORI + '&l_type=4';
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}

function ShowRace(divid, race) //显示同种族列表
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    GetId(divid).innerHTML = "ERROR:" + xmlHttp.statusText;
                }
            }
            else {
                GetId(divid).innerHTML = "<div>&nbsp;Data accessing</div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'race=' + race + '&l_type=5';
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}


function ShowClass(divid, player_class) //同职业列表
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;

                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    GetId(divid).innerHTML = "ERROR:" + xmlHttp.statusText;
                }
            }
            else {
                GetId(divid).innerHTML = "<div>&nbsp;Data accessing</div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'player_class=' + player_class + '&l_type=6';
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}

function ShowHotAccount(divid) //热门账号
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    GetId(divid).innerHTML = "ERROR:" + xmlHttp.statusText;
                }
            }
            else {
                GetId(divid).innerHTML = "<div>&nbsp;Data accessing</div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'l_type=7';
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}

function difaccount(divid, SKU) //相关账号
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //alert(xmlHttp.responseText);
                    GetId(divid).innerHTML = xmlHttp.responseText;
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    GetId(divid).innerHTML = "ERROR:" + xmlHttp.statusText;
                }
            }
            else {
                GetId(divid).innerHTML = "<div>&nbsp;Data accessing</div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'SKU=' + SKU + '&l_type=8';
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}


function countlist(caption, divid, race, player_class, gender) //显示账号列表
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', 'viewlist.php', true);
        //xmlHttp.open('POST','ajaxProxy.php',true);
        //xmlHttp.open('GET','proxy.php?id='+rid,false);
        //xmlHttp.open('GET','ajaxProxy.php?id='+rid,false);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            //var divH = GetId("toolTipLayer").offsetHeight;
            //var divW = GetId("toolTipLayer").offsetWidth;
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    GetId(divid).innerHTML = caption + xmlHttp.responseText;
                    // window.status='NOTE：If the Property board exceeds your screen, please using the keys:Up,Down,Left,Right in the keyboard to have a complete view. ';
                }
                else {
                    GetId(divid).toElement.innerHTML = caption + " ERROR: " + xmlHttp.statusText;
                }
            }
            else {
                GetId(divid).toElement.innerHTML = caption + " Data accessing...";
            }
        }
    }
    else {
        GetId(divid).toElement.innerHTML = caption + " Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'race=' + race + '&player_class=' + player_class + '&gender=' + gender + '&l_type=3';
    xmlHttp.send(SendData);
    // xmlHttp.send(null);
}


function HideTip()//隐藏属性函数
{
    GetId("toolTipLayer").style.display = "none";
    GetId("toolTipLayer").innerHTML = "";
}
//tooltip
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
var toolTipSTYLE = "";
function initToolTips()//Tip初始化函数
{
    if (ns4 || ns6 || ie4) {
        if (ns4) toolTipSTYLE = document.toolTipLayer;
        else if (ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
        else if (ie4) toolTipSTYLE = document.all.toolTipLayer.style;
        if (ns4) document.captureEvents(Event.MOUSEMOVE);
        else {
            toolTipSTYLE.visibility = "visible";
            toolTipSTYLE.display = "none";
        }
        document.onmousemove = moveToMouseLoc;


    }
}
//hide by urn 2009 12 31
function moveToMouseLoc(e) {
    var ex;
    var ey;

    switch (getOs()) {
        case 1: ex = event.x; ey = event.y; break;
        case 2: ex = e.pageX; ey = e.pageY; ; break;
        case 0: ; break;
    }
    if (ns4 || ns6) {
        x = e.pageX;
        y = e.pageY;
    }
    else {
        //   x = event.x + document.body.scrollLeft;
        //  y = event.y + document.body.scrollTop;
        x = ex + document.documentElement.scrollLeft - 60;
        y = ey + document.documentElement.scrollTop;
    }

    var divH = GetId("toolTipLayer").offsetHeight;
    var divW = GetId("toolTipLayer").offsetWidth;
    var winH = document.body.clientHeight;
    var winW = document.body.clientWidth;
    offsetX = 10;
    offsetY = 15;
    offsetX = (x + divW > winW) ? (winW - ex - divW - 3) : (10);
    offsetY = (y + divH > winH) ? (winH - ey - divH - 3) : (15);
    //if (event.y + divH >= winH && event.x + divW > winW){offsetX = winW - (event.x+divW+3);offsetY = 10}
    toolTipSTYLE.left = x + offsetX + 'px';
    toolTipSTYLE.top = y + offsetY + 'px';

    //  toolTipSTYLE.left = (document.documentElement.clientWidth - divW) / 2 + document.documentElement.scrollLeft + 'px';
    //  toolTipSTYLE.top = (document.documentElement.clientHeight - divH) / 2 + document.documentElement.scrollTop + 'px';
    //var xx = document.documentElement.clientWidth / 2 + document.documentElement.scrollLeft + document.body.scrollLeft;
    //var yy = document.documentElement.clientHeight / 2 + document.documentElement.scrollTop + document.body.scrollTop;
    //  toolTipSTYLE.left = document.documentElement.scrollLeft + $(this).offset().left+$(this).width();
    //  toolTipSTYLE.top = document.documentElement.scrollTop + $(this).offset().top+ $(this).height();

    //window.status = "divW:"+divW +" divH:"+ divH +" winW: "+winW + " winH: "+winH +" mouseX:"+event.x +" mouseY:"+event.y+" offsetX:"+offsetX+" offsetY:"+offsetY
    if (jQuery.browser.msie && $.browser.version == '8.0') {
        //alert(e.clientX + ':' + e.clientY);
        toolTipSTYLE.left = window.event.clientX + document.documentElement.scrollLeft;
        toolTipSTYLE.top = window.event.clientY + document.documentElement.scrollTop;
        //toolTipSTYLE.left = document.documentElement.clientWidth / 2 + document.documentElement.scrollLeft + document.body.scrollLeft;
        //toolTipSTYLE.top = document.documentElement.clientHeight / 2 + document.documentElement.scrollTop + document.body.scrollTop;
    }
    return true;
}


function getOs() {
    if (navigator.userAgent.indexOf("MSIE") > 0) return 1;
    if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) return 2;
    if (isSafari = navigator.userAgent.indexOf("Safari") > 0) return 3;
    if (isCamino = navigator.userAgent.indexOf("Camino") > 0) return 4;
    if (isMozilla = navigator.userAgent.indexOf("Gecko/") > 0) return 5;
    return 0;
}

// Trim() , Ltrim() , RTrim() 函数
String.prototype.Trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function() {
    return this.replace(/(^\s*)/g, "");
}

String.prototype.RTrim = function() {
    return this.replace(/(\s*$)/g, "");
}


function GetQueryStrings(name) {
    name = name.toLowerCase();
    name = name.Trim();
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.hash.substr(1).toLowerCase().match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
    return null;
}


function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.hash.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

function UperFirstasc(str) {
    var index;
    var tmpStr;
    var tmpChar;
    var preString;
    var postString;
    var strlen;
    str = str.replace(" ", "");
    tmpStr = str.toLowerCase();
    strLen = tmpStr.length;
    if (strLen > 0) {
        for (index = 0; index < strLen; index++) {
            if (index == 0) {
                tmpChar = tmpStr.substring(0, 1).toUpperCase();
                postString = tmpStr.substring(1, strLen);
                tmpStr = tmpChar + postString;
            }
            else {
                tmpChar = tmpStr.substring(index, index + 1);
                if (tmpChar == " " && index < (strLen - 1)) {
                    tmpChar = tmpStr.substring(index + 1, index + 2).toUpperCase();
                    preString = tmpStr.substring(0, index + 1);
                    postString = tmpStr.substring(index + 2, strLen);
                    tmpStr = preString + tmpChar + postString;
                }
            }
        }
    }
    return tmpStr;
}

function ChangedValue(parentid, objid) {
    var parentdiv = document.getElementById(parentid);
    var flag_all = false;

    if (((objid.indexOf('All')) != -1) && (objid != 'Alliance')) {
        eval(UperFirstasc(parentid) + "='All'");
        flag_all = true;
    }
    childdiv = parentdiv.getElementsByTagName('span');
    for (i = 1; i < childdiv.length; i++) {
        if (childdiv[i].id == objid)
            childdiv[i].className = (flag_all == true) ? 'all' : 'tagcelhover';
        else
            childdiv[i].className = '';
    }
}


function ChangeValue(parentid, objid) {
    var parentdiv = document.getElementById(parentid);
    var flag_all = false;

    if (((objid.indexOf('All')) != -1) && (objid != 'Alliance')) {
        eval(UperFirstasc(parentid) + "='All'");
        flag_all = true;
    }
    else
        eval(UperFirstasc(parentid) + "='" + objid + "'");
    ///accounts/link/变量_参数
    if (typeof (_gat) == 'object') {
        var pageTracker = _gat._getTracker("UA-1989152-1");
        pageTracker._initData();
        pageTracker._trackPageview("/accounts/search/" + UperFirstasc(parentid) + "_" + objid);
    }
    //urchinTracker("/accounts/search/"+UperFirstasc(parentid)+"_"+objid);
    Page = 1;
    ChangeHash(1);
    //childdiv=parentdiv.childNodes;
    childdiv = parentdiv.getElementsByTagName('span');
    //alert(childdiv.length);

    for (i = 1; i < childdiv.length; i++) {
        if (childdiv[i].id == objid)
            childdiv[i].className = (flag_all == true) ? 'all' : 'tagcelhover';
        else
            childdiv[i].className = '';
    }
}

function ChangePage(page) {
    Page = page;
    ChangeHash(2);
}

function ChangeHash(l_type) {
    //	/价格_参数/等级_参数/职业_参数/种族_参数/阵营_参数/性别_参数/
    //urchinTracker("/accounts/link/Price_"+Price+"/Level_"+Level+"/Class_"+Class+"/Race_"+Race+"/Faction_"+Faction+"/Gender_"+Gender+/PageSize_"+PageSize);
    var tmphash = 'Page=' + Page;
    tmphash += (Level == 'All') ? '' : ('&Level=' + Level);
    tmphash += (Itemlevel == 'All') ? '' : ('&Itemlevel=' + Itemlevel);
    tmphash += (Gender == 'All') ? '' : ('&Gender=' + Gender);
    tmphash += (Class == 'All') ? '' : ('&Class=' + Class);
    tmphash += (Race == 'All') ? '' : ('&Race=' + Race);
    tmphash += (Role_ori == 'All') ? '' : ('&Role_ori=' + Role_ori);
    tmphash += (Price == 'All') ? '' : ('&Price=' + Price);
    tmphash += (Faction == 'All') ? '' : ('&Faction=' + Faction);
    tmphash += (Order == 'All') ? '' : ('&Order=' + Order);
    tmphash += (Talent == 'All') ? '' : ('&Talent=' + Talent);
    tmphash += (OrderMethod == 'All') ? '' : ('&OrderMethod=' + OrderMethod);
    tmphash += (PageSize == 'All') ? '' : ('&PageSize=' + PageSize);
    window.location.hash = tmphash;
    switch (l_type) {
        case 1:
            //method=false;
            //TrunPage("count_size",Level,Gender,Class,Race,Role_ori,Price,Faction,Order,Page,Talent,1,OrderMethod,PageSize);
            method = true;
            TrunPage("left_content", Level, Itemlevel, Gender, Class, Race, Role_ori, Price, Faction, Order, Page, Talent, 2, OrderMethod, PageSize);
            break;
        case 2:
            method = true;
            TrunPage("left_content", Level, Itemlevel, Gender, Class, Race, Role_ori, Price, Faction, Order, Page, Talent, 2, OrderMethod, PageSize);
            break;
        case 3:
            method = true;
            TrunPage("left_content", Level, Itemlevel, Gender, Class, Race, Role_ori, Price, Faction, Order, Page, Talent, 2, OrderMethod, PageSize);
            break;
        default:
            break;
    }

}

function ChangeOrder(orderindex, ordervalue) {
    var orderid = document.getElementById('order');
    var orderchild = orderid.getElementsByTagName('td');
    for (i = 0; i < orderchild.length; i++)
        orderchild[i].className = '';

    orderchild[orderindex].className = 'on';
    Order = ordervalue;
    Page = 1;
    ChangeHash(2);
}

function changeOption(type) {
    var buy_option1 = document.getElementById('buy_option1');
    var buy_option2 = document.getElementById('buy_option2');
    var selectoption1 = document.getElementById('selectoption1');
    var selectoption2 = document.getElementById('selectoption2');

    if (type == 1) {
        buy_option1.className = 'buyoption-on';
        buy_option2.className = 'buyoption';
        selectoption1.innerHTML = '<img src=\"/skin1/newsale/images/accoption_r.gif\" alt=\"Selected\" />';
        selectoption2.innerHTML = '&nbsp;'
        AccountState[1].selected = true;
    }
    else if (type == 2) {
        buy_option2.className = 'buyoption-on';
        buy_option1.className = 'buyoption';
        selectoption2.innerHTML = '<img src=\"/skin1/newsale/images/accoption_r.gif\" alt=\"Selected\" />';
        selectoption1.innerHTML = '&nbsp;'
        AccountState[0].selected = true;
    }

}

/*
function getMiniCart(divid)
{
GetId(divid).style.display=''; //先设置为显示
CreateXMLHttpRequest();
if(xmlHttp)
{
if (GetWebBrowser()==1)
{
xmlHttp.onreadystatechange=ResMiniCart(divid);
xmlHttp.open('POST','/ajax_comm.php',false);
}
else
{
xmlHttp.open('POST','/ajax_comm.php',true);
xmlHttp.onreadystatechange=function() //同步方式下的获得返回结果的时间句柄
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
eval(xmlHttp.responseText);
alert(minicart_total_cost);
alert(minicart_total_items);
GetId(divid).innerHTML ='';
}
else
{
GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
}
}
else
{
GetId(divid).innerHTML="<div><img src=\"/skin1/newsale/images/loading.gif\" border=0></div>";
}
}
}
}
else
{
GetId(divid).innerHTML="Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
}
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
// xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
xmlHttp.send('');
if (GetWebBrowser()==1)
xmlHttp.onreadystatechange=ResMiniCart(divid);
}

function ResMiniCart(divid)//同步方式下的获得返回结果的时间句柄
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
eval(xmlHttp.responseText);
alert(minicart_total_cost);
alert(minicart_total_items);
GetId(divid).innerHTML ='';
}
else
{
GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
}
}
else
{
GetId(divid).innerHTML="<div><img src=\"/skin1/newsale/images/loading.gif\" border=0></div>";
}
}

*/

function getMiniCart(divid, method) {
    //GetId(divid).style.display=''; //先设置为显示
    CreateXMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('POST', '/ajax_comm.php', true);
        xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
        {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    //GetId(divid).innerHTML = xmlHttp.responseText;
                    eval(xmlHttp.responseText);
                    //alert(minicart_total_cost);
                    //alert(minicart_total_items);
                    //GetId(divid).innerHTML ='';
                    //window.location.hash="#"
                    if (method == "show") {
                        document.getElementById('cartshow_productname').innerHTML = cart_show_pn;
                        document.getElementById('cartshow_total').innerHTML = minicart_total_items;
                        document.getElementById('cartshow_total').title = "Total:$" + minicart_total_cost + ", Click to view&amp;edit your cart.";
                        document.getElementById('cartshow_amount').innerHTML = "$" + minicart_total_cost;

                        show_subMenu(divid);
                        if (!mouseover_flag) {
                            setTimeout(function() { hide_subMenu(divid) }, hide_minicart_seconds); //hide_minicart_seconds 的声明在 by_phoenix.js
                        }
                    }
                }
                else {
                    getMiniCart(divid, method);
                    //GetId(divid).innerHTML="ERROR:"+xmlHttp.statusText;
                    // getMiniCart(divid);
                }
            }
            else {
                //GetId(divid).innerHTML="<div><img src=\"/skin1/newsale/images/loading.gif\" border=0></div>";
            }
        }
    }
    else {
        GetId(divid).innerHTML = "Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!";
    }
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存
    var SendData = 'l_type=2';
    xmlHttp.send(SendData);
}


function CheckUName(login, divid) //显示时间
{
    GetId(divid).style.display = ''; //先设置为显示
    CreateXMLHttpRequest();
    GetId(divid).innerHTML = "";
    if (login != "") {
        if (xmlHttp) {
            xmlHttp.open('POST', '/ajax_comm.php', true);
            xmlHttp.onreadystatechange = function()//同步方式下的获得返回结果的时间句柄
            {
                var divH = GetId(divid).offsetHeight;
                var divW = GetId(divid).offsetWidth;

                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        // alert(xmlHttp.responseText);
                        GetId(divid).innerHTML = xmlHttp.responseText;
                    }
                    else {
                        //GetId(divid).innerHTML="<span>ERROR:("+xmlHttp.statusText+"<span>";
                        CheckUName(login, divid);
                    }
                }
                else {
                    //GetId(divid).innerHTML="onload....";
                }
            }
        }
        else {
            GetId(divid).innerHTML = "<span>:(Sorry, your internet browser does not support the XMLHttpRequest, please update to IE6 or above!</span>";
        }
        xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
        // xmlHttp.setRequestHeader("If-Modified-Since","0"); // 删除缓存

        var SendData = 'login=' + login + '&l_type=1';
        xmlHttp.send(SendData);
        // xmlHttp.send(null);
    }
    /*	else
    GetId(divid).innerHTML="<span>:(Please fill in the blank space with your name<span>";*/

}



function getLeft(obj) {
    if (obj == null)
        return null;
    var mendingObj = obj;
    var mendingLeft = mendingObj.offsetLeft;
    while (mendingObj != null && mendingObj.offsetParent != null && mendingObj.offsetParent.tagName != "BODY") {
        mendingLeft = mendingLeft + mendingObj.offsetParent.offsetLeft;
        mendingObj = mendingObj.offsetParent;
    }

    return mendingLeft;
};
function getTop(obj) {
    if (obj == null)
        return null;
    var mendingObj = obj;
    var mendingTop = mendingObj.offsetTop;
    while (mendingObj != null && mendingObj.offsetParent != null && mendingObj.offsetParent.tagName != "BODY") {
        mendingTop = mendingTop + mendingObj.offsetParent.offsetTop;
        mendingObj = mendingObj.offsetParent;
    }
    return mendingTop;
};
//获取鼠标的位置
function getMousePosition(event) {
    var position = {
        MouseX: 0,
        MouseY: 0
    }
    if (event.pageX != undefined) {
        position.MouseX = event.pageX;
        position.MouseY = event.pageY;
    }
    else {
        var target = EventUtil.getTarget(event);
        position.MouseX = event.offsetX + getLeft(target);
        position.MouseY = event.offsetY + getTop(target);

    }
    return position;

}
