﻿// JScript 文件
var moneyChar = "$";
function GameChange(){
    selectValidata('lblGame','SelectGame','0');
    var gameCode = document.getElementById("SelectGame").value;
    
    var server = document.getElementById("SelectServer");
    server.length=0;
    server.options.add(new Option("Loading...","0"));
    document.getElementById("hfGameCode").value = gameCode;
    var game = document.getElementById("SelectGame");
    var gameName;
    for(var i=0;i<game.length;i++)
    {
        if(game[i].value == gameCode)
        {
            gameName = game[i].text;
        }
    }
    if(gameCode="013"){window.location.href="/wow-gold/"}
    else if (gameCode == "019") { window.location.href="/wow-eu-gold/"}
    else if (gameCode == "035") { window.location.href="/2Moons/"}
    else if (gameCode == "065") { window.location.href="/age-of-conan/"}
    else if (gameCode == "068") { window.location.href="/age-of-conan-eu/"}
    else if (gameCode == "003") { window.location.href="/eve/"}
    else if (gameCode == "009") { window.location.href="/everquest/"}
    else if (gameCode == "002") { window.location.href="/everquest-2/"}
    else if (gameCode == "001") { window.location.href="/Final-Fantasy-XI-Gil/"}
    else if (gameCode == "052") { window.location.href="/Fly-For-Fun/"}
    else if (gameCode == "027") { window.location.href="/Gaia-online/"}
    else if (gameCode == "058") { window.location.href="/gw/"}
    else if (gameCode == "069") { window.location.href="/GW-Globs-of-Ectoplasm/"}
    else if (gameCode == "008") { window.location.href="/City-of-Villains/"}
    else if (gameCode == "012") { window.location.href="/lineage-2/"}
    else if (gameCode == "030") { window.location.href="/lord-of-the-rings/"}
    else if (gameCode == "034") { window.location.href="/lord-of-the-rings-eu/"}
    else if (gameCode == "014") { window.location.href="/maple-story/"}
    else if (gameCode == "033") { window.location.href="/maple-story-eu/"}
    else if (gameCode == "020") { window.location.href="/SilkRoad/"}
    else if (gameCode == "011") { window.location.href="/swg/"}
    else if (gameCode == "062") { window.location.href="/Tibia/"}
    else if (gameCode == "084") { window.location.href="/Aion/"}
    else if (gameCode == "015") { window.location.href="/Dungeons-Dragons-online/"}
    else if (gameCode == "007") { window.location.href="/Guild-Wars/"}
    else if (gameCode == "045") { window.location.href="/knight-online/"}
    else if (gameCode == "016") { window.location.href="/RF-Online/"}
    else if (gameCode == "079") { window.location.href="/Warhammer-Online-eu/"}
    else if (gameCode == "078") { window.location.href="/Warhammer-Online/"}
    else if (gameCode == "010") { window.location.href="/Runescape2/"}
    else if (gameCode == "032") { window.location.href="/Cabal/"}
    else
    {
    window.location.href="/Cheap.Gold." +gameCode + "." + gameName.replace(new RegExp(' ',"gm"),'_') + ".aspx"
    //$.get("GoldDataDispose.aspx",{type:"game",GameCode:gameCode},GameChangeBack);
    }
}

function GameChangeBack(data){
        var server = document.getElementById("SelectServer");
        var value = data.split('|');
        server.length=0;
        server.options.add(new Option("---Please Choose Server---","0"));
        for(var i=0;i<value.length;i++)
        {
            server.options.add(new Option(value[i].split('^')[1],value[i].split('^')[0]));
        }
}

function ServerChange(){
    selectValidata('lblServer','SelectServer','0');
    var gameCode = document.getElementById("SelectGame").value;
    var serverCode = document.getElementById("SelectServer").value;
    document.getElementById("hfServer").value = serverCode;
    var server = document.getElementById("SelectServer");
    for(var i=0;i<server.length;i++)
    {
        if(server[i].value == serverCode)
        {
            document.getElementById("hfServerName").value = server[i].text;
        }
    }
    $.get("/GoldDataDispose.aspx",{type:"server",GameCode:gameCode,ServerCode:serverCode,TIME:new Date().toLocaleTimeString()},ServerChangeBack);
}

function ServerChangeBack(data){
    var product = document.getElementById("SelectProduct");
    var gold = product.value;
    var table = document.getElementById("spProductTable");
    var str = "<h6>VOLUME DISCOUNT</h6>";
    str += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"table_gold_list\"><tr><th>NAME</th><th>TOTAL</th><th>Operate</th></tr>";
    var products = data.split('|');
    product.length=0;
    product.options.add(new Option("---Please Choose Product---","0"));
    for(var i=0;i<products.length-1;i++)
    {
        var temp = products[i].split('^')[1];
        
        product.options.add(new Option(products[i].split('^')[0],products[i].split('^')[1]+"|"+products[i].split('^')[2]));
        if(gold == products[i].split('^')[1]+"|"+products[i].split('^')[2])
        {
            product.options[i+1].selected = true;
        }
        str +=("<tr onmouseover=\"javascript:this.bgColor='#FCFEB7'\" onmouseout=\"javascript:this.bgColor=''\"><td>"+products[i].split('^')[0]+"</td><td>$"+temp.split(':')[0]+"</td><td><a onclick=\"mychoose('"+products[i].split('^')[1]+"','"+products[i].split('^')[2]+"');return false\" href=\"#\">Choose</a></td></tr>");
    }
    str += ("</table>");
    document.getElementById("spProductTable").innerHTML = str;
}


function ProductChange(){
    selectValidata('lblProduct','SelectProduct','0');
    var productCode = document.getElementById("SelectProduct").value;
    document.getElementById("hfProduct").value = productCode.split('|')[1];
    if(productCode!="0"&&productCode!=""){
        var infos = productCode.split("|");
        document.getElementById("lblPrice").innerHTML = "$"+infos[0].split(":")[0];
        document.getElementById("lblEURPrice").innerHTML = "€"+infos[0].split(":")[1];
        document.getElementById("lblGBPPrice").innerHTML = "￡"+infos[0].split(":")[2];
    }
    if(moneyChar == "EUR")
    {
        document.getElementById("lblPrice").style.color = "black";
        document.getElementById("lblEURPrice").style.color = "red";
        document.getElementById("lblGBPPrice").style.color = "black";
    }
}


function changeMoney(moy)
    {
        if(moy=="")
            return;
        var pp =document.getElementById("SelectProduct");
        for(var i=0;i<pp.length;i++){
            if(pp[i].selected==true)
            {
                CurrentSelect=i;
            }
        }        
        if(moy=="USD")
        {
            moneyChar="$";
            document.getElementById("lblPrice").style.color = "red";
            document.getElementById("lblEURPrice").style.color = "black";
            document.getElementById("lblGBPPrice").style.color = "black";
        }
        else if(moy=="EUR")
        {
            moneyChar="€";
            document.getElementById("lblPrice").style.color = "black";
            document.getElementById("lblEURPrice").style.color = "red";
            document.getElementById("lblGBPPrice").style.color = "black";
        }
        else if(moy=="GBP")
        {
            moneyChar="￡";
            document.getElementById("lblPrice").style.color = "black";
            document.getElementById("lblEURPrice").style.color = "black";
            document.getElementById("lblGBPPrice").style.color = "red";
        }
        $.get("/ChangeMoney.aspx",{type:moy,TIME:new Date().toLocaleTimeString()},ServerChange);
    }
    
 function mychoose(price,guid){
 
    document.getElementById("lblPrice").innerHTML = "$"+price.split(":")[0];
    document.getElementById("lblEURPrice").innerHTML = "€"+price.split(":")[1];
    document.getElementById("lblGBPPrice").innerHTML = "￡"+price.split(":")[2];
    var products = document.getElementById("SelectProduct");
    for(var i=0;i<products.length;i++)
    {
        if(products[i].value.split('|')[1] == guid)
        {
            products[i].selected = true;
        }
    }
    var productCode = document.getElementById("SelectProduct").value;
    document.getElementById("hfProduct").value = productCode.split('|')[1];
    selectValidata('lblProduct','SelectProduct','0');
}