﻿jQuery(document).ready(function() {
    initLeftMenu();
    var gamecode = jQuery("#leftGameCode").val();
    initMenu(gamecode);
});

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);
    jQuery("a",liList.Special).replaceWith(links.SpecialLink);


    //EQ2 FFXI SW
    if (gamecode == '007' || gamecode == '003' || gamecode == '004' || gamecode == '005' || gamecode=='118' || gamecode=='130') {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).show();
        jQuery(liList.Item).hide();
        jQuery(liList.Account).hide();
        jQuery(liList.CDKey).show();
        jQuery(liList.Special).hide();
        jQuery(tips[0]).show();
        jQuery(tips[1]).show();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).show();
        jQuery(tips[5]).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(liList.Special).hide();
        jQuery(tips[0]).hide();
        jQuery(tips[1]).hide();
        jQuery(tips[2]).hide();
        jQuery(tips[3]).hide();
        jQuery(tips[4]).show();
        jQuery(tips[5]).hide();
    }
    else {
        jQuery(liList.Gold).show();
        jQuery(liList.PL).show();
        jQuery(liList.Item).show();
        jQuery(liList.Account).show();
        jQuery(liList.CDKey).show();
        jQuery(liList.Special).show();
        tips.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>');
    var special=jQuery('<a href="/account/myaccount.aspx">WoW Special Needs</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>');
    }

    //EQ2
    if (gameCode == '007') {
        gold = jQuery('<a href="/everquest-2/">Buy 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
    if (gameCode == '003') {
        gold = jQuery('<a href="/Final-Fantasy-XI-Gil/">Buy 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>');
    }

    //SW
    if (gameCode == '004') {
        gold = jQuery('<a href="/swg/">Buy 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>');
    }

    //Lineage-2
    if (gameCode == '005') {
        gold = jQuery('<a href="/lineage-2/">Buy 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>');
    }

    //lor
    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>');
    }
    
    //swg
    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,SpecialLink:special };

}
function GetMenuList(liList) {
    return { Gold: liList[0], PL: liList[1], Item: liList[2], Account: liList[3], CDKey: liList[4],Special:liList[5] };
}

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');
            });
        }
    }
}
