Raw Source
Amynka / LPuNKTKit

// ==UserScript==
// @version     5.5.3
// @author      LPuNKT
// @date        2013-05-22
// @name        LPuNKTKit
// @namespace   lpunktkit
// @grant       GM_setValue
// @grant       GM_getValue
// @grant       GM_deleteValue
// @grant       GM_log
// @updateURL      http://userscripts-mirror.org/scripts/show/118405.html
// @updateURL     http://userscripts-mirror.org/scripts/review/118405.html
// @downloadURL   http://userscripts-mirror.org/scripts/review/118405.html
// @description Kit de utilidades para oGame Redesign 5
// @icon        http://s3.amazonaws.com/uso_ss/icon/117512/large.png?1325107247
// @include     http://*.ogame.*/game/*
// @include     http://ogame.*/
// @include     http://www.ogame.*/
// @require     https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// ==/UserScript==

//OgameKit 3.01 -- http://userscripts-mirror.org/scripts/show/108998
//Resources in Flight 1.26 -- http://userscripts-mirror.org/scripts/show/58079
//Show IPM and Phalanx Range 1.01 -- http://userscripts-mirror.org/scripts/show/82029
//Disable Useless Stuff 1.03 -- http://userscripts-mirror.org/scripts/show/104181
//Pranger In Header 1.03 -- http://userscripts-mirror.org/scripts/show/61874
//Color Flight Slots 1.04 -- http://userscripts-mirror.org/scripts/show/73289
//Shortcut Keys 1.27 -- http://userscripts-mirror.org/scripts/show/83284
//Current Planet Name On Message Pages 1.01 -- http://userscripts-mirror.org/scripts/show/74117
//Fix Action Icons 1.17 -- http://userscripts-mirror.org/scripts/show/67948
//Reply Circular Messages 1.03 -- http://userscripts-mirror.org/scripts/show/82634
//BBCode -- http://userscripts-mirror.org/scripts/show/54537
//Smiles -- http://userscripts-mirror.org/scripts/show/54538
//Chat Alianza -- http://userscripts-mirror.org/scripts/show/65521
//Color the Message Subjects 1.08 -- http://userscripts-mirror.org/scripts/show/86257
//mailColoration -- http://userscripts-mirror.org/scripts/show/101703
//Message button in left menu 0.1 -- http://userscripts-mirror.org/scripts/show/93205
//Set the Focus Correctly 1.02 -- http://userscripts-mirror.org/scripts/show/83850
//Fix the Universe Name in the Pillory 1.04 -- http://userscripts-mirror.org/scripts/show/94540
//Planet Navigation Keys 1.06 -- http://userscripts-mirror.org/scripts/show/82484
//Compactador Batallas 0.08 -- http://userscripts-mirror.org/scripts/show/75647
//Missing Sats 1.05 -- http://userscripts-mirror.org/scripts/show/81699
//Fleet Empty Space 1.00 -- http://userscripts-mirror.org/scripts/show/103449
//Show Resource Details 1.03 -- http://userscripts-mirror.org/scripts/show/84148
//Point Board Link Really to the Forum 1.00 -- http://userscripts-mirror.org/scripts/show/85889
//Moons to the Right 1.05 -- http://userscripts-mirror.org/scripts/show/71588
//Direct Colonization 1.00 -- http://userscripts-mirror.org/scripts/show/83845
//Retarted Star -- http://userscripts-mirror.org/scripts/show/74641
//Coordinates Links Fix 1.00 -- http://userscripts-mirror.org/scripts/show/118405
//Additional Resource Loading Buttons 1.03 -- http://userscripts-mirror.org/scripts/show/81197
//Options in User Name 1.02 -- http://userscripts-mirror.org/scripts/show/75283
//Return Fleet Question 1.01 -- http://userscripts-mirror.org/scripts/show/111756
//Merchant Warning 1.00 -- http://userscripts-mirror.org/scripts/show/83847
//Efficiency Tool 0.1 -- http://userscripts-mirror.org/scripts/show/106920
//Small planets -- http://userscripts-mirror.org/scripts/show/93656
//Fleet Contents 1.02 -- http://userscripts-mirror.org/scripts/show/95547
//Destination Player Name on 3rd Fleet Dispatch Page 1.00 -- http://userscripts-mirror.org/scripts/show/119743
//Spy from the Fleet Movement Page 1.05 -- http://userscripts-mirror.org/scripts/show/96510
//Short Header 1.03 -- http://userscripts-mirror.org/scripts/show/56750
//Highlight Players and Alliances -- http://userscripts-mirror.org/scripts/show/50678
//AutoExpoFleet for Raiders (HF) 1.1.3 -- http://userscripts-mirror.org/scripts/show/105310

//Cambios:
// Adecuar lista de planetas a la nueva ventana de Mercader
// Corregido reloj en la barra de links
// Mostrar calculadora de comercio solo donde corresponde
// Corregido desactivar advertencia de colonizacion
// Corregido detalles de recursos
// Nombre de jugador contempla puntos de honor, si se usa como acceso a opciones
// Corregido recursos en transito
// Corregido lunas a la derecha
// Corregido BBCode y Smiles
// Corregido compactador de batallas
// Corregido produccion optima
// Corregido tiempo y recursos en hangar
// Corregido llenado de almacenes
// Corregido satelites necesarios
// Corregido Fleet Content
// Mostrar link al Chat en la barra de links
// Ocultacion de robo y/o escombros vacios en el CR
// Corregido Pregunta de retorno de flota
// Corregido iconos de accion
// Corregir teclas rapidas
// Eliminado //require http://sizzlemctwizzle.com/updater.php por no existir ya el dominio
// Corregido fleet slot colored
// Eliminado borde de seleccion de planeta
// Sumado opcion de resaltado de planeta/luna activo
// Coloreado de slots tambien en Galaxy (y resaltado de infos generales de galaxia)
// Corregido deteccion de idioma, universo y pagina
// Corregido calcular tiempo de fabricacion de flotas y defensas
// Corregido rango de misiles y phalanx
// Corregido posicionamiento botones de carga
// Mostrar recursos para desmontar una construccion (excepto terraformer y base lunar)
// Teclas rapidas para los botones de carga de AntiGame
// Eliminado fecha del compactador de batallas para mensajes
// Sumado repartidos automatico de escombros SAC
// Corregido comportamiento por defecto de opciones de configuracion
// Sumado boton donaciones
// Corregido iluminacion de planeta activo

// ToDo:
// Repartidor de SAC automatico RECUPERANDO PERDIDAS
// Corregir smiles para compatibilizarlo con spoiler
// Colores de resalte de jugadores y alianzas configurables (en vista de galaxia)
// Cantidades de resalte de escombros configurables (en vista de galaxia)

const DEBUG_MODE = 0; //0: none; 1: basic; 2: extended; 3: language texts; !=0: errors

const VERSION_LPUNKTKIT = "5.5.3 \u042F";

var strUrl_Script;        const URL_SCRIPT = 'http://userscripts-mirror.org/scripts/show/117512';
                          const URL_SCRIPT_T = 'http://userscripts-mirror.org/scripts/show/118405';


var strUniverse;

/**
 * Configuracion de las ventanas de configuracion del script
 */
//Default Color Font
var   strColor_LPuNKTKit;        const COLOR_LPUNKTKIT   = "lime";
                                 const COLOR_LPUNKTKIT_T = "aquamarine";

//Available Color Fonts
const arrColorFont = [
                     'Cornflower Blue',
                     'Deep Sky Blue',
                     'Cyan',
                     'Light Blue',
                     'Aquamarine',
                     'Light Green',
                     'Spring Green',
                     'Lime',
                     'LimeGreen',
                     'Yellow Green',
                     'Yellow',
                     'Khaki',
                     'Gold',
                     'Orange',
                     'Tomato',
                     'Chocolate',
                     'Crimson',
                     'Medium Purple',
                     'Dark Magenta',
                     'Fuchsia',
                     'Violet',
                     'Pink',
                     'Lavender',
                     'White',
                     'Silver',
                     'Gray',
                     ];

/**
 * Lenguaje en uso (dependiendo el idioma en opciones se usa uno u otro)
 */
var LANG;       //Textos del idioma

const DEFAULT_LANG = 'en'; //Idioma por defecto

var divClear = '<div style="clear:both;height:4px;"></div>';

var hr       = '<hr style="margin:4px 0;border-top-color:#111;' +
               'border-bottom-color:#444' +
               ';border-width:1px 0;' +
               'border-style:solid;display:block;">';

/**
 * Coloreado de mensajes
 */
var arrColorMessages = new Array();

/**
 * Compactador de batallas
 */
var arrColorBatalla = new Array(); // {CODE}, color, text

/**
*  Datos de flotas/defensas. LoadDatosFlota() lo inicializa.
*/
var arrDatosFlota = new Array(); //S.Name, L.Name, Metal, Cristal, Deuterio, Carga

/**
 * Den, Almacenes, produccion y recursos actuales
 */
var pMetal; var metal;
var pCristal; var cristal;
var pDeuterio; var deuterio;

/**
* Calculo de satelites necesarios
*/
var energyBalance;  //Produccion de energia excedente
var energyProduced; //Produccion de energia total
var energyPerSat;   //Produccion de energia por satelite

/**
* Tecnologia Ionica
*/
var lvlIonica;

/**
* Pagina actual
*/
var strPaginaActual;

/**
 * Opciones
 */
const LINK_NAME_LENGTH = 20;


var show_PayPal;                const SHOW_PAYPAL = true;
var link1_name;                 const LINK1_NAME = 'ToolsForOgame';
var link1_href;                 const LINK1_HREF = 'http://www.toolsforogame.com/';
var link2_name;                 const LINK2_NAME = 'OGame Calc';
var link2_href;                 const LINK2_HREF = 'http://proxyforgame.com/';
var link3_name;                 const LINK3_NAME = 'Infuza';
var link3_href;                 const LINK3_HREF = 'http://www.infuza.com/es/weekly/';
var link4_name;                 const LINK4_NAME = 'OSimulate';
var link4_href;                 const LINK4_HREF = 'http://www.osimulate.com';
var set_Clock_Links;            const SET_CLOCK_LINKS            = true;

var fix_Tooltips;               const FIX_TOOLTIPS               = true;
var show_Fleet_Resources;       const SHOW_FLEET_RESOURCES       = false;
var color_Metal;                const COLOR_METAL                = '#C0C0C0';
var color_Cristal;              const COLOR_CRISTAL              = '#00FFFF';
var color_Deuterio;             const COLOR_DEUTERIO             = '#00FF7F';
var show_Resources_Per_Fleet;   const SHOW_RESOURCES_PER_FLEET   = false;
var show_Empty_Space;           const SHOW_EMPTY_SPACE           = false;
var color_Empty_Space;          const COLOR_EMPTY_SPACE          ='#FFA500';
var show_Color_Flight_Slots;    const SHOW_COLOR_FLIGHT_SLOTS    = false;
var color_Slot_0;               const COLOR_SLOT_0               = '#DC143C';
var color_Slot_1;               const COLOR_SLOT_1               = '#FFA500';
var color_Slot_2;               const COLOR_SLOT_2               = '#FFFF00';
var color_Slot_3;               const COLOR_SLOT_3               = '#00FF7F';

var show_Load_Buttons;          const SHOW_LOAD_BUTTONS          = false;
var show_Return_Fleet_Question; const SHOW_RETURN_FLEET_QUESTION = false;
var remove_Adv;                 const REMOVE_ADV                 = false;
var show_Fleet_Content;         const SHOW_FLEET_CONTENT         = false;
var show_Dest_Player_Name;      const SHOW_DEST_PLAYER_NAME      = false;
var use_Direct_Spy;             const USE_DIRECT_SPY             = false;
var show_Auto_Expo_Fleet;       const SHOW_AUTO_EXPO_FLEET       = false;
var show_No_Escape;             const SHOW_NO_ESCAPE             = false;
var color_No_Escape;            const COLOR_NO_ESCAPE            = '#DC143C';
var color_Escape;               const COLOR_ESCAPE               = '#00FF7F';

var show_Time_Ships_Defenses;   const SHOW_TIME_SHIPS_DEFENSES   = true;
var show_Llenado_Almacenes;     const SHOW_LLENADO_ALMACENES     = true;
var color_M_Warehouse_0;        const COLOR_M_WAREHOUSE_0        = '#FA8072';
var color_C_Warehouse_0;        const COLOR_C_WAREHOUSE_0        = '#90EE90';
var color_D_Warehouse_0;        const COLOR_D_WAREHOUSE_0        = '#87CEFA';
var color_M_Warehouse_80;       const COLOR_M_WAREHOUSE_80       = '#DC143C';
var color_C_Warehouse_80;       const COLOR_C_WAREHOUSE_80       = '#9ACD32';
var color_D_Warehouse_80;       const COLOR_D_WAREHOUSE_80       = '#6495ED';
var color_M_Warehouse_100;      const COLOR_M_WAREHOUSE_100      = '#8B0000';
var color_C_Warehouse_100;      const COLOR_C_WAREHOUSE_100      = '#808000';
var color_D_Warehouse_100;      const COLOR_D_WAREHOUSE_100      = '#4169E1';
var color_M_Den_0;              const COLOR_M_DEN_0              = '#FA8072';
var color_C_Den_0;              const COLOR_C_DEN_0              = '#90EE90';
var color_D_Den_0;              const COLOR_D_DEN_0              = '#87CEFA';
var color_M_Den_80;             const COLOR_M_DEN_80             = '#DC143C';
var color_C_Den_80;             const COLOR_C_DEN_80             = '#9ACD32';
var color_D_Den_80;             const COLOR_D_DEN_80             = '#6495ED';
var color_M_Den_100;            const COLOR_M_DEN_100            = '#8B0000';
var color_C_Den_100;            const COLOR_C_DEN_100            = '#808000';
var color_D_Den_100;            const COLOR_D_DEN_100            = '#4169E1';

var show_Production_Ratio;      const SHOW_PRODUCTION_RATIO      = true;
var show_Resources_Info;        const SHOW_RESOURCES_INFO        = false;
var color_Res_Almacen;          const COLOR_RES_ALMACEN          = '#DAA520';
var color_Res_Den;              const COLOR_RES_DEN              = '#87CEFA';
var color_Res_Prod;             const COLOR_RES_PROD             = '#9ACD32';
var color_Energy_Used;          const COLOR_ENERGY_USED          = '#DC143C';
var show_Daily_Ships_Defenses;  const SHOW_DAILY_SHIPS_DEFENSES  = false;

var show_Uni_Name_In_Pillory;   const SHOW_UNI_NAME_IN_PILLORY   = true;
var disable_Useless_Stuff;      const DISABLE_USELESS_STUFF      = true;
var set_Focus_Correctly;        const SET_FOCUS_CORRECTLY        = true;
var disable_Star;               const DISABLE_STAR               = true;
var fix_Forum_Link;             const FIX_FORUM_LINK             = true;
var use_Short_Header;           const USE_SHORT_HEADER           = true;
var show_Confirm_Trader;        const SHOW_CONFIRM_TRADER        = true;
var show_Trade_Calculator;      const SHOW_TRADE_CALCULATOR      = false;
var show_Pranger_In_Header;     const SHOW_PRANGER_IN_HEADER     = false;
var show_Options_In_UserName;   const SHOW_OPTIONS_IN_USERNAME   = false;

var show_Link_Fixed;            const SHOW_LINK_FIXED            = false;
var highlight_Players;          const HIGHLIGHT_PLAYERS          = false;
var set_Fix_Action_Icons;       const SET_FIX_ACTION_ICONS       = true;

var show_Planet_Nav_Keys;       const SHOW_PLANET_NAV_KEYS       = false;
var show_Moons_Right;           const SHOW_MOONS_RIGHT           = false;
var show_Small_Planets;         const SHOW_SMALL_PLANETS         = false;
var show_Full_Planet;           const SHOW_FULL_PLANET           = false;
var color_Full_Planet_0;        const COLOR_FULL_PLANET_0        = '#DC143C';
var color_Full_Planet_1;        const COLOR_FULL_PLANET_1        = '#FFA500';
var color_Full_Planet_2;        const COLOR_FULL_PLANET_2        = '#FFFF00';
var color_Full_Planet_3;        const COLOR_FULL_PLANET_3        = '#00FF7F';
var show_Planeta_Activo;        const SHOW_PLANETA_ACTIVO        = true;

var show_Sats_Balance;          const SHOW_SATS_BALANCE          = false;
var show_Sats_Terraformer;      const SHOW_SATS_TERRAFORMER      = false;
var show_Sats_Graviton;         const SHOW_SATS_GRAVITON         = false;

var show_Efficiency;            const SHOW_EFFICIENCY            = false;
var show_Range;                 const SHOW_RANGE                 = false;
var show_Demolish;              const SHOW_DEMOLISH              = true;

var show_Shortcuts;             const SHOW_SHORTCUTS             = false;
var show_Key_Everywhere;        const SHOW_KEY_EVERYWHERE        = true;
var show_Key_Mailbox;           const SHOW_KEY_MAILBOX           = true;
var show_Key_Fleet;             const SHOW_KEY_FLEET             = true;
var show_Key_Trader;            const SHOW_KEY_TRADER            = true;

