﻿jQuery(document).ready(function() {
    initLeftMenu();
    var gamecode = jQuery("#leftGameCode").val();
    initMenu(gamecode);
    var selGameList = document.getElementById("ddlGame");
    if (typeof selGameList != "undefined" && selGameList.options.length>0) {
        for (var i = 0; i < selGameList.options.length; i++) {
            if (gamecode == selGameList.options[i].value) {
                selGameList.selectedIndex = i;
                break;
            }
        }
    }
});

function initMenu(gamecode) {
    var menu = jQuery("#leftMent_ul li");
    var tips = jQuery(".pro_sm_li");
    var liList = GetMenuList(menu);
    var links = CreateNewLine(gamecode);

    jQuery("a", liList.Gold).replaceWith(links.GoldLink);
    jQuery("a", liList.PL).replaceWith(links.PLLink);
    jQuery("a", liList.Item).replaceWith(links.ItemLink);
    jQuery("a", liList.Account).replaceWith(links.AccountLink);
    jQuery("a", liList.CDKey).replaceWith(links.CDKeyLink);


    //AION-EU //AION-US
    if (gamecode == '087' || gamecode == '083') {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).show();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).show();
        jQuery(liList.CDKey).hide();
        jQuery(tips[0]).show();
        jQuery(tips[1]).show();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).show();
        jQuery(tips[4]).hide();
    }

    //EVE Guild-Wars
    else if (gamecode == '003' || gamecode == '007' || gamecode == '100' ) {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).show();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).hide();
        jQuery(tips[0]).show();
        jQuery(tips[1]).show();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).hide();
    }

    //EQ2 FFXI SW
    else if (gamecode == '002' || gamecode == '001' || gamecode == '011' || gamecode == '012'|| gamecode=='130' || gamecode=='118') {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).show();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).show();
        jQuery(tips[0]).show();
        jQuery(tips[1]).show();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).show();
    }

    //EQ1
    else if (gamecode == '009') {
        jQuery(liList.Gold).hide();
        jQuery(liList.PL).show();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).hide();
        jQuery(tips[0]).hide();
        jQuery(tips[1]).show();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).hide();
    }

    //lor
    else if (gamecode == '006') {
        jQuery(liList.Gold).hide();
        jQuery(liList.PL).hide();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).show();
        jQuery(tips[0]).hide();
        jQuery(tips[1]).hide();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).show();
    }
    else if (gamecode == '110' ||
             gamecode == '111' ||
             gamecode == '104' ||
             gamecode == '014' ||
             gamecode == '069' ||
             gamecode == '099' ||
             gamecode == '010' ||
             gamecode == '114') {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).hide();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).hide();
        jQuery(tips[0]).show();
        jQuery(tips[1]).hide();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).hide();
    }
    else if (gamecode == '101' || gamecode == '102') {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).show();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).hide();
        jQuery(tips[0]).show();
        jQuery(tips[1]).hide();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).hide();
    }
    else if (gamecode == '123') {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).hide();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).hide();
        jQuery(tips[0]).show();
        jQuery(tips[1]).hide();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).hide();
    }
    else {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).show();
        jQuery(liList.Item).show();
        jQuery(liList.Account).show();
        jQuery(liList.CDKey).show();
        tips.show();
    }
    jQuery("#leftMent_ul").show();
    jQuery("#LeftTips").show();

}


function CreateNewLine(gameCode) {
    //WOW-US
    var gold = jQuery('<a href="/gold/WoWGoldProduct.aspx?gameCode=013">WoW Gold</a>');
    var pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
    var item = jQuery('<a href="/item-wow/">WoW Item</a>');
    var account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
    var cdk = jQuery('<a href="/wow-us-cdkey/">WoW CDkey</a>');

    //WOW-EU
    if (gameCode == '019') {
        gold = jQuery('<a href="/gold/WoWGoldProduct.aspx?gameCode=019">WoW Gold</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-EU/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-eu/">WoW-EU Accounts</a>');
        cdk = jQuery('<a href="/wow-eu-cdkey/">WoW CDkey</a>');
    }

    //AION-EU
    else if (gameCode == '087') {
        gold = jQuery('<a href="/Aion-EU/">Buy Gold</a>');
        pl = jQuery('<a href="/power-leveling/Aion-EU/">Powerleveling</a>');
        account = jQuery('<a href="/account-aion-eu/">Aion-EU Accounts</a>');
        cdk = jQuery('<a href="/wow-us-cdkey/">WoW CDkey</a>');
    }

    //AION-US
    else if (gameCode == '083') {
        gold = jQuery('<a href="/Aion-US/">Buy Gold</a>');
        pl = jQuery('<a href="/power-leveling/Aion-US/">Powerleveling</a>');
        account = jQuery('<a href="/account-aion-us/">Aion-US Accounts</a>');
        cdk = jQuery('<a href="/wow-us-cdkey/">WoW CDkey</a>');
    }

    else if (gameCode == '010') {
        gold = jQuery('<a href="/Runescape2-Gold/">Buy RS Gold</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-EU/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-eu/">WoW-EU Accounts</a>');
        cdk = jQuery('<a href="/wow-eu-cdkey/">WoW CDkey</a>');
    }

    //EVE
    else if (gameCode == '003') {
        gold = jQuery('<a href="/eve/">Buy EVE Gold</a>');
        pl = jQuery('<a href="/power-leveling/EVE-Online/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/wow-us-cdkey/">WoW CDkey</a>');
    }

    //EQ2
    else if (gameCode == '002') {
        gold = jQuery('<a href="/everquest-2/">Buy EQ2 Gold</a>');
        pl = jQuery('<a href="/power-leveling/Ever-Quest-2/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/eq2-cdkey/">Buy CDkey</a>');
    }

    //FFXI
    else if (gameCode == '001') {
        gold = jQuery('<a href="/Final-Fantasy-XI-Gil/">Buy FFXI Gold</a>');
        pl = jQuery('<a href="/power-leveling/Final-Fantasy-XI/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/ffxi-cdkey/">Buy CDkey</a>');
    }

    //ffxiv
    else if (gameCode == '100') {
        gold = jQuery('<a href="/Final-Fantasy-XIV-Gil/">Buy FFXIV Gold</a>');
        pl = jQuery('<a href="/power-leveling/Final-Fantasy-XIV/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/ffxiv-cdkey/">Buy CDkey</a>');
    }
    //Star Wars Galaxies
    else if (gameCode == '011') {
        gold = jQuery('<a href="/swg/">Buy SWG Gold</a>');
        pl = jQuery('<a href="/power-leveling/Star-Wars-Galaxies/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/swg-cdkey/">Buy CDkey</a>');
    }

    //Guild Wars
    else if (gameCode == '007') {
        gold = jQuery('<a href="/gw/">Buy Gold</a>');
        pl = jQuery('<a href="/power-leveling/Guild-Wars/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/wow-us-cdkey/">WoW CDkey</a>');
    }
    //Maple Story
    else if (gameCode == '014') {
        gold = jQuery('<a href="/maple-story/">Buy Gold</a>');
        pl = jQuery('<a href="/power-leveling/Guild-Wars/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/wow-us-cdkey/">WoW CDkey</a>');
    }

    //RIFT-USA
    else if (gameCode == '101') {
        gold = jQuery('<a href="/RIFT-USA/">Buy RIFT US Gold</a>');
        pl = jQuery('<a href="/RIFT-EUR/">RIFT-EUR</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }
    //RIFT-EUR
    else if (gameCode == '102') {
        gold = jQuery('<a href="/RIFT-EUR/">Buy RIFT EU Gold</a>');
        pl = jQuery('<a href="/RIFT-USA/">RIFT-USA</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }

    //Lineage-2
    else if (gameCode == '012') {
        gold = jQuery('<a href="/lineage-2/">Buy Lineage2 Gold</a>');
        pl = jQuery('<a href="/power-leveling/Lineage-2/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/lineage2-cdkey/">Buy CDkey</a>');
    }

    //EQ1 
    else if (gameCode == '009') {
        gold = jQuery('<a href="/gold/WoWGoldProduct.aspx?gameCode=013">Buy WoW Gold</a>');
        pl = jQuery('<a href="/power-leveling/Ever-Quest/">Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        cdk = jQuery('<a href="/wow-us-cdkey/">WoW CDkey</a>');
    }

    //lor
    /*else if (gameCode == '006') {
    gold = jQuery('<a href="/gold/WoWGoldProduct.aspx?gameCode=013">Buy WoW Gold</a>');
    pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
    account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
    jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }*/

    //APB
    else if (gameCode == '110') {
        gold = jQuery('<a href="/Apb-Reloaded/">Buy APB-US Gold</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }
    //APB-EU
    else if (gameCode == '111') {
        gold = jQuery('<a href="/Apb-Reloaded-EU/">Buy APB-EU Gold</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }

    //TERA
    else if (gameCode == '104') {
        gold = jQuery('<a href="/Tera/">Buy Tera Gold</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }

    //GW-Globs of Ectoplasm 
    else if (gameCode == '069') {
        gold = jQuery('<a href="/GW-Globs-of-Ectoplasm/">Buy GW-GOE</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }

    //GW-Zaishen Keys
    else if (gameCode == '099') {
        gold = jQuery('<a href="/GW-Zaishen Keys/">Buy GW-ZK</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }

    else if (gameCode == '114') {
        gold = jQuery('<a href="/Edeneternal/">Buy Gold</a>');
        pl = jQuery('<a href="/power-leveling/World-of-Warcraft-US/">WoW Powerleveling</a>');
        account = jQuery('<a href="/account-wow-us/">WoW-US Accounts</a>');
        jQuery('<a href="/lro-cdkey/">Buy CDkey</a>');
    }
    else if (gameCode == '123') {
        gold = jQuery('<a href="/Drakensang-oline/">Buy Drakensang Gold</a>');
        pl = jQuery('<a href="/power-leveling/Drakensang-oline/">Drakensang-oline Powerleveling</a>');
        account = jQuery('<a href="/account-Drakensang-oline/">Drakensang-oline Accounts</a>');
        jQuery('<a href="/Drakensang-oline-cdkey/">Buy CDkey</a>');
    }
    else if (gameCode == '130') {
    gold = jQuery('<a href="/swtor-us/">Swtor Credit</a>');
    pl = jQuery('<a href="/power-leveling/swtor-us/">Swtor PowerLeveling</a>');
    cdk = jQuery('<a href="/swtor-us-oline-cdkey/">Swtor CD-key</a>');
    }
     else if (gameCode == '118') {
     gold = jQuery('<a href="/swtor-eu/">Swtor Credit</a>');
     pl = jQuery('<a href="/power-leveling/swtor-eu/">Swtor PowerLeveling</a>');
     cdk = jQuery('<a href="/swtor-eu-oline-cdkey/">Swtor CD-key</a>');
    }

    return { GoldLink: gold, PLLink: pl, ItemLink: item, AccountLink: account, CDKeyLink: cdk };
}

function GetMenuList(liList) {
    return { Gold: liList[0], PL: liList[1], Item: liList[2], Account: liList[3], CDKey: liList[4] };
}

var curTip = "";
function displayToolTip(id) {
    if (curTip != "") {
        hideToolTip(curTip);
    }
    var ss = id;
    document.getElementById(id).style.display = 'block';
    curTip = id;
}

function hideToolTip(id) {
    document.getElementById(id).style.display = 'none';
    curTip = "";
}

function initLeftMenu() {
    var activeIndex = 0;
    var lis = jQuery('#leftMent_ul li');
    for (var i = 0; i < lis.length; i++) {
        if (jQuery(lis[i]).attr('class') != 'active') {
            jQuery(lis[i]).mouseover(function() {
                jQuery(this).attr('class', 'active');
            });

            jQuery(lis[i]).mouseout(function() {
                jQuery(this).removeAttr('class');
            });
        }
    }
}