var current_Planet_Name;        const CURRENT_PLANET_NAME        = true;
var reply_CC;                   const REPLY_CC                   = false;
var show_BBCode;                const SHOW_BBCODE                = false;
var show_Smiles;                const SHOW_SMILES                = false;
var show_Message_Button_Left;   const SHOW_MESSAGE_BUTTON_LEFT   = false;
var show_Colored_Messages;      const SHOW_COLORED_MESSAGES      = false;

var show_Compactador_Batallas;  const SHOW_COMPACTADOR_BATALLAS  = false;
var show_Escombros_SAC;         const SHOW_ESCOMBROS_SAC         = true;
var modo_Reparto_SAC;           const MODO_REPARTO_SAC           = 1; // [0 = 'equal' | 1 = 'proportional']
var rec_Perdidas_SAC;           const REC_PERDIDAS_SAC           = false;

// ratio de conversión de recursos a metal
var rat_Metal_SAC;              const RAT_METAL_SAC              = 2;
var rat_Cristal_SAC;            const RAT_CRISTAL_SAC            = 1.5;
var rat_Deuterio_SAC;           const RAT_DEUTERIO_SAC           = 1;

// porcentaje de recursos utilizados para obtener el deuterio de perdidas
var prop_Metal_SAC;             const PROP_METAL_SAC             = 60;
var prop_Cristal_SAC;           const PROP_CRISTAL_SAC           = 40;

// ocultar escombros o robos, si son inexexistentes, en CR para CC
var hide_Stolen_CR;             const HIDE_STOLEN_CR             = true;
var hide_Debris_CR;             const HIDE_DEBRIS_CR             = true;

var usar_CR_Friki;              const USAR_CR_FRIKI              = false;
var availCRFriki = false;

var id_Chat;                    const ID_CHAT                    = 0;
var show_Chat;                  const SHOW_CHAT                  = false;
var link_Chat;                  const LINK_CHAT                  = false;

var min_Escombros;              const MIN_ESCOMBROS              = 10000;
var show_Debris;                const SHOW_DEBRIS                = 3;

/**
 * Otros
 */
var unsafe;

if (navigator.userAgent.indexOf('Firefox')>-1)
{
    var FireFox = true;
}
else
{
    var FireFox = false;
}

// Google Chrome & Opera
if(! FireFox)
{
    function GM_getValue(key,defaultVal)
    {
         var retValue = localStorage.getItem(key);

         if ( ! retValue ) return defaultVal;
              return retValue;
    }

    function GM_setValue(key,value)
    {
         localStorage.setItem(key, value);
    }
}

/**
 *  SCRIPT LPuNKTKit
 */
function main()
{
  if (document.location.href.indexOf('ogame') < 0) return;

  getPaginaActual();

  if (DEBUG_MODE > 0) GM_log('main: ' + strPaginaActual);

  if ( (strPaginaActual=="unknown") ||
       (strPaginaActual=="techinfo") ||
       (strPaginaActual=="globalTechtree") ||
       (strPaginaActual=="techtree") ||
       (strPaginaActual=="buddies") ||
       (strPaginaActual=="notices") ||
       (strPaginaActual=="empire"))
  {
    //el script no funciona en estas paginas, por ahora.
    if (DEBUG_MODE > 0) GM_log('main >> Don\'t work pages: ' + strPaginaActual);
  }
  else if ((strPaginaActual=="home") ||
           (strPaginaActual=="combatreport") ||
           (strPaginaActual=="writemessage") ||
           (strPaginaActual=="search") ||
           (strPaginaActual=="pranger"))
  {
    if (DEBUG_MODE > 0) GM_log('main >> loadOptions: ' + strPaginaActual);

    loadOptions();

  }
  else
  {
    if (DEBUG_MODE > 0) GM_log('main >> initialize: ' + strPaginaActual);

    initialize();

    unsafe = window;
    try
    {
      unsafe = unsafeWindow
    }
    catch (e)
    {
    }

    if (((strPaginaActual =='defense') || (strPaginaActual =='shipyard') ||
         (strPaginaActual =='resources')) &&
        (show_Time_Ships_Defenses))
        setInterval(function() {loadResources();calculateTime();}, 500);

    switch (strPaginaActual) {
    case "traderOverview":
         if (DEBUG_MODE > 0) GM_log('main >> case trader: ' + strPaginaActual);

         setInterval( function () {
                         if (window.location.href.indexOf('page=traderResources') > -1) {
                            if (DEBUG_MODE > 0) GM_log('main >> case trader: ' + window.location.href);
                            ConfirmTrader();
                            TradeCalculator();
                         } else {
                            var myDiv = document.getElementById('lpk-Calculator');
                            if (myDiv) myDiv.parentNode.removeChild(myDiv);
                         }
                      }, 1000);

         break;

    case "resourceSettings":
         if (DEBUG_MODE > 0) GM_log('main >> case resourceSettings: ' + strPaginaActual);

         loadProduction();

         addWarehousesGraphic();

         if (EsPlaneta()) {
             addProductionRatio();
             shipsAndDefenses();
         }
         break;

    case "galaxy":

         if (DEBUG_MODE > 0) GM_log('main >> case galaxy: ' + strPaginaActual);

         HighlightPlayers();

         FixActionIcons();

         highlightDebris();

         ColorFlightSlots();

         break;

    case "movement":
         if (DEBUG_MODE > 0) GM_log('main >> case movement: ' + strPaginaActual);

         FixTooltips();

         EmptySpace();

         ResourcesPerFleet();

         ColorFlightSlots();

         ResourcesInFlight();

         ReturnFleetQuestion();

         DirectSpy();

         break;

    case "messages":
         if (DEBUG_MODE > 0) GM_log('main >> case messages: ' + strPaginaActual);

         ColoredSubjects();

         CurrentPlanetNameOnMessagesPages();

         ReplyCircularMessages();

         ColoredHeader();

         CompactadorBatallas();

         break;

/*    case "showmessage":
         if (DEBUG_MODE > 0) GM_log('main >> case showmessage: ' + strPaginaActual);

         ReplyCircularMessages();

         ColoredHeader();

         break;*/

    case "alliance":
         if (DEBUG_MODE > 0) GM_log('main >> case alliance: ' + strPaginaActual);

         ChatAlianza();

         break;

    case "flotten1":
    case "fleet1":
         if (DEBUG_MODE > 0) GM_log('main >> case fleet1: ' + strPaginaActual);

         ColorFlightSlots();
         FleetContents();
         showNoEscape();

         break;

    case "flotten2":
    case 'fleet2':
         if (DEBUG_MODE > 0) GM_log('main >> case fleet2: ' + strPaginaActual);

         FleetContents();

         break;

    case "flotten3":
    case "fleet3":
         if (DEBUG_MODE > 0) GM_log('main >> case fleet3: ' + strPaginaActual);

         DestinationPlayerName();
         QuitarAdvertencia();
         ResourceLoadButtons();
         FleetContents();

         break;

    case "station":
         if (DEBUG_MODE > 0) GM_log('main >> case station: ' + strPaginaActual);

         Efficiency();
         MissingSatsInprove('33');
         ShowIPMandPhalanxRange();
         InfoUnmount();
         DisableUselessStuff();

         break;

    case 'resources':
         if (DEBUG_MODE > 0) GM_log('main >> case resources: ' + strPaginaActual);

         MissingSats();
         InfoUnmount();
         DisableUselessStuff();

         break;

    case 'shipyard':
         if (DEBUG_MODE > 0) GM_log('main >> case shipyard: ' + strPaginaActual);

         MissingSats();
         DisableUselessStuff();

         break;

    case 'defense':
         if (DEBUG_MODE > 0) GM_log('main >> case defense: ' + strPaginaActual);

         ShowIPMandPhalanxRange();

         break;

    case 'research':
         if (DEBUG_MODE > 0) GM_log('main >> case research: ' + strPaginaActual);

         getLvlIonica();
         MissingSatsInprove('199');
         DisableUselessStuff();

         break;

    default:
         if (DEBUG_MODE > 0) GM_log('main >> case default: ' + strPaginaActual);

         break;
    } //switch
  } //else

  UniverseNameInPillory();

  MessageButtonLeft();

  BBCode();

  NewSmiles();

  SmallPlanets();

  ForumLink();

  ResourcesInfo();

  OgameOptionsInUserName();

  PrangerInHeader();

  ShortcutKeys();

  PlanetNavigationKeys();

  FocusCorrectly();

  QuitarEstrella(disable_Star);

  MoonsToRight();

  LinkFixed();

  showLinks();

  ShortHeader();

  AutoExpoFleet();

  ShowFullPlanet();

  PlanetaMoonActivo();

  mouseOverImageSwitch();

//StoreLangPack (LANG_EN, 'EN');
//StoreLangPack (LANG_FR, 'FR');
}

function replaceAll( text, str1, str2 ){
         var command = 'text.replace(/' + str1 + '/gi,\'' + str2 + '\')';
         return eval(command);
}

function extraerNumeroCadena(numero) {
   return numero.replace(/[^\d\.]/g,'');
}

function insertAfter(referenceNode, node){

        if (referenceNode.nextSibling)
            referenceNode.parentNode.insertBefore(node, referenceNode.nextSibling)

        else
            referenceNode.parentNode.appendChild(node);
}

document.getElementsByClassName = function (cl)
{
    if (DEBUG_MODE > 1) GM_log('getElementsByClassName: ' + strPaginaActual);

    var retnode = [];
    var myclass = new RegExp ("\\b" + cl + "\\b");
    var elem = this.getElementsByTagName ("*");

    for (var i = 0; i < elem.length; i++)
    {
       var classes = elem [i].className;
       if (myclass.test (classes))
          retnode.push (elem [i]);
    }
    return retnode;
}

function getElementsByClass(searchClass,node,tag) {

    if (DEBUG_MODE > 1) GM_log('getElementsByClass: ' + strPaginaActual);

    var classElements = new Array();

    if (node == null)
        node = document;

    if (tag == null)
        tag = '*';

    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;

    for (var i = 0, j = 0; i < elsLen; i++) {

         var sep = els[i].className.split(" ");
         var content = false;

         for( var k = 0; k < sep.length; k++){

              if(sep[k] == searchClass)
                 content = true;
         }

         if (els[i].className == searchClass || content) {
             classElements[j] = els[i];
             j++;
         }
    }

    return classElements;
}

function addDots (n)
{
   if (DEBUG_MODE > 1) GM_log('addDots: ' + strPaginaActual);

   n += '';
   var rgx = /(\d+)(\d{3})/;

   while (rgx.test (n))
         n = n.replace (rgx, '$1' + '.' + '$2');

   return n;
}

function trim (myString)
{
         var myNewString = myString.replace(/^\s+/g,'').replace(/\s+$/g,'');

         if (DEBUG_MODE > 1) GM_log('trim: [ ' + myNewString + ' ] ' + strPaginaActual);

         return myNewString;
}

function roundNumber(num, dec) {
  var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
  return result;
}

function setStyleSet (strStyle) {
  try {
      if (DEBUG_MODE > 0) GM_log('setStyleSet: ' + strPaginaActual);

      var myStyle = document.createElement('style');
          myStyle.setAttribute('type', 'text/css');
          myStyle.appendChild(document.createTextNode(strStyle));

      if (window.opera)
          document.body.appendChild(myStyle)
      else
          document.head.appendChild(myStyle);

   } catch(e) {
         if (DEBUG_MODE != 0)  GM_log('setStyleSet [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function mouseOverImageSwitch()
{
    if (DEBUG_MODE > 1) GM_log('mouseOverImageSwitch: ' + strPaginaActual);


    $('img.lpunktkit-micon').bind(
        'mouseenter',
        function(){
            var tempSrc = $(this).attr('src');
            $(this).attr('src', $(this).attr('rel'));
            $(this).attr('rel', tempSrc);
        }
    ).bind(
        'mouseleave',
        function(){
            var tempSrc = $(this).attr('src');
            $(this).attr('src', $(this).attr('rel'));
            $(this).attr('rel', tempSrc);
        }
    );
}

function getPaginaActual()
{
  try {
      var myUrl = window.location + "";
      if (window.location.hostname == myUrl.substring(7).replace(/\//g,"") )
      {
        strPaginaActual = "home";
      }
      else
      {
        //averiguar en que apartado del juego estamos
        partes = myUrl.substring(myUrl.indexOf('?')+1).split("&");
        comienzos = myUrl.substring(0, myUrl.indexOf('?')).split("/");

        if (DEBUG_MODE > 0) GM_log('getPaginaActual: [ ' + partes + ' ]');

        if (comienzos[comienzos.length-1] == "index.php") {
          for (i = 0; i < partes.length; i++) {
               if (partes[i].indexOf('page=') >= 0) {
                   strPaginaActual_2 = partes[i].substring(partes[i].indexOf('=') + 1);
                   strPaginaActual = strPaginaActual_2.split('#')[0];

                   if (DEBUG_MODE > 0) GM_log('getPaginaActual: [ ' + strPaginaActual + ' ]');

                   break;
               }
          }

        } else if (myUrl.indexOf('/game/pranger.php') >= 0)
          strPaginaActual = "pranger";
        else
          strPaginaActual = "unknown";
      }

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('getPaginaActual [ERROR]: <' + e + '> ');
   }
}

function getUniverse() {
   try {
         if (document.location.href.indexOf ('/game/index.php?') < 0)
             return;

         if (DEBUG_MODE > 0) GM_log('getUniverse: ' + strPaginaActual);

         var metas = document.getElementsByTagName('META');

         if (! metas) return;

         var i;
         for (i = 0; i < metas.length; i++)
              if (metas[i].getAttribute('NAME') == "ogame-universe")
                  break;

         if (metas[i])
             var strUniv = metas[i].getAttribute('CONTENT').replace(/\./g,'_').toUpperCase()

         else {
             var strUniv = document.location.href.split (/\//) [2];
                 strUniv = strUniv.replace(/\./g,'_').toUpperCase();
         }

         if (DEBUG_MODE > 0) GM_log('getUniverse: [ ' + strUniv + ' ] ' + strPaginaActual);

         return strUniv;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('getUniverse [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function getLanguage() {
   try {
         if (document.location.href.indexOf ('/game/index.php?') < 0)
             return;

         if (DEBUG_MODE > 0) GM_log('getLanguage: ' + strPaginaActual);

         var metas = document.getElementsByTagName('META');

         if (! metas) return;

         var i;
         for (i = 0; i < metas.length; i++)
              if (metas[i].getAttribute('NAME') == "ogame-language")
                  break;

         if (metas[i])
             var strLang = metas[i].getAttribute('CONTENT').toUpperCase()

         else
             var strLang = DEFAULT_LANG;

         if (DEBUG_MODE > 1) GM_log('getLanguage: [ ' + strLang + ' ] ' + strPaginaActual);

         return strLang;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('getLanguage [ERROR]: <' + e + '> ' + strPaginaActual);
   }

}

function getUniSpeed() {
   try {
         if (document.location.href.indexOf ('/game/index.php?') < 0)
             return;

         if (DEBUG_MODE > 0) GM_log('getUniSpeed: ' + strPaginaActual);

         var metas = document.getElementsByTagName('META');

         if (! metas) return;

         var i;
         for (i = 0; i < metas.length; i++)
              if (metas[i].getAttribute('NAME') == "ogame-universe-speed")
                  break;

         if (metas[i])
             var intSpeed = parseInt(metas[i].getAttribute('CONTENT'))

         else
             var intSpeed = 1;

         if (DEBUG_MODE > 1) GM_log('getUniSpeed: [ ' + intSpeed + ' ] ' + strPaginaActual);

         return intSpeed;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('getUniSpeed [ERROR]: <' + e + '> ' + strPaginaActual);
   }

}

function EsPlaneta() {
   try {
         if (document.location.href.indexOf ('/game/index.php?') < 0)
             return;

         if (DEBUG_MODE > 2) GM_log('EsPlaneta: ' + strPaginaActual);

         var metas = document.getElementsByTagName('META');

         if (! metas) return;

         var i;
         for (i = 0; i < metas.length; i++)
              if (metas[i].getAttribute('NAME') == "ogame-planet-type")
                  break;

         if (metas[i]) {
             if (DEBUG_MODE > 2) GM_log('EsPlaneta: [ ' + metas[i].getAttribute('CONTENT') + ' ] ' + strPaginaActual);

             return (metas[i].getAttribute('CONTENT').indexOf('planet')>=0);

         } else {
             if (DEBUG_MODE > 2) GM_log('EsPlaneta: [ DEFAULT false ] ' + strPaginaActual);

             return false;
         }

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('EsPlaneta [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * devuelve "session=xxxxxxx"
 */
function getSession()
{
  try {
        if (DEBUG_MODE > 1) GM_log('getSession: ' + strPaginaActual);

        var arrSession = document.getElementsByTagName('ogame-session');

        if (arrSession[0])
        var strSess = 'session=' + arrSession[0].content

        else {
        var myUrl = window.location + "";
           myUrl = myUrl.replace("#","");

        var fragmento = myUrl.substring( myUrl.search("session=") );
        var partes = fragmento.split("&");

        var strSess = partes[0];
        }

        if (DEBUG_MODE > 2) GM_log('getSession: [ ' + strSess + ' ] ' + strPaginaActual);

        return strSess;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('getSession [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}


function getVersionOgame() {
   try {
        if (DEBUG_MODE > 1) GM_log('getVersionOgame: ' + strPaginaActual);

        var arrVersion = [0,0,0];

        var oVersion = document.getElementsByName ("ogame-version");

        if (oVersion && (oVersion.length > 0))
        {
            arrVersion = oVersion [0].content.split (".");
        }

        if (DEBUG_MODE > 2) GM_log('getVersionOgame: [ ' + arrVersion + ' ] ' + strPaginaActual);

        return arrVersion;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('getVersionOgame [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function checkVersionOgame() {
   try {
      if (DEBUG_MODE > 1) GM_log('checkVersionOgame: ' + strPaginaActual);

      var oldVersion = false;

      //Comprobar version de oGame
      var arrVersion = getVersionOgame();
      if ( (parseInt(arrVersion[0]) < 2) ||
           ( (parseInt(arrVersion[0]) == 2) &&
             (parseInt(arrVersion[1]) < 3) ))
         oldVersion = true;

      if (DEBUG_MODE > 2) GM_log('checkVersionOgame: [ OldVersion = ' + oldVersion + ' ] ' + strPaginaActual);

      return oldVersion;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('checkVersionOgame [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function getLvlIonica()
{
   try {
        if (strPaginaActual != 'research')
            return;

        if (DEBUG_MODE != 0) GM_log('getLvlIonica: ' + strPaginaActual);

        var theA = document.getElementById('details121');

        if (theA == null)
            return;

        theSpans = theA.getElementsByTagName ("span");

        for (var j = 0; j < theSpans.length; j++)

             if (theSpans [j].className == "textlabel") {
                 var lvlIonica = parseInt (theSpans [j].nextSibling.textContent)

                 break;
             }

        if (DEBUG_MODE > 1) GM_log('getLvlIonica: Tech. Ionica = ' + lvlIonica + ' >> ' + strPaginaActual);

        GM_setValue("level_ionica" + strUniverse, lvlIonica);

   } catch(e) {
        if (DEBUG_MODE != 0) GM_log('getLvlIonica [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function initialize()
{
  if (DEBUG_MODE > 0) GM_log('initialize: ' + strPaginaActual);

  //carga de datos
  loadOptions();

  // Mostrar botones
  addOptions();
}

/**
 * Calcula la produccion por minuto y la carga en las variables globales
 */
function loadProduction()
{
  try {
      if ((strPaginaActual != 'defense') && (strPaginaActual != 'shipyard') &&
          (strPaginaActual != 'resources') && //Satelites balance 0
          (strPaginaActual != 'resourceSettings'))
          return;

      if (DEBUG_MODE > 1) GM_log('loadProduction: ' + strPaginaActual);

      var priTag;
      var ultTag;

      var resourcesText = document.body.innerHTML.substring (
                          document.body.innerHTML.indexOf('function initAjaxResourcebox'),
                          document.body.innerHTML.indexOf('function getAjaxEventbox'));


      // Metal
      var res = resourcesText.substring (
                              resourcesText.indexOf('metal'),
                              resourcesText.indexOf('crystal'));

      var myMatch = res.split('<td>')[3];

      priTag = myMatch.indexOf('>');
      ultTag = myMatch.indexOf('<', priTag);
      myMatch = myMatch.substring(priTag + 1, ultTag);

      pMetal = myMatch.replace(/\./g,"");
      pMetal = parseInt(pMetal);
      pMetal = pMetal/60; //produccion por minuto

      // Cristal
      res = resourcesText.substring (
                          resourcesText.indexOf('crystal'),
                          resourcesText.indexOf('deuterium'));

      myMatch = res.split('<td>')[3];

      priTag = myMatch.indexOf('>');
      ultTag = myMatch.indexOf('<', priTag);
      myMatch = myMatch.substring(priTag + 1, ultTag);

      pCristal = myMatch.replace(/\./g,"");
      pCristal = parseInt(pCristal);
      pCristal = pCristal/60; //produccion por minuto

      // deuterium
      res = resourcesText.substring (
                          resourcesText.indexOf('deuterium'),
                          resourcesText.indexOf('energy'));

      myMatch = res.split('<td>')[3];

      priTag = myMatch.indexOf('>');
      ultTag = myMatch.indexOf('<', priTag);
      myMatch = myMatch.substring(priTag + 1, ultTag);

      pDeuterio = myMatch.replace(/\./g,"");
      pDeuterio = parseInt(pDeuterio);
      pDeuterio = pDeuterio/60; //produccion por minuto

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('loadProduction [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Carga los recursos existentes en las variables globales
 */
function loadResources()
{
  try {
     if ((strPaginaActual != 'defense') && (strPaginaActual != 'shipyard') &&
         (strPaginaActual != 'resources') && //Satelites balance 0
         (strPaginaActual != 'resourceSettings') &&
         (strPaginaActual != 'flotten1') && // No Scape
         (strPaginaActual != 'fleet1') )
         return;

     if (DEBUG_MODE > 1) GM_log('loadResources: ' + strPaginaActual);

     metal = trim( document.getElementById('resources_metal').innerHTML.replace(/\./g,""));
     cristal = trim( document.getElementById('resources_crystal').innerHTML.replace(/\./g,""));
     deuterio = trim( document.getElementById('resources_deuterium').innerHTML.replace(/\./g,""));

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('loadResources [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Agrega los graficos de ocupacion de almacenes en el apartado de recursos
 */
function addWarehousesGraphic()
{
  try {
         if (strPaginaActual != "resourceSettings") return;

         if (! show_Llenado_Almacenes) return;

         if (DEBUG_MODE > 0) GM_log('addWarehouseGraphic: ' + strPaginaActual);

         /**
         * Tiempos de llenado de almacenes
         */
         var tAlmMetal; var tAlmCristal; var tAlmDeuterio;
         var tDenMetal; var tDenCristal; var tDenDeuterio;

         /**
         * Capacidad de almacenes
         */
         var aMetal; var aCristal; var aDeuterio;
         var dMetal; var dCristal; var dDeuterio;

         /**
         * Carga los valores de capacidad de almacenes
         */
         function loadWarehouses()
         {
              try {
                   if (DEBUG_MODE > 1) GM_log('addWarehouseGraphic >> loadWarehouses: ' + strPaginaActual);

                   var priTag;
                   var ultTag;

                   var resourcesText = document.body.innerHTML.substring (
                          document.body.innerHTML.indexOf('function initAjaxResourcebox'),
                          document.body.innerHTML.indexOf('function getAjaxEventbox'));


                   // Metal
                   var res = resourcesText.substring (
                              resourcesText.indexOf('metal'),
                              resourcesText.indexOf('crystal'));

                   var myMatch = res.split('<td>')[2];

                   priTag = myMatch.indexOf('>');
                   ultTag = myMatch.indexOf('<', priTag);
                   myMatch = myMatch.substring(priTag + 1, ultTag);

                   aMetal = myMatch.replace(/\./g,"");
                   aMetal = parseInt(aMetal);

                   // Cristal
                   res = resourcesText.substring (
                              resourcesText.indexOf('crystal'),
                              resourcesText.indexOf('deuterium'));

                   myMatch = res.split('<td>')[2];

                   priTag = myMatch.indexOf('>');
                   ultTag = myMatch.indexOf('<', priTag);
                   myMatch = myMatch.substring(priTag + 1, ultTag);

                   aCristal = myMatch.replace(/\./g,"");
                   aCristal = parseInt(aCristal);

                   // Deuterio
                   res = resourcesText.substring (
                              resourcesText.indexOf('deuterium'),
                              resourcesText.indexOf('energy'));

                   myMatch = res.split('<td>')[2];

                   priTag = myMatch.indexOf('>');
                   ultTag = myMatch.indexOf('<', priTag);
                   myMatch = myMatch.substring(priTag + 1, ultTag);

                   aDeuterio = myMatch.replace(/\./g,"");
                   aDeuterio = parseInt(aDeuterio);

                   if (getVersionOgame()[0] == 3) {
                       dMetal = theMetal[3].substring(theMetal[3].indexOf('>')+1).replace("</span>",'');
                       dMetal = parseInt(dMetal);

                       dCristal = theCristal[3].substring(theCristal[3].indexOf('>')+1).replace("</span>",'');
                       dCristal = parseInt(dCristal);

                       dDeuterio = theDeuterio[3].substring(theDeuterio[3].indexOf('>')+1).replace("</span>",'');
                       dDeuterio = parseInt(dDeuterio);
                   }

              } catch(e) {
                  if (DEBUG_MODE != 0) GM_log('addWarehouseGraphic >> loadWarehouses [ERROR]: <' + e + '> ' + strPaginaActual);
              }
         }

         /**
         * Calcula el tiempo de llenado de los almacenes
         */
         function calculateWarehouses()
         {
              try {
                   if (DEBUG_MODE > 1) GM_log('addWarehouseGraphic >> calculateWarehouses: ' + strPaginaActual);

                   tAlmMetal = ((aMetal - metal)/pMetal)*60/getUniSpeed();
                   tAlmCristal = ((aCristal - cristal)/pCristal)*60/getUniSpeed();
                   tAlmDeuterio = ((aDeuterio - deuterio)/pDeuterio)*60/getUniSpeed();

                   if (getVersionOgame()[0] == 3) {
                       tDenMetal = ((dMetal - metal)/pMetal)*60/getUniSpeed();
                       tDenCristal = ((dCristal - cristal)/pCristal)*60/getUniSpeed();
                       tDenDeuterio = ((dDeuterio - deuterio)/pDeuterio)*60/getUniSpeed();
                   }

              } catch(e) {
                   if (DEBUG_MODE != 0) GM_log('addWarehouseGraphic >> calculateWarehouses [ERROR]: <' + e + '> ' + strPaginaActual);
              }
         }

         function generateDivAlmacen (strRecurso, blnPlaneta, intTAlmacen, strFontColor, strBackColor, dblPorcentaje) {

              var myDiv = document.createElement('div');
                  myDiv.appendChild(document.createTextNode(strRecurso));

              if (blnPlaneta)
                  myDiv.appendChild(document.createTextNode(' (' + secondsToTime(intTAlmacen) + '):'))
              else
                  myDiv.appendChild(document.createTextNode(':'));

              var myDivBack = document.createElement('div');
                  myDivBack.setAttribute('style', 'float:right;width:400px;height:15px;' +
                                                  'border:1px solid ' + strBackColor + ';' +
                                                  'background-color:DarkSlateGray;');

              myDiv.appendChild(myDivBack);

              var myDivFront = document.createElement('div');
                  myDivFront.setAttribute('style', 'background-color:' + strBackColor + ';height:100%;' +
                                                   'width:' + dblPorcentaje + '%;text-align:center;');

              myDivBack.appendChild(myDivFront);

              var mySpan = document.createElement('span');
                  mySpan.setAttribute('style', 'color:' + strFontColor + ';font-weight:bold;');

                  mySpan.appendChild(document.createTextNode(' ' + dblPorcentaje + '%'));

              myDivFront.appendChild(mySpan);

              var divClear = document.createElement('div');
                  divClear.setAttribute('style', 'clear:both;height:4px;');

              myDiv.appendChild(divClear);

              return myDiv;

         }

         loadResources();
         loadWarehouses();
         calculateWarehouses();

         colorM = color_M_Warehouse_0; //'Salmon';
         colorC = color_C_Warehouse_0; //'LightGreen';
         colorD = color_D_Warehouse_0; //'LightSkyBlue'; //"#9C0";

         colorFM = colorFC = colorFD = 'black';

         porcentajeMetal = roundNumber((metal*100)/aMetal,2);
         if (porcentajeMetal>=100) {
           porcentajeMetal=100;
           colorM = color_M_Warehouse_100; //'DarkRed ';//"#C00";
         }
         else if (porcentajeMetal>80)
         {
           colorM = color_M_Warehouse_80; //'crimson';//"#ea8700";
         }

         porcentajeCristal = roundNumber((cristal*100)/aCristal, 2);
         if (porcentajeCristal>=100) {
           porcentajeCristal=100;
           colorC = color_C_Warehouse_100; //'Olive';//"#C00";
         }
         else if (porcentajeCristal>80)
         {
           colorC = color_C_Warehouse_80; //'YellowGreen';//"#ea8700";
         }

         porcentajeDeuterio = roundNumber((deuterio*100)/aDeuterio, 2);
         if (porcentajeDeuterio>=100) {
           porcentajeDeuterio=100;
           colorD = color_D_Warehouse_100; //'RoyalBlue';//"#C00";
         }
         else if (porcentajeDeuterio>80)
         {
           colorD = color_M_Warehouse_80; //'CornflowerBlue';//"#ea8700";
         }

         if (getVersionOgame()[0]==3) {
             colorDM = color_M_Den_0; //'Salmon';
             colorDC = color_C_Den_0; //'LightGreen';
             colorDD = color_D_Den_0; //'LightSkyBlue';

             porcentajeDMetal = roundNumber((metal*100)/dMetal, 2);
             if (porcentajeDMetal>=100) {
                 porcentajeDMetal=100;
                 colorDM = color_M_Den_100; //'DarkRed ';
             }
             else if (porcentajeDMetal>80)
             {
                  colorDM = color_M_Den_80; //'crimson';
             }

             porcentajeDCristal = roundNumber((cristal*100)/dCristal, 2);
             if (porcentajeDCristal>=100) {
                 porcentajeDCristal=100;
                 colorDC = color_C_Den_100; //'Olive';
             }
             else if (porcentajeDCristal>80)
             {
               colorDC = color_C_Den_80; //'YellowGreen';
             }

             porcentajeDDeuterio = roundNumber((deuterio*100)/dDeuterio, 2);
             if (porcentajeDDeuterio>=100) {
                 porcentajeDDeuterio=100;
                 colorDD = color_D_Den_100; //'RoyalBlue';
             }
             else if (porcentajeDDeuterio>80)
             {
                  colorDD = color_D_Den_80; //'CornflowerBlue';
             }
         }

         var objVacation = getElementsByClass('tipsTitleAdvice',document,'a')[0];
         if (objVacation != null) var blnVacation = (objVacation.getAttribute('title').indexOf('Vacation') > -1)
         else var blnVacation = false;

         var blnPlaneta = EsPlaneta() && (! blnVacation);

         var divAlmacenes = document.createElement('div');
             divAlmacenes.setAttribute('style', 'margin:10px auto;width:90%;font-size:10px;' +
                                                'max-width:610px;');

         var divClear = document.createElement('div');
             divClear.setAttribute('style', 'clear:both;height:4px;');

             divAlmacenes.appendChild(divClear);

         var divRight = document.createElement('div');
             divRight.setAttribute('align', 'right');

         divAlmacenes.appendChild(divRight);

         var myFont = document.createElement('font');
             myFont.setAttribute('style', 'color:#FF6600;font-weight:bold;');
             myFont.size = 4;

             myFont.appendChild(document.createTextNode('* ' + LANG.MISC.txt_Warehouses + ' *'));

         divRight.appendChild(myFont);

         divRight.appendChild(divClear.cloneNode(true));
         divRight.appendChild(divClear.cloneNode(true));
         divRight.appendChild(divClear.cloneNode(true));

         divAlmacenes.appendChild(generateDivAlmacen (LANG.SERVER.txt_RES_metal,
                                                      blnPlaneta,
                                                      tAlmMetal,
                                                      colorFM,
                                                      colorM,
                                                      porcentajeMetal));

         divAlmacenes.appendChild(generateDivAlmacen (LANG.SERVER.txt_RES_cristal,
                                                      blnPlaneta,
                                                      tAlmCristal,
                                                      colorFC,
                                                      colorC,
                                                      porcentajeCristal));

         divAlmacenes.appendChild(generateDivAlmacen (LANG.SERVER.txt_RES_deuterio,
                                                      blnPlaneta,
                                                      tAlmDeuterio,
                                                      colorFD,
                                                      colorD,
                                                      porcentajeDeuterio));

         document.getElementsByClassName('mainRS')[0].appendChild(divAlmacenes);

         if ( (getVersionOgame()[0]==3) &&
              ((dMetal > 0) || (dCristal > 0) || (dDeuterio > 0)) )
         {
            var hr = document.createElement('hr');
                hr.setAttribute('style', 'margin:4px 0;border-top-color:#111;' +
                                         'border-bottom-color:#444;' +
                                         'border-width:1px 0;' +
                                         'border-style:solid;display:block;');

                divAlmacenes.appendChild(hr);

                divAlmacenes.appendChild(divClear.cloneNode(true))

            var divRight2 = document.createElement('div');
                divRight2.setAttribute('align', 'right');

            var myFont2 = document.createElement('font');
                myFont2.setAttribute('style', 'color:#FF6600;font-weight:bold;');
                myFont2.size = 4;

                myFont2.appendChild(document.createTextNode('* ' + LANG.MISC.txt_Dens + ' *'));

            divRight2.appendChild(myFont2);

            divAlmacenes.appendChild(divRight2);

            divAlmacenes.appendChild(divClear.cloneNode(true));
            divAlmacenes.appendChild(divClear.cloneNode(true));
            divAlmacenes.appendChild(divClear.cloneNode(true));

            if (dMetal > 0) // Escondite de metal
                divAlmacenes.appendChild(generateDivAlmacen (LANG.SERVER.txt_RES_metal,
                                                             blnPlaneta,
                                                             tDenMetal,
                                                             colorFM,
                                                             colorDM,
                                                             porcentajeDMetal));

            if (dCristal > 0) // Escondite de cristal
                divAlmacenes.appendChild(generateDivAlmacen (LANG.SERVER.txt_RES_cristal,
                                                             blnPlaneta,
                                                             tDenCristal,
                                                             colorFC,
                                                             colorDC,
                                                             porcentajeDCristal));

            if (dDeuterio > 0) // Escondite de deuterio
                divAlmacenes.appendChild(generateDivAlmacen (LANG.SERVER.txt_RES_deuterio,
                                                             blnPlaneta,
                                                             tDenDeuterio,
                                                             colorFD,
                                                             colorDD,
                                                             porcentajeDDeuterio));

            divAlmacenes.appendChild(divClear.cloneNode(true));

         }

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('addWarehousesGraphic [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Agrega info de produccion ideal al apartado de recursos
 */
function addProductionRatio()
{
  try {
       if (strPaginaActual != "resourceSettings") return;

       if (! show_Production_Ratio) return;

       if (DEBUG_MODE > 0) GM_log('addProductionRatio: ' + strPaginaActual);

       var colorM = "green"; var colorC = "green"; var colorD = "green";

       // Produccion "ideal" regla 3:2:1
       // tomamos como referencia el metal
       var pMetalIdeal = pMetal;

       var pCristalIdeal;

       if (pMetal > 0)
           pCristalIdeal = (pMetalIdeal/3)*2
       else
           pCristalIdeal = pCristal;

       var pDeuterioIdeal;

       if (pMetal > 0)
           pDeuterioIdeal = pMetalIdeal/3
       else if (pCristal > 0)
           pDeuterioIdeal = pCristalIdeal/2
       else
           pDeuterioIdeal = pDeuterio;

       if (pMetal < pMetalIdeal) colorM = "#D29D00";
       if (pCristal < pCristalIdeal) colorC = "#D29D00";
       if (pDeuterio < pDeuterioIdeal) colorD = "#D29D00";

       var myTr = document.createElement('tr');

       var myTdLabel = document.createElement('td');
           myTdLabel.setAttribute('class', 'label');
           myTdLabel.setAttribute('colspan', 2);
           myTdLabel.setAttribute('style', 'font-size:92%;');

           myTdLabel.appendChild(document.createTextNode(LANG.MISC.txt_prod321 + ':'));

       myTr.appendChild(myTdLabel);

       var myTdUndermark = document.createElement('td');
           myTdUndermark.setAttribute('class', 'undermark');

       var mySpan1 = document.createElement('span');
           mySpan1.setAttribute('style', 'color:' + colorM + ';');
           mySpan1.appendChild(document.createTextNode(addDots(Math.ceil(pMetalIdeal*60))));

       myTdUndermark.appendChild(mySpan1);

       myTr.appendChild(myTdUndermark);

       var myTdUndermark2 = myTdUndermark.cloneNode(false);

       myTr.appendChild(myTdUndermark2);

       var mySpan2 = document.createElement('span');
           mySpan2.setAttribute('style', 'color:' + colorC + ';');
           mySpan2.appendChild(document.createTextNode(addDots(Math.ceil(pCristalIdeal*60))));

       myTdUndermark2.appendChild(mySpan2);

       var myTdUndermark3 = myTdUndermark.cloneNode(false);

       myTr.appendChild(myTdUndermark3);

       var mySpan3 = document.createElement('span');
           mySpan3.setAttribute('style', 'color:' + colorD + ';');
           mySpan3.appendChild(document.createTextNode(addDots(Math.ceil(pDeuterioIdeal*60))));

       myTdUndermark3.appendChild(mySpan3);

       var theTrSummary = getElementsByClass('summary', document, 'tr')[0];

       insertAfter(theTrSummary, myTr);
   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('addProductionRatio [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Calcula numero de naves por dia en funcion de la produccion
 */
function shipsAndDefenses()
{
  try {
        if (strPaginaActual != "resourceSettings") return;

        if (! show_Daily_Ships_Defenses) return;

        if (DEBUG_MODE > 0) GM_log('shipsAndDefensese: ' + strPaginaActual);

        /**
        * Produccion diaria
        */
        var metalAlDia; var cristalAlDia; var deuterioAlDia;

        /**
        * Calcula cuantas unidades de "objeto" se pueden hacer con los recursos diarios
        */
        function perDay(objeto)
        {
             try {
                  if (DEBUG_MODE > 1) GM_log('shipsAndDefensese >> perDay: ' + strPaginaActual);

                  var x = -1;
                  var dia = new Array();
                      dia[0] = (objeto.metal==0) ? -1 : Math.floor(metalAlDia/objeto.metal);
                      dia[1] = (objeto.cristal==0) ? -1 : Math.floor(cristalAlDia/objeto.cristal);
                      dia[2] = (objeto.deuterio==0) ? -1 : Math.floor(deuterioAlDia/objeto.deuterio);

                  for (i=0; i < 3; i++)
                  {
                       if(dia[i] > -1)
                       {
                          if ( (dia[i] < x) || (x==-1) )
                                x = dia[i];
                       }
                  }

                  //podemos hacer x al dia, eso cuanto cuesta en total?
                  objeto.totalMetalDia = objeto.metal*x;
                  objeto.totalCristalDia = objeto.cristal*x;
                  objeto.totalDeuterioDia = objeto.deuterio*x;
                  objeto.alDia = x;

             } catch(e) {
                  if (DEBUG_MODE != 0) GM_log('shipsAndDefensese >> perDay [ERROR]: <' + e + '> ' + strPaginaActual);
             }
        }

        /**
        * Espera 1 segundo antes de calcular nada
        */
        function showDailyUnits (naves,defensas)
        {
             try {
                  if (DEBUG_MODE > 1) GM_log('shipsAndDefensese >> showDailyUnits: ' + strPaginaActual);

                  function showDailyUnitsTable(listaObjetos)
                  {
                       try {
                            if (DEBUG_MODE > 2) GM_log('shipsAndDefensese >> showDailyUnits >> showDailyUnitsTable: ' + strPaginaActual);

//                            var myDiv = document.getElementById('unidadesDiarias');
                                myDiv.style.display = 'none';

                            var myTable = document.createElement('table');
                                myTable.setAttribute('style', 'font-size:10px;');

                            var myTr = document.createElement('tr');

                                myTable.appendChild(myTr);

                            var myTd16 = document.createElement('td');
                                myTd16.setAttribute('width', '16%');

                                myTr.appendChild(myTd16.cloneNode(true));
                                myTr.appendChild(myTd16.cloneNode(true));
                                myTr.appendChild(myTd16.cloneNode(true));
                                myTr.appendChild(myTd16.cloneNode(true));
                                myTr.appendChild(myTd16.cloneNode(true));
                                myTr.appendChild(myTd16.cloneNode(true));

                            var myTr2 = myTr.cloneNode(false);

                                myTable.appendChild(myTr2);

                            var myTd6 = document.createElement('td');
                                myTd6.setAttribute('colspan', '6');

                                myTr2.appendChild(myTd6);

                            var myFont = document.createElement('font');
                                myFont.setAttribute('style', 'color:#FF6600;size=4;font-weight:bold;');

                                myTd6.appendChild(myFont);

                                myFont.appendChild(document.createTextNode('* ' + LANG.MISC.txt_produccionPlanetaria + ' *'));

                                myTd6.appendChild(document.createElement('br'));
                                myTd6.appendChild(document.createElement('br'));

                            var myTr3 = myTr.cloneNode(false);

                                myTable.appendChild(myTr3);

                            var myTd2 = document.createElement('td');
                                myTd2.setAttribute('colspan', '2');

                                myTr3.appendChild(myTd2);

                            var myTdLabel = document.createElement('td');
                                myTdLabel.setAttribute('class', 'label');
                                myTdLabel.appendChild(document.createTextNode(LANG.MISC.txt_produccion));

                                myTr3.appendChild(myTdLabel);

                            var myTd3Label = myTdLabel.cloneNode(false);
                                myTd3Label.setAttribute('colspan', '3');

                                myTr3.appendChild(myTd3Label);

                            var myCenter = document.createElement('center');

                                myTd3Label.appendChild(myCenter);

                                myCenter.appendChild(document.createTextNode(LANG.MISC.txt_excedente));

                            var myTr4 = myTr.cloneNode(false);

                                myTable.appendChild(myTr4);

                            var myTd2Label = myTdLabel.cloneNode(false);
                                myTd2Label.setAttribute('colspan', '2');

                                myTr4.appendChild(myTd2Label);

                                myTdLabel = myTdLabel.cloneNode(false);
                                myTdLabel.appendChild(document.createTextNode(LANG.MISC.txt_porDia));
                                myTr4.appendChild(myTdLabel);

                                myTdLabel = myTdLabel.cloneNode(false);
                                myTdLabel.appendChild(document.createTextNode(LANG.SERVER.txt_RES_metal));
                                myTr4.appendChild(myTdLabel);

                                myTdLabel = myTdLabel.cloneNode(false);
                                myTdLabel.appendChild(document.createTextNode(LANG.SERVER.txt_RES_cristal));
                                myTr4.appendChild(myTdLabel);

                                myTdLabel = myTdLabel.cloneNode(false);
                                myTdLabel.appendChild(document.createTextNode(LANG.SERVER.txt_RES_deuterio));
                                myTr4.appendChild(myTdLabel);

                            var myTdUndermark = document.createElement('td');
                                myTdUndermark.setAttribute('class', 'undermark');

                            for( i = 0; i < listaObjetos.length; i++)
                            {
                                obj = listaObjetos[i];

                                myTr5 = myTr.cloneNode(false);
                                if (i%2 == 0) myTr5.setAttribute('class', 'alt');

                                myTable.appendChild(myTr5);

                                var myTdLabel = myTd2Label.cloneNode(false);
                                    myTdLabel.appendChild(document.createTextNode(obj.nombre));

                                    myTr5.appendChild(myTdLabel);

                                var myTdUndermark = myTdUndermark.cloneNode(false);
                                    myTdUndermark.appendChild(document.createTextNode(obj.alDia));

                                    myTr5.appendChild(myTdUndermark);

                                var myTd = myTd16.cloneNode(false);
                                    myTd.appendChild(document.createTextNode(addDots(metalAlDia-obj.totalMetalDia)));

                                    myTr5.appendChild(myTd);

                                var myTd = myTd16.cloneNode(false);
                                    myTd.appendChild(document.createTextNode(addDots(cristalAlDia-obj.totalCristalDia)));

                                    myTr5.appendChild(myTd);

                                var myTd = myTd16.cloneNode(false);
                                    myTd.appendChild(document.createTextNode(addDots(deuterioAlDia-obj.totalDeuterioDia)));

                                    myTr5.appendChild(myTd);

                            }

                            for (i=(myDiv.childNodes.length-1); i >= 0; i--)
                                 myDiv.removeChild(myDiv.childNodes[i]);

                                myDiv.appendChild(myTable);
                                myDiv.style.display = 'block';

                       } catch(e) {
                            if (DEBUG_MODE != 0)
                                GM_log('shipsAndDefensese >> showDailyUnits >> showDailyUnitsTable [ERROR]: ' +
                                       '<' + e + '> ' + strPaginaActual);
                       }
                  }

                  //creamos el contenedor
                  var divContenedor = document.createElement('div');
                      divContenedor.setAttribute('id', 'contenedor');
                      divContenedor.setAttribute('style', 'width:90%;margin:0 auto;');

                  var theMainRs = getElementsByClass('mainRS', document, 'div')[0];
                      theMainRs.appendChild(divContenedor);

                  //creamos los enlaces para mostrar naves/defensas
                  //link de flota
                  var linkFlota = window.document.createElement('a');
                      linkFlota.setAttribute('href', '#unidadesDiarias');
                      linkFlota.textContent = LANG.MISC.txt_flota;
                      linkFlota.style.color = strColor_LPuNKTKit;
                      linkFlota.style.textDecoration = 'overline';
                      linkFlota.setAttribute('onmouseover', 'this.style.textDecoration="none"');
                      linkFlota.setAttribute('onmouseout', 'this.style.textDecoration="overline"');
                      linkFlota.style.margin = "5px 10px";
                      linkFlota.addEventListener('click',
                                                 function() {showDailyUnitsTable(naves);},
                                                 false);

                  //link de defensa
                  var linkDefensa = window.document.createElement('a');
                      linkDefensa.setAttribute('href', '#unidadesDiarias');
                      linkDefensa.textContent = LANG.MISC.txt_defensa;
                      linkDefensa.style.color = strColor_LPuNKTKit;
                      linkDefensa.style.textDecoration = 'overline';
                      linkDefensa.setAttribute('onmouseover', 'this.style.textDecoration="none"');
                      linkDefensa.setAttribute('onmouseout', 'this.style.textDecoration="overline"');
                      linkDefensa.style.margin = "5px 10px";
                      linkDefensa.addEventListener('click',
                                                   function() {showDailyUnitsTable(defensas);},
                                                   false);

                  divContenedor.appendChild(linkFlota);
                  divContenedor.appendChild(linkDefensa);

                  var myDiv = document.createElement('div');
                      myDiv.setAttribute('id', 'unidadesDiarias');
                      myDiv.setAttribute('style', 'display:none;');

                  divContenedor.appendChild(myDiv);

             } catch(e) {
                  if (DEBUG_MODE != 0) GM_log('shipsAndDefensese >> showDailyUnits [ERROR]: <' + e + '> ' + strPaginaActual);
             }
        }

        LoadDatosFlota(false);

        metalAlDia = pMetal*60*24;
        cristalAlDia = pCristal*60*24;
        deuterioAlDia = pDeuterio*60*24;

        //con estos recursos, que naves podemos hacer?
        var naves = new Array();
        //sondas
        var sonda = new Object;
            sonda.nombre   = arrDatosFlota[12][1]; //LANG.SERVER.txt_SHIP_LG_sonda;
            sonda.metal    = arrDatosFlota[12][2];
            sonda.cristal  = arrDatosFlota[12][3];
            sonda.deuterio = arrDatosFlota[12][4];
        perDay(sonda);
        naves.push(sonda);

        //satelites
        var satelite = new Object;
            satelite.nombre   = arrDatosFlota[13][1];//LANG.SERVER.txt_SHIP_LG_satelite;
            satelite.metal    = arrDatosFlota[13][2];
            satelite.cristal  = arrDatosFlota[13][3];
            satelite.deuterio = arrDatosFlota[13][4];
        perDay(satelite);
        naves.push(satelite);

        //npc
        var npc = new Object;
            npc.nombre   = arrDatosFlota[0][1];//LANG.SERVER.txt_SHIP_LG_npc;
            npc.metal    = arrDatosFlota[0][2];
            npc.cristal  = arrDatosFlota[0][3];
            npc.deuterio = arrDatosFlota[0][4];
        perDay(npc);
        naves.push(npc);

        //ngc
        var ngc = new Object;
            ngc.nombre   = arrDatosFlota[1][1];//LANG.SERVER.txt_SHIP_LG_ngc;
            ngc.metal    = arrDatosFlota[1][2];
            ngc.cristal  = arrDatosFlota[1][3];
            ngc.deuterio = arrDatosFlota[1][4];
        perDay(ngc);
        naves.push(ngc);

        //colonizadores
        var coloniza = new Object;
            coloniza.nombre   = arrDatosFlota[10][1];//LANG.SERVER.txt_SHIP_LG_colonizador;
            coloniza.metal    = arrDatosFlota[10][2];
            coloniza.cristal  = arrDatosFlota[10][3];
            coloniza.deuterio = arrDatosFlota[10][4];
        perDay(coloniza);
        naves.push(coloniza);

        //recicladores
        var reciclador = new Object;
            reciclador.nombre   = arrDatosFlota[11][1];//LANG.SERVER.txt_SHIP_LG_reciclador;
            reciclador.metal    = arrDatosFlota[11][2];
            reciclador.cristal  = arrDatosFlota[11][3];
            reciclador.deuterio = arrDatosFlota[11][4];
        perDay(reciclador);
        naves.push(reciclador);

        //cazas ligeros
        var cl = new Object;
            cl.nombre   = arrDatosFlota[2][1];//LANG.SERVER.txt_SHIP_LG_cl;
            cl.metal    = arrDatosFlota[2][2];
            cl.cristal  = arrDatosFlota[2][3];
            cl.deuterio = arrDatosFlota[2][4];
        perDay(cl);
        naves.push(cl);

        //cazas pesados
        var cp = new Object;
            cp.nombre   = arrDatosFlota[3][1];//LANG.SERVER.txt_SHIP_LG_cp;
            cp.metal    = arrDatosFlota[3][2];
            cp.cristal  = arrDatosFlota[3][3];
            cp.deuterio = arrDatosFlota[3][4];
        perDay(cp);
        naves.push(cp);

        //cruceros
        var crucero = new Object;
            crucero.nombre   = arrDatosFlota[4][1];//LANG.SERVER.txt_SHIP_LG_crucero;
            crucero.metal    = arrDatosFlota[4][2];
            crucero.cristal  = arrDatosFlota[4][3];
            crucero.deuterio = arrDatosFlota[4][4];
        perDay(crucero);
        naves.push(crucero);

        //naves de batalla
        var nb = new Object;
            nb.nombre   = arrDatosFlota[5][1];//LANG.SERVER.txt_SHIP_LG_nb;
            nb.metal    = arrDatosFlota[5][2];
            nb.cristal  = arrDatosFlota[5][3];
            nb.deuterio = arrDatosFlota[5][4];
        perDay(nb);
        naves.push(nb);

        //acorazados
        var acorazado = new Object;
            acorazado.nombre   = arrDatosFlota[6][1];//LANG.SERVER.txt_SHIP_LG_acorazado;
            acorazado.metal    = arrDatosFlota[6][2];
            acorazado.cristal  = arrDatosFlota[6][3];
            acorazado.deuterio = arrDatosFlota[6][4];
        perDay(acorazado);
        naves.push(acorazado);

        //bombarderos
        var bombardero = new Object;
            bombardero.nombre   = arrDatosFlota[7][1];//LANG.SERVER.txt_SHIP_LG_bombardero;
            bombardero.metal    = arrDatosFlota[7][2];
            bombardero.cristal  = arrDatosFlota[7][3];
            bombardero.deuterio = arrDatosFlota[7][4];
        perDay(bombardero);
        naves.push(bombardero);

        //destructores
        var destructor = new Object;
            destructor.nombre   = arrDatosFlota[8][1];//LANG.SERVER.txt_SHIP_LG_destructor;
            destructor.metal    = arrDatosFlota[8][2];
            destructor.cristal  = arrDatosFlota[8][3];
            destructor.deuterio = arrDatosFlota[8][4];
        perDay(destructor);
        naves.push(destructor);

        //estrellas de la muerte
        var edlm = new Object;
            edlm.nombre   = arrDatosFlota[9][1];//LANG.SERVER.txt_SHIP_LG_edlm;
            edlm.metal    = arrDatosFlota[9][2];
            edlm.cristal  = arrDatosFlota[9][3];
            edlm.deuterio = arrDatosFlota[9][4];
        perDay(edlm);
        naves.push(edlm);

        //defensas
        var defensas = new Array();
        //lanzamisiles
        var lanza = new Object;
            lanza.nombre   = arrDatosFlota[14][1];//LANG.SERVER.txt_DEFENSE_LG_lanza;
            lanza.metal    = arrDatosFlota[14][2];
            lanza.cristal  = arrDatosFlota[14][3];
            lanza.deuterio = arrDatosFlota[14][4];
        perDay(lanza);
        defensas.push(lanza);

        //lasers peque
        var laserp = new Object;
            laserp.nombre   = arrDatosFlota[15][1];//LANG.SERVER.txt_DEFENSE_LG_laserp;
            laserp.metal    = arrDatosFlota[15][2];
            laserp.cristal  = arrDatosFlota[15][3];
            laserp.deuterio = arrDatosFlota[15][4];
        perDay(laserp);
        defensas.push(laserp);

        //lasers grandes
        var laserg = new Object;
            laserg.nombre   = arrDatosFlota[16][1];//LANG.SERVER.txt_DEFENSE_LG_laserg;
            laserg.metal    = arrDatosFlota[16][2];
            laserg.cristal  = arrDatosFlota[16][3];
            laserg.deuterio = arrDatosFlota[16][4];
        perDay(laserg);
        defensas.push(laserg);

        //gauss
        var gauss = new Object;
            gauss.nombre   = arrDatosFlota[17][1];//LANG.SERVER.txt_DEFENSE_LG_gauss;
            gauss.metal    = arrDatosFlota[17][2];
            gauss.cristal  = arrDatosFlota[17][3];
            gauss.deuterio = arrDatosFlota[17][4];
        perDay(gauss);
        defensas.push(gauss);

        //ionicos
        var ionico = new Object;
            ionico.nombre   = arrDatosFlota[18][1];//LANG.SERVER.txt_DEFENSE_LG_ionico;
            ionico.metal    = arrDatosFlota[18][2];
            ionico.cristal  = arrDatosFlota[18][3];
            ionico.deuterio = arrDatosFlota[18][4];
        perDay(ionico);
        defensas.push(ionico);

        //plasmas
        var plasma = new Object;
            plasma.nombre   = arrDatosFlota[19][1];//LANG.SERVER.txt_DEFENSE_LG_plasma;
            plasma.metal    = arrDatosFlota[19][2];
            plasma.cristal  = arrDatosFlota[19][3];
            plasma.deuterio = arrDatosFlota[19][4];
        perDay(plasma);
        defensas.push(plasma);

        //misiles interplanetarios
        var mInterplanet = new Object;
            mInterplanet.nombre   = LANG.SERVER.txt_DEFENSE_LG_mInterplanet;
            mInterplanet.metal    = 12500;
            mInterplanet.cristal  = 2500;
            mInterplanet.deuterio = 10000;
        perDay(mInterplanet);
        defensas.push(mInterplanet);

        //misiles intercepcion
        var mIntercep = new Object;
            mIntercep.nombre   = LANG.SERVER.txt_DEFENSE_LG_mIntercep;
            mIntercep.metal    = 8000;
            mIntercep.cristal  = 0;
            mIntercep.deuterio = 2000;
        perDay(mIntercep);
        defensas.push(mIntercep);

        //mostramos resultados
        showDailyUnits(naves,defensas);

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('shipsAndDefenses [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function highlightDebris()
{
  try {
         if (strPaginaActual != 'galaxy') return;

         if ( (min_Escombros <= 0) || (show_Debris <= 0) )
            return;

         if (DEBUG_MODE > 0) GM_log('highlightDebris: ' + strPaginaActual);

         var imgDebrisX1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAA" +
                          "AeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQU" +
                          "AAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdw" +
                          "nLpRPAAAAl1JREFUSEvtl2tLG1EQhvMfWqWiiNWqMYbY1lsStgkxx" +
                          "BtpqVBbpUXwJ/mLj/scme3syblFxE8G9svZmXnfeedyNo3G2++1FF" +
                          "hY3W34nsWdY9PsnZm1ryPzbuvIhOzkHJvldmHtNw7GZm/43fq7vlV" +
                          "eoYA4m4f16ukMpjZwyH7187BmL76TX/c1vyQwIBpYB2r2L8z77W6N" +
                          "hEvU9e2eXVsCSWAyg60PXM5GV3dWVuRc6Qyitvi0i8s8YOoUA5Z3H" +
                          "/fH5kOrH7WlVNhkZUzAHGCyXWj2grZLu/97IwuYzs4BRmpfxr2L35" +
                          "aQbsgs4Jw60zTY0Wya5Hb31DsBYWCHIbWJZf3pcDwDrKVlzA5Pr+1" +
                          "8Q7D6IRPONBLSADL48a9iG5pPIVNJWRKW4GRPf0g8sZ1pLt/YcOaT" +
                          "UGcPKd9CCU1DMb2tdzVMfeDUD0VQQAMinbtANIHYNHhrvHk0maknw" +
                          "DoDFkZqb8t7NpwmjPTB5qIxdIatcttQmy8nV3Y7kSnqDH/eBQlgL+" +
                          "BLeyPTnz4pttU7Ty8Q1puwBYzHXYsEX2wVBrLrBxNLTmfImW2+9je" +
                          "DHTGy5hggMsbZN1YAU+/UkkFyGbEsYCtXCcpl4AvO+xSo25Rp4BLQ" +
                          "12w6EMDUeh7wJLBbr1DGOVKLLzVPAvPZksqEjHeK+Eolhiyj2sqMz" +
                          "SRfDLGM8E1dnZSCjhacZMaakK41jda9vDF0KjbMaUgZu/PLUXrWtS" +
                          "hOsNbMdTAfcH/6d85rMfC5GyuJu+dRJGQ/l9Sp3Ux2kvXx+Z/oLn9" +
                          "R4M7oaVWG5PXW+LX+sbg4j22NQnMt5k9MAAAAAElFTkSuQmCC";

         var imgDebrisX5 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAA" +
                          "AeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQU" +
                          "AAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdw" +
                          "nLpRPAAAAl5JREFUSEvtl9lOG0EQRf0PLAKBUEICGGMZkrDY1mDLW" +
                          "GaTiUAKWZQIif/Ov3TmNKqhpt2bEeIplualp6rurVtLjxuN/7+3Um" +
                          "BpY6/he5Z3T0yzd2HefR6Zhe1jE7KTc2zW2oW1/3A4NvvDG+vv+lZ" +
                          "5hQLi/HexqJ7OYGoDh+w3DoY1e/GdfHus+SWBAdHAOlCzf2UWd7o1" +
                          "Ei5R17d7cW8JJIHJDLY+cDkb3T1YWZFzvTOI2uLTLq7zgKlTDFjev" +
                          "f8yNiutftSWUmGTlTEBc4DJdqnZC9qu7j33RhYwnZ0DjNS+jHtX3y" +
                          "0h3ZBZwDl1pmmwo9k0yZ3uuXcCwsAOQ2oTy/rj0XgGWEvLmB2d39v" +
                          "5hmD1QyacaSSkAWTw9U/FNjSfQqaSsiQswcme/pB4YjvTXL6x4cwn" +
                          "oc4eUr6FEpqGYvqr3tUw9YFTPxRBAQ2IdO4C0QRi0+Ct8dbxZKaeA" +
                          "OsMWBipvS3v2XCaMNIHm4vG0Bm2ym1DbT6d3dntRKaoM7x9CBLAXs" +
                          "BX90emP31SbLt3mV4grDdhCxiPuxYJvtwqDGQ3DyeWnM6QM9t87VO" +
                          "DHTGy5hggMsbZN1YAU+/UkkFyGbEsYCtXCcpl4AvO+xSo25Rp4BLQ" +
                          "12w6EMDUeh7wJLBbr1DGOVKLLzVPAvPZksqEjHeL+Eolhiyj2sqMz" +
                          "SRfDLGM8E1dnZSCjhacZMaakK41jda9/mnoVGyY05AydueXo/Sia1" +
                          "GcYK2Z62A+4P7095zXYuBzN1YSd8+jSMh+LqlTu5nsJOuTyx/RXf6" +
                          "qwJ3R06oMyeut8Vv9Y3Fx/gF0xbWWfL5J4QAAAABJRU5ErkJggg%3" +
                          "D%3D";

         var imgDebrisX10 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AA" +
                          "AAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQ" +
                          "UAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABd" +
                          "wnLpRPAAAAlxJREFUSEvtl9lOG0EQRf0PCSiICJEFMMYygbDY1sSW" +
                          "scwmJwoSWwRC4v8/opnTqIaadm+OEE9Ympeeqrq3bi09bjTef2+lw" +
                          "MLKVsP3LG4emmbvxKzujsyH9QMTspNzbJbbhbX/tjc228Pf1t/1rf" +
                          "IKBcTZNEz1dAZTGzhkv/JjWLMX38nlY80vCQyIBtaBmv0z83GjWyP" +
                          "hEnV9uydXlkASmMxg6wOXs9HFg5UVOT93BlFbfNrFeR4wdYoBy7sv" +
                          "P8fmU6sftaVU2GRlTMAcYLJdaPaCtktbL72RBUxn5wAjtS/j3tm1J" +
                          "aQbMgs4p840DXY0mya50T32TkAY2GFIbWJZf98fzwBraRmz/eMrO9" +
                          "8QrH7IhDONhDSADP7cV2xD8ylkKilLwhKc7OkPiSe2M83lGxvOfBL" +
                          "q7CHlWyihaSim/+pdDVMfOPVDERTQgEjnLhBNIDYN3hqvHUxm6gmw" +
                          "zoCFkdrb8p4NpwkjfbC5aAydYavcNtRm5+jCbicyRZ3h34cgAewFf" +
                          "Gl7ZPrTZ8XWe6fpBcJ6E7aA8bhrkeCLrcJA9uvexJLTGXJmm6/9y2" +
                          "BHjKw5BoiMcfaNFcDUO7VkkFxGLAvYylWCchn4gvM+Beo2ZRq4BPQ" +
                          "1mw4EMLWeBzwJ7NYrlHGO1OJLzZPAfLakMiHjzSK+Uokhy6i2MmMz" +
                          "yRdDLCN8U1cnpaCjBSeZsSaka02jdc9vDZ2KDXMaUsbu/HKU/utaF" +
                          "CdYa+Y6mA+4P72b81oMfO7GSuLueRQJ2c8ldWo3k51kfXh6E93lrw" +
                          "rcGT2vypC83hq/1T8WF+cJBPaST/B/YW4AAAAASUVORK5CYII%3D";

         var imgDebrisX100 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AA" +
                          "AAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQ" +
                          "UAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABd" +
                          "wnLpRPAAAAmRJREFUSEvtl9lKI0EUhvMOLowo4oxbjCHquCWhTYgh" +
                          "LiEOCjozLgje+By+edlfSbWnK7VFxCsDfVN9zvn/85+lOpXK9++rF" +
                          "JhZ3Ky4ntmNQ1Vtnaql3z01tXagfHbmHJv5eqbtl/f6aqt7of1t3y" +
                          "IvX0CcXyqqeBqdkQ7ss1/c7pbsje/g+qnkFwUGRALLQNX2uZpeb5Z" +
                          "I2ERt3+bpjSYQBSYz2LrAzVnv6lHLipwLjU7QFp96NkwDpk4hYPPu" +
                          "525f/ai1g7aUCpukjAmYAky2M9WW13Zu8703koDp7Bjw8O5ZS+3Ku" +
                          "HX+VxOSDZkEnFJnmgY7mk2SXG+eOCfAD2wxpDahrFf2+2PAUlrGbP" +
                          "/kRs83BIsfMuFMIyENIJ0/DwVb33waMoWUOWETnOzpDxPP2I41l2t" +
                          "sOHNJKLOHlGuh+KYhG92WuxqmLnDqhyIoIAGRzl4gkkBoGpw1Xj0Y" +
                          "jNUTYJkBCyO2t817NpwkjPTe5qIxZIa1fNtQm53jK72dyBR1upePX" +
                          "gLYG/C5rZ5qj94UW2udxRcI682wBYzHXosEn61lCrK/9gaanMyQM9" +
                          "189SOFHTGS5hggMsbZHisWB8DUO7ZkkNyMWBKwlisH5TJwBed9DNR" +
                          "uyjhwDuhqNhkIYGo9CXgU2K6XL+MUqfGlNNQ8CsxnSywTMt7IwiuV" +
                          "GGYZlVZmaCb5YghlhG/s6qQUdLTBiWYsCcla02jN4X9Fp2LDnPqU0" +
                          "Ts/H6UPXYvGCdaSuQzmAm6P7ie8Fj2fu6GS2HseRXz2E0kd281kZ7" +
                          "I+PPsX3OWfCtzova1Kn7zOGn/VPxYb5xWOuwt9R16/MwAAAABJRU5" +
                          "ErkJggg%3D%3D";
         /**
         * Resalta los escombros grandes
         */
         function setHighlightDebris()
         {
           try {
                if (strPaginaActual != 'galaxy') return;

                if ( (min_Escombros <= 0) ||
                     (show_Debris <= 0) )
                   return;


                if (DEBUG_MODE > 2) GM_log('setHighlightDebris: ' + strPaginaActual);

                var coordenadasActuales = new Array();
                    coordenadasActuales[1] = $('#galaxy_input').val();
                    coordenadasActuales[2] = $('#system_input').val();

                var url = window.location + "";

                    url = url.substring(0, url.search("page"));
                    url = url + "page=fleet1" + ( (parseInt(getVersionOgame()[0])==3) ? '' : '&' + getSession() );

                var theGalaxyTable = document.getElementById('galaxytable');
                var arrTr = getElementsByClass('row', theGalaxyTable, 'tr');

                for (var i = 0; i < arrTr.length; i++) {
                     var theTd = getElementsByClass('debris', arrTr[i], 'td')[0];

                     var theA = getElementsByClass('tipsGalaxy', theTd, 'a')[0];

                     if (theA == null)
                         continue;

                     var debrisId = theA.getAttribute('rel').replace("#debris", "");

                     var theDebrisDiv = document.getElementById('debris' + debrisId);

                     var arrLiDebris = getElementsByClass('debris-content', theDebrisDiv, 'li');

                     var partes = arrLiDebris[0].innerHTML.split(' ');
                     var metDebris = parseInt(partes[1].replace(/\./g,""));

                         partes = arrLiDebris[1].innerHTML.split(' ');
                     var criDebris = parseInt(partes[1].replace(/\./g,""));

                     var contenido = metDebris + criDebris;

                     var imgDebris1 = theA.getElementsByTagName('img')[0];
                     var imgDebris2 = theDebrisDiv.getElementsByTagName('img')[0];

                     var strColor;

                     if (min_Escombros > 0) {

                        if (contenido >= min_Escombros) {

                            if (contenido >= (min_Escombros * 100)) {
                                if (( show_Debris == 1 ) || (show_Debris == 3 )) {
                                   imgDebris1.setAttribute("src", imgDebrisX100);
                                   imgDebris2.setAttribute("src", imgDebrisX100);

                                   strColor = 'white';

                                } else {
                                   theA.removeChild(imgDebris1);

                                   strColor = 'rgb(139,0,139)';
                                }

                            } else if (contenido >= (min_Escombros * 10)) {
                                if (( show_Debris == 1 ) || (show_Debris == 3 )) {
                                   imgDebris1.setAttribute("src", imgDebrisX10);
                                   imgDebris2.setAttribute("src", imgDebrisX10);

                                   strColor = 'white';

                                } else {
                                   theA.removeChild(imgDebris1);

                                   strColor = 'rgb(255,0,255)';
                                }

                            } else if (contenido >= (min_Escombros * 5)) {
                                if (( show_Debris == 1 ) || (show_Debris == 3 )) {
                                   imgDebris1.setAttribute("src", imgDebrisX5);
                                   imgDebris2.setAttribute("src", imgDebrisX5);

                                   strColor = 'white';

                                } else {
                                   theA.removeChild(imgDebris1);

                                   strColor = 'rgb(220,20,60)';
                                }

                            } else {
                                if (( show_Debris == 1 ) || (show_Debris == 3 )) {
                                   imgDebris1.setAttribute("src", imgDebrisX1);
                                   imgDebris2.setAttribute("src", imgDebrisX1);

                                   strColor = 'white';

                                } else {
                                   theA.removeChild(imgDebris1);

                                   strColor = 'rgb(255,145,34)';
                                }
                            }

                        } else {
                            if (( show_Debris == 1 ) || (show_Debris == 3 )) {
                               strColor = 'white';

                            } else {
                               theA.removeChild(imgDebris1);

                               strColor = 'rgb(131,145,156)';
                            }
                        }

                        var myDiv = document.getElementById('lpunktkit-debris' + debrisId);
                        if (myDiv != null) myDiv.parentNode.removeChild(myDiv);

                        if (show_Debris >= 2) {
                             var myDiv = document.createElement('div');
                                 myDiv.setAttribute('id', 'lpunktkit-debris' + debrisId);

                                 if (show_Debris == 3)
                                     myDiv.setAttribute('style', 'position:absolute; top: 0;' +
                                                                 'left:' + theTd.offsetLeft + 'px;' +
                                                                 'width:' + theTd.offsetWidth + 'px;' +
                                                                 'z-order:90;text-align:center;' +
                                                                 'font-weight:bold;color:' + strColor + ';' +
                                                                 'font-size:9px;')
                                 else
                                     if (contenido >= min_Escombros)
                                         myDiv.setAttribute('style', 'position:absolute; top: 0;' +
                                                                 'left:' + theTd.offsetLeft + 'px;' +
                                                                 'width:' + theTd.offsetWidth + 'px;' +
                                                                 'z-order:90;text-align:center;' +
                                                                 'font-weight:bold;color:black;' +
                                                                 'font-size:9px;background-color:' + strColor + ';');


                                 myDiv.appendChild(document.createTextNode(addDots(metDebris)));
                                 myDiv.appendChild(document.createElement('br'));
                                 myDiv.appendChild(document.createTextNode(addDots(criDebris)));

                             theA.appendChild(myDiv);
                        }
                     }
                }

           } catch(e) {
                if (DEBUG_MODE != 0)
                    GM_log('setHighlightDebris [ERROR]: <' + e + '> ' + strPaginaActual);
           }
         }

         setInterval(setHighlightDebris, 500);

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('highlightDebris [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}


/**
 * Recibe una tabla que contiene la info de la flota en cuestion.
 * Devuelve los valores de los 3 recursos que transporta
 */
function getRecursosFlota(tabla)
{
  try {
        if (DEBUG_MODE > 0) GM_log('getRecursosFlota: ' + strPaginaActual);

        if (show_Empty_Space)
            var recursos = new Array(0,0,0,0)
        else
            var recursos = new Array(0,0,0);

        var i = 0;

        var arrTr = tabla.getElementsByTagName('tr');

        for (var j=0; j < arrTr.length; j++) {
            if (! show_Empty_Space) {
                if (j>=(arrTr.length-3)) {

                    recursos[i] = trim( arrTr[j].getElementsByTagName('td')[1].innerHTML );
                    i++;
                }
            } else {
                if (j>=(arrTr.length-4)) {
                    var theTd = arrTr[j].getElementsByTagName('td')[1];
                    var theFont = theTd.getElementsByTagName('font')[0];
                    if (theFont)
                        recursos[i] = trim( theFont.innerHTML )
                    else
                        recursos[i] = trim( theTd.innerHTML );

                    i++;
                }
            }
        }

        return recursos;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('getRecursosFlota [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Nueva funcion para agregar puntos en los miles y usar formato Ogame
 * (ej: 400k, 3M)
 */
function puntos(numero)
{
  try {
         if (DEBUG_MODE > 1) GM_log('puntos: ' + strPaginaActual);

         var cadena = "";
         numero = parseInt(numero, 10);

         if (numero == 0) return "0";
         //cambiamos 1.000.000 por 1M
         if (numero % 1000000 == 0) cadena = (numero / 1000000) + "M";
         else
         {
           //cambiamos 900.000 por 900k
           if ((numero % 1000 == 0) && (numero < 1000000) ) cadena = (numero/1000) + "k";
           else
           {
             //si no es cifra redonda, agregamos los puntos
             if (numero < 1000) cadena = numero + "";
             else
             {
               unidades = numero % 1000 + "";

               if (numero < 1000000)
               {
                 cadena = Math.floor(numero / 1000) + "." + unidades;
               }
               else
               {
                 millones=Math.floor(numero/1000000);
                 miles=Math.floor((numero-millones*1000000)/1000) + "";

                 if (miles > 0)
                     cadena = millones + "M " + miles + "k"
                 else
                     cadena = millones + "M " + unidades;
               }
             }
           }
         }

         return cadena;

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('puntos [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Calcula el tiempo necesario para construir flota/defensas
 */
function calculateTime()
{
   try {
        if ((strPaginaActual !='defense') && (strPaginaActual !='shipyard') &&
            (strPaginaActual !='resources')) //Satelites balance 0
             return;

        if (! show_Time_Ships_Defenses) return;

        if (DEBUG_MODE > 0) GM_log('calculateTime: ' + strPaginaActual);

        existe = $("#costs");

        if (existe.length>0)
        {
            var necesarios=new Array();
                necesarios[0]=0;//metal
                necesarios[1]=0;//cristal
                necesarios[2]=0;//deuterio
                necesarios[3]=0;//energia

            $('#costs #resources li.metal').each(function() {
                palabra = this.title.split(" ");

                palabra[palabra.length-1] = traduce(palabra[palabra.length-1]);

                if (DEBUG_MODE > 1) GM_log('calculateTime: < ' +
                                            palabra[palabra.length-1] + ' [' + palabra[0] + '] > ' +
                                            strPaginaActual);

                switch (palabra[palabra.length-1].toUpperCase()) {
                   case "METAL": necesarios[0] = palabra[0].replace(/\./g,"");
                                                 /*palabra[0].substring(1,
                                                 palabra[0].length).replace(/\./g,"");*/

                                 if (DEBUG_MODE > 1) GM_log('calculateTime: case metal ' +
                                     '[ necesarios[0] = ' + necesarios[0] + ' ] ' + strPaginaActual);

                                 break;

                   case "CRISTAL": necesarios[1] = palabra[0].replace(/\./g,"");
                                                 /*palabra[0].substring(1,
                                                 palabra[0].length).replace(/\./g,"");*/

                                   if (DEBUG_MODE > 1) GM_log('calculateTime: case cristal ' +
                                     '[ necesarios[1] = ' + necesarios[1] + ' ] ' + strPaginaActual);

                                   break;

                   case "DEUTERIO": necesarios[2] = palabra[0].replace(/\./g,"");
                                                 /*palabra[0].substring(1,
                                                 palabra[0].length).replace(/\./g,"");*/

                                    if (DEBUG_MODE > 1) GM_log('calculateTime: case deuterio ' +
                                        '[ necesarios[2] = ' + necesarios[2] + ' ] ' + strPaginaActual);

                                    break;

                   default: necesarios[3] = palabra[0].replace(/\./g,"");
                                                 /*palabra[0].substring(1,
                                                 palabra[0].length).replace(/\./g,"");*/

                            if (DEBUG_MODE > 1) GM_log('calculateTime: case default ' +
                               '[ necesarios[3] = ' + necesarios[3] + ' ] ' + strPaginaActual);

                            break;
                }
            });

            tiempoPorUnidad = timeToSeconds($('#action ul li .time').html());
            if (DEBUG_MODE > 1) GM_log('calculateTime: ' +
                '[ tiempoPorUnidad = ' + tiempoPorUnidad + ' ] ' + strPaginaActual);

            var myP = document.getElementById('lpunktkit-time');
            if (myP != null) myP.parentNode.removeChild(myP);

            if ((strPaginaActual =='defense') || (strPaginaActual =='shipyard')) {
               $('#action ul li ' + (document.getElementById('possibleInTime') ?
                          '#possibleInTime' : '.time')).after('<p id="lpunktkit-time">' +
                          LANG.MISC.txt_tiempoTotal + ": " +
                          '<span style="color:' + strColor_LPuNKTKit +
                          ';font-weight:bold;">' + secondsToTime(0) + '</span></p>')

            } else { // Satelites balance 0
                  var div = document.getElementById('detail');

                  var arrHidden = div.getElementsByTagName('input');

                  var blnFound = false;

                  for (i=0; i < arrHidden.length; i++) {

                      if (arrHidden[i].value == '212')  //Satelites en Recursos
                      {

                         if (arrHidden[i].value == '212') {
                             $('#action ul li ' + (document.getElementById('possibleInTime') ?
                               '#possibleInTime' : '.time')).after('<p id="lpunktkit-time">' +
                               LANG.MISC.txt_tiempoTotal + ": " +
                               '<span style="color:' + strColor_LPuNKTKit +
                               ';font-weight:bold;">' + secondsToTime(0) + '</span></p>')

                         }
                      }
                  }
            }

            entradaUsuario = $('li.enter input').val();

            if (DEBUG_MODE > 1)
                GM_log('calculateTime: ' + '[ entradaUsuario = ' + entradaUsuario + ' ] ' + strPaginaActual);

            if ((parseInt(entradaUsuario) == 0) || (entradaUsuario == ''))
            {
                 $('#lpunktkit-time').html(LANG.MISC.txt_tiempoTotal + ': ' +
                      '<span style="color:' + strColor_LPuNKTKit +
                      ';font-weight:bold;">' + secondsToTime(0) + '</span>');

            for ( i=0; i<3; i++) {
                  var menos = document.getElementById('menos' + i);
                  if (menos) menos.parentNode.removeChild(menos);
            }
            }
            else if (parseInt(entradaUsuario)>0)
            {
                 $('#lpunktkit-time').html(LANG.MISC.txt_tiempoTotal + ': ' +
                      '<span style="color:' + strColor_LPuNKTKit +
                      ';font-weight:bold;">' +
                      secondsToTime(tiempoPorUnidad*entradaUsuario) +
                      '</span>');

            //calculamos cuantos recursos supone hacer esas
            //"x" naves, y lo mostramos
            recursosParaX = new Array();
            color = new Array();

            if (necesarios[0] > 0) //necesitamos metal
            {
               met = necesarios[0]*entradaUsuario;
               recursosParaX.push(met);

               if (DEBUG_MODE > 1)
                   GM_log('calculateTime: ' + '[ met = ' + met + ' ] ' +
                                              '[ metal = ' + metal + ' ] ' + strPaginaActual);

               if (met > metal) color.push("red")
               else color.push("green");
            }

            if (necesarios[1] > 0) //cristal
            {
               cri = necesarios[1]*entradaUsuario;
               recursosParaX.push(cri);

               if (DEBUG_MODE > 1) GM_log('calculateTime: ' +
                   '[ cri = ' + cri + ' ] ' +
                   '[ cristal = ' + cristal + ' ] ' + strPaginaActual);

               if (cri > cristal) color.push("red")
               else color.push("green");
            }

            if (necesarios[2] > 0) //y deuterio
            {
               deu = necesarios[2]*entradaUsuario;
               recursosParaX.push(deu);

               if (DEBUG_MODE > 1) GM_log('calculateTime: ' +
                   '[ deu = ' + deu + ' ] ' +
                   '[ deuterio = ' + deuterio + ' ] ' + strPaginaActual);

               if (deu > deuterio) color.push("red")
               else color.push("green");
            }

            $('#costs #resources li.metal span').each( function (i) {

               //mostramos datos
               if ($('#menos' + i).length != 0)
                  $('#menos' + i).replaceWith( '<p style="font-size:10px;' +
                           'color:' + color[i] + ';" id="menos' + i + '">-' +
                           puntos(recursosParaX[i]) + '</p>' )
               else
                   $(this).after( '<p style="font-size:10px;color:' +
                                  color[i] + ';" id="menos' + i + '">-' +
                                  puntos(recursosParaX[i]) + '</p>' );
            });

            } //if (parseInt(entradaUsuario)>0)

        } //if (existe.length>0)

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('calculateTime [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Inicializa array de colores de mensajes
 */
function LoadColorMessages() {
   try {

       if (DEBUG_MODE > 0) GM_log('loadColorMessages: ' + strPaginaActual);

       arrColorMessages = [

          //Texto                                       //Color
          [LANG.SERVER.txt_MISSION_colorDeploy, '#CCFF66'],
          [LANG.SERVER.txt_MISSION_colorReturn,  '#888833'],
          [LANG.SERVER.txt_MISSION_colorCircularMsg,   '#00FFFF'],
          [LANG.SERVER.txt_MISSION_colorHarvest,  '#EE82EE'],
          [LANG.SERVER.txt_MISSION_colorEspionageReport,  '#CCFFCC'],
          [LANG.SERVER.txt_MISSION_colorEspionageAction, '#FF3300'],
          [LANG.SERVER.txt_MISSION_colorPM,   '#00BFFF'],
          [LANG.SERVER.txt_MISSION_colorArrive,  '#FFFF33'],
          [LANG.SERVER.txt_MISSION_colorExpedition,  '#AAAABB'],
          [LANG.SERVER.txt_MISSION_colorColonize,  '#8080FF'],
          [LANG.SERVER.txt_MISSION_colorForeign, '#008000']

       ];

       if ( GM_getValue('messageColor0' + strUniverse, arrColorMessages[0][1]) == -1 )
       {
            for(var z = 0 ; z < arrColorMessages.length ; z++) {
                GM_setValue('messageText' + z + strUniverse, arrColorMessages[z][0]);
                GM_setValue('messageColor' + z + strUniverse, arrColorMessages[z][1]);
            }

       }
       else
       {
           for(var z = 0 ; z < arrColorMessages.length ; z++)
               if (GM_getValue('messageColor' + z + strUniverse, -1) != -1) {
                   arrColorMessages[z][0] = GM_getValue('messageText' + z + strUniverse,
                                                         arrColorMessages[z][0]);
                   arrColorMessages[z][1] = GM_getValue('messageColor' + z + strUniverse,
                                                         arrColorMessages[z][1]);
               }
       }

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('LoadColorMessages [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Inicializa array de tipos de nave/defensa
 */
function LoadDatosFlota(blnFriki) {
  try {
        if (DEBUG_MODE > 0) GM_log('LoadDatosFlota: ' + strPaginaActual);

        if (blnFriki) {
           arrDatosFlota = [
           //S.Name,                              L.Name,                               Metal, Crystal,    Duty,   Cargo
           [LANG.SERVER.txt_CR_SHIP_SH_PCarga,       LANG.CR_FRIKI.txt_SHIP_LG_npc,            2000,    2000,       0,    5000],
           [LANG.SERVER.txt_CR_SHIP_SH_GrCarga,      LANG.CR_FRIKI.txt_SHIP_LG_ngc,            6000,    6000,       0,   25000],
           [LANG.SERVER.txt_CR_SHIP_SH_CLigero,      LANG.CR_FRIKI.txt_SHIP_LG_cl,             3000,    1000,       0,      50],
           [LANG.SERVER.txt_CR_SHIP_SH_CPesado,      LANG.CR_FRIKI.txt_SHIP_LG_cp,             6000,    4000,       0,     100],
           [LANG.SERVER.txt_CR_SHIP_SH_Crucero,      LANG.CR_FRIKI.txt_SHIP_LG_crucero,       20000,    7000,    2000,     800],
           [LANG.SERVER.txt_CR_SHIP_SH_NB,           LANG.CR_FRIKI.txt_SHIP_LG_nb,            45000,   15000,       0,    1500],
           [LANG.SERVER.txt_CR_SHIP_SH_Acoraz,       LANG.CR_FRIKI.txt_SHIP_LG_acorazado,     30000,   40000,   15000,     750],
           [LANG.SERVER.txt_CR_SHIP_SH_Bomb,         LANG.CR_FRIKI.txt_SHIP_LG_bombardero,    50000,   25000,   15000,     500],
           [LANG.SERVER.txt_CR_SHIP_SH_Destruc,      LANG.CR_FRIKI.txt_SHIP_LG_destructor,    60000,   50000,   15000,    2000],
           [LANG.SERVER.txt_CR_SHIP_SH_Edlm,         LANG.CR_FRIKI.txt_SHIP_LG_edlm,        5000000, 4000000, 1000000, 1000000],
           [LANG.SERVER.txt_CR_SHIP_SH_Colony,       LANG.CR_FRIKI.txt_SHIP_LG_colonizador,   10000,   20000,   10000,    7500],
           [LANG.SERVER.txt_CR_SHIP_SH_Recy,         LANG.CR_FRIKI.txt_SHIP_LG_reciclador,    10000,    6000,    2000,   20000],
           [LANG.SERVER.txt_CR_SHIP_SH_Sonda,        LANG.CR_FRIKI.txt_SHIP_LG_sonda,             0,    1000,       0,       0],
           [LANG.SERVER.txt_CR_SHIP_SH_Satelite,     LANG.CR_FRIKI.txt_SHIP_LG_satelite,          0,    2000,     500,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_Lanza,     LANG.CR_FRIKI.txt_DEFENSE_LG_lanza,       2000,       0,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_LPeque,    LANG.CR_FRIKI.txt_DEFENSE_LG_laserp,      1500,     500,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_LGrande,   LANG.CR_FRIKI.txt_DEFENSE_LG_laserg,      6000,    2000,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CGauss,    LANG.CR_FRIKI.txt_DEFENSE_LG_gauss,      20000,   15000,    2000,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CIonico,   LANG.CR_FRIKI.txt_DEFENSE_LG_ionico,      2000,    6000,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CPlasma,   LANG.CR_FRIKI.txt_DEFENSE_LG_plasma,     50000,   50000,   30000,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CupPeque,  LANG.CR_FRIKI.txt_DEFENSE_LG_cupPeque,   10000,   10000,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CupGrande, LANG.CR_FRIKI.txt_DEFENSE_LG_cupGrande,  50000,   50000,       0,       0]
           ];
        } else {
           arrDatosFlota = [
           //S.Name,                              L.Name,                          Metal, Crystal,    Duty,   Cargo
           [LANG.SERVER.txt_CR_SHIP_SH_PCarga,       LANG.SERVER.txt_SHIP_LG_npc,               2000,    2000,       0,    5000],
           [LANG.SERVER.txt_CR_SHIP_SH_GrCarga,      LANG.SERVER.txt_SHIP_LG_ngc,               6000,    6000,       0,   25000],
           [LANG.SERVER.txt_CR_SHIP_SH_CLigero,      LANG.SERVER.txt_SHIP_LG_cl,                3000,    1000,       0,      50],
           [LANG.SERVER.txt_CR_SHIP_SH_CPesado,      LANG.SERVER.txt_SHIP_LG_cp,                6000,    4000,       0,     100],
           [LANG.SERVER.txt_CR_SHIP_SH_Crucero,      LANG.SERVER.txt_SHIP_LG_crucero,          20000,    7000,    2000,     800],
           [LANG.SERVER.txt_CR_SHIP_SH_NB,           LANG.SERVER.txt_SHIP_LG_nb,               45000,   15000,       0,    1500],
           [LANG.SERVER.txt_CR_SHIP_SH_Acoraz,       LANG.SERVER.txt_SHIP_LG_acorazado,        30000,   40000,   15000,     750],
           [LANG.SERVER.txt_CR_SHIP_SH_Bomb,         LANG.SERVER.txt_SHIP_LG_bombardero,       50000,   25000,   15000,     500],
           [LANG.SERVER.txt_CR_SHIP_SH_Destruc,      LANG.SERVER.txt_SHIP_LG_destructor,       60000,   50000,   15000,    2000],
           [LANG.SERVER.txt_CR_SHIP_SH_Edlm,         LANG.SERVER.txt_SHIP_LG_edlm,           5000000, 4000000, 1000000, 1000000],
           [LANG.SERVER.txt_CR_SHIP_SH_Colony,       LANG.SERVER.txt_SHIP_LG_colonizador,      10000,   20000,   10000,    7500],
           [LANG.SERVER.txt_CR_SHIP_SH_Recy,         LANG.SERVER.txt_SHIP_LG_reciclador,       10000,    6000,    2000,   20000],
           [LANG.SERVER.txt_CR_SHIP_SH_Sonda,        LANG.SERVER.txt_SHIP_LG_sonda,                0,    1000,       0,       0],
           [LANG.SERVER.txt_CR_SHIP_SH_Satelite,     LANG.SERVER.txt_SHIP_LG_satelite,             0,    2000,     500,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_Lanza,     LANG.SERVER.txt_DEFENSE_LG_lanza,          2000,       0,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_LPeque,    LANG.SERVER.txt_DEFENSE_LG_laserp,         1500,     500,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_LGrande,   LANG.SERVER.txt_DEFENSE_LG_laserg,         6000,    2000,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CGauss,    LANG.SERVER.txt_DEFENSE_LG_gauss,         20000,   15000,    2000,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CIonico,   LANG.SERVER.txt_DEFENSE_LG_ionico,         2000,    6000,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CPlasma,   LANG.SERVER.txt_DEFENSE_LG_plasma,        50000,   50000,   30000,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CupPeque,  LANG.SERVER.txt_DEFENSE_LG_cupPeque,      10000,   10000,       0,       0],
           [LANG.SERVER.txt_CR_DEFENSE_SH_CupGrande, LANG.SERVER.txt_DEFENSE_LG_cupGrande,     50000,   50000,       0,       0]
           ];
        }

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('LoadDatosFlota [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function LoadColoresCR (blnFriki) {

  try {
        if (! show_Compactador_Batallas) return;

        if (DEBUG_MODE > 0) GM_log('LoadColoresCR: ' + strPaginaActual);

        if (blnFriki) {
           arrColorBatalla = [
           [/{COLOR_T1}/gi,   '#FFFFFF', LANG.CR.txt_titles],
           [/{COLOR_A1}/gi,   '#00FF40', LANG.SERVER.txt_CR_attacker],
           [/{COLOR_A2}/gi,   '#00DDDD', LANG.SERVER.txt_CR_attacker + ' - ' + LANG.CR.txt_lostShips],
           [/{COLOR_D1}/gi,   '#ED7010', LANG.SERVER.txt_CR_Defender],
           [/{COLOR_D2}/gi,   '#00DDDD', LANG.SERVER.txt_CR_Defender + ' - ' + LANG.CR.txt_lostShips],
           [/{COLOR_R1}/gi,   '#FFCC66', LANG.CR.txt_lostUnits],
           [/{COLOR_R2}/gi,   '#09A64F', LANG.CR.txt_lossesXRes],
           [/{COLOR_R4}/gi,   '#F0EC64', LANG.MISC.txt_recursos + ' - ' + LANG.CR.txt_stolen],
           [/{COLOR_R3}/gi,   '#FF0000', LANG.CR.txt_debris + ' ' + LANG.SERVER.txt_CR_and + ' ' +
                                         LANG.CR.txt_totLoses],
           [/{COLOR_RA1}/gi,  '#00FF40', LANG.CR.txt_profit + ' - ' + LANG.CR.txt_attHarvest],
           [/{COLOR_RAM1}/gi, '#09A64F', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_metal],
           [/{COLOR_RAC1}/gi, '#09A64F', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_cristal],
           [/{COLOR_RAD1}/gi, '#09A64F', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_deuterio],
           [/{COLOR_RA2}/gi,  '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.CR.txt_attNoHarvest],
           [/{COLOR_RAM2}/gi, '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_metal],
           [/{COLOR_RAC2}/gi, '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_cristal],
           [/{COLOR_RAD2}/gi, '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_deuterio],
           [/{COLOR_RD}/gi,   '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.CR.txt_defHarvest],
           [/{COLOR_RDM}/gi,  '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_metal],
           [/{COLOR_RDC}/gi,  '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_cristal],
           [/{COLOR_RDD}/gi,  '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.CR_FRIKI.txt_RES_deuterio],
           [/{COLOR_L}/gi,    '#CCFF66', '\u0025 ' + LANG.CR.txt_moon],
           [/{COLOR_IN}/gi,   '#FFFFFF', LANG.CR.txt_others]
           ];
        } else {
           arrColorBatalla = [
           [/{COLOR_T1}/gi,   '#FFFFFF', LANG.CR.txt_titles],
           [/{COLOR_A1}/gi,   '#00FF40', LANG.SERVER.txt_CR_attacker],
           [/{COLOR_A2}/gi,   '#00DDDD', LANG.SERVER.txt_CR_attacker + ' - ' + LANG.CR.txt_lostShips],
           [/{COLOR_D1}/gi,   '#ED7010', LANG.SERVER.txt_CR_Defender],
           [/{COLOR_D2}/gi,   '#00DDDD', LANG.SERVER.txt_CR_Defender + ' - ' + LANG.CR.txt_lostShips],
           [/{COLOR_R1}/gi,   '#FFCC66', LANG.CR.txt_lostUnits],
           [/{COLOR_R2}/gi,   '#09A64F', LANG.CR.txt_lossesXRes],
           [/{COLOR_R4}/gi,   '#F0EC64', LANG.MISC.txt_recursos + ' - ' + LANG.CR.txt_stolen],
           [/{COLOR_R3}/gi,   '#FF0000', LANG.CR.txt_debris + ' ' + LANG.SERVER.txt_CR_and + ' ' +
                                         LANG.CR.txt_totLoses],
           [/{COLOR_RA1}/gi,  '#00FF40', LANG.CR.txt_profit + ' - ' + LANG.CR.txt_attHarvest],
           [/{COLOR_RAM1}/gi, '#09A64F', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_metal],
           [/{COLOR_RAC1}/gi, '#09A64F', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_cristal],
           [/{COLOR_RAD1}/gi, '#09A64F', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_deuterio],
           [/{COLOR_RA2}/gi,  '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.CR.txt_attNoHarvest],
           [/{COLOR_RAM2}/gi, '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_metal],
           [/{COLOR_RAC2}/gi, '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_cristal],
           [/{COLOR_RAD2}/gi, '#00DDDD', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_deuterio],
           [/{COLOR_RD}/gi,   '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.CR.txt_defHarvest],
           [/{COLOR_RDM}/gi,  '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_metal],
           [/{COLOR_RDC}/gi,  '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_cristal],
           [/{COLOR_RDD}/gi,  '#ED7010', LANG.CR.txt_profit + ' - ' + LANG.SERVER.txt_RES_deuterio],
           [/{COLOR_L}/gi,    '#CCFF66', '\u0025 ' + LANG.CR.txt_moon],
           [/{COLOR_IN}/gi,   '#FFFFFF', LANG.CR.txt_others]
           ];
        }

        if ( GM_getValue('batallaColor0' + strUniverse, arrColorBatalla[0][1]) == -1 )
        {
             for(var z = 0 ; z < arrColorBatalla.length ; z++)
                 GM_setValue('batallaColor' + z + strUniverse, arrColorBatalla[z][1]);

        }
        else
        {
            for(var z = 0 ; z < arrColorBatalla.length ; z++)
                if (GM_getValue('batallaColor' + z + strUniverse, -1) != -1)
                    arrColorBatalla[z][1] = GM_getValue('batallaColor' + z + strUniverse, -1);
        }

        LANG.SERVER.txt_CR_SHIP_SH_PCarga       = GM_getValue("batallaName1" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_PCarga);
        LANG.SERVER.txt_CR_SHIP_SH_GrCarga      = GM_getValue("batallaName2" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_GrCarga);
        LANG.SERVER.txt_CR_SHIP_SH_CLigero      = GM_getValue("batallaName3" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_CLigero);
        LANG.SERVER.txt_CR_SHIP_SH_CPesado      = GM_getValue("batallaName4" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_CPesado);
        LANG.SERVER.txt_CR_SHIP_SH_Crucero      = GM_getValue("batallaName5" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Crucero);
        LANG.SERVER.txt_CR_SHIP_SH_NB           = GM_getValue("batallaName6" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_NB);
        LANG.SERVER.txt_CR_SHIP_SH_Acoraz       = GM_getValue("batallaName7" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Acoraz);
        LANG.SERVER.txt_CR_SHIP_SH_Bomb         = GM_getValue("batallaName8" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Bomb);
        LANG.SERVER.txt_CR_SHIP_SH_Destruc      = GM_getValue("batallaName9" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Destruc);
        LANG.SERVER.txt_CR_SHIP_SH_Edlm         = GM_getValue("batallaName10" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Edlm);
        LANG.SERVER.txt_CR_SHIP_SH_Colony       = GM_getValue("batallaName11" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Colony);
        LANG.SERVER.txt_CR_SHIP_SH_Recy         = GM_getValue("batallaName12" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Recy);
        LANG.SERVER.txt_CR_SHIP_SH_Sonda        = GM_getValue("batallaName13" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Sonda);
        LANG.SERVER.txt_CR_SHIP_SH_Satelite     = GM_getValue("batallaName14" + strUniverse, LANG.SERVER.txt_CR_SHIP_SH_Satelite);
        LANG.SERVER.txt_CR_DEFENSE_SH_Lanza     = GM_getValue("batallaName15" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_Lanza);
        LANG.SERVER.txt_CR_DEFENSE_SH_LPeque    = GM_getValue("batallaName16" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_LPeque);
        LANG.SERVER.txt_CR_DEFENSE_SH_LGrande   = GM_getValue("batallaName17" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_LGrande);
        LANG.SERVER.txt_CR_DEFENSE_SH_CGauss    = GM_getValue("batallaName18" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_CGauss);
        LANG.SERVER.txt_CR_DEFENSE_SH_CIonico   = GM_getValue("batallaName19" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_CIonico);
        LANG.SERVER.txt_CR_DEFENSE_SH_CPlasma   = GM_getValue("batallaName20" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_CPlasma);
        LANG.SERVER.txt_CR_DEFENSE_SH_CupPeque  = GM_getValue("batallaName21" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_CupPeque);
        LANG.SERVER.txt_CR_DEFENSE_SH_CupGrande = GM_getValue("batallaName22" + strUniverse, LANG.SERVER.txt_CR_DEFENSE_SH_CupGrande);

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('LoadColoresCR [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

/**
 * Opciones del script
 */
function loadOptions()
{
  try {
     if (DEBUG_MODE > 0) GM_log('loadOptions: ' + strPaginaActual);

     strUniverse = getUniverse();

     if (! getLangPack()) {

         //Establecer idioma del script
         switch (getLanguage())
         {
             case 'ES': LANG = LANG_ES;
                        break;

             case 'EN': LANG = LANG_EN;
                        break;

             case 'FR': LANG = LANG_FR;
                        break;

             default:   LANG = LANG_EN;
                        break;
         }
     }

     if ( (LANG.CR_FRIKI.txt_RES_metal) &&
          (trim(LANG.CR_FRIKI.txt_RES_metal).length > 0))
         availCRFriki = true
     else
         availCRFriki = false;

     //Color de la fuente de la cofiguracion del script
     if ( VERSION_LPUNKTKIT.indexOf('\u042F') >= 0 ) {
         strColor_LPuNKTKit    = GM_getValue("strColor_LPuNKTKit" + strUniverse, COLOR_LPUNKTKIT_T);
         strUrl_Script         = URL_SCRIPT_T;
     } else {
         strColor_LPuNKTKit    = GM_getValue("strColor_LPuNKTKit" + strUniverse, COLOR_LPUNKTKIT);
         strUrl_Script         = URL_SCRIPT;
     }

     // Nivel de ionica, para desmontar edificios
     lvlIonica                 = GM_getValue("level_ionica" + strUniverse, 0);

     //Links
     show_PayPal               = GM_getValue("showPayPal" + strUniverse, SHOW_PAYPAL);

     link1_name                = GM_getValue("link1_name" + strUniverse, LINK1_NAME).substring(0, LINK_NAME_LENGTH);
     link1_href                = GM_getValue("link1_href" + strUniverse, LINK1_HREF);

     link2_name                = GM_getValue("link2_name" + strUniverse, LINK2_NAME).substring(0, LINK_NAME_LENGTH);
     link2_href                = GM_getValue("link2_href" + strUniverse, LINK2_HREF);

     link3_name                = GM_getValue("link3_name" + strUniverse, LINK3_NAME).substring(0, LINK_NAME_LENGTH);
     link3_href                = GM_getValue("link3_href" + strUniverse, LINK3_HREF);

     link4_name                = GM_getValue("link4_name" + strUniverse, LINK4_NAME).substring(0, LINK_NAME_LENGTH);
     link4_href                = GM_getValue("link4_href" + strUniverse, LINK4_HREF);

     set_Clock_Links           = GM_getValue("setClockLinks" + strUniverse, SET_CLOCK_LINKS);

     //Opciones
     set_Fix_Action_Icons      = GM_getValue("setFixActionIcons" + strUniverse, SET_FIX_ACTION_ICONS);
     set_Focus_Correctly       = GM_getValue("setFocusCorrectly" + strUniverse, SET_FOCUS_CORRECTLY);
     disable_Useless_Stuff     = GM_getValue("disableUselessStuff" + strUniverse, DISABLE_USELESS_STUFF);
     fix_Forum_Link            = GM_getValue("fixForumLink" + strUniverse, FIX_FORUM_LINK);
     disable_Star              = GM_getValue("disableStar" + strUniverse, DISABLE_STAR);
//     show_Confirm_Trader       = GM_getValue("showConfirmTrader" + strUniverse, SHOW_CONFIRM_TRADER);
     use_Short_Header          = GM_getValue("useShortHeader" + strUniverse, USE_SHORT_HEADER);
     show_Trade_Calculator     = GM_getValue("showTradeCalculator" + strUniverse, SHOW_TRADE_CALCULATOR);

     //Menu superior
     show_Uni_Name_In_Pillory  = GM_getValue("showUniNameInPillory" + strUniverse, SHOW_UNI_NAME_IN_PILLORY);
     show_Pranger_In_Header    = GM_getValue("showPrangerInHeader" + strUniverse, SHOW_PRANGER_IN_HEADER);
     show_Options_In_UserName  = GM_getValue("showOptionsInUserName" + strUniverse, SHOW_OPTIONS_IN_USERNAME);

     // Recursos
     show_Daily_Ships_Defenses = GM_getValue("showDailyShipsDefenses" + strUniverse, SHOW_DAILY_SHIPS_DEFENSES);
     show_Production_Ratio     = GM_getValue("showProductionRatio" + strUniverse, SHOW_PRODUCTION_RATIO);
     show_Llenado_Almacenes    = GM_getValue("showLlenadoAlmacenes" + strUniverse, SHOW_LLENADO_ALMACENES);

     color_M_Warehouse_0       = GM_getValue("colorMWarehouse0" + strUniverse, COLOR_M_WAREHOUSE_0);
     color_C_Warehouse_0       = GM_getValue("colorCWarehouse0" + strUniverse, COLOR_C_WAREHOUSE_0);
     color_D_Warehouse_0       = GM_getValue("colorDWarehouse0" + strUniverse, COLOR_D_WAREHOUSE_0);
     color_M_Warehouse_80      = GM_getValue("colorMWarehouse80" + strUniverse, COLOR_M_WAREHOUSE_80);
     color_C_Warehouse_80      = GM_getValue("colorCWarehouse80" + strUniverse, COLOR_C_WAREHOUSE_80);
     color_D_Warehouse_80      = GM_getValue("colorDWarehouse80" + strUniverse, COLOR_D_WAREHOUSE_80);
     color_M_Warehouse_100     = GM_getValue("colorMWarehouse100" + strUniverse, COLOR_M_WAREHOUSE_100);
     color_C_Warehouse_100     = GM_getValue("colorCWarehouse100" + strUniverse, COLOR_C_WAREHOUSE_100);
     color_D_Warehouse_100     = GM_getValue("colorDWarehouse100" + strUniverse, COLOR_D_WAREHOUSE_100);

     color_M_Den_0             = GM_getValue("colorMDen0" + strUniverse, COLOR_M_DEN_0);
     color_C_Den_0             = GM_getValue("colorCDen0" + strUniverse, COLOR_C_DEN_0);
     color_D_Den_0             = GM_getValue("colorDDen0" + strUniverse, COLOR_D_DEN_0);
     color_M_Den_80            = GM_getValue("colorMDen80" + strUniverse, COLOR_M_DEN_80);
     color_C_Den_80            = GM_getValue("colorCDen80" + strUniverse, COLOR_C_DEN_80);
     color_D_Den_80            = GM_getValue("colorDDen80" + strUniverse, COLOR_D_DEN_80);
     color_M_Den_100           = GM_getValue("colorMDen100" + strUniverse, COLOR_M_DEN_100);
     color_C_Den_100           = GM_getValue("colorCDen100" + strUniverse, COLOR_C_DEN_100);
     color_D_Den_100           = GM_getValue("colorDDen100" + strUniverse, COLOR_D_DEN_100);

     show_Resources_Info       = GM_getValue("showResourcesInfo" + strUniverse, SHOW_RESOURCES_INFO);

     color_Res_Almacen         = GM_getValue("colorResAlmacen" + strUniverse, COLOR_RES_ALMACEN);
     color_Res_Den             = GM_getValue("colorResDen" + strUniverse, COLOR_RES_DEN);
     color_Res_Prod            = GM_getValue("colorResProd" + strUniverse, COLOR_RES_PROD);
     color_Energy_Used         = GM_getValue("colorEnergyUsed" + strUniverse, COLOR_ENERGY_USED);

     //Galaxia
     highlight_Players         = GM_getValue("highlightPlayers" + strUniverse, HIGHLIGHT_PLAYERS);
     show_Link_Fixed           = GM_getValue("showLinkFixed" + strUniverse, SHOW_LINK_FIXED);

     //Planetas
//     show_Planet_Nav_Keys      = GM_getValue("showPlanetNavKeys" + strUniverse, SHOW_PLANET_NAV_KEYS);
     show_Moons_Right          = GM_getValue("showMoonsRight" + strUniverse, SHOW_MOONS_RIGHT);
     show_Small_Planets        = GM_getValue("showSmallPlanets" + strUniverse, SHOW_SMALL_PLANETS);
     show_Full_Planet          = GM_getValue("showFullPlanet" + strUniverse, SHOW_FULL_PLANET);
     color_Full_Planet_0       = GM_getValue("colorFullPlanet" + strUniverse, COLOR_FULL_PLANET_0);
     color_Full_Planet_1       = GM_getValue("colorFullPlanet1" + strUniverse, COLOR_FULL_PLANET_1);
     color_Full_Planet_2       = GM_getValue("colorFullPlanet2" + strUniverse, COLOR_FULL_PLANET_2);
     color_Full_Planet_3       = GM_getValue("colorFullPlanet3" + strUniverse, COLOR_FULL_PLANET_3);
     show_Planeta_Activo       = GM_getValue("showPlanetaActivo" + strUniverse, SHOW_PLANETA_ACTIVO);

     //Informacion
     show_Range                = GM_getValue("showRange" + strUniverse, SHOW_RANGE);
     show_Efficiency           = GM_getValue("showEfficiency" + strUniverse, SHOW_EFFICIENCY);
     show_Time_Ships_Defenses  = GM_getValue("showTimeShipsDefenses" + strUniverse, SHOW_TIME_SHIPS_DEFENSES);
     show_Demolish             = GM_getValue("showDemolish" + strUniverse, SHOW_DEMOLISH);

     //Satelites
     show_Sats_Balance         = GM_getValue("showSatsBalance" + strUniverse, SHOW_SATS_BALANCE);
     show_Sats_Graviton        = GM_getValue("showSatsGraviton" + strUniverse, SHOW_SATS_GRAVITON);
     show_Sats_Terraformer     = GM_getValue("showSatsTerraformer" + strUniverse, SHOW_SATS_TERRAFORMER);

     //Mensajes
     current_Planet_Name       = GM_getValue("currentPlanetName" + strUniverse, CURRENT_PLANET_NAME);
//     reply_CC                  = GM_getValue("replyCC" + strUniverse, REPLY_CC);
     show_Colored_Messages     = GM_getValue("showColoredMessages" + strUniverse, SHOW_COLORED_MESSAGES);
     show_BBCode               = GM_getValue("showBBCode" + strUniverse, SHOW_BBCODE);
     show_Smiles               = GM_getValue("showSmiles" + strUniverse, SHOW_SMILES);
     show_Message_Button_Left  = GM_getValue("showMessageButtonLeft" + strUniverse, SHOW_MESSAGE_BUTTON_LEFT);

     //Compactador
     show_Compactador_Batallas = GM_getValue("showCompactadorBatallas" + strUniverse, SHOW_COMPACTADOR_BATALLAS);
     hide_Stolen_CR            = GM_getValue("hideStolenCR" + strUniverse, HIDE_STOLEN_CR);
     hide_Debris_CR            = GM_getValue("hideDebrisCR" + strUniverse, HIDE_DEBRIS_CR);
     show_Escombros_SAC        = GM_getValue("showEscombrosSAC" + strUniverse, SHOW_ESCOMBROS_SAC);
     modo_Reparto_SAC          = GM_getValue("modoRepartoSAC" + strUniverse, MODO_REPARTO_SAC);
     rec_Perdidas_SAC          = GM_getValue("recPerdidasSAC" + strUniverse, REC_PERDIDAS_SAC);
     rat_Metal_SAC             = GM_getValue("ratMetalSAC" + strUniverse, RAT_METAL_SAC);
     rat_Cristal_SAC           = GM_getValue("ratCristalSAC" + strUniverse, RAT_CRISTAL_SAC);
     rat_Deuterio_SAC          = GM_getValue("ratDeuterioSAC" + strUniverse, RAT_DEUTERIO_SAC);

     if (availCRFriki)
         usar_CR_Friki         = GM_getValue("usarCRFriki" + strUniverse, USAR_CR_FRIKI);

     // Recursos transportados
     fix_Tooltips              = GM_getValue("fixTooltips" + strUniverse, FIX_TOOLTIPS);
     show_Fleet_Resources      = GM_getValue("showFleetResources" + strUniverse, SHOW_FLEET_RESOURCES);
     show_Resources_Per_Fleet  = GM_getValue("showResourcesPerFleet" + strUniverse, SHOW_RESOURCES_PER_FLEET);
     show_Empty_Space          = GM_getValue("showEmptySpace" + strUniverse, SHOW_EMPTY_SPACE);

     color_Metal               = GM_getValue("colorMetal" + strUniverse, COLOR_METAL);
     color_Cristal             = GM_getValue("colorCristal" + strUniverse, COLOR_CRISTAL);
     color_Deuterio            = GM_getValue("colorDeuterio" + strUniverse, COLOR_DEUTERIO);
     color_Empty_Space         = GM_getValue("colorEmptySpace" + strUniverse, COLOR_EMPTY_SPACE);

     // Flota
     show_Color_Flight_Slots   = GM_getValue("showColorFlightSlots" + strUniverse, SHOW_COLOR_FLIGHT_SLOTS);
     color_Slot_0              = GM_getValue("colorSlot0" + strUniverse, COLOR_SLOT_0);
     color_Slot_1              = GM_getValue("colorSlot1" + strUniverse, COLOR_SLOT_1);
     color_Slot_2              = GM_getValue("colorSlot2" + strUniverse, COLOR_SLOT_2);
     color_Slot_3              = GM_getValue("colorSlot3" + strUniverse, COLOR_SLOT_3);

     show_Load_Buttons         = GM_getValue("showLoadButtons" + strUniverse, SHOW_LOAD_BUTTONS);
     remove_Adv                = GM_getValue("removeAdv" + strUniverse, REMOVE_ADV);
     show_Return_Fleet_Question= GM_getValue("showReturnFleetQuestion" + strUniverse, SHOW_RETURN_FLEET_QUESTION);
     show_Fleet_Content        = GM_getValue("showFleetContent" + strUniverse, SHOW_FLEET_CONTENT);
     show_Dest_Player_Name     = GM_getValue("showDestPlayerName" + strUniverse, SHOW_DEST_PLAYER_NAME);
     use_Direct_Spy            = GM_getValue("useDirectSpy" + strUniverse, USE_DIRECT_SPY);
//     show_Auto_Expo_Fleet      = GM_getValue("showAutoExpoFleet" + strUniverse, SHOW_AUTO_EXPO_FLEET);
//     show_No_Escape            = GM_getValue("showNoEscape" + strUniverse, SHOW_NO_ESCAPE);
     color_No_Escape           = GM_getValue("colorNoEscape" + strUniverse, COLOR_NO_ESCAPE);
     color_Escape              = GM_getValue("colorEscape" + strUniverse, COLOR_ESCAPE);

     // Teclas rapidas
     show_Shortcuts            = GM_getValue("showShortcuts" + strUniverse, SHOW_SHORTCUTS);
     show_Key_Everywhere       = GM_getValue("showKeyEverywhere" + strUniverse, SHOW_KEY_EVERYWHERE);
     show_Key_Mailbox          = GM_getValue("showKeyMailbox" + strUniverse, SHOW_KEY_MAILBOX);
     show_Key_Fleet            = GM_getValue("showKeyFleet" + strUniverse, SHOW_KEY_FLEET);
     show_Key_Trader           = GM_getValue("showKeyTrader" + strUniverse, SHOW_KEY_TRADER);

     // Chat de alianza
     show_Chat                 = GM_getValue("showChat" + strUniverse, SHOW_CHAT);
     id_Chat                   = GM_getValue("idChat" + strUniverse, ID_CHAT);
     link_Chat                 = GM_getValue("linkChat" + strUniverse, LINK_CHAT);

     // Resalte de escombros
     min_Escombros             = GM_getValue("minEscombros" + strUniverse, MIN_ESCOMBROS);

     show_Debris               = GM_getValue("showDebris" + strUniverse, SHOW_DEBRIS);

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('loadOptions [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

// name           OGame Redesign: Retarted Star
// description    Removes the annoying blinky stars in 1.2.1
function QuitarEstrella(blnQuitar)
{
  try {
       if (! blnQuitar) return;

       if (DEBUG_MODE > 0) GM_log('QuitarEstrella: ' + strPaginaActual);

       var star = document.getElementById('star');
       if (star) star.parentNode.removeChild(star);

       star = document.getElementById('star1');
       if (star) star.parentNode.removeChild(star);

       star = document.getElementById('star2');
       if (star) star.parentNode.removeChild(star);

   } catch(e) {
         if (DEBUG_MODE != 0) GM_log('QuitarEstrella [ERROR]: <' + e + '> ' + strPaginaActual);
   }
}

function addOptions()
{
  try {
        if ((strPaginaActual == 'showmessage') ||
            (strPaginaActual == "combatreport") ||
            (strPaginaActual == "writemessage") ||
            (strPaginaActual == "search") ||
            (strPaginaActual == 'buddies'))
            return;

        if (DEBUG_MODE > 0) GM_log('addOptions: ' + strPaginaActual);

        const SIZE_FONT = '10px';

        var strImagen = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAd" +
                        "CAYAAADGgB7AAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA" +
                        "AgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpR" +
                        "PAAAAAlwSFlzAAAK6wAACusBgosNWgAAAd1JREFUWEftl11OwzAMx9" +
                        "cCGt26teto99Gxln0IsSNwBV554ZXzcQ6OwBmQOAECZOKwhKxNtiTL" +
                        "EEJU+qupY7u/OFaqeg1yNa9v8dYYvjzBx/sbHbu8jo5PGs/pysOcr4" +
                        "8P+qkRrFhcweRiuamSPFdV9cFn5iObI7ZiuYK8nAMrgDYZBm5AyYB0" +
                        "bQwO/YUxgmXjKWhDoSMGOANTLOB8dmkJplsRWz9SPauKjaezej/ZQr" +
                        "BtXMfn5YLmtgKTNvk+YEIsgqHcgDmCwgX/WrAJbqVtj93c3YNMuGLV" +
                        "nKndaivzYk4blL2s1nPrra3Oi8+yOTGPFRg9yxyCVSEHeWHe/M2gRY" +
                        "NQriqGeVi1WO7maWB28pPDHwOoGJho2zYv+st6TpLH6KtkDFaFkC1K" +
                        "sUg3YNXk2yqq6ftHwEzPJFV1VHk832ftYlcxVdOb2AUI3rtC/M+A7Y" +
                        "A4HJj/vQWgA+F5ngxGtLmrGAMSIXFrNCAOVzEKIFTNpNcUvu4q5gDG" +
                        "biuDdndXX+w9j1UPgtDsW4n/e2GcQCdKIIx6VO0uUSfmanUi4ArJmK" +
                        "u7OSYxLRSZxxxhFHMZ/1diACrJRpCkI4jPBl/qZ1xRP4UoIWJ3Ps4E" +
                        "e33cS4eAYu8warB/Z4MKfALth6dmKmiZygAAAABJRU5ErkJggg%3D%3D";

        var strImagen_on = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAA" +
                        "AAdCAYAAADGgB7AAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQU" +
                        "AAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwn" +
                        "LpRPAAAAAlwSFlzAAAK6wAACusBgosNWgAAAd1JREFUWEftl21OwzA" +
                        "MhtcCGt26teto99Gxln0IsSNwDq7EHfjPX87BETgDEidAgEwclpC1y" +
                        "ZZkGUKISq+aOrb7xLFS1WuQq3l9g7fG8OUJPt7f6NjldXR80nhOVx7" +
                        "mfH180E+NYMXiCiYXy02V5Lmqqg8+Mx/ZHLEVyxXk5RxYAbTJMHADS" +
                        "gaka2Nw6C+MESwbT0EbCh0xwBmYYgHns0tLMN2K2PqR6llVbDyd1fv" +
                        "JFoJt4zo+Lxc0txWYtMn3ARNiEQzlBswRFC7414JNcCtte+z27h5kw" +
                        "hWr5kztVluZF3PaoOxltZ5bb211XnyWzYl5rMDoWeYQrAo5yAvz5m8" +
                        "GLRqEclUxzMOqxXI3TwOzk58c/hhAxcBE27Z50V/Wc5I8Rl8lY7Aqh" +
                        "GxRikW6Aasm31ZRTd8/AmZ6Jqmqo8rj+T5rF7uKqZrexC5A8N4V4n8" +
                        "GbAfE4cD87y0AHQjP82Qwos1dxRiQCIlbowFxuIpRAKFqJr2m8HVXM" +
                        "QcwdlsZtLu7+mLveax6EIRm30r