Guest User

Grepolis Dio Tools

a guest
May 20th, 2014
2,123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        DIO-TOOLS
  3. // @namespace   DIO
  4. // @version     0.209
  5. // @updateURL   http://userscripts.org:8080/scripts/source/184630.user.js
  6. // @downloadURL http://userscripts.org:8080/scripts/source/184630.user.js
  7. // @description DIO-Tools is a small extension for the browser game Grepolis. (unit counter, unit strength, smiley box, trade options, improved boxes (commands, trades & spells), ww share & changes to the UI)
  8. // @include     http://*.grepolis.com/game*
  9. // @include     http://*forum.*.grepolis.com/*.php*
  10. // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
  11.  
  12. // @icon        http://s7.directupload.net/images/140128/vqchpigi.gif
  13. // @iconURL     http://s7.directupload.net/images/140128/vqchpigi.gif
  14. // @copyright   2013+, DIONY
  15. // ==/UserScript==
  16.  
  17.  
  18. //http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
  19.  
  20.  
  21. /*******************************************************************************************************************************
  22.  * Changes
  23.  * ----------------------------------------------------------------------------------------------------------------------------
  24.  * | ● TradeButton erscheint nichtmehr während der Bauphase eines WW's
  25.  * | ● Layoutänderungen im Forum für die Smileybox im Editor angepasst (gab Probleme bei anderen Märkten)
  26.  * | ● Ausnahme: Deutsche Schildersmileys (Dafuer/Dagegen) werden in anderen Märkten durch englische Pendants ersetzt
  27.  * | ● Extrasmiley im Forum hinzugefügt
  28.  * | ● Kontextmenü: Vertauscht die Positionen von "Stadtübersicht" und "Stadt selektieren"
  29.  * | ● Extrasmiley im Forum hinzugefügt
  30.  * | ● Verteidigungsformular: Ohne "Uhr" bei anderen Märkten
  31.  * ----------------------------------------------------------------------------------------------------------------------------
  32.  *******************************************************************************************************************************/
  33.  
  34. /*******************************************************************************************************************************
  35.  * Bugs / TODOs
  36.  * ----------------------------------------------------------------------------------------------------------------------------
  37.  * | ● Beim WW Garten wird der Next-Button falsch positioniert
  38.  * | ● Aktivitätsbox für Angriffe blendet nicht aus
  39.  * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
  40.  * | ● Stadticons werden nicht sofort geladen
  41.  * | ● ...
  42.  * ----------------------------------------------------------------------------------------------------------------------------
  43.  *******************************************************************************************************************************/
  44.  
  45. /*******************************************************************************************************************************
  46.  * Global stuff
  47.  *******************************************************************************************************************************/
  48. var uw = unsafeWindow || window, data; // data??
  49.  
  50. var $ = uw.jQuery || jQuery; // (Game || Forum)
  51.  
  52. // Game values
  53. var LID = "en", WID = "", AID = 0, PID  = 0;
  54. if(uw.location.pathname === "/game/index"){
  55.     LID = uw.Game.locale_lang.split("_")[0];
  56.     WID = uw.Game.world_id;
  57.     AID = uw.Game.alliance_id;
  58.     PID = uw.Game.player_id;
  59.    
  60.     var unitVal; // unit values
  61.    
  62.     var autoTownTypes = {}; // town type (ld, lo, sd, so, fd, fo)  
  63.     var manuTownTypes = JSON.parse(GM_getValue("town_types", "{}"));
  64.    
  65.     var townPopulation = {};
  66.    
  67.     $.prototype.reverseList = [].reverse;
  68. }
  69.  
  70. //console.log(GM_listValues());
  71.  
  72. //console.log(GM_getValue("de48_ratio"));
  73.  
  74. //console.log(GM_getValue("de44_ratio"));
  75.  
  76. /*******************************************************************************************************************************
  77.  * Images
  78.  *******************************************************************************************************************************/
  79. var img = "data:image/png;base64,"+
  80.     "iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhU"+
  81.     "IIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/S"+
  82.     "MBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFA"+
  83.     "FgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCR"+
  84.     "FRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf"+
  85.     "14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c"+
  86.     "93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRBy"+
  87.     "AgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cw"+
  88.     "wOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUM"+
  89.     "yJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6"+
  90.     "WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9r"+
  91.     "kZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX"+
  92.     "836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/V"+
  93.     "HDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostq"+
  94.     "i2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9"+
  95.     "JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9j"+
  96.     "L5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5"+
  97.     "pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwv"+
  98.     "SFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlh"+
  99.     "bL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1r"+
  100.     "gV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi"+
  101.     "8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZ"+
  102.     "zG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7v"+
  103.     "DvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9q"+
  104.     "wHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8"+
  105.     "o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl";
  106. var img_small_transp = img +
  107.     "/FRgAAA/1JREFUeNqsk0mMVFUUhv9733313quxu6qosrppGpqhuwkyCKh02oEYp8REEVwYExOXxrhyZ3RtdGPc6cKdCcbEEOMYjEENoiBGwiw0Kj1QFFVd45vvu/e4kBA1ATae7cn5c875/"+
  108.     "h8AGP6nMm7VvPfpZ9fsqKmXjaDTbbrUuJ2YAABh5yqV6Y1PViY3m0wYi9XpLTxdGhNXvtm/jwvxECPKVoeseqMbNW8rxhjX1fWbiqlM/qVus8HjKOHF6ijLj64pxPVjh3uhPhxr/czaWubj"+
  109.     "S3WvccszTcuJimOr62Lx5H2PPLD9znO/L3HTQObiVx/1OudPdlsh5nu+dk2DnqoOW2c6bjK4qZiSIfXqC/FI0Zl8/ZXnd96zrmRsykaM+22v3nYLVqYwAcYnu31/a+QnU9xgjURj6b/wbgB"+
  110.     "I4kgHYYSpqQ079+15rrpuImfsmt3hPPr47vxjD8/WZnZtHV81Pko9P9hSr7dmGHCMgKs3fWC5PPzgh/vf/pNomWRwiig5T0RzRDRHMjxD/f5Z+fPxz4P7Z7afFsC7I8PW+D/G2Y3NVpas7O"+
  111.     "ja9XvefOPVPaaZ8NBzAQAyjiEjiSROoJKEV8tDBuP88qFvfziYNvXKXMaKvFCtJsJVMbuxzEHYvbDs7i3msw9ImTIcJEjn8mg1mohjhSCIAAJKpSEIYbHKisqIZsJd7nuLts1eY4zNAXTcG"+
  112.     "AQy1fPlC5WC/WLgetXvjhxlCF04Th6FfAGkOWzbgtLAocO/4tgvp/HZgS8yFy5cnPJjPZNxxHqt9TtS0WVRyttkm5w2TwzbCw0PBw58jYUzx7F9x12Y3LwNjAiDKEGrNcCJn75HNaOgk9go"+
  113.     "ZsW0ECw0DPZ+KZ864jdDsJGiY5gm2z09Vvhg1Yp09dx8H3NLHTAGtAOBUhqwbY5V5SwmKja8QOLaIMGlhocwlgeTBHuXB9IFAHGlHSjOcKIziC/nttWqW9YV4dgC7V6IUqKRcwRGS2nYKQY"+
  114.     "Fjt8aIRabPsB0q+/J9yIJ99/ZdNKulMGpk3+07h73s7hjyMGGWuZv3gwIIoWOK+EGMTwvAtNy0JXGWyJb/ASdNq6blwwuhGM5dsXK5UWgMeV6QTmICR0/QdtXuDaI0RzE8EKF+ZaLpU4cpo"+
  115.     "bLX4rs0KdMK6ZUorXWMQASpu3UrHJtr1WpPcFEquxGATq+BzABbtgAAdxiIBVDlhM4Y+mU6aRnhZJrZbf1Y0K0nzqdo0opLQiATqJl7Q/Omla6Y3Oec3J5RpwbjDHBGDMAKCKeQBMxQOvQj"+
  116.     "bQMmxQG80SUXI+lZJwbtkiZOWHbQ8IUWW7wFMA5A+OMEQdjDACISIGICNCktVRSeSqM+rGMBkqpAETJXwMA90ECQGSWVcUAAAAASUVORK5CYII=";
  117. var img_big_transp  = img +
  118.     "/FRgAABHZJREFUeNp0lMtv1FUcxc+9v3t/j3l0Xm2npaXYkhKshVJBBFMSQiAaTXRlTDQaSdSdf4s740ZdmJCoGxcEDQsT0LhQCcQHFpRpqS10Hp2Zzvzev3vv1wViXMBZndUnn805DACkV"+
  119.     "xyfP/3CO/lq9VWVZguTyyfs8UMnsHn5c+R/+TJo3LrzcTOWF1zJrm+0oxSPiQUARqWBCv3vm43b30b9btvJj/hMiBt687ev5+j+VYupn1q72SLAKtWCvdYPMvMoGHtYJDBqgCUNDESxvGa7"+
  120.     "bjRTUGPnDlVev9sMvvju97bxbOtt1+bXiOjSWjPKHmkGQJY8+cZLT9Y/M8asBP6wGvr+RKcf1rf74dLte2Gr76c3GLAqLXaWMeb2A3XnsbCyJ46fPzp95rknatO1gnNquuSeMYSnh4Fe0Mo"+
  121.     "sJ9rUE2Xag0jtELAyWXWpH2R3HwWjRBntSf7kywv12ZmSh2enS87S5MjY4XqxvDCen8k7cqVoi1cAzA5iHSpjTk5UnN6IJzcGoQIAiH9hJjPYaAfZjtYGRARLcEyVHMyVXQQp4dhMxY4yM9"+
  122.     "nohpOrLf/oxVutr3aj7FQ5J/MALgEAf6hoW6wwlrcrBEAZQphp+CkhIUJiNCwO5B2GQ/UCXlucGD0+VfJ2A/VNmpkjzxyonP2/GUYccez0XG051kCgCC5/AB0SEKUKUUYAEWJFqBdtPl/L7"+
  123.     "b2y1l0fL+c+nd9TfN9zxIIAkJMWP1f0xHthqmtbgwSkNSyLI9EGXHHEmhBrgs0ZCIS1bohGNxwRgh+fmxzpONJif2wMppjjOAdreXZx72huf6cb08n9NVZ3BKqejYpnQzAgMQZ+oujPls/6"+
  124.     "scKmH2M7TIeuK+5MlD2xujn8udWPzossTag8PpKf3VNAYydkV9Z7mB3LgakhCoyTNtiKU309NmrJNzRjOxaYZ2G+ViqWPXnk1lYfrX50FQDEvn37mrY1uLyn4r11bLaCa3/1MIgz7AwS3O9"+
  125.     "FSmXUAGM3F2dLiyeeGkXBlSBDaHZjNPuR6fnZRc7YBUMExhjjoyP2u4dnSx/tHctjN0ixvZOAC4ZUG600tSbKXnpgujCttbHudSK4jsDqeh+NVvBDmOg3U2UaACCIyLR3k9s317tJ3ubOeM"+
  126.     "WDKwVcycE5WYyxSVda6PQibO1EEBbHrp9gu+dv9AP1AYDGfwvgnDOLs9h15HQcxQejKLEEMxAgWGSgjUYQJhgMYpAxGCsK/N0OO83AfKiJf8I4N0TEAEBYtqw65epBXSx1ulyZ1AToBRy2y"+
  127.     "cHJuSAikCbELAOXGjsRw4Ysaj7lloqJ/2LYbv1qwnCdAC28YnHMLldX7NGJZZL2YBjH2jeKaelxSMk5MUaSjBbKMJ0BjJMsOVYO5vm036mpKAyyON4krbWI/GDXsM6PJsuG0nEqhksHDBZY"+
  128.     "aAGQxDgDYCwYRYYIBA1msjiOhmngN7Io2qKH52gJYQnHEYzBllI63LIsBsbBiDjADdiDA2VEMMwARForMtrEBKRpnGiVZRpE5p8BAORgaeW/uJkgAAAAAElFTkSuQmCC";
  129.  
  130. var alarmSound = "data:application/octet-stream;base64,"+
  131.     "//uAxAAAA6QBc/QAACRUQu0/NZIICWYFd2cBkIlwJxYfn1AhOS5/5f/P/5/iN/8u//S2LGQbkFAAgAAAAAAEx/AAao4WFY+iAytfRdMVkAhsZAOhkDjwkbbZWmFl0mRpXvytOG2luIw1Z6b"+
  132.     "yPt6H2urgQns4a0CxzGUCGEJsSlT2l5EhzFHSiIky7CQgICLz0t+afZ3mcRhyG0hlORTCHH8RUr2u4XqXknUrLvpns0Z+XgwWkgY0tg6gF3X534ZjLN25ls0w1Tqbw2ilEZXLJyOQ9duT8p"+
  133.     "13mv/3Idic5hhn3+08Yxs5WsbtWk1vW9f/ce/n+Hecx3vP995bv7+xeh9g76Uq83W/////+au0vMv/9c7nyVxuL3GsQ47CpIDcPB35BXcv//////////////+b5j///////////////wIsS"+
  134.     "Qbaw1yEKuZ6uWRzZAQwAAEAAClP6ACxBNO8DILOgFPgZSwkDBhYhBSQgAj/+4DEEoAa3d9p+akAAiazrP+wgASoRIaEvusJEkRNw+yAni0JSLbD5FaEaRRE+LOApYbAICkMFhDLJMFgihFC"+
  135.     "wK8J4IaWRvJEkaEwkeJonyUKzkAFwGxoKTOjJFsmiXJtEihkorICMBCVEV4d46CmTRMk8Q0xJ1EiRqXSTIw6ocokCKopMjmRBlPds0QOstJHTU1O6C1up1fW6vfV+vUidLyiuXR3N/cySWY"+
  136.     "omKX/XZIwRGVOkQdAmzf///l1jSbKMv/WKkwOuS5GiKRAAgr9BAJIMAAOlNBGVxEq1TvC87sPxE4KlkYwkXBu7wL40b0Wr2g+RgJDDXWYJVkTeeap6iPs4WRbXhSVs44ptoPNLJKegayMQW"+
  137.     "Ie2aBjlNY//7+f4SqQo5BlpSDuUfZLGkXDjoduLWpeXi3g6ebsY3///HDd9/Q86zoNWmVJGWHWY3jqrIYiJFAgWSl+zWciOCsCL7LzKFOIdGyJRtUVl//7YMQOAA21lW3sDFVqH7Rt/YQWt"+
  138.     "B4hfbP9ugq0k/3/5F7FvGNu7ISvYkrZhFiMDX/+lciJYpkfTmd7HRtwo5V7qTuc9bKv/9HWepHktZXV3X3fZEZG1rR9rI5F//b0sylszUEk4GXzoAkiEILRU1ZcwKrD8DBEMEJhbpuLPnuW"+
  139.     "4/0Fx/t2RRRhcMNzkDgTMMWb1DFqW6DcSCjY1BDxxdA3Pe0ZKJYU315shrUl7Ue8P8u40u0QYRHQKJNogUinsWKcTlC5Z3Yw1kj33so1Vce9CNv08/p//fS1mQnvq+ZiOlzIRXD4uqkA63c"+
  140.     "edUFKe5YwMQEAGiXu2cGIgZoOyvYqkQCrXf/7YMQLABERn3PsGLdhhhvvvYMNvIS2ZblPPsAoYftdtUMdpeWt5U03HH5a3CqlWxdwQhByksIXUrQQett2Q6CEmV0Ydxnqrs+/WbaJ1JI0Kz"+
  141.     "LS0MfBRyoQ09ksmSp3O/r8s6lnu39PX29/6mklYks/rV2LNac6uPOKBZBIilBjCIkYWESCvrn9xFIjEAm2p+5UZXn+4ktRURoUFQQPSs5grIpFZzFDXIIlnt/SJpWHEguMZszc8edW092js"+
  142.     "/7jFfMbGaPndttgrSSdvLdwBzMJD9aV7QzHJucJ2///kNHf8cIAcQZRNmwZfLk5BjEAkmF8X1CyiYYIAkSHfKBDIXIZizp4yv/7YMQOAAzs+XfsMEvhyDHuPYYV5GOhPsdtPWX70s2QlpMc"+
  143.     "WJBKbQgPur3zvE35Mt91bLkOtglnPVlKeKCiSBhbSoMwhjvTtOtUNlMuyIli9/pcgkRv///Ox//w64xpVbW1LkAAIAAgHsFtQZFqIOm1ELlVuWiu9bz3T9DCbTN6XMmqdXvd+9c4KIcjMjm"+
  144.     "hcMnxwDsI/TlL7KdE2sMIJwEGIc6VWgiySkzELqj4wSBxEsJB1itJM0hWkdzz3vdpDSH2W6+5rf///+n///lFthAO8rW/23kyIgIbSeyHCjkFKBeIyYcYRJXAyGyw91JLZj8In69G0uIOuP"+
  145.     "9X+vaI7QmfSQekfP/7UMQZAA4tkXnsLFHh0J6ufYYZdDT2PvXZR93N3dUfp5+jfbFxV3L9i7/qFjl1sL9Nj4UXqSiIKrGHdHclFe0zr///////shnP9fT3qzUfkgrRcfXZqOoAAABAroltS"+
  146.     "EoR1e4hUIKAyJQR0GftDlhYXGJ0M6vtAXD8pOwfse1bWQggTDl5xoR3lh4ojfucSu7/d3ZQWNCiot/t5cZjv67Muik3/Rl/KS9lhLq1S2j42Z/n75UKBAs8APv//9bvqa1wsIjqGyIold+4"+
  147.     "U0AAAAD/+2DEA4AQwZFv7DBR4cAyLv2ElXQAdknSpAyqEDSQIUSiOrpc7xRGBqdz529AcIeNx1tt+PS4WvlusK1QSWDgO03OQDkuIBmJJ9+T9YYn52aT+Sk81lR8UN7t5LVMvTK2vfL/SB2"+
  148.     "dtGno3c060Zz1f/RZBmYrmN0faroqf///7/6NIl7EUxBBxAIzQooLJBAQ/taT3siHMgAACUX8kWTU1N4sIWHUATkway3BmjfxDsJEJZsU0CYWmn/PdySNGIVXQpDkUDGj0VmlK5+6qx5ziA"+
  149.     "0oBB5Ss7nEEbvNYwM45nU7MZRooWU7lGKyqb8l0RK/+n///7vvMn+/6t1IyKNQSNPf6c//+2DEAIAO/PV17BkS4aea7z2EoVzbc3EAAAlJ+pDAa6omAqvOBFo0rBShkbe6nn5hXfnYhBFh5"+
  150.     "2FyORVE+kzo/lWDIGLlxQPoQtK2nSvLR3dJKSWpAOh+J6dEq2iJWpmrRRYaYSpA9qQdVEK10o9qvip3vU8EX7nMIa//MsKHOpdNosIwVDwM0Q0/0b+1EsgAICaU+IEUhsNnJELVEZExk4WS"+
  151.     "tNdl2UJoTskJEmcGBOIQeZXJVHirqMYIcRzBrMQgxzFiPSZpIaiKsWgG8W1MY8VpLTFVwKbHMMsakhq40sUHhMNgc4ZSB1ipn//8y44z/XcbIl3fyacxAAAAJeZBhhHkJBH/+2DEB4AOQYd"+
  152.     "z7KBTocSwrn2EFqyoaKFWEhmUqFKWPZDGUHz2XKC9QwVCoJZ+/NsGgwNEtKuId6AseqENpSZMDodVzPP+/Vpbig9GuGoWneL3WEiK+DQ/WIQQwVFRiMhBnungQswZWPT/////++b/X/93YI"+
  153.     "tb05qvyHhEAAAABVhSVARpGIeAkQJU3q33fa03rvyuDLNPeppI48Qj1luzNMonBVm9OQsPFkAqLaGVbJIzxkw38jb0um02kdj36b9mlllIOPiELHi24CKR1LGnchr29ZnRtf/////6uj2//"+
  154.     "b1nSLIEYJRqCyq9/HZTAAACBPhCwwtQD4ZqDViFSNsGR9YjaS//+2DEDYAPhZ9z7CRR4cie7r2WDXyWNZlMbiMzTRSGohMLCMTGJhuCmzndznELMIEDGoDGEIgMrr192ePg3U9jWVCUJLTv"+
  155.     "LjClT9+VStikmYZeUqEjEABFbf9mBgIcAQz1vN////87FbU//znrPuudXdW+CKX03vyzKgAAAIB0IkSIgjuGMsUZBEYidaClEtptXlWIEUbpdKYdJOeu6fHhuVnIufmuXyz9XtUrY6NwmJ7"+
  156.     "fJwy81hnQzWmzIzsQJnZSf2yNm1IrRQ4s1xQOln/0v3wYYS0///mkHepaDyhQ0skWCjTxQXCias/XaFYAAAEA9kAqGvyZAZxILUQoQHM3YtOuSwD/+2DEDgAO3YVx7KC1oZCXLr2WFSzGJw"+
  157.     "NUmquUdyvS6CIamJuHYdu+R0TVW5krOhLGMKH31OvUr9V15J4oO7lEpoqvuKbptTz0iQwIU2Zqnfz1/cBSxEUOyv9vL3///6tucn/qtcw+5yCB0VAScmzXV5TOrgAAEorpF+SMcwxEFhQpU"+
  158.     "qPBduqyMYDnQJDYvri5rJBRvGxIjOj2OCy6qk63O6qKIIihla2zfIpxcaOD4YVJTCTuln7FEBWPFrVFhIkXAdqCwheHNf//9qI3Qx6MYVAra+/XiWcAAlpufQRigiIICLKQUFSJOpS3zUWl"+
  159.     "uxQSXkZldn61PUOMC2TuH/8zuNj0gCD/+1DEGIBOoY957JhR4bwZ7fmWDTgZJTHu51bv//vT76bErUdZF93v/r5/7iTz3ZrBtelMRTOIIooIYZ02eq6mbt/////8zbFX3RZ0qejKjGZAIju"+
  160.     "ggEQ9jN+nZUUAAJwVybG4LqB8yxwMKz0RiS1jQOHw8OtkRcV6kdcFJgbliT2x12/m/bcWLcNh/UWUKCzEmRl+yCAOj2k6FOFncjNDY8Fmklo5bAAM6MHQVUPP7nHgqG///yyVje54KiJqA+"+
  161.     "sgZA7HqIq/jL64Y3QAABBJ//tgxAQADsGHc+wwqeG4sO69lgk8fMkaMoHxHNoqUeUoOl4l41gYsE42JbLsLyd37yt57si2Cae1TkozWrVr03Lq5KpGoPFw6pujqX6Krqoku0eNO6ILlOgQC"+
  162.     "IwzGQ1Ts/0uQVIYm7mXNde6J//f06ucrm/oqZnMpnFR9CiDjgwzDgze2miFEiAJRXzDoRcwMqdJAOz1CyH2fvcB8eWmTE+MSYvPVdl8D1bUZp+X9ooVLZySJlq2V+l0K7BmM7qzKsjEarlY"+
  163.     "nTTckhwEUlC3Y90UlWX8spDHMyN71ev/6f1rRzrqf/e6WpLuGASB8HL0y9XM2ZeUNSAcan8IXihGoIJkKlpK//tgxAmADvmPd+wgU+HIsS79hIltIMOUPcNzqCJuxG4xf+AZRTUVDduV5gc"+
  164.     "ts4wJAvh8Xcf9xtwsiIpRZpIrETPu7uQSbDKNR6+OKqLOuFz76eID+mFaShpMVXp+COYl5tkPW/+/9OnvSczOdf7MtS5OtAkroGIi769/9iGUVAJRufUJQX2FuDVi7oigWTbOsAulm8zA+B"+
  165.     "zIj1CzWJ4sntRpVSKRprCOHLKvNgRgdlqzVSc8IHKo51IjpuU8yoisdHBuV2EkDqCFuRxVmaum9lFmIrX/////s7k6Nf6rDIqEdmOVUKgyNTLosCTPqJgxAACSbm1CmgUNNo0NbXUDA0Yiw"+
  166.     "K2Z//tgxAyAD3Gfa+yMtwn2MKv9kwrInsFLtzhEgoKCtMX9f+8+61qOtfdZvm97nXGg2xMZtgxbKqnpSB7jB0vd7ReVB9J4Cu6MGEB0Mw7VAghiEIRqMSbtvKc56f/////vIQhaa806vU53"+
  167.     "OZRc7GFEQ4oJmMclh7ka+odDAAAAgAyExhBi84wDrKLPKO0gEBXhPNNmYFf+Dn+d5u2Fqdk+Oqan1BgUGh1hwODQCr9f2J1PWswit2F0fvmoSqvBBTMme5newNhVLm2cilI7BqyFspUUEqr"+
  168.     "fmPQ1byv/+n+//6FpaZyEN0szPdWWVbRQsDo3PSyLD2vf64hUQgBjberJABdIGuyw//tgxAgADhGFb+wgUenMsW39gYq11oVqSQEhtzVTgZ5YkyjGAcbmd2gv05jYwAwCoUIEAczX8aGNaH"+
  169.     "8I9O68Z6zddrU20F9RDM1d91bxA9qVhK0TFKUSKVg7OeTR6ylKMQU+Tt7V///+lVltv7JItFWncZLyXO25dEUgRmbftNF0EIheXDRVL9DQH4mVeSduEViEYhV/kluZ5a5ndieTzX4dBqrsZ"+
  170.     "xRFBHod0+KQV6EBGhBQguSrxynWJ+xG6SvMXZoZltNTJ37f56vcDNDlVEbf0yv///bJy79mciULc1UQ9xglITcFrYV/uEYDIAAMkn8FGS8xpcZVEGmRKjkkZkBkp0CG//tgxA4ADlTDY+ww"+
  171.     "acnPLG19hIlthHi6kaemPo9Ko/DMvC88RNXYh9tHWuzPnyGcKM8IWBl5cQYmK55mZZGfgiooKuY7c8aXAlyW7MfDSAzujQ7w3L///OBPSUe8qWlUfu2uJ0FH+UsCnb/mf1QxsZADJE9YO9E"+
  172.     "DjLsGkVrV2WSUPbCzOKKmDAOxERKlCCbdnhA9z+ekrsy6dljdFnggID2NeR4Upyo+UG5SFOx2Y/VqK1lRiI4Q5hQMwIehBTCJzLrkHASGfZfJ7N6r7/80qH25mh4x/EyJ5ZPOz1Xrv6rf2Y"+
  173.     "Y4QQDtjv9A9Gnm6A8eARgoTiaby6thcEwqrzLte32ChQK8//tgxBKADlWLa+w8ZWHVLm09hg01HAVJISJBRxmIG5BvsOsqkVOOQL1V9SZCM6Rc9fQ+u65w2rCVYIsQQoC0VPM4SJDUz9/89"+
  174.     "/9fX/Tn+nyX3emzfbspX6fa2cFzCoEcI51N90OjSQgHdXPqBBl9jwPBwQQBYVdlEzEXD8EpUfPhIgqhHQsSupq/mavLhb/u8hQWnVzmZIbVXCHrnoQtmPZVPYlNWKd/5bN9jQdyCoCY1gM3"+
  175.     "0Js7pDMjDZVzLll/LL//8+wvzl/ukz/SFrMd3EGjjEiJ/ub7z9pmaDEArrL9ZSPcE0i60a0pCZ733W5tI0FB3ZJAq4VriSPZ76jBMiT3f3UA//tQxBaADe2DaewkS2ncM+y9hgz1fzulwdU"+
  176.     "R1UqEOqIrAhgTJPR3MJVzpO6KyKh7hWKSbCLSxSNB41iOjr3tlfZJzehLro3+2h1g9tS/fN1Epgs9XmzEN70IsKRgZdHPacElzi1A98BCQdcdopOCEDb5mWS1VkrmY+sll38eeXFH/EgRPs"+
  177.     "FDUqx12q4KESrzGkdAtSG8DVGVaYmBYdtbSrn84ycHBD3Uuf55sJFEMRQnp0yf1LkiHn//P//+2WT/8+r8Hh7/mfNSfYiKGJSqbv/7cMQAgA+dj1/sDLfp1jHrfaYM9PtDVBICZI5dRRyAU"+
  178.     "yvcUtKIKl4UcIkpk411/IDjX0UxK7eFm5S1LWOqPc7Z7Vw7osyJvsJSjxIpLGRjhmt9WcnFSEjLz3kCkFJwfYBvkSmQk2HzIvKa6aneGZfnG6x9dFkYtmn9kH1i767dVSiIVUVchHaGEUOq"+
  179.     "KpjN4hdXasiGICDG05IAZIcJByJrLQg4I6qWgGwiGTKY5A8V4DpK63ZfHu7QkkptTb8ZypRtUVzVWEoZeLkyXhmoKRSpbTn/7hvSr3WtWFOYLNJA55KR45ORL5MxHeNuXP8+pw8pWa+S6Wc"+
  180.     "1+EZvDOIxll40Un6KOaU1n8lqdDMG7tZdzEBoZ1anA5xfZc5AVcruuNF7kmcqm7QyTl3QvH3PiLITZzTrJfxua0P/+1DEGQAPKY9h7Bix6cSvaz2WDVVj7TTMn4/fYn5CQq62LfTWZOG13Z"+
  181.     "vCToOjubSUqjZzo/N0+tVEaon6LrdkUo+/u7RVi2+ZqGvQWIQo5ild5lQIsJzC8+mE4m810ZmIgDjaVkbYARE1z+q0FgtcSsbII41JyFwQbxlAvc5VQI3nA6BDSGehEZOpnVQJWpelkITbV"+
  182.     "rVUi3Mzp7+ebLIVpyFgobZTYvLv+00nCNURwA9TarCX7TIjnx49/83zM/y79PO7Qx+dpSdKU54nSs/8//tgxAEADnjXW+0waOnjMWs9h4zlZ0dDBytyWw1CkwQE4KowJ4CihVWAASvFvN+G"+
  183.     "JE0iNj8VyocrKLt2QpYpRwVIjHY1Iq+1TDXnqbwvkdzY7qYJR4dBk57xiDXc1JVzFli0O++PygtDVMuwu2MM4lMlyEm7Avl29fUvu1+8O2xrJGb/n9du7uWR3NAbscltWqAjCbYAaCNBByX"+
  184.     "ZGiSwp7Ip+f6NhyPGO/dBgnuvQxhvIhLUGRijIZyEkbptyhiPrvUpBl4e8I2EuVU0oR1j6fFKBR22JS6XHciUz6m28cRZoju70ZCRHfMnhpzcuZXRD79Wn8U6R++h1BaPTMGiepu4NqYE//"+
  185.     "tgxAKADgkxU+wwammzGen9hgzlJJtNuM2Ef0AtaQlUh8W/aNMN0ZM0gSjIFLMlcNaQuXJgdMBd0ahQpzqs58I8iUy4bVk+qRriHw0CNdhE+ZE0FhDm0FohJsTVfbOfs2vMyvz/JjTpUalvA"+
  186.     "wXH3jGF8cjva5+u26nsdxp9f+nnKdVNTIEjCSkiRYYsmIBwwsClWCb8hgDATPWBh77qvcbUEolOrsHCibNKtko66feYMYxIYEDGVwu5wowx25KsL/P6xZehsRilMG/WS1Pf5HMcV0bu/p5i"+
  187.     "H6tNen2+3/Ul0rvyzRUlD+9t9v6le5hWRSIAYWYSij2Byj4CYzIUrX19VNc9//tgxAwADcUPScwwaumwG+k5hI0VODzRVWmDK1dFFXEzzaWGq04vClhnCU7mhohpfQjUVsaGpuRSsZk8MyI"+
  188.     "zPaHPfDEpxNvMs5SSysrzqpmRCPJWCva2t9dX/6E5at1ueNXtG/35covQteFNTMISGQWyzRZVSBUaxBjQ4ZU6bsRVsBoRgMvT0FhIhBQale6imMUOMMGO0My3mtw5bXBifujMZd5q9KF+G2"+
  189.     "4ap/mRBkIlM02yFd2oxwKfcBFO+qfWWjriFvpig+PAppu//T++Xrbq/1pcsv7VepqIZVULoWYeqghM5DUctE7SWaFyDrJyQF6pwRj5+zLklYUvBypGEBChyqFh//tgxBaADkWfR8wwaOnmt"+
  190.     "Gf9gw44lDmxOhUzD5LE9lpHCv9PbPeIghFpk+q7KXD3SXKzQrqRZKRxDdYjkxJXLYy6UPLsP53mn8n+t7b9/K5Hl/0m6XLCUw7zpEsiopEASRSiai7yB4i6gcsGJUCX60hsrUZPATyw0/VJ"+
  191.     "SZVqutJb8jFvclS0M9Vn87or89TZs74mY5cTXqfO7jvUF0w95x6zWt0fOY0z2hEfzl5rmAhjwsVy6OONDjMZ7X//87J9LMvNfLfI8/lu3M51dShysVXCHBlZqGZkQxCTTjkCEMuAiwAlHUv"+
  192.     "nASj7S29hbyz7+znakagcEYrZdEO46+reOBtXpKRW//twxBiADuWjQfWEAALlI2c/MvAAzT1FJwYfSxS8VTXa8DuKofjbqrRY65v5uri2mFfS5iab5S++o9de7/n/f40/mu9opevueOH476"+
  193.     "uofRevuJiv65q5eJmKxjKju8K5sxIxmscVr1kaTBQLQiao5DnCQAyAgxqVXhbhXYYQmK6TV2BM7TiVO5SrxR0QpKnMfr5RlomE4xppTwZcJJxQbiciVVKgSa7fNC+qWeC+UacX1mymguL1d"+
  194.     "I8yVldEqqu2KZLzPGJbjw2VzTdFOkILIp2BkkY4jXCRDBA0sQswYMGDFwrlczUrm2t6pne65mx9V986i+NYkGhMpAIDQfmHLmxC5jix4kQW8UFRfQhI9H/5Z//9Km3NrpPr47bZJJa0kUAH"+
  195.     "qoVrKyvnyBEODlHzBbWgqSDaYSfLoP/7YMQSABTBLTW494ABmxNmdxjAAB/NE/kuhbmphdBOQ0XiGopwen7MkCsJar1W1qhbR7AzKU1iwmjRMq1XTwYLc3ba0+/nVD9040aHOGsoc+YZXiv"+
  196.     "v3r+sS8VRu6RMbXL5Wtz3wpvPaFLH38WvTe8S01muN6tvV66zX5x97+90x8YxGEJ4JHQaSpcxKeoclKj0k3Qj/+1Ftx26XX+f761uNsAgCnVrEdzQ5afA/ShkfD/gjiXtUZINxEJkDK0GGa"+
  197.     "oO46nLS4yXhQTDwSzM/A4JByYnuef3fA4eIiWfr+llpcZMrZuvfmCADD4SDs8fWfDG9YKiI9HOgg7/8EJOYFAoHAwGA//7EMQDgAk4zaG41vAAAAA0g4AABIGAYCAIAACojw8C6JngXQX/w"+
  198.     "AmgRrwR0ewnv5BLqjP/JIaQtJ0YX/xmDkjxSMhhv/zZaLTIvf/+Yh1YK//JEmf/6qpMQU1FMy45OC4yqqqqqqqq//sQxAgDwAABpAAAACAAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  199.     "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xDEMYPAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  200.     "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMRbA8AAAaQAAAAgAAA0gAAABKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  201.     "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxISDwAABpAAAACAAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  202.     "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=";
  203.  
  204.  
  205. /*******************************************************************************************************************************
  206.  * Graphic filters
  207.  *******************************************************************************************************************************/
  208. if(uw.location.pathname === "/game/index"){
  209.     $('<svg width="0%" height="0%">'+
  210.       '<filter id="GrayScale">'+
  211.       '<feColorMatrix type="matrix" values="0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0">'+
  212.       '</filter>'+
  213.       '<filter id="Sepia">'+
  214.       '<feColorMatrix type="matrix" values="0.343 0.669 0.119 0 0 0.249 0.626 0.130 0 0 0.172 0.334 0.111 0 0 0.000 0.000 0.000 1 0">'+
  215.       '</filter>'+
  216.       '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>'+
  217.       '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>'+
  218.       '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>'+
  219.       '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>'+
  220.       '</svg>').appendTo('#ui_box');
  221. }
  222. /*******************************************************************************************************************************
  223.  * Language version (german and english)
  224.  *******************************************************************************************************************************/
  225. if(!(uw.location.pathname === "/game/index")){
  226.     LID = uw.location.host.split(".")[1];
  227. }
  228. // English => default
  229. if((LID !== "de") && (LID !== "fr")&& (LID !== "ru")){ LID = "en"; }
  230.  
  231. if(PID == 84367){ LID = "de"; }
  232.  
  233. // Language Array
  234. var LANG = {
  235.     de : {
  236.         set : {
  237.             txt: {
  238.                 dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
  239.                 act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
  240.                 prv: "Vorschau einzelner Funktionen:",
  241.             },
  242.             // opt: [label, tooltip]
  243.             bir: [ "Biremenzähler",        "Zählt die jeweiligen Biremen einer Stadt und summiert diese. (Anzeige im Minimap-Bullauge links oben)" ],
  244.             sml: [ "Smileys",           "Erweitert die BBCode-Leiste um eine Smileybox" ],
  245.             str: [ "Einheitenstärke",  "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu" ],
  246.             trd: [ "Handel",            "Erweitert das Handelsfenster um einen Prozentualer Handel, einen Rekrutierungshandel und Limitmarker für Stadtfeste" ],
  247.             cnt: [ "EO-Zähler",            "Zählt die ATT/UT-Anzahl im EO-Fenster (bisher nur bei eigenen Eroberungen)" ],
  248.             way: [ "Laufzeit",          "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an" ],
  249.             wwc: [ "Weltwunder",        "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)" ],
  250.             sim: [ "Simulator",         "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox" ],
  251.             spl: [ "Zauberbox",         "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)" ],
  252.             mov: [ "Aktivitätsboxen",  "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)" ],
  253.             pop: [ "Popup",             'Ändert Gunst-Popup' ],
  254.             tsk: [ "Taskleiste",        'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start' ],
  255.             irc: [ "Chat",              "Ersetzt den Allianzchat durch einen IRC-Chat" ],
  256.             bbc: [ "BBCode-Leiste",     "Erweitert BBCode-Leiste um ein automatisches DEF-Formular" ],
  257.             com: [ "Vergleich",         "Fügt Einheitenvergleichstabellen hinzu" ],
  258.             twn: [ "Stadticons",        "Fügt Stadttyp-Icons zur Stadtliste hinzu" ],
  259.             con: [ "Kontextmenu",       'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
  260.             sen: [ "Abgeschickt",       'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
  261.             tov: [ "Stadtübersicht",   'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
  262.             scr: [ "Mausrad",           'Man kann mit dem Mausrad die Übersichten wechseln'],
  263.            
  264.             sav_btn: "Speichern", don_btn: "http://s7.directupload.net/images/140131/ctahnu2q.png",
  265.         },
  266.         sml : { std: "Standard ", gre: "Grepolis ", nat: "Natur ", ppl: "Leute ", oth: "Sonstige " },
  267.         uni : "Verfügbare Einheiten",
  268.         bbc : {
  269.             ttl: "Übersicht: Stadtverteidigung", inf: "Informationen zur Stadt:", mov: "Truppenbewegungen:", dev: "Abweichung", but: "Einfügen",
  270.             sel: [ "Detailierte Landeinheiten",  "Premiumboni", "Silberstand", "Truppenbewegungen" ]
  271.         },
  272.         wwc : { leg: "WW-Anteil", stg: "Stufe", tot: "Gesamt"},
  273.         sim : { str: "Einheitenstärke", los: "Verluste", mod: "ohne Modifikatoreinfluss" },
  274.         com : {
  275.             dsc: "Einheitenvergleich", hck: "Schlag", prc: "Stich", dst: "Distanz", sea: "See", att: "Angriff", def: "Verteidigung", spd: "Geschwindigkeit",
  276.             bty: "Beute (Rohstoffe)", cap: "Transportkapazität", res: "Baukosten (Rohstoffe)", fav: "Gunst", tim: "Bauzeit (s)"
  277.         },
  278.         trd : { uni: "Ressourcenverhältnis eines Einheitentyps", rat: "Anteil an der Lagerkapazität der Zielstadt", prc: "Prozentualer Handel"},
  279.         sen : { rst: "Zurücksetzen", lab: "Abgeschickt" },
  280.         con : "Selektieren"
  281.     },
  282.     en : {
  283.         set : {
  284.             txt: {
  285.                 dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
  286.                 act: "Activate/deativate features of the toolset:",
  287.                 prv: "Preview of several features:",
  288.             },
  289.             // opt: [label, tooltip]
  290.             bir: [ "Bireme counter",    "Counts the biremes of a city and sums these" ],
  291.             sml: [ "Smilies",           "Extends the bbcode bar by a smiley box" ],
  292.             str: [ "Unit strength",     "Adds unit strength tables in various areas" ],
  293.             trd: [ "Trade",             "Extends the trade window by a percentage trade, a recruitment trade and limit markers for city festivals" ],
  294.             cnt: [ "Conquests",         "Counts the attacks/supports in the conquest window (only own conquests yet)" ],
  295.             way: [ "Troop speed",       "Displays improved troop speed in the attack/support window" ],
  296.             wwc: [ "World wonder",      "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  297.             sim: [ "Simulator",         "Adaptation of the simulator layout & permanent display of the extended modifier box" ],
  298.             spl: [ "Spell box",         "Compressed sliding & magnetic spell box (position memory)" ],
  299.             mov: [ "Activity boxes",    "Improved display of trade and troop activity boxes (position memory)" ],
  300.             pop: [ "Popup",             "Changes the favor popup" ],
  301.             tsk: [ "Taskbar",           "Increases the taskbar and minimizes the daily reward window on startup" ],
  302.             irc: [ "Chat",              'Replaced the alliance chat by an irc chat. (FlashPlayer required)' ],
  303.             bbc: [ "BBCode bar",        "Extends the bbcode bar by an automatic defense form" ],
  304.             com: [ "Comparison",        "Adds unit comparison tables" ],
  305.             twn: [ "Town icons",        "Adds town type icons to the town list" ],
  306.             con: [ "Context menu",      'Swaps "Select town" and "City overview" in the context menu'],
  307.             sen: [ "Sent units",        'Shows sent units in the attack/support window'],
  308.             tov: [ "Town overview",     'Replaces the new town overview with the old window style'],
  309.             scr: [ "Mouse wheel",       'You can change the views with the mouse wheel'],
  310.            
  311.             sav_btn: "Save", don_btn: "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif",
  312.         },
  313.         sml : { std: "Standard ", gre: "Grepolis ", nat: "Nature ", ppl: "People ", oth: "Other " },
  314.         uni : "Available Units",
  315.         bbc : {
  316.             ttl: "Overview: Town defense", inf: "Town information:", mov: "Troop movements:", dev: "Deviation", but: "Insert",
  317.             sel: [ "Detailed land units",  "Premium bonuses", "Silver volume", "Troop movements" ]
  318.         },
  319.         wwc : { leg: "WW Share", stg: "Stage", tot: "Total"},
  320.         sim : { str: "Unit strength", los: "Loss", mod: "without modificator influence" },
  321.         com : {
  322.             dsc: "Unit comparison", hck: "Blunt", prc: "Sharp", dst: "Distance", sea: "Sea", att: "Offensive", def: "Defensive", spd: "Speed",
  323.             bty: "Booty (resources)", cap: "Transport capacity", res: "Costs (resources)", fav: "Favor", tim: "Recruiting time (s)"
  324.         },
  325.         trd : { uni: "Resource ratio of an unit type", rat: "Share of the storage capacity of the target city", prc: "Percentage trade"},
  326.         sen : { rst: "Reset", lab: "Sent units" },
  327.         con : "Select town"
  328.     },
  329.     fr : {  
  330.         set : {  
  331.             txt: {  
  332.                 dsc: "DIO-Tools offres certains écrans, une boîte de smiley, les options <br>commerciales, des changements à la mise en page et d'autres choses.",  
  333.                 act: "Activation/Désactivation des fonctions:",  
  334.                 prv: "Aperçu des fonctions séparées:",  
  335.             },  
  336.             // opt: [label, tooltip]  
  337.             bir: [ "<nobr>Compteur de birèmes&nbsp;&nbsp;</nobr>", "Totalise l'ensemble des birèmes présentent en villes et les résume. (Remplace la mini carte dans le cadran)" ],  
  338.             sml: [ "Smileys",               "Rajoutes une boite de smilies à la boite de bbcode" ],  
  339.             str: [ "Force unitaire",        "Ajoutes des tableaux de force unitaire dans les différentes armes" ],  
  340.             trd: [ "Commerce",              "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],  
  341.             cnt: [ "<nobr>Compteur conquête</nobr>",       "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête (valable que pour ses propre conquêtes)" ],  
  342.             way: [ "<nobr>Vitesse des troupes&nbsp;&nbsp;</nobr>",  "Rajoutes le temps de trajet avec le bonus accélération" ],  
  343.             wwc: [ "<nobr>Merveille du monde</nobr>",   "Compteur de ressource et calcul d'envoi + bouton précédent et suivant sur les merveilles finies(ne peut être désactivé pour le moment)" ],  
  344.             sim: [ "Simulateur",            "Modification de la présentation du simulateur et affichage permanent des options premium" ],  
  345.             spl: [ "<nobr>Boîte de magie</nobr>",      "Boîte de sort cliquable et positionnable" ],  
  346.             mov: [ "<nobr>Boîte d'activité</nobr>",       "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)" ],  
  347.             pop: [ "Popup",             'Change la popup de faveur' ],  
  348.             tsk: [ "<nobr>Barre de tâches&nbsp;&nbsp;</nobr>",     "La barre de tâches augmente et minimise le fenêtre de bonus journalier" ],  
  349.             irc: [ "Chat",                  "Remplace le chat de l'alliance à travers un chat IRC. (FlashPlayer requis)" ],  
  350.             bbc: [ "<nobr>Barre de BBCode</nobr>",      "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique" ],  
  351.             com: [ "Comparaison",           "Ajoutes des tableaux de comparaison des unités" ],  
  352.             twn: [ "<nobr>Icônes des villes</nobr>",       "Ajoutes desicônes de type de ville à la liste de ville" ],  
  353.             con: [ "Menu contextuel",       'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
  354.             sen: [ "Unités envoyées",     'Affiche unités envoyées dans la fenêtre attaque/support'],
  355.             tov: [ "Aperçu de ville",      "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
  356.             scr: [ "Molette de la souris",  'Avec la molette de la souris vous pouvez changer les vues'],
  357.            
  358.             sav_btn: "Sauver", don_btn: "http://s7.directupload.net/images/140131/ctahnu2q.png",  
  359.         },  
  360.         sml : { std: "Standard ", gre: "Grepolis ", nat: "Nature ", ppl: "Gens ", oth: "Autres " },  
  361.         uni : "Unités disponibles",  
  362.         bbc : {  
  363.             ttl: "Aperçu: Défense de ville", inf: "Renseignements sur la ville:", mov: "Mouvements de troupes:", dev: "Différence", but: "Insertion",
  364.             sel: [ "Unités terrestres détaillées",  "Bonus premium", "Remplissage de la grotte", "Mouvements de troupes" ]
  365.         },  
  366.         wwc : { leg: "Participation", stg: "Niveau", tot: "Total"},
  367.         sim : { str: "Force unitaire", los: "Pertes", mod: "sans influence de modificateur" },
  368.         com : {  
  369.             dsc: "Comparaison des unités", hck: "Contond.", prc: "Blanche", dst: "Jet", sea: "Navale", att: "Attaque", def: "Défense", spd: "Vitesse",  
  370.             bty: "Butin", cap: "Capacité de transport", res: "Coût de construction", fav: "Faveur", tim: "Temps de construction (s)"
  371.         },
  372.         trd : { uni: "Ratio des ressources d'un type d'unité", rat: "Part de la capacité de stockage de la ville cible", prc: "Commerce de pourcentage"},
  373.         sen : { rst: "Remettre", lab: "Envoyée" },
  374.         con : "Sélectionner"
  375.     },
  376.     ru : {
  377.         set : {
  378.             txt: {
  379.                 dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
  380.                 act: "Включение/выключение функций:",
  381.                 prv: "Примеры внесённых изменений:",
  382.             },
  383.             // opt: [label, tooltip]
  384.             bir: [ "Счётчик бирем",     "Показывает число бирем во всех городах" ],
  385.             sml: [ "Смайлы",          "Добавляет кнопку для вставки смайлов в сообщения" ],
  386.             str: [ "Сила отряда",     "Добавляет таблицу общей силы отряда в некоторых окнах" ],
  387.             trd: [ "Торговля",          "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
  388.             cnt: [ "Завоевания",      "Отображение общего числа атак/подкреплений в окне завоевания города (only own conquests yet)" ],
  389.             way: [ "30% ускорение",        "Отображает примерное время движения отряда с 30% бонусом" ],
  390.             wwc: [ "Чудо света",       "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  391.             sim: [ "Симулятор",            "Изменение интерфейса симулятора, добавление новых функций" ],
  392.             spl: [ "Заклинания",      "Изменяет положение окна заклинаний" ],
  393.             mov: [ "Перемещения",        "Показывает окна пересылки ресурсов и перемещения войск" ],
  394.             pop: [ "Благосклонность",    "Отображение окна с уровнем благосклонности богов" ],
  395.             tsk: [ "Таскбар",            "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру" ],
  396.             irc: [ "Чат",                'Замена чата игры на irc-чат' ],
  397.             bbc: [ "BB-коды",           "Добавляет кнопку для вставки в сообщение отчёта о городе" ],
  398.             com: [ "Сравнение юнитов",   "Добавляет окно сравнения юнитов" ],
  399.             twn: [ "Типы городов",       "Добавляет иконку к городу в списке" ],
  400.             con: [ "Context menu",      'Swaps "Select town" and "City overview" in the context menu'],
  401.             sen: [ "Sent units",        'Shows sent units in the attack/support window'],
  402.             tov: [ "Обзор Город",     'Заменяет новый обзор города с старом стиле окна'],  // ?
  403.             scr: [ "Колесо мыши",     'С помощью колеса мыши вы можете изменить взгляды'], // ?
  404.            
  405.             sav_btn: "Сохраниить", don_btn: "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif",
  406.         },
  407.         sml : { std: "Standard ", gre: "Grepolis ", nat: "Nature ", ppl: "People ", oth: "Other " },
  408.         uni : "Доступные войска",
  409.         bbc : {
  410.             ttl: "Обзор: Отчёт о городе", inf: "Информация о войсках и постройках:", mov: "Перемещения:", dev: "Отклонение", but: "Вставка",
  411.             sel: [ "Детальный отчёт",  "Премиум-бонусы", "Серебро в пещере", "Перемещения" ]
  412.         },
  413.         wwc : { leg: "WW Share", stg: "Stage", tot: "Total"},
  414.         sim : { str: "Сила войск", los: "Потери", mod: "без учёта заклинаний, бонусов, исследований", att: "Обычная атака"},
  415.         com : {
  416.             dsc: "Сравнение юнитов", hck: "Ударное", prc: "Колющее", dst: "Дальнего боя", sea: "Морские", att: "Атака", def: "Защита", spd: "Скорость",
  417.             bty: "Добыча (ресурсы)", cap: "Вместимость транспортов", res: "Стоимость (ресурсы)", fav: "Благосклонность", tim: "Время найма (с)"
  418.         },
  419.         trd : { uni: "Resource ratio of an unit type", rat: "Share of the storage capacity of the target city", prc: "Percentage trade"},
  420.         sen : { rst: "Сброс", lab: "Отправлено" },
  421.         con : "выбирать"
  422.     }
  423. };
  424.  
  425. /*******************************************************************************************************************************
  426.  * Settings
  427.  *******************************************************************************************************************************/
  428. // (De)activation of the features
  429. var options, options_def = {
  430.     bir : true, // Biremes counter
  431.     sml : true, // Smileys
  432.     str : true, // Unit strength
  433.     trd : true, // Trade options
  434.     way : true, // Troop speed
  435.     cnt : true, // Attack/support counter
  436.     sim : true, // Simulator
  437.     spl : true, // Spell box
  438.     mov : false,// Activity boxes
  439.     tsk : true, // Task bar
  440.     irc : true, // IRC-Chat
  441.     pop : true, // Favor popup
  442.     wwc : true, // World wonder
  443.     bbc : true, // BBCode bar
  444.     com : true, // Unit comparison
  445.     twn : true, // Town icons
  446.     con : true, // Context menu
  447.     sen : true, // Sent units
  448.     tov : true, // Town overview
  449.     scr : true, // Mausrad
  450. };
  451.  
  452. // Get options
  453. if(uw.location.pathname === "/game/index"){
  454.     // join GM variables and delete old ones (transitional)
  455.     var GM_list = GM_listValues(), op;
  456.     GM_list.forEach(function(op) {
  457.         if(op.substring(0,3) === "set"){
  458.             GM_deleteValue(op);
  459.         }
  460.     });
  461.    
  462.     // Check default options
  463.     options = JSON.parse(GM_getValue("options", JSON.stringify(options_def)));
  464.    
  465.     for(var opt in options_def){
  466.         if(options_def.hasOwnProperty(opt)){
  467.             if(options[opt] == undefined) {
  468.                 options[opt] = options_def[opt];
  469.             }
  470.         }
  471.     }
  472. }
  473.  
  474. //console.log(options);
  475. var firstLoad = true;
  476. function loadSettingImages(){
  477.     if(firstLoad){
  478.         $('<style type="text/css"> .dio_tools_bg { background:url(http://s1.directupload.net/images/140422/4hotfxip.png) 320px 10px no-repeat;} </style>').appendTo('head');
  479.        
  480.         var bg_medusa = new Image(); bg_medusa.src = 'http://s7.directupload.net/images/140202/dz8ziycu.png';
  481.        
  482.         var img_bi = new Image(); img_bi.src = 'http://i.imgur.com/94m7Gg8.png';
  483.         var img_sm = new Image(); img_sm.src = 'http://i.imgur.com/Y3BsENb.png';
  484.         var img_un = new Image(); img_un.src = 'http://i.imgur.com/LXkSxsS.png';
  485.        
  486.         firstLoad = false;
  487.     }
  488. }
  489.  
  490. // Add DIO-Tools to grepo settings
  491. function settings() {
  492.     var wid = $(".settings-menu").get(0).parentNode.id;
  493.    
  494.     if(!$("#dio_tools").get(0)){
  495.         $(".settings-menu ul:last").append('<li id="dio_li"><img id="dio_icon" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif"></div> <a id="dio_tools" href="#"> DIO-Tools</a></li>');
  496.        
  497.         if($('#RepConvSetupLink').get(0)) { $('#RepConvSetupLink').before('<img id="grc_icon" src="http://grepolis.potusek.eu/img/octopus.png"> '); }
  498.        
  499.         $('#dio_icon').css({ width: '15px', verticalAlign: 'middle', marginTop: '-2px' });
  500.        
  501.         // icon adaption of other scripts
  502.         setTimeout(function(){
  503.             $('#quackicon, #grc_icon').css({
  504.                 width: '15px',
  505.                 verticalAlign: 'middle',
  506.                 marginTop: '-2px'
  507.             });
  508.             $('#quackicon').css({
  509.                 height:'12px'
  510.             });
  511.         }, 1);
  512.     }
  513.    
  514.     $(".settings-link").click(function () {
  515.         $('.section').each(function(){
  516.             $(this).get(0).style.display = "block";
  517.         });
  518.         $('.settings-container').removeClass("dio_tools_bg");
  519.         if($('#dio_settings').get(0)) { $('#dio_settings').get(0).style.display = "none"; }
  520.     });
  521.    
  522.     $("#dio_tools").click(function () {
  523.         if($('.email').get(0)) { $('.settings-container').removeClass("email"); }
  524.        
  525.         $('.settings-container').addClass("dio_tools_bg");
  526.        
  527.         //console.log(GM_info);
  528.        
  529.         if(!$('#dio_settings').get(0)){
  530.             $('.settings-container').append(
  531.                 '<div id="dio_settings" class="player_settings section"><div class="game_header bold">'+
  532.                 '<a href="http://adf.ly/eDM1y" target="_blank" style="color:white">DIO-Tools (v'+ GM_info.script.version +')</a></div>'+
  533.                 '<p>'   + LANG[LID].set.txt.dsc + '</p>'+
  534.                 '<p class="bold"><u>'+ LANG[LID].set.txt.act + '</u></p>'+
  535.                 '<table width="100%" style=" font-size: 0.8em;"><tr><td width="24%">'+
  536.                 '<div id="bir" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.bir[0] +'</div></div><br><br>'+
  537.                 '<div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.sml[0] +'</div></div><br><br>'+
  538.                 '<div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.str[0] +'</div></div><br><br>'+
  539.                 '<div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.bbc[0] +'</div></div><br><br>'+
  540.                 '<div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.con[0] +'</div></div><br><br>'+
  541.                 '</td><td width="21%">'+
  542.                 '<div id="trd" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.trd[0] +'</div></div><br><br>'+
  543.                 '<div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.cnt[0] +'</div></div><br><br>'+
  544.                 '<div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.way[0] +'</div></div><br><br>'+
  545.                 '<div id="wwc" class="checkbox_new disabled"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.wwc[0] +'</div></div><br><br>'+
  546.                 '<div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.sen[0] +'</div></div><br><br>'+
  547.                 '</td><td width="20%">'+
  548.                 '<div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.sim[0] +'</div></div><br><br>'+
  549.                 '<div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.spl[0] +'</div></div><br><br>'+
  550.                 '<div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.tsk[0] +'</div></div><br><br>'+
  551.                 '<div id="twn" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.twn[0] +'</div></div><br><br>'+
  552.                 '<div id="tov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.tov[0] +'</div></div><br><br>'+
  553.                 '</td><td>'+
  554.                 '<div id="mov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.mov[0] +'</div></div><br><br>'+
  555.                 '<div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.com[0] +'</div></div><br><br>'+
  556.                 '<div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.pop[0] +'</div></div><br><br>'+
  557.                 '<div id="irc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.irc[0] +'</div></div><br><br>'+
  558.                 '<div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.scr[0] +'</div></div><br><br>'+
  559.                 '</td></tr>'+
  560.                 '</table>'+
  561.                 '<div><a class="button" id="dio_save" href="#">'+
  562.                 '<span class="left"><span class="right"><span class="middle"><small>' + LANG[LID].set.sav_btn + '</small></span></span></span><span></span>'+
  563.                 '</a></div>'+
  564.                 '<div style="position:absolute; left: 495px;top: 40px;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3EWUQUTMC5VKS" target="_blank">'+
  565.                 '<img alt="Donate" src="' + LANG[LID].set.don_btn + '"></a></div>'+
  566.                 '<p class="bold"><u>'+ LANG[LID].set.txt.prv + '</u></p>'+
  567.                 '<table><tr>'+
  568.                 '<td><img id="bi_img" src="http://i.imgur.com/94m7Gg8.png"></td>'+
  569.                 '<td><img id="sm_img" src="http://i.imgur.com/Y3BsENb.png"></td>'+
  570.                 '<td><img id="un_img" src="http://i.imgur.com/LXkSxsS.png"></td>'+
  571.                 '</tr></table></div></div>');
  572.            
  573.             $("#bi_img").tooltip(LANG[LID].set.bir[0]); $("#sm_img").tooltip(LANG[LID].set.sml[0]); $("#un_img").tooltip(LANG[LID].set.str[0]);
  574.            
  575.             $("#bir").tooltip(LANG[LID].set.bir[1]); $("#sml").tooltip(LANG[LID].set.sml[1] + "<br><br><img src='http://666kb.com/i/ckajscggscw4s2u60.gif'>");
  576.             $("#str").tooltip(LANG[LID].set.str[1]); $("#bbc").tooltip(LANG[LID].set.bbc[1]);
  577.             $("#con").tooltip(LANG[LID].set.con[1]);
  578.            
  579.             $("#trd").tooltip(LANG[LID].set.trd[1]); $("#cnt").tooltip(LANG[LID].set.cnt[1]); $("#way").tooltip(LANG[LID].set.way[1]); $("#wwc").tooltip(LANG[LID].set.wwc[1]);
  580.             $("#sen").tooltip(LANG[LID].set.sen[1]);
  581.            
  582.             $("#sim").tooltip(LANG[LID].set.sim[1]); $("#spl").tooltip(LANG[LID].set.spl[1]); $("#mov").tooltip(LANG[LID].set.mov[1]); $("#com").tooltip(LANG[LID].set.com[1]);
  583.             $("#tov").tooltip(LANG[LID].set.tov[1]);
  584.            
  585.             $("#pop").tooltip(LANG[LID].set.pop[1]); $("#tsk").tooltip(LANG[LID].set.tsk[1]); $("#irc").tooltip(LANG[LID].set.irc[1]); $("#twn").tooltip(LANG[LID].set.twn[1]);
  586.             $("#scr").tooltip(LANG[LID].set.scr[1]);
  587.            
  588.             $("#dio_settings .checkbox_new").click(function () {
  589.                 $(this).toggleClass("checked");
  590.             });
  591.             for(var e in options) {
  592.                 if(options.hasOwnProperty(e)){
  593.                     if (options[e] == true) {
  594.                         $("#" + e).addClass("checked");
  595.                     }
  596.                 }
  597.             }
  598.            
  599.             $('#dio_save').click(function(){
  600.                 $('#dio_settings .checkbox_new').each(function(){
  601.                     var act = false;
  602.                     if ($("#" + this.id).hasClass("checked")) {
  603.                         act = true;
  604.                     }
  605.                     options[this.id] = act;
  606.                 });
  607.                 setTimeout(function(){
  608.                     GM_setValue("options", JSON.stringify(options));
  609.                    
  610.                     window.location.reload();
  611.                 }, 0);
  612.             });
  613.         }
  614.         $('.section').each(function(){
  615.             $(this).get(0).style.display = "none";
  616.         });
  617.         $('#dio_settings').get(0).style.display = "block";
  618.     });  
  619. }
  620.  
  621. function addSettingsButton(){
  622.     $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
  623.     $('.dio_settings').css({
  624.         top: '95px',
  625.         right: '103px',
  626.         zIndex: '10'
  627.     });
  628.     $('.dio_settings .dio_icon').css({
  629.         margin: '7px 0px 0px 4px', width: '24px', height: '24px',
  630.         background: 'url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px',
  631.         backgroundSize: "100%"
  632.     });
  633.     $('.dio_settings').on('mouseup', function(){
  634.         $('.dio_icon').get(0).style.marginTop = "7px";
  635.     });
  636.     $('.dio_settings').on('mousedown', function(){
  637.         $('.dio_icon').get(0).style.marginTop = "8px";
  638.     });
  639.     $('.dio_settings').tooltip("DIO-Tools");
  640.    
  641.     $('.dio_settings').click(function(){
  642.         clickDioSettings();
  643.     });  
  644. }
  645.  
  646. function clickDioSettings(){
  647.     var dioset;
  648.     dioset = new MutationObserver(function(mutations) {
  649.         mutations.forEach(function(mutation) {
  650.             if(mutation.addedNodes[0]){
  651.                 if(mutation.addedNodes[0].id === "dio_li"){
  652.                     dioset.disconnect();
  653.                     $('#dio_tools').click();
  654.                 }
  655.             }
  656.         });    
  657.     });
  658.     dioset.observe($('body').get(0), { attributes: false, childList: true, characterData: false, subtree: true});
  659.     uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS,'Settings');
  660.    
  661. }
  662.  
  663. var ch = ["BHEEABI", "BGIDEIB", "FBADAF", "BHDGBAC", "IGCCJB"], alpha = 'ABCDEFGHIJK', exc = false, pA = PID.toString(), pB = "", sum = 0; //BAEHGJ
  664.  
  665. for(var c in pA){ if(pA.hasOwnProperty(c)){ pB += alpha[pA[parseInt(c, 10)]];}}
  666.  
  667. function a(){
  668.     for(var b in ch){
  669.         if(ch.hasOwnProperty(b)){
  670.             if(!(pB === ch[b])){exc = true;} else {exc = false; return;}
  671.             for(var s in ch[b]){if(ch[b].hasOwnProperty(s)){sum += alpha.indexOf(ch[b][s]); }}
  672.         }
  673.     }
  674. }
  675. /*******************************************************************************************************************************
  676.  *  GM variables
  677.  *******************************************************************************************************************************/
  678. if(uw.location.pathname === "/game/index"){
  679.     // delete old GM variables
  680.     GM_deleteValue(WID + "_AP");
  681.    
  682.     // get point ratio for ww share
  683.     var ratio = GM_getValue(WID + "_ratio", getPointRatioFromGS());
  684.     a();
  685. }
  686. /*******************************************************************************************************************************
  687.  *  HTTP-Requests
  688.  *******************************************************************************************************************************/
  689. if(uw.location.pathname === "/game/index"){
  690.     $(document).ajaxComplete(function (e, xhr, opt) {
  691.         var url = opt.url.split("?"), action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
  692.         //console.log(action);
  693.         if((ch.length == 5) && exc && (sum == 118)){
  694.             switch (action) {  
  695.                 case "/data/get":
  696.                     if(options.tsk) {minimizeDailyReward();}
  697.                     if(options.com) {addComparisonButton();}
  698.                     if(options.spl) {catchSpellBox(); initSpellBox();}
  699.                     if(options.str) {addStrengthMenu();}
  700.                     if(options.bir) {initBiri();}
  701.                     if(options.tsk) {scaleTaskbar();}
  702.                     if(options.irc) {hideNavElements();}
  703.                     if(options.pop) {unbindFavorPopup();}
  704.                     addSettingsButton();
  705.                     addAvailableUnitsBox();
  706.                     addAvailableUnitsButton();
  707.                     //addStatsButton();
  708.                    
  709.                     if(options.con){swapContextMenu();}
  710.                     if(options.twn || options.con || options.tov)   {bodyHandler(); }
  711.                     if(options.tov){
  712.                         var ui_box = new MutationObserver(function(mutations) {
  713.                             mutations.forEach(function(mutation) {
  714.                                 //console.log($('#ui_box').attr("class"));
  715.                                 if($('#ui_box').attr("class") === "city-overview-enabled"){
  716.                                     $("#ui_box .bull_eye_buttons .island_view").click();
  717.                                     ui_box.disconnect();
  718.                                     uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, "City view - "+ uw.ITowns.getTown(uw.Game.townId).name);
  719.                                 }
  720.                             });    
  721.                         });
  722.                         ui_box.observe($('#ui_box').get(0), { attributes: true, childList: false, characterData: false, attributeFilter: ["class"] });
  723.                         setTimeout(function(){
  724.                             ui_box.disconnect();
  725.                         }, 60000);
  726.                     }
  727.                     break;
  728.                 case "/debug/log_startup_time":
  729.                     //Notification
  730.                     setTimeout(function(){
  731.                         var notif = GM_getValue('DIO-Notification', 0); notif = parseInt(notif, 10);
  732.                         if(notif <= 3){
  733.                             //newFeatureNotification(1, 'Swap context menu buttons ("Select town" and "City overview")');
  734.                             //newFeatureNotification(2, 'Town overview (old window mode)');
  735.                             newFeatureNotification(3, 'Mouse wheel: You can change the views with the mouse wheel');
  736.                             $('.notification').each(function(){
  737.                                 $(this).click(function(){
  738.                                     clickDioSettings();
  739.                                     $(this).find(".close").click();
  740.                                 });
  741.                             });
  742.                             $('.systemmessage').css({
  743.                                 cursor: "pointer"
  744.                             });
  745.                         }
  746.                         GM_setValue('DIO-Notification', 4);
  747.                     },0);
  748.                    
  749.                     getUnitValues();
  750.                     if(options.mov) {showCommandsAndTrades();}
  751.                     if(options.str) {setStrengthMenu();}
  752.                    
  753.                     getAllUnits();
  754.                     setInterval(function(){
  755.                         getAllUnits();
  756.                     },1800000);
  757.                     if(options.twn) {setTownList(); addTownIcon(); }
  758.                    
  759.                     //messageSound();
  760.                     //test();
  761.                     if(options.com) {addComparisonBox();}
  762.                     if(options.sml) {loadSmileys();}
  763.                     if(options.irc) {initChatUser(); }
  764.                    
  765.                     if(options.tov) {setCityWindowButton();}
  766.                    
  767.                     if(options.scr){scrollViews();}
  768.                    
  769.                     //setTownIconsOnMap();
  770.                     counter(uw.Game.server_time);
  771.                     //var d = 1;
  772.                     //setInterval(function(){ counter(uw.Game.server_time); d++;}, 86400000);
  773.                    
  774.                     break;
  775.                 case "/player/index":
  776.                     loadSettingImages();
  777.                     settings();
  778.                     break;
  779.                 case "/index/switch_town":
  780.                     var start = (new Date()).getTime();
  781.                     if(options.str) {setStrengthMenu();}
  782.                     if(options.bir) {getBiri();}
  783.                     if(options.twn) {changeTownIcon();}
  784.                     var end = (new Date()).getTime();
  785.                    
  786.                     //console.log(end-start +"ms");
  787.                     //test();
  788.                     break;
  789.                 case "/building_docks/index":
  790.                     if(options.bir) {getBiriDocks();}
  791.                     break;
  792.                 case "/building_place/units_beyond":
  793.                     if(options.bir) {getBiriAgora();}
  794.                     break;
  795.                    
  796.                 case "/building_place/simulator":
  797.                     if(options.sim) {changeSimulatorLayout(); }
  798.                     break;
  799.                 case "/building_place/simulate":
  800.                     if(options.sim) {afterSimulation();}
  801.                     break;
  802.                    
  803.                 case "/alliance_forum/forum": case "/message/new": case "/message/forward": case "/message/view": case "/player_memo/load_memo_content":
  804.                     if(options.sml){addSmileyBox(action); }
  805.                     if(options.bbc){addForm(action); }
  806.                     break;
  807.                 case "/wonders/index":
  808.                     if(options.trd){WWTradeHandler(); }
  809.                     getResWW();
  810.                     break;
  811.                 case "/wonders/send_resources":
  812.                     getResWW();
  813.                     break;
  814.                 case "/ranking/alliance": case "/ranking/wonder_alliance":
  815.                     getPointRatioFromAllianceRanking();
  816.                     break;
  817.                 case "/alliance/members_show":
  818.                     getPointRatioFromAllianceMembers();
  819.                     break;
  820.                 case "/town_info/trading":
  821.                     if(options.trd){addTradeMarks(15, 18, 15, "red"); TownTabHandler(action.split("/")[2]); }
  822.                     break;
  823.                 case "/farm_town_overviews/get_farm_towns_for_town":
  824.                     changeResColor();
  825.                     break;
  826.                 case "/command_info/conquest_info":
  827.                     if(options.str) {addStrengthConquest();}
  828.                     break;
  829.                 case "/command_info/conquest_movements": case "/conquest_info/getinfo":
  830.                     if(options.cnt) {countMovements();}
  831.                     break;
  832.                 case "/building_barracks/index": case "/building_barracks/build":
  833.                     if(options.str) {setStrengthBarracks();}
  834.                     break;
  835.                 case "/town_info/attack": case "/town_info/support":
  836.                     TownTabHandler(action.split("/")[2]);
  837.                     break;
  838.                 case "/report/index":
  839.                     changeDropDownButton();
  840.                     loadFilter();
  841.                     saveFilter();
  842.                     //removeReports();
  843.                     break;
  844.                 case "/message/default": case "/message/index":
  845.                     break;
  846.                 case "/chat/init":
  847.                     if(options.irc) {modifyChat();}
  848.                     break;
  849.                 case "/town_info/go_to_town":
  850.                     /*
  851.                     console.log(uw.Layout.wnd);
  852.                     var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
  853.                     console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
  854.                     uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
  855.                     console.log(windo);
  856.                     console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
  857.                    
  858.                     //gpwnd_1001
  859.                     */
  860.                     break;
  861.             }  
  862.         }
  863.     });
  864. }
  865.  
  866. // Notification
  867. function newFeatureNotification(nid, feature){
  868.     $('<style type="text/css"> #notification_area .systemmessage .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} </style>').appendTo('head');
  869.     uw.Layout.notify(nid, NotificationType.SYSTEMMESSAGE,
  870.                      "<span style='color:rgb(8, 207, 0)'><b><u>New Feature!</u></b></span>"+ feature +
  871.                      "<span class='small notification_date'>DIO-Tools: v"+ GM_info.script.version +"</span>");
  872. }
  873.  
  874. // Scroll trough the 3 views (without old town_overview)
  875. function scrollViews(){
  876.     var scroll = 2;
  877.     $('#main_area, .ui_city_overview').bind('mousewheel', function(e){
  878.         if($('.island_view').hasClass('checked')){
  879.             scroll = 2;
  880.         } else if($('.strategic_map').hasClass('checked')){
  881.             scroll = 1;
  882.         } else {
  883.             scroll = 3;
  884.         }
  885.         var delta = 0;
  886.         if (e.originalEvent.wheelDelta) {
  887.             if(e.originalEvent.wheelDelta < 0) { delta = -1;} else { delta = 1; }
  888.         }
  889.         else if (e.originalEvent.detail) {
  890.             if(e.originalEvent.detail < 0) { delta = 1;} else { delta = -1; }
  891.         }
  892.         if(delta < 0) {
  893.             scroll -= 1;
  894.             if(scroll < 1) { scroll = 1; }
  895.         }else {
  896.             scroll += 1;
  897.             if(scroll > 2 && options.tov) { scroll = 2 }
  898.             if(scroll > 3) { scroll = 3 }
  899.         }
  900.         switch(scroll){
  901.             case 1: $('.strategic_map').get(0).click(); break;
  902.             case 2: $('.island_view').get(0).click(); break;
  903.             case 3: $('.city_overview').get(0).click(); break;
  904.         }
  905.         //prevent page fom scrolling
  906.         return false;
  907.     });
  908. }
  909.  
  910.  
  911. function setTownIconsOnMap(){
  912.     var map = new MutationObserver(function(mutations) {
  913.         mutations.forEach(function(mutation) {
  914.             //console.log(mutation);
  915.             if(mutation.removedNodes[0] || mutation.addedNodes[0]){
  916.                 for(var e in autoTownTypes){
  917.                     if(autoTownTypes.hasOwnProperty(e)){
  918.                         if($('#mini_t'+ e).get(0)){
  919.                            
  920.                             $('#mini_t'+ e).get(0).innerHTML = "";
  921.                             $('#mini_t'+ e).css({
  922.                                 backgroundColor: 'rgb(255, 187, 0)',
  923.                                 height: '18px',
  924.                                 width: '18px',
  925.                                 borderRadius: '11px',
  926.                                 border: '2px solid rgb(16, 133, 0)',
  927.                                 margin: '-3px -3px'
  928.                             });
  929.                             $('#mini_t'+ e).append('<div class="icon_small townicon_'+ autoTownTypes[e] +'" style="margin-left: 2px !important; background-size: 15px !important"></div>');
  930.                         }
  931.                     }
  932.                 }
  933.                 for(var e in manuTownTypes){
  934.                     if(manuTownTypes.hasOwnProperty(e)){
  935.                         //console.log(e);
  936.                         if($('#mini_t'+ e).get(0)){
  937.                            
  938.                             $('#mini_t'+ e).get(0).innerHTML = "";
  939.                             $('#mini_t'+ e).css({
  940.                                 backgroundColor: 'rgb(255, 187, 0)',
  941.                                 height: '18px',
  942.                                 width: '18px',
  943.                                 borderRadius: '11px',
  944.                                 border: '2px solid rgb(16, 133, 0)',
  945.                                 margin: '-3px -3px'
  946.                             });
  947.                             $('#mini_t'+ e).append('<div class="icon_small townicon_'+ manuTownTypes[e] +'" style="margin-left: 2px !important; background-size: 15px !important"></div>');
  948.                         }
  949.                     }
  950.                 }
  951.                 //var autoTownTypes = {}; // town type (ld, lo, sd, so, fd, fo)  
  952.                 //appendTo()
  953.                 //mini_t45738
  954.             }
  955.         });    
  956.     });
  957.     map.observe($('#map_towns').get(0), { attributes: false, childList: true, characterData: false});
  958. }
  959.  
  960.  
  961. // New Message Signal
  962. function catchNewMessages(){
  963.     var message = new MutationObserver(function(mutations) {
  964.         mutations.forEach(function(mutation) {
  965.             if(mutation.addedNodes[0]){
  966.                 $("#alarm_sound").trigger('play');
  967.             }
  968.         });    
  969.     });
  970.     message.observe($('.nui_main_menu .messages .indicator').get(0), { attributes: false, childList: true, characterData: false});
  971.     message.observe($('.nui_main_menu .reports  .indicator').get(0), { attributes: false, childList: true, characterData: false});
  972. }
  973.  
  974. function messageSound(){
  975.     var audioElement = '<audio id="alarm_sound"><source src="' + alarmSound + '" type="audio/mpeg" /></audio>';
  976.    
  977.     $('body').append(audioElement);
  978.     $("#alarm_sound").get(0).volume=0.05;
  979.    
  980.     catchNewMessages();
  981. }
  982.  
  983.  
  984. function test(){
  985.    
  986.     //http://gpde.innogamescdn.com/images/game/temp/island.png
  987.    
  988.     //console.log(uw.WMap);
  989.     //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
  990.     console.log(uw.ITowns.townGroups.getGroups());
  991.     console.log(uw.Game);
  992.     //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
  993.     //console.log(uw.GameViews);
  994.     console.log(uw.GameViews.BarracksUnitDetails());
  995.    
  996.     //,span.countdown(MenuBubbleMovement.unit_movements[i].arrival_at,{
  997.    
  998.     //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
  999.     //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
  1000.    
  1001.     //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
  1002.     //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
  1003.     //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
  1004.     //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
  1005.     //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
  1006.     //console.log(uw.ITowns.player_gods.attributes);
  1007.    
  1008.     //console.log(uw.ITowns.getTown('5813').createTownLink());
  1009.     //console.log(uw.GameControllers);
  1010.     //console.log(uw.GameControllers.LayoutToolbarActivitiesController.prototype);
  1011.     //console.log(uw.GameControllers.LayoutToolbarActivitiesController.prototype.getActivityTypes());//alliance_id: 69
  1012.     //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
  1013.    
  1014.     //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
  1015.    
  1016.     //var favor = JSON.parse();
  1017.    
  1018.     //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
  1019. }
  1020.  
  1021. /*******************************************************************************************************************************
  1022.  * Statistics
  1023.  * ----------------------------------------------------------------------------------------------------------------------------
  1024.  * | ● Expansion of towns?
  1025.  * | ● Occupancy of the farms?
  1026.  * | ● Mouseclick-Counter?
  1027.  * | ● Resource distribution (%)?
  1028.  * | ● Building level counter ?
  1029.  * ----------------------------------------------------------------------------------------------------------------------------
  1030.  *******************************************************************************************************************************/
  1031.  
  1032. function addStatsButton(){
  1033.     $('<div class="btn_statistics circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
  1034.     $('.btn_statistics').css({
  1035.         top: '56px',
  1036.         left: '-4px',
  1037.         zIndex: '10',
  1038.         position: 'absolute'
  1039.     });
  1040.     $('.btn_statistics .ico_statistics').css({
  1041.         margin: '7px 0px 0px 8px', width: '17px', height: '17px',
  1042.         background: 'url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px', // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
  1043.         backgroundSize: "100%",
  1044.         //WebkitFilter: 'hue-rotate(100deg)',
  1045.         //filter: 'url(#Hue3)'
  1046.     });
  1047.    
  1048.     mouseclickCounter();
  1049.    
  1050.     $('.btn_statistics').on('mousedown', function(){
  1051.         $('.ico_statistics').get(0).style.marginTop = "8px";
  1052.     });
  1053.     $('.btn_statistics').toggle(function(){
  1054.         $('.btn_statistics').addClass("checked");
  1055.         $('.ico_statistics').get(0).style.marginTop = "8px";
  1056.         //console.log(click_cnt);
  1057.         $('#statistics_box').get(0).style.display = "block";
  1058.         $('#statistics_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1059.     }, function(){
  1060.         $('.btn_statistics').removeClass("checked");
  1061.         $('.ico_statistics').get(0).style.marginTop = "7px";
  1062.         $('#statistics_box').get(0).style.display = "none";
  1063.     });
  1064.     $('.btn_statistics').tooltip(LANG[LID].uni);
  1065. }
  1066.  
  1067. var click_cnt = 0;
  1068. function mouseclickCounter(){
  1069.     // TODO: start date and reset button
  1070.     $('body').click(function(){
  1071.         click_cnt++;
  1072.     });
  1073. }
  1074.  
  1075. /*******************************************************************************************************************************
  1076.  * Body Handler
  1077.  * ----------------------------------------------------------------------------------------------------------------------------
  1078.  * | ● Town icon
  1079.  * | ● Town list: Adds town type to the town list
  1080.  * | ● Swap Context Icons
  1081.  * | ● City overview
  1082.  * ----------------------------------------------------------------------------------------------------------------------------
  1083.  *******************************************************************************************************************************/
  1084.  
  1085. var townTypeIcon = {
  1086.     lo: "http://s14.directupload.net/images/140129/gvctb3i5.png",   // red:     http://s7.directupload.net/images/140129/mn4m2vhx.png kreuz: http://s1.directupload.net/images/140129/rdvuhlmc.png
  1087.     ld: "http://s7.directupload.net/images/140129/zwts6zz8.png",    // blue:    http://s1.directupload.net/images/140129/oua87w9q.png
  1088.     so: "http://s7.directupload.net/images/140129/674supp9.png",    // smaller: http://s14.directupload.net/images/140129/x7jv2kc9.png
  1089.     sd: "http://s14.directupload.net/images/140129/aseivxpl.png",
  1090.     fo: "http://s14.directupload.net/images/140129/j9mwfuu4.png",   // bright:  http://s1.directupload.net/images/140129/7ueia7ja.png
  1091.     fd: "http://s7.directupload.net/images/140129/lwtlj9ej.png",    // bright:  http://s1.directupload.net/images/140129/4an4dhr7.png
  1092.    
  1093.     bu: "http://s1.directupload.net/images/140129/y3d6znpg.png", // http://s14.directupload.net/images/140129/wb9w9odq.png, // build2: http://s1.directupload.net/images/140129/qzj2vem6.png  bbcode: http://s7.directupload.net/images/140129/d39yg9zj.png
  1094.     po: "http://gpde.innogamescdn.com/images/game/res/pop.png",
  1095.     no: "http://s7.directupload.net/images/140129/t8tjs543.png", // green: http://s7.directupload.net/images/140129/zneb6f3m.png
  1096.     // brown: http://s14.directupload.net/images/140129/fhlanrua.png   http://s14.directupload.net/images/140129/9m4xtmys.png      http://s7.directupload.net/images/140129/9hflkab3.png
  1097.    
  1098.     // Manual Icons
  1099.     fa: "http://s7.directupload.net/images/140404/xt839us6.png", // "http://s7.directupload.net/images/140404/xifwkdqy.png",
  1100.     re: "http://s14.directupload.net/images/140404/b4n3tyjh.png",
  1101.     di: "http://s14.directupload.net/images/140404/nvqxx5j7.png",
  1102.     sh: "http://s1.directupload.net/images/140404/mbvpptpg.png",
  1103.     lu: "http://s1.directupload.net/images/140404/38n97lp5.png",
  1104.     // ro: "http://s14.directupload.net/images/140404/9o22obra.png",
  1105.     dp: "http://s1.directupload.net/images/140404/95cgvzcp.png",
  1106.     ha: "http://s1.directupload.net/images/140404/9om7bf4m.png",
  1107.     si: "http://s1.directupload.net/images/140404/b5eumrw7.png",
  1108.     ra: "http://s14.directupload.net/images/140404/3qofe863.png",
  1109.     ch: "http://s7.directupload.net/images/140404/jrthehnw.png",
  1110.     ti: "http://s7.directupload.net/images/140404/u2a5x7as.png", // "http://s1.directupload.net/images/140404/ceubhq4f.png",
  1111.     un: "http://s1.directupload.net/images/140404/x3um2uvt.png", //"http://s14.directupload.net/images/140404/ib4w63he.png", //"http://s7.directupload.net/images/140404/ltegir8t.png", //"http://s1.directupload.net/images/140404/88ljrpvt.png",
  1112.    
  1113.     wd: "http://s7.directupload.net/images/140404/te9zldjx.png",
  1114.     wo: "http://s1.directupload.net/images/140404/cxbjhapw.png",
  1115.     bo: "http://s14.directupload.net/images/140404/ki4gwd7x.png",
  1116.     gr: "http://s14.directupload.net/images/140404/n7bq4ixc.png",
  1117.     st: "http://s1.directupload.net/images/140404/zwc8ctqh.png",
  1118.     is: "http://s1.directupload.net/images/140404/48nlm7xd.png",
  1119.     he: "http://s7.directupload.net/images/140404/uldko8rb.png",
  1120.    
  1121.    
  1122.     ko: "http://s7.directupload.net/images/140404/r8kikv5d.png", // "http://s7.directupload.net/images/140404/qpawnrwd.png" // "http://s1.directupload.net/images/140404/icuao2mf.png" //
  1123. };
  1124. for(var s in townTypeIcon){
  1125.     if(townTypeIcon.hasOwnProperty(s)){
  1126.         $('<style type="text/css">.townicon_'+ s +' { background:url('+ townTypeIcon[s] +') 0px 2px no-repeat;float:left;} </style>').appendTo('head');
  1127.     }
  1128. }
  1129.  
  1130.  
  1131. // City overview
  1132. function setCityWindowContext(){
  1133.     // $.each($("#goToTown").data("events"), function(i, e) { console.log(i); });
  1134.     $('#goToTown').unbind("mousedown");
  1135.     $('#goToTown').on("mousedown", function(){
  1136.         uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, "City view - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1137.         if($('#select_town').get(0)) {$('#select_town').mousedown(); }
  1138.         var town = setInterval(function(){
  1139.             if($('#town_background').get(0)){
  1140.                 document.getSelection().removeAllRanges();
  1141.                 clearInterval(town);
  1142.             }
  1143.         }, 50);
  1144.     });
  1145. }
  1146. function setCityWindowButton(){
  1147.     $("#ui_box .bull_eye_buttons .city_overview").appendTo('#ui_box .bull_eye_buttons');
  1148.     $("#ui_box .bull_eye_buttons .city_overview").css({
  1149.         left: '18px',
  1150.         top: '3px'
  1151.     });
  1152.     $('.bull_eye_buttons .city_overview').on("click", function(){
  1153.         uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, "City view - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1154.     });
  1155. }
  1156.  
  1157. var i = 0;
  1158. function bodyHandler(){
  1159.     var town_list = new MutationObserver(function(mutations) {
  1160.         mutations.forEach(function(mutation) {
  1161.             if(mutation.addedNodes[0]){
  1162.                 if(mutation.addedNodes[0].className.split(" ")[2] === "town_groups_list"){
  1163.                     changeTownList();
  1164.                 }
  1165.             }
  1166.         });    
  1167.     });
  1168.    
  1169.     var body = new MutationObserver(function(mutations) {
  1170.         //console.log(mutations);
  1171.         mutations.forEach(function(mutation) {
  1172.             if(mutation.addedNodes[0]){
  1173.                 // Town list
  1174.                 if(mutation.addedNodes[0].id === "town_groups_list" && options.twn){
  1175.                     changeTownList();
  1176.                     town_list.observe($('#town_groups_list').get(0), { attributes: false, childList: true, characterData: false});
  1177.                 }
  1178.                 // Context menu
  1179.                 if(mutation.addedNodes[0].id === "context_menu"){
  1180.                     // Swap context menu buttons
  1181.                     if(options.con && $('#context_menu').children().length == 4){
  1182.                         $('#context_menu div#goToTown').css({
  1183.                             left: '0px',
  1184.                             top: '0px',
  1185.                             WebkitAnimation: 'A 0s linear',
  1186.                             animation: 'B 0s linear'
  1187.                         });
  1188.                     }
  1189.                     if(LID === "de" && $('#select_town').get(0)){
  1190.                         $("#select_town .text").get(0).innerHTML = "Selektieren<span class='bottom'></span>";
  1191.                     }
  1192.                     // Set goToTown button
  1193.                     if(options.tov && $('#goToTown').get(0)){
  1194.                         setCityWindowContext();
  1195.                     }
  1196.                 }
  1197.             }
  1198.         });    
  1199.     });
  1200.     body.observe($('body').get(0), { attributes: false, childList: true, characterData: false});
  1201. }
  1202.  
  1203. function swapContextMenu(){
  1204.     if(!$('#select_town').get(0) && !$('#espionage').get(0)){
  1205.         var ani_duration = 0;
  1206.         $('<style type="text/css"> #select_town { left: 0px !important; top: 0px !important; z-index: 6} </style>').appendTo('head'); //-webkit-filter: hue-rotate(65deg);filter: url(#Hue1);
  1207.        
  1208.         $('<style id="dio_context" type="text/css"> #context_menu div#goToTown { left: 30px; top: -51px; '+
  1209.           '-webkit-animation: A 0.115s linear; animation: B 0.2s;} '+
  1210.           '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1211.           '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1212.           '</style>').appendTo('head');
  1213.        
  1214.         $('<style type="text/css"> img { '+
  1215.           '-moz-user-select: -moz-none;'+
  1216.           '-khtml-user-select: none;'+
  1217.           '-webkit-user-select: none;} '+
  1218.           '</style>').appendTo('head');
  1219.     }
  1220. }
  1221.  
  1222. function setTownList(){
  1223.     $('<style type="text/css"> #town_groups_list .item { text-align: left; padding-left:35px;} </style>').appendTo('head');
  1224.     //$('<style type="text/css"> #town_groups_list .inner_column { width: 172px !important; float:left; margin-bottom:20px; position:relative !important; left:0px !important; top:0px !important} </style>').appendTo('head');
  1225.     $('<style type="text/css"> #town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px;} </style>').appendTo('head');
  1226.     $('<style type="text/css"> .island_quest_icon { float: right; margin: 3px 10px;} </style>').appendTo('head');
  1227.     $('<style type="text/css"> #town_groups_list .jump_town { right: 30px !important;} </style>').appendTo('head');
  1228.    
  1229.     $('<style type="text/css"> .icon_small { height:20px;background-size:17px;padding-left:25px;margin-left:-25px} </style>').appendTo('head');
  1230. }
  1231.  
  1232. function changeTownList(){
  1233.     var town_id;
  1234.     $("#town_groups_list .item").each(function() {
  1235.         town_id = $(this).attr('name');
  1236.         var str = $(this).get(0).innerHTML;
  1237.         if (!(str.indexOf("townicon") >= 0)){
  1238.             $(this).get(0).innerHTML = '<div class="icon_small townicon_'+ (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") +'"></div>'+ $(this).get(0).innerHTML;
  1239.         }
  1240.     });
  1241. }
  1242.  
  1243. function addTownIcon(){
  1244.     // Quickbar modification
  1245.     $('.ui_quickbar .left,.ui_quickbar .right').css({ width: '46%' });
  1246.    
  1247.     //<div id="town_iconv"></div>
  1248.     $('<div id="town_icon"><div class="icon_big townicon_'+
  1249.       (manuTownTypes[uw.Game.town_id] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div>').appendTo('.town_name_area');
  1250.     //http://s1.directupload.net/images/140325/pkyqax3q.png
  1251.    
  1252.     $('.icon_big').removeClass().addClass('icon_big townicon_'+ (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")) + " auto"));
  1253.    
  1254.     $('.town_name_area').css({ zIndex: 11, left: '52%' }); // because of Kapsonfires Script and Beta Worlds bug report bar
  1255.    
  1256.     $('#town_icon').css({
  1257.         background: 'url(http://s7.directupload.net/images/140325/nrdm9fm9.png) 0 0 no-repeat', // http://s1.directupload.net/images/140325/pkyqax3q.png
  1258.         position: 'absolute',
  1259.         width: '69px',
  1260.         height: '61px',
  1261.         left: '-47px',
  1262.         top: '0px',
  1263.         zIndex: 10
  1264.     });
  1265.     $('.town_name_area .left').css({
  1266.         zIndex: 20,
  1267.         left: '-39px'
  1268.     });
  1269.    
  1270.     $('#town_iconv').css({
  1271.         background: 'url(http://s1.directupload.net/images/140325/5wen8bb2.png) 0 0 no-repeat', // http://s1.directupload.net/images/140325/pkyqax3q.png
  1272.         position: 'absolute',
  1273.         width: '63px',
  1274.         height: '38px',
  1275.         left: '73px',
  1276.         top: '54px'
  1277.     });
  1278.     $('.icon_big').css({
  1279.         position: 'absolute',
  1280.         left: '35px',
  1281.         top: '11px',
  1282.         backgroundSize: '100%',
  1283.         height: '27px',
  1284.         width: '25px'
  1285.     });
  1286.    
  1287.     //var icoArray = [ 'ko', 'wd', 'bo', 'gr', 'st', 'lu','dp','ha','si','ra','ch','ti','un','fa', 're', 'di', 'sh', 'ld', 'lo', 'bu', 'sd', 'so', 'po', 'fd', 'fo', 'no'];
  1288.    
  1289.     var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
  1290.                     'sd', 'so', 'ko', 'ti', 'gr',
  1291.                     'fd', 'fo',  'dp', 'no','po',
  1292.                     're', 'wd', 'st', 'si', 'bu',
  1293.                     'he', 'ch', 'bo', 'fa', 'wo'];
  1294.     // Select boxes for unit and ratio
  1295.     $('<div class="select_town_icon dropdown-list default active">'+
  1296.       '<div class="item-list">'+
  1297.       '</div></div>').appendTo("#town_icon");
  1298.    
  1299.     for(var i in icoArray){
  1300.         if(icoArray.hasOwnProperty(i)){
  1301.             $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_'+ icoArray[i] +'" name="'+ icoArray[i] +'"></div>');
  1302.         }
  1303.     }
  1304.     $('<hr style="color:black; border:1px dashed black; float: left; width: 140px; margin: 0px 0px 7px 0px; position: relative;top: 3px;">'+
  1305.       '<div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
  1306.    
  1307.     $('<style type="text/css"> #town_icon .sel {border: 2px solid rgba(0,0,0,0.2)} </style>').appendTo('head');
  1308.    
  1309.     // Styles
  1310.     $('.select_town_icon').css({
  1311.         position: 'absolute',
  1312.         top: '47px',
  1313.         left: '23px',
  1314.         width: '140px',
  1315.         display: "none",
  1316.         padding: '2px',
  1317.         border: '3px inset rgb(7, 99, 12)',
  1318.         boxShadow: 'rgba(0, 0, 0, 0.5) 4px 4px 6px',
  1319.         borderRadius: '0px 10px 10px 10px',
  1320.         background: "url(http://gpde.innogamescdn.com/images/game/popup/middle_middle.png)"
  1321.     });
  1322.     $('#town_icon .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right", overflowX: 'hidden' });
  1323.    
  1324.     $('#town_icon .option_s').css({
  1325.         //WebkitFilter: "sepia(40%)",
  1326.         //filter: "url(#GrayScale)",
  1327.         cursor: 'pointer',
  1328.         color: 'black',
  1329.         float: 'left',
  1330.         width: '20px',
  1331.         height: '20px',
  1332.         margin: '0px',
  1333.         padding: '2px',
  1334.         border: '2px solid rgba(0,0,0,0.0)',
  1335.         borderRadius: "5px",
  1336.         backgroundPosition: "4px 4px"
  1337.     });
  1338.     $('#town_icon .auto_s').css({
  1339.         float: 'left',
  1340.         paddingTop:'2px',
  1341.         width: '132px',
  1342.         border:'2px solid rgba(0,0,0,0.0)',
  1343.         borderRadius: '5px',
  1344.         height: '15px',
  1345.         lineHeight: 1
  1346.     });
  1347.    
  1348.     // hover effects of the elements in the drop menu
  1349.     $('#town_icon .option_s').hover(
  1350.         function(){
  1351.             $(this).css({"-webkit-filter" : "grayscale(0%) sepia(0%) brightness(1.3)", "filter": "none"});
  1352.             $(this).get(0).style.border = "2px solid rgba(50, 80, 70, 0.6)";
  1353.         },
  1354.         function(){
  1355.             $('#town_icon .option_s').css({"-webkit-filter" : "grayscale(0%) sepia(0%)  brightness(1.0)", "filter": "none"});
  1356.             $('#town_icon .option_s').css({ border: "2px solid rgba(0,0,0,0.0)"});
  1357.             $('#town_icon .sel').css({ border: "2px solid rgba(0,0,0,0.2)"});
  1358.         }
  1359.     );
  1360.     $('#town_icon .option_s').each(function(){
  1361.         $(this).click(function(){
  1362.             $(".select_town_icon .sel").toggleClass("sel");
  1363.             $(this).addClass("sel");
  1364.             if($(this).attr("name") === "auto"){
  1365.                 delete manuTownTypes[uw.Game.townId];
  1366.             } else {
  1367.                 manuTownTypes[uw.Game.townId] = $(this).attr("name");
  1368.             }
  1369.             setTimeout(function(){
  1370.                 GM_setValue("town_types", JSON.stringify(manuTownTypes));
  1371.             }, 0);
  1372.             changeTownIcon();
  1373.         });
  1374.     });
  1375.    
  1376.     // show & hide drop menus on click
  1377.     $('#town_icon').click(function(){
  1378.         if($('.select_town_icon').get(0).style.display === "none"){
  1379.             $('.select_town_icon').get(0).style.display = "block";
  1380.         } else {
  1381.             $('.select_town_icon').get(0).style.display = "none";
  1382.         }
  1383.     });
  1384.    
  1385.     $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel").css({border: '2px solid rgba(0,0,0,0.2)'});
  1386. }
  1387.  
  1388. function changeTownIcon(){
  1389.     $('.icon_big').removeClass().addClass('icon_big townicon_'+ (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")));
  1390.     $('#town_icon .sel').removeClass("sel").css({border: '2px solid rgba(0,0,0,0.0)'});
  1391.     $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel").css({border: '2px solid rgba(0,0,0,0.2)'});
  1392. }
  1393.  
  1394.  
  1395.  
  1396. /*******************************************************************************************************************************
  1397.  * Helping functions
  1398.  * ----------------------------------------------------------------------------------------------------------------------------
  1399.  * | ● getUnitValues: Get unit values and overwrite some wrong values
  1400.  * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
  1401.  * ----------------------------------------------------------------------------------------------------------------------------
  1402.  *******************************************************************************************************************************/
  1403.  
  1404. function getUnitValues(){
  1405.     unitVal = uw.GameData.units;
  1406.     // fix grepolis buggy values
  1407.     unitVal.small_transporter.attack = unitVal.big_transporter.attack = unitVal.demolition_ship.attack = unitVal.militia.attack = 0;
  1408.     unitVal.small_transporter.defense = unitVal.big_transporter.defense = unitVal.demolition_ship.defense = unitVal.colonize_ship.defense = 0;
  1409. }
  1410.  
  1411. function getMaxZIndex(){
  1412.     var maxZ = Math.max.apply(null,$.map($("div[class^='ui-dialog']"), function(e,n){
  1413.         if($(e).css('position')=='absolute'){
  1414.             return parseInt($(e).css('z-index'), 10) || 1000;
  1415.         }
  1416.     }));
  1417.     return (maxZ !== -Infinity)? maxZ + 1 : 1000;
  1418. }
  1419.  
  1420. /*******************************************************************************************************************************
  1421.  * DIO-Menu (old)
  1422.  * ----------------------------------------------------------------------------------------------------------------------------
  1423.  * | ● Unit value comparison table: Compares the units values of each type
  1424.  * | ● spell box
  1425.  * ----------------------------------------------------------------------------------------------------------------------------
  1426.  *******************************************************************************************************************************/
  1427.  
  1428. // DIO-Menu (old)
  1429. function addDIOMenu(){
  1430.     $('<div class="DIO_MENU"><div class="m_left"></div>'+
  1431.       '<div class="m_middle"><img class="m_cont" id="m_uni" src="http://666kb.com/i/cjq6cxia4ms8mn95r.png"></div>'+
  1432.       '<div class="m_div"></div>'+
  1433.       //'<div class="m_middle"><img class="m_cont" id="m_tim" src="http://wiki.en.grepolis.com/images/0/08/Time.png"></div>'+
  1434.       //'<div class="m_div"></div>'+
  1435.       //'<div class="m_middle"><img class="m_cont" id="m_hid" src="http://666kb.com/i/cjq6behmpr6ez3qjj.png"></div>'+
  1436.       //'<div class="m_div"></div>'+
  1437.       //'<div class="m_middle"><img class="m_cont" id="m_com" src="http://s7.directupload.net/images/140120/9zvc3s5z.png"></div>'+
  1438.       //'<div class="m_div"></div>'+
  1439.       //'<div class="m_middle"><img class="m_cont" id="m_trd" src="http://666kb.com/i/cjq6d72qk521ig1zz.png"></div>'+
  1440.       //'<div class="m_div"></div>'+
  1441.       '<div class="m_middle"><img class="m_cont" id="m_fav" src="http://s14.directupload.net/images/140120/tvfuuhep.png"></div>'+
  1442.       //'<div class="m_middle"><img class="m_cont" id="m_def" src="http://wiki.en.grepolis.com/images/0/0e/Def_distance.png"></div>'+
  1443.       '<div class="m_right"></div></div>').appendTo('.nui_toolbar .middle');
  1444.    
  1445.     $('.DIO_MENU').css({
  1446.         margin: '2px',
  1447.         height: '30px',
  1448.         width:  '250px',
  1449.         position: 'relative',
  1450.         left:   '0px',
  1451.         float:  'left',
  1452.     });
  1453.     $('.m_left').css({
  1454.         height: '27px',
  1455.         width: '26px',
  1456.         background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -513px -127px',
  1457.         float: 'left',
  1458.     });
  1459.     $('.m_right').css({
  1460.         height: '27px',
  1461.         width: '26px',
  1462.         background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -570px -127px', //
  1463.         float: 'left',
  1464.     });
  1465.     $('.m_div').css({
  1466.         height: '27px',
  1467.         width: '2px',
  1468.         background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -567px -127px',
  1469.         float: 'left',
  1470.     });
  1471.     $('.m_middle').css({
  1472.         background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -540px -127px',
  1473.         height: '27px',
  1474.         width: '26px',
  1475.         float: 'left',
  1476.     });
  1477.     $('.m_cont').css({
  1478.         margin: '2px',
  1479.         height: '90%',
  1480.         width: '90%',
  1481.         WebkitFilter: 'hue-rotate(-60deg)',
  1482.         filter: 'url(#Hue3)'
  1483.     });
  1484.     $('.m_cont').hover(
  1485.         function() {
  1486.             $(this).parent().css('background','url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -29px -307px');
  1487.             $(this).css('cursor','pointer');
  1488.             $(this).css({
  1489.                 WebkitFilter: 'hue-rotate(150deg)',
  1490.                 filter: 'url(#Hue2)'
  1491.             });
  1492.         }, function(){
  1493.             $(this).parent().css('background','url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -540px -127px');
  1494.             if($(this).hasClass('active')) {
  1495.                 $(this).css({
  1496.                     WebkitFilter: 'hue-rotate(60deg)',
  1497.                     filter: 'url(#Hue1)',
  1498.                 });
  1499.             } else {
  1500.                 $(this).css({
  1501.                     WebkitFilter: 'hue-rotate(-60deg)',
  1502.                     filter: 'url(#Hue3)',
  1503.                 });
  1504.             }
  1505.         }
  1506.     );
  1507.     $('.m_cont').toggle(
  1508.         function(){
  1509.             $(this).toggleClass('active');
  1510.             $(this).css('WebkitFilter','hue-rotate(60deg)');
  1511.             switch(this.id){
  1512.                 case 'm_uni':
  1513.                     $('#unit_box').get(0).style.display = "block";
  1514.                     $('#unit_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1515.                     break;
  1516.                 case 'm_fav': if(!$('.btn_gods_spells').hasClass("active")) {$('.btn_gods_spells').get(0).click(); } break;
  1517.             }
  1518.         }, function(){
  1519.             $(this).toggleClass('active');
  1520.             $(this).css('WebkitFilter','hue-rotate(-60deg)');
  1521.             if(this.id === 'm_uni') $('#unit_box').get(0).style.display = "none";
  1522.             if(this.id === 'm_fav') {if($('.btn_gods_spells').hasClass("active")) {$('.btn_gods_spells').get(0).click();}}
  1523.         }
  1524.     );
  1525. }
  1526.  
  1527. /*******************************************************************************************************************************
  1528.  * Available units
  1529.  * ----------------------------------------------------------------------------------------------------------------------------
  1530.  * | ● Shows all available units
  1531.  * ----------------------------------------------------------------------------------------------------------------------------
  1532.  *******************************************************************************************************************************/
  1533. function addAvailableUnitsButton(){
  1534.     $('<div class="btn_available_units circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1535.     $('.btn_available_units').css({
  1536.         top: '86px',
  1537.         left: '119px',
  1538.         zIndex: '10',
  1539.         position: 'absolute'
  1540.     });
  1541.     $('.btn_available_units .ico_available_units').css({
  1542.         margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  1543.         background: 'url(http://s1.directupload.net/images/140323/w4ekrw8b.png) no-repeat 0px 0px', //http://gpde.innogamescdn.com/images/game/res/unit.png
  1544.         backgroundSize: "100%",
  1545.         WebkitFilter: 'hue-rotate(100deg)',
  1546.         filter: 'url(#Hue3)'
  1547.     });
  1548.     $('.btn_available_units').on('mousedown', function(){
  1549.         $('.ico_available_units').get(0).style.marginTop = "6px";
  1550.     });
  1551.     $('.btn_available_units').toggle(function(){
  1552.         $('#available_units_box').get(0).style.display = "block";
  1553.         $('#available_units_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1554.         $('.btn_available_units').addClass("checked");
  1555.         $('.ico_available_units').get(0).style.marginTop = "6px";
  1556.     }, function(){
  1557.         $('#available_units_box').get(0).style.display = "none";
  1558.         $('.btn_available_units').removeClass("checked");
  1559.         $('.ico_available_units').get(0).style.marginTop = "5px";
  1560.     });
  1561.     $('.btn_available_units').tooltip(LANG[LID].uni);
  1562. }
  1563.  
  1564. /*******************************************************************************************************************************
  1565.  * Comparison
  1566.  * ----------------------------------------------------------------------------------------------------------------------------
  1567.  * | ● Compares the units of each unit type
  1568.  * ----------------------------------------------------------------------------------------------------------------------------
  1569.  *******************************************************************************************************************************/
  1570. function addComparisonButton(){
  1571.     $('<div class="btn_comparison circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1572.     $('.btn_comparison').css({
  1573.         top: '51px',
  1574.         left: '120px',
  1575.         zIndex: '10',
  1576.         position: 'absolute'
  1577.     });
  1578.     $('.btn_comparison .ico_comparison').css({
  1579.         margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  1580.         background: 'url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px',
  1581.         backgroundSize: "100%",
  1582.         WebkitFilter: 'hue-rotate(60deg)',
  1583.         filter: 'url(#Hue1)'
  1584.     });
  1585.     $('.btn_comparison').on('mousedown', function(){
  1586.         $('.ico_comparison').get(0).style.marginTop = "6px";
  1587.     });
  1588.     $('.btn_comparison').toggle(function(){
  1589.         $('#unit_box').get(0).style.display = "block";
  1590.         $('#unit_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1591.         $('.btn_comparison').addClass("checked");
  1592.         $('.ico_comparison').get(0).style.marginTop = "6px";
  1593.     }, function(){
  1594.         $('#unit_box').get(0).style.display = "none";
  1595.         $('.btn_comparison').removeClass("checked");
  1596.         $('.ico_comparison').get(0).style.marginTop = "5px";
  1597.     });
  1598.     $('.btn_comparison').tooltip(LANG[LID].com.dsc);
  1599. }
  1600.  
  1601. function addComparisonBox(){
  1602.     var pos = {
  1603.         att: { hack: "36%", pierce: "27%",  distance: "45.5%",  ship: "72.5%" },
  1604.         def: { hack: "18%", pierce: "18%",  distance: "18%",    ship: "81.5%" }
  1605.     };
  1606.    
  1607.     var unitIMG = "http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png";
  1608.     $('<div id="unit_box" class="ui-dialog">'+
  1609.       '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  1610.       '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  1611.       '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  1612.       '<div style="height:20px; margin-left:35px;">'+
  1613.       '<a class="hack" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.hack +';">'+
  1614.       '<span style="margin-left:20px">'+ LANG[LID].com.hck +'</span></a>'+
  1615.       '<a class="pierce" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.pierce +';">'+
  1616.       '<span style="margin-left:20px">'+ LANG[LID].com.prc +'</span></a>'+
  1617.       '<a class="distance" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.distance +';">'+
  1618.       '<span style="margin-left:20px">'+ LANG[LID].com.dst +'</span></a>'+
  1619.       '<a class="ship" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.ship +';">'+
  1620.       '<span style="margin-left:20px">'+ LANG[LID].com.sea +'</span></a>'+
  1621.       '</div><hr>'+
  1622.       '<div class="box_content"></div></div>').appendTo('body');
  1623.    
  1624.     $('#unit_box a').css({
  1625.         float: 'left',
  1626.         backgroundRepeat: 'no-repeat',
  1627.         backgroundSize: '25px',
  1628.         lineHeight: '2',
  1629.         marginRight:'10px'
  1630.     });
  1631.     $('#unit_box span').css({
  1632.         marginLeft: '27px',
  1633.     });
  1634.     $('#unit_box').draggable({
  1635.         containment: "body",
  1636.         snap: "body",
  1637.     });
  1638.     $('#unit_box').css({
  1639.         position: 'absolute',
  1640.         top: '100px',
  1641.         left: '200px',
  1642.         zIndex: getMaxZIndex() + 1,
  1643.         display: 'none'
  1644.     });
  1645.     $('#unit_box .box_content').css({
  1646.         background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  1647.         backgroundSize: '140px'
  1648.     });
  1649.    
  1650.     $('#unit_box').bind("mousedown",function(){
  1651.         $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  1652.     });
  1653.    
  1654.     addComparisonTable("hack");
  1655.     addComparisonTable("pierce");
  1656.     addComparisonTable("distance");
  1657.     addComparisonTable("ship");
  1658.    
  1659.     $('#unit_box .t_hack').get(0).style.display = "block";
  1660.    
  1661.     switchComparisonTables();
  1662.    
  1663.     $('#unit_box hr').css({ border: '1px solid', color: '#804000', float:'none' });
  1664. }
  1665.  
  1666. function switchComparisonTables(){
  1667.     $('#unit_box .hack, #unit_box .pierce, #unit_box .distance, #unit_box .ship').click(function(){
  1668.         $('#unit_box [class^="t_"]').css({ display : "none" });
  1669.         $('#unit_box .t_'+this.className).get(0).style.display = "block";
  1670.     });
  1671. }
  1672.  
  1673. var ttpArray = [], t = 0;
  1674. function addComparisonTable(type){
  1675.     var pos = {
  1676.         att: { hack: "36%", pierce: "27%",  distance: "45.5%",  ship: "72.5%" },
  1677.         def: { hack: "18%", pierce: "18%",  distance: "18%",    ship: "81.5%" }
  1678.     };
  1679.     var unitIMG = "http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png";
  1680.     var strArray = [
  1681.         "<td></td>",
  1682.         '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att[type] +';"></div></td>',
  1683.         '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.def[type] +';"></div></td>',
  1684.         '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 63%;"></div></td>',
  1685.         (type !== "ship") ? '<td><div class="booty"></div></td>' : '<td><div class="bla" style="background-image: url('+ unitIMG +'); background-position: 0% 91%;"></div></td>',
  1686.         '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 54%;"></div></td>',
  1687.         '<td><div class="bla" style="background: url(http://de.cdn.grepolis.com/images/game/res/favor.png)"></div></td>',
  1688.         '<td><div class="bla" style="background: url(http://de.cdn.grepolis.com/images/game/res/time.png);"></div></td>'
  1689.     ];
  1690.    
  1691.     for(var e in unitVal){
  1692.         if(unitVal.hasOwnProperty(e)){
  1693.             var valArray = [];
  1694.            
  1695.             if(type === (unitVal[e].attack_type || "ship") && (e !== "militia")) {
  1696.                 valArray.att    = Math.round(unitVal[e].attack*10 / unitVal[e].population) / 10;
  1697.                 valArray.def    = Math.round(((unitVal[e].def_hack + unitVal[e].def_pierce + unitVal[e].def_distance)*10)/(3*unitVal[e].population)) / 10;
  1698.                 valArray.def    = valArray.def || Math.round(unitVal[e].defense*10/unitVal[e].population) / 10;
  1699.                 valArray.speed  = unitVal[e].speed;
  1700.                 valArray.booty  = Math.round(((unitVal[e].booty)*10) / unitVal[e].population) / 10;
  1701.                 valArray.booty  = valArray.booty || Math.round(((unitVal[e].capacity ? unitVal[e].capacity + 6 : 0)*10) / unitVal[e].population) / 10;
  1702.                 valArray.favor  = Math.round((unitVal[e].favor *10)/ unitVal[e].population) / 10;
  1703.                 valArray.res    = Math.round((unitVal[e].resources.wood + unitVal[e].resources.stone + unitVal[e].resources.iron)/(unitVal[e].population));
  1704.                 valArray.time   = Math.round(unitVal[e].build_time / unitVal[e].population);
  1705.                
  1706.                 valArray.hero   = (!uw.Game.is_hero_world && ((e === "griffin") || (e === "calydonian_boar")))? "-webkit-filter:grayscale(100%); filter: url(#GrayScale)": "";
  1707.                
  1708.                 strArray[0] += '<td class="un'+ (t) +'"><div class="unit index_unit unit_icon40x40 ' + e + '" style="'+ valArray.hero +'"></div></td>';
  1709.                 strArray[1] += '<td class="bold" style="color:'+ ((valArray.att>19)?'green':((valArray.att<10 && valArray.att!=0 )?'red':'black')) +';">'+ valArray.att +'</td>';
  1710.                 strArray[2] += '<td class="bold" style="color:'+ ((valArray.def>19)?'green':((valArray.def<10 && valArray.def!=0 )?'red':'black')) +';">'+ valArray.def +'</td>';
  1711.                 strArray[3] += '<td class="bold">'+ valArray.speed  +'</td>';
  1712.                 strArray[4] += '<td class="bold">'+ valArray.booty  +'</td>';
  1713.                 strArray[5] += '<td class="bold">'+ valArray.res    +'</td>';
  1714.                 strArray[6] += '<td class="bold" style="color:'+ ((valArray.favor>0)?'rgb(0, 0, 214)':'black') +';">'+ valArray.favor   +'</td>';
  1715.                 strArray[7] += '<td class="bold">'+ valArray.time   +'</td>';
  1716.                
  1717.                 ttpArray[t] = unitVal[e].name; t++;
  1718.             }
  1719.         }
  1720.     }
  1721.    
  1722.     $('<table class="t_'+ type +'" cellpadding="1px" style="display:none">'+
  1723.       '<tr>'+ strArray[0] +'</tr>'+
  1724.       '<tr class="tr_att">'+ strArray[1] +'</tr><tr class="tr_def">'+ strArray[2] +'</tr>'+
  1725.       '<tr class="tr_spd">'+ strArray[3] +'</tr><tr class="tr_bty_'+ type +'">'+ strArray[4] +'</tr>'+
  1726.       '<tr class="tr_res">'+ strArray[5] +'</tr><tr class="tr_fav">'+ strArray[6] +'</tr><tr class="tr_tim">'+ strArray[7] +'</tr>'+
  1727.       '</table>').appendTo('#unit_box .box_content');
  1728.    
  1729.     for(var i = 0; i <= t; i++){
  1730.         $('.un'+i).tooltip(ttpArray[i]);
  1731.     }
  1732.    
  1733.     $('.tr_att').tooltip(LANG[LID].com.att);
  1734.     $('.tr_def').tooltip(LANG[LID].com.def + " (Ø)");
  1735.     $('.tr_spd').tooltip(LANG[LID].com.spd);
  1736.     $('.tr_bty_'+ type).tooltip(((type!=="ship")? LANG[LID].com.bty : LANG[LID].com.cap));
  1737.     $('.tr_res').tooltip(LANG[LID].com.res);
  1738.     $('.tr_fav').tooltip(LANG[LID].com.fav);
  1739.     $('.tr_tim').tooltip(LANG[LID].com.tim);
  1740.    
  1741.     //$('#unit_box .box_content').css({ position: 'relative' });
  1742.     $('#unit_box .bla').css({
  1743.         height: '25px',
  1744.         width: '25px',
  1745.         backgroundSize: '100%',
  1746.         float: 'left'
  1747.     });
  1748.     $('#unit_box .booty').css({
  1749.         width: '25px',
  1750.         height: '25px',
  1751.         background: 'url(http://de.cdn.grepolis.com/images/game/layout/layout_2.56_compressed.png)',
  1752.         backgroundSize: '3400%',
  1753.         backgroundPosition: '0% 58.5%'
  1754.     });
  1755. }
  1756.  
  1757. /*******************************************************************************************************************************
  1758.  * Reports and Messages
  1759.  * ----------------------------------------------------------------------------------------------------------------------------
  1760.  * | ● Storage of the selected filter (only in German Grepolis yet)
  1761.  * ----------------------------------------------------------------------------------------------------------------------------
  1762.  *******************************************************************************************************************************/
  1763.  
  1764. var filter = "all";
  1765. function saveFilter(){
  1766.     $('#dd_filter_type_list .item-list div').each(function(){
  1767.         $(this).click(function(){
  1768.             filter = $(this).attr("name");
  1769.         });
  1770.     });
  1771.     /*
  1772.     var i = 0;
  1773.     $("#report_list a").each(function () {
  1774.         console.log((i++) +" = " + $(this).attr('data-reportid'));
  1775.     });
  1776.     */
  1777. }
  1778.  
  1779. function loadFilter(){
  1780.     if(!($('#dd_filter_type_list .selected').attr("name") === filter)){
  1781.         $('#dd_filter_type .caption').get(0).click();
  1782.         $('#dd_filter_type_list .item-list div[name='+ filter +']').get(0).click();
  1783.     }
  1784. }
  1785.  
  1786. function removeReports(){
  1787.     $("#report_list li:contains('spioniert')").each(function () {
  1788.         //$(this).remove();
  1789.     });
  1790. }
  1791.  
  1792.  
  1793. var zut = 0;
  1794. var messageArray = {};
  1795. function filterPlayer(){
  1796.     if(!$('#message_filter_list').get(0)) {
  1797.         $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
  1798.         $("#message_list").get(0).style.display = "none";
  1799.     }
  1800.     if(zut < parseInt($('.es_last_page').get(0).value, 10)-1){
  1801.         $('.es_page_input').get(0).value = zut++;
  1802.         $('.jump_button').get(0).click();
  1803.         $("#message_list li:contains('')").each(function () {
  1804.             $(this).appendTo('#message_filter_list');
  1805.         });
  1806.     } else {
  1807.         zut = 1;
  1808.     }
  1809. }
  1810.  
  1811.  
  1812. /*******************************************************************************************************************************
  1813.  * World Wonder
  1814.  * ----------------------------------------------------------------------------------------------------------------------------
  1815.  * | ● click adjustment
  1816.  * | ● Share calculation (= ratio of player points to alliance points)
  1817.  * | ● Resources calculation & counter (stores amount)
  1818.  * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
  1819.  * ----------------------------------------------------------------------------------------------------------------------------
  1820.  *******************************************************************************************************************************/
  1821.  
  1822. // getPointRatio: Default
  1823. function getPointRatioFromGS(){
  1824.     var gs = 0, AP = 0;
  1825.     setTimeout(function(){
  1826.         GM_xmlhttpRequest({
  1827.             method: "GET",
  1828.             url: "http://de.grepostats.com/world/" + WID + "/alliance/" + AID,
  1829.             onload: function(response) {
  1830.                 gs = response.responseText;
  1831.                 gs = gs.substr(gs.indexOf("Punkte"));
  1832.                 gs = gs.substr(gs.indexOf("<td>")+4);
  1833.                 gs = gs.substr(0, gs.indexOf("</td>"));
  1834.                 AP = parseInt(gs.replace(/\,/g, ''), 10);
  1835.                 //console.log("Allianzpunkte: " + AP);
  1836.                 ratio = 100 / AP * uw.Game.player_points;
  1837.                 GM_setValue(WID + "_ratio", ratio);
  1838.             }
  1839.         });  
  1840.     }, 0);
  1841. }
  1842.  
  1843. function getPointRatioFromAllianceRanking(){
  1844.     ratio = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
  1845.     setTimeout(function(){
  1846.         GM_setValue(WID + "_ratio", ratio);
  1847.     },0);
  1848. }
  1849.  
  1850. function getPointRatioFromAllianceMembers(){
  1851.     var points = 0;
  1852.     $('#ally_members_body tr').each(function(){
  1853.         points += parseInt($(this).children().eq(2).text(), 10) || 0;
  1854.     });
  1855.     ratio = 100 / points * uw.Game.player_points;
  1856.     setTimeout(function(){
  1857.         GM_setValue(WID + "_ratio", ratio);
  1858.     },0);
  1859. }
  1860.  
  1861. if(uw.location.pathname === "/game/index"){
  1862.     var ww_res = JSON.parse(GM_getValue(WID + "_ww_res", '{}'));
  1863. }
  1864.  
  1865. // TODO: Split function...
  1866. function getResWW(){
  1867.     var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
  1868.    
  1869.     for(var e in wndArray){
  1870.         if(wndArray.hasOwnProperty(e)){
  1871.             var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  1872.            
  1873.             if(!$(wndID + '.wonder_finished').get(0)){
  1874.                 var res = 0,
  1875.                     ww_share = {total: {share:0, sum:0}, stage: {share:0, sum:0}},
  1876.                     ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
  1877.                     res_stages = [ 2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
  1878.                     stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
  1879.                     speed = uw.Game.game_speed;
  1880.                
  1881.                 ww_res[ww_type] = ww_res[ww_type] || {};
  1882.                
  1883.                 ww_res[ww_type][stage] = ww_res[ww_type][stage] || 0;
  1884.                
  1885.                 if(!$(wndID + '.ww_ratio').get(0)) {
  1886.                     $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
  1887.                     $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
  1888.                     $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
  1889.                 }
  1890.                
  1891.                 $(wndID + '.wonder_progress').css({
  1892.                     margin: '0 auto 5px'
  1893.                 });
  1894.                 $(wndID + '.wonder_header').css({
  1895.                     textAlign: 'left',
  1896.                     margin: '10px -8px 12px 3px'
  1897.                 });
  1898.                 $(wndID + '.build_wonder_icon').css({
  1899.                     top: '25px',
  1900.                 });
  1901.                 $(wndID + '.wonder_progress_bar').css({
  1902.                     top: '54px',
  1903.                 });
  1904.                 $(wndID + '.wonder_controls').css({
  1905.                     height: '380px',
  1906.                 });
  1907.                
  1908.                 $(wndID + '.trade fieldset').css({
  1909.                     float: 'right',
  1910.                 });
  1911.                
  1912.                 $(wndID + '.wonder_res_container').css({
  1913.                     right: '29px'
  1914.                 });
  1915.                
  1916.                 $(wndID + '.ww_ratio').css({
  1917.                     position: 'relative',
  1918.                     height: 'auto'
  1919.                 });
  1920.                 $(wndID + 'fieldset').css({
  1921.                     height: 'auto'
  1922.                 });
  1923.                 $(wndID + '.town-capacity-indicator').css({
  1924.                     marginTop: '0px'
  1925.                 });
  1926.                
  1927.                 for(var d in res_stages){
  1928.                     if(res_stages.hasOwnProperty(d)){
  1929.                         ww_share.total.sum += res_stages[d];
  1930.                     }
  1931.                 }
  1932.                
  1933.                 ww_share.total.sum *= speed * 300000;
  1934.                
  1935.                 ww_share.total.share = parseInt(ratio * (ww_share.total.sum / 100), 10);
  1936.                
  1937.                 ww_share.stage.sum = speed * res_stages[stage-1] * 300000;
  1938.                
  1939.                 ww_share.stage.share = parseInt(ratio * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
  1940.                 setResWW(stage, ww_type, ww_share, wndID);
  1941.                
  1942.                 $(wndID + '.wonder_res_container .send_resources_btn').click(function(){
  1943.                     ww_res[ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
  1944.                     ww_res[ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
  1945.                     ww_res[ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
  1946.                    
  1947.                     //console.log(ww_res[ww_type][stage]);
  1948.                    
  1949.                     setResWW(stage, ww_type, ww_share, wndID);
  1950.                    
  1951.                     setTimeout(function(){
  1952.                         GM_setValue(WID + "_ww_res", JSON.stringify(ww_res));
  1953.                     }, 0);
  1954.                 });
  1955.             } else {
  1956.                 $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
  1957.                
  1958.                 $(wndID + '.pos_Y').css({
  1959.                     top: '-266px',
  1960.                 });
  1961.             }
  1962.         }
  1963.     }
  1964. }
  1965.  
  1966. function setResWW(stage, ww_type, ww_share, wndID){
  1967.     //console.log(ww_res);
  1968.     var width_stage, width_total, res_total = 0, disp_stage = "none", disp_total = "none";
  1969.    
  1970.     for(var z in ww_res[ww_type]){
  1971.         if(ww_res[ww_type].hasOwnProperty(z)){
  1972.             res_total += ww_res[ww_type][z];
  1973.         }
  1974.     }
  1975.    
  1976.     if(ww_share.stage.share > ww_res[ww_type][stage]){
  1977.         width_stage = (242 / ww_share.stage.share) * ww_res[ww_type][stage];
  1978.     } else {
  1979.         width_stage = 0;
  1980.         disp_stage = "block";
  1981.     }
  1982.     if(ww_share.total.share > res_total){
  1983.         width_total = (242 / ww_share.total.share) * res_total;
  1984.     } else {
  1985.         width_total = 0;
  1986.         disp_total = "block";
  1987.     }
  1988.     //console.log(ratio);
  1989.    
  1990.     $(wndID + '.ww_ratio').get(0).innerHTML = "";
  1991.     $(wndID + '.ww_ratio').append('<legend>'+ LANG[LID].wwc.leg +' (<span style="color:#090">'+ (Math.round(ratio * 100) / 100) +'%</span>):</legend>'+
  1992.                                   '<div class="town-capacity-indicator">'+
  1993.                                   '<div class="icon all_res"></div>'+
  1994.                                   '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">'+
  1995.                                   '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  1996.                                   '<div class="progress overloaded">'+
  1997.                                   '<div class="indicator3" style="left: 0px; width:'+ width_stage +'px"></div>'+
  1998.                                   '<span class="ww_perc">' + Math.round(ww_res[ww_type][stage]/ww_share.stage.share*100) + '%</span>'+
  1999.                                   '<div class="indicator4" style="left: 0px; display:'+ disp_stage +'"></div>'+
  2000.                                   '</div>'+
  2001.                                   '<div class="amounts">'+ LANG[LID].wwc.stg +': <span class="curr">'+ pointNumber(ww_res[ww_type][stage]) +'</span> / '+
  2002.                                   '<span class="max">'+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +'</span></div>'+
  2003.                                   '</div></div>'+
  2004.                                   '<div class="town-capacity-indicator">'+
  2005.                                   '<div class="icon all_res"></div>'+
  2006.                                   '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">'+
  2007.                                   '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  2008.                                   '<div class="progress overloaded">'+
  2009.                                   '<div class="indicator3" style="left: 0px; width:'+ width_total +'px;"></div>'+
  2010.                                   '<span class="ww_perc">'+ Math.round(res_total/ww_share.total.share*100) +'%</span>'+
  2011.                                   '<div class="indicator4" style="left: 0px; display:'+ disp_total +'"></div>'+
  2012.                                   '</div>'+
  2013.                                   '<div class="amounts">'+ LANG[LID].wwc.tot +': <span class="curr">'+ pointNumber(res_total) +'</span> / '+
  2014.                                   '<span class="max">'+ pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) +'</span></div>'+
  2015.                                   '</div></div>');
  2016.    
  2017.     $('.ww_ratio .progress').css({
  2018.         //position: 'absolute',
  2019.         //textAlign: 'center',
  2020.         lineHeight: '1',
  2021.         color: 'white',
  2022.         fontSize: '0.8em'
  2023.     });
  2024.    
  2025.     $(wndID + '.ww_perc').css({
  2026.         position:'absolute',
  2027.         width:'242px',
  2028.         textAlign: 'center'
  2029.     });
  2030.    
  2031.     $(wndID + '.indicator4').css({
  2032.         background: 'url(http://gpde.innogamescdn.com/images/game/layout/progressbars-sprite_2.53.png) no-repeat 0 0',
  2033.         backgroundPosition: '0px -355px',
  2034.         height: '10px',
  2035.         zIndex: '13000',
  2036.         width: '242px'
  2037.     });
  2038.     $(wndID + '.all_res').css({
  2039.         background: 'url(http://de.cdn.grepolis.com/images/game/layout/resources_2.32.png) no-repeat 0 -90px',
  2040.         width: '30px',
  2041.         height: '30px',
  2042.         margin: '0 auto',
  2043.         marginLeft: '5px'
  2044.     });
  2045.     $(wndID + '.town-capacity-indicator').css({
  2046.         marginTop: '0px'
  2047.     });
  2048.    
  2049.     $(wndID + '.ww_ratio').tooltip("<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>"+
  2050.                                    "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>"+
  2051.                                    "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>("+ (Math.round((ratio) * 100) / 100) +"%)</span></td>"+
  2052.                                    "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>"+
  2053.                                    "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ LANG[LID].wwc.stg + "&nbsp;" + stage +"</td>"+
  2054.                                    "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +"</td>"+
  2055.                                    "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>"+
  2056.                                    "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ LANG[LID].wwc.tot +"</td>"+
  2057.                                    "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.total.share / 1000) * 1000) +"</td>"+
  2058.                                    "<td>"+ pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) +"</td>"+
  2059.                                    "</tr></table>");
  2060. }
  2061.  
  2062. // Adds points to numbers
  2063. function pointNumber(number) {
  2064.     var sep; if(LID === "de"){ sep = "."; } else { sep = ",";}
  2065.    
  2066.     number = number.toString();
  2067.     if (number.length > 3) {
  2068.         var mod = number.length % 3;
  2069.         var output = (mod > 0 ? (number.substring(0,mod)) : '');
  2070.        
  2071.         for (var i=0 ; i < Math.floor(number.length / 3); i++) {
  2072.             if ((mod == 0) && (i == 0)) {
  2073.                 output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
  2074.             } else {
  2075.                 output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
  2076.             }
  2077.         }
  2078.         number = output;
  2079.     }
  2080.     return number;
  2081. }
  2082.  
  2083. /*******************************************************************************************************************************
  2084.  * Farming Village Overview
  2085.  * ----------------------------------------------------------------------------------------------------------------------------
  2086.  * | ● Color change on possibility of city festivals
  2087.  * ----------------------------------------------------------------------------------------------------------------------------
  2088.  *******************************************************************************************************************************/
  2089.  
  2090. function changeResColor(){
  2091.     var res, res_min, i = 0;
  2092.     $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function(){
  2093.         if($(this).parent().hasClass("stone")){
  2094.             res_min = 18000;
  2095.         } else {
  2096.             res_min = 15000;
  2097.         }
  2098.         res = parseInt($(this).get(0).innerHTML, 10);
  2099.         if((res >= res_min) && !($(this).hasClass("town_storage_full"))){
  2100.             $(this).get(0).style.color = '#0A0';
  2101.         }
  2102.         if(res < res_min){
  2103.             $(this).get(0).style.color = '#000';
  2104.         }
  2105.     });
  2106. }
  2107.  
  2108. /*******************************************************************************************************************************
  2109.  * Conquest Info
  2110.  * -----------------------------------------------------------------------------------------------------------------------------
  2111.  * | ● Amount of supports und attacks in the conquest window
  2112.  * | ● Layout adjustment (for reasons of clarity)
  2113.  * | - TODO: conquest window of own cities
  2114.  * -----------------------------------------------------------------------------------------------------------------------------
  2115.  *******************************************************************************************************************************/
  2116.  
  2117. function countMovements(){
  2118.     var i = 0, a = 0;
  2119.     $('#unit_movements .support').each(function(){
  2120.         i++;
  2121.     });
  2122.     $('#unit_movements .attack_land, #unit_movements .attack_sea, #unit_movements .attack_takeover').each(function(){
  2123.         a++;
  2124.     });
  2125.    
  2126.     var str = "<div style='position: absolute;width: 100px;margin-top: -16px;left: 40%;'><div style='float:left;margin-right:5px;'></div>"+
  2127.         "<div class='troops' id='count_def'></div>"+
  2128.         "<div class='troops' style='color:green;'> " + i + "</div>"+
  2129.         "<div class='troops' id='count_off'> </div>"+
  2130.         "<div style='color:red;'> " + a + "</div></div>"+
  2131.         "<hr class='move_hr'>";
  2132.    
  2133.     if($('.gpwindow_content .tab_content .bold').get(0)){
  2134.         $('.gpwindow_content .tab_content .bold').append(str);
  2135.     } else {
  2136.         $('.gpwindow_content h4:eq(1)').append(str);
  2137.        
  2138.         // TODO: set player link ?
  2139.         /*
  2140.         $('#unit_movements li div').each(function(){
  2141.            
  2142.             //console.log($(this).get(0).innerHTML);
  2143.         });
  2144.         */
  2145.     }
  2146.     $('.move_hr').css({
  2147.         margin: '7px 0px 0px 0px',
  2148.         backgroundColor: '#5F5242',
  2149.         height: '2px',
  2150.         border: '0px solid'
  2151.     });
  2152.    
  2153.     // smaller movements
  2154.     $('#unit_movements').css({
  2155.         fontSize: '0.80em'
  2156.     });
  2157.     $('.incoming').css({
  2158.         width: '150px',
  2159.         height: '45px',
  2160.         float: 'left'
  2161.     });
  2162.     $('#unit_movements div').each(function(){
  2163.         if($(this).attr('class') === "unit_movements_arrow"){
  2164.             // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
  2165.             if(!$(this).get(0).style.background) { $(this).get(0).remove(); }
  2166.         } else {
  2167.             // realign texts
  2168.             $(this).css({
  2169.                 margin: '3px',
  2170.                 paddingLeft: '3px'
  2171.             });
  2172.         }
  2173.     });
  2174.    
  2175.     $('.troops').css({
  2176.         float: 'left',
  2177.         margin: '0px 5px 0px 0px',
  2178.         height:'18px',
  2179.         width:'18px',
  2180.         position: 'relative'
  2181.     });
  2182.     $('#count_def').css({
  2183.         background: 'url(http://de.cdn.grepolis.com/images/game/place/losts.png)',
  2184.         backgroundPosition: '0 -36px'
  2185.     });
  2186.     $('#count_off').css({
  2187.         background: 'url(http://de.cdn.grepolis.com/images/game/place/losts.png)',
  2188.         backgroundPosition: '0 0px'
  2189.     });
  2190. }
  2191.  
  2192. /*******************************************************************************************************************************
  2193.  * Town window
  2194.  * ----------------------------------------------------------------------------------------------------------------------------
  2195.  * | ● TownTabHandler (trade, attack, support,...)
  2196.  * | ● Sent units box
  2197.  * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
  2198.  * | ● Trade options:
  2199.  * |    - Ressource marks on possibility of city festivals
  2200.  * |    - Percentual Trade: Trade button
  2201.  * |    - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
  2202.  * ----------------------------------------------------------------------------------------------------------------------------
  2203.  *******************************************************************************************************************************/
  2204.  
  2205. // TODO: Change both functions in MultipleWindowHandler()
  2206. function TownTabHandler(action){
  2207.     var wndArray, wndID, wndA;
  2208.     wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN);
  2209.     for(var e in wndArray){
  2210.         if(wndArray.hasOwnProperty(e)){
  2211.             wndA = wndArray[e].getAction(); wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2212.             if(wndA === action){
  2213.                 switch(action){
  2214.                     case "trading":
  2215.                         if(!$(wndID + '.rec_trade').get(0)){
  2216.                             addRecTrade(wndID);
  2217.                         }
  2218.                         if(!($(wndID + '.btn_trade').get(0))){
  2219.                             addPercentTrade(wndID, false);
  2220.                         }
  2221.                         //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
  2222.                         break;
  2223.                     case "support": case "attack":
  2224.                         if(options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))){
  2225.                             addShortDuration(wndID);
  2226.                         }
  2227.                         if(options.sen) {
  2228.                             addSentUnitsBox(wndID, action);
  2229.                         }
  2230.                         break;
  2231.                     case "rec_mark":
  2232.                         //addTradeMarks(wndID, 15, 18, 15, "lime");
  2233.                         break;
  2234.                 }
  2235.             }
  2236.         }
  2237.     }
  2238. }
  2239.  
  2240. function WWTradeHandler(){
  2241.     var wndArray, wndID, wndA;
  2242.     wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
  2243.     for(var e in wndArray){
  2244.         if(wndArray.hasOwnProperty(e)){
  2245.             wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2246.             if(!($(wndID + '.btn_trade').get(0) || $(wndID +'.next_building_phase').get(0) || $(wndID +'#ww_time_progressbar').get(0))){
  2247.                 addPercentTrade(wndID, true);
  2248.             }
  2249.         }
  2250.     }
  2251. }
  2252.  
  2253. /*******************************************************************************************************************************
  2254.  * ● Sent units box
  2255.  *******************************************************************************************************************************/
  2256. var sentUnitsArray = JSON.parse(GM_getValue(WID +"_sentUnitsArray", '{ "attack": {}, "support": {} }'));
  2257.  
  2258. function addSentUnitsBox(wndID, action){
  2259.     if(!$(wndID + '.sent_units_box').get(0)){
  2260.         var selectedUnitsArray = {};
  2261.         $('<div class="game_inner_box sent_units_box"><div class="game_border ">'+
  2262.           '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>'+
  2263.           '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div><div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  2264.           '<div class="game_header bold">'+
  2265.           '<div class="icon_sent townicon_'+ (action == "attack" ? "lo" : "ld") +'"></div><span>'+ LANG[LID].sen.lab +' ('+ (action == "attack" ? "OFF" : "DEF") +')</span>'+
  2266.           '</div>'+
  2267.           '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">'+
  2268.           '<div id="btn_sent_units_reset" class="button_new">'+
  2269.           '<div class="left"></div>'+
  2270.           '<div class="right"></div>'+
  2271.           '<div class="caption js-caption">'+ LANG[LID].sen.rst +'<div class="effect js-effect"></div></div>'+
  2272.           '</div>'+
  2273.           '</div></div>').appendTo(wndID + '.attack_support_window');
  2274.        
  2275.         /* New-Feature Info
  2276.         $('<div style="width:130px; margin-bottom: 10px">'+
  2277.           '<div style="margin: -4px 0px 0px 4px; float:left; width: 24px; height: 24px; background-image: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif); background-size: 100%; background-position: 0px 0px; background-repeat: no-repeat no-repeat;"></div>'+
  2278.           '<div style="color: green;line-height:1;"><b><nobr>&nbsp;New Feature!</nobr></b></div></div>').prependTo(wndID + '.sent_units_box');
  2279.         */
  2280.         updateSentUnitsBox(wndID, action);
  2281.        
  2282.         $(wndID + '.icon_sent').css({
  2283.             height: '20px',
  2284.             marginTop: '-2px',
  2285.             width: '20px',
  2286.             backgroundSize: '17px',
  2287.             paddingLeft: '0px',
  2288.             marginLeft: '0px'
  2289.         });
  2290.        
  2291.         $(wndID + '.sent_units_box').css({
  2292.             position: 'absolute',
  2293.             right: '0px',
  2294.             bottom: '16px',
  2295.             width: '192px',
  2296.             //border: '2px solid green',
  2297.             //borderRadius: '5px',
  2298.             //padding: '5px'
  2299.         });
  2300.         $(wndID + '.troops').css({ padding: '6px 0px 6px 6px' });
  2301.        
  2302.         setTimeout(function(){
  2303.             $(wndID +'.send_units_form a').each(function(){
  2304.                 $(this).click(function(){
  2305.                     selectedUnitsArray = getSelectUnits(wndID);
  2306.                 });
  2307.             });
  2308.         },10);
  2309.        
  2310.         $(wndID + '.unit_input').on("blur", function(){
  2311.             selectedUnitsArray = getSelectUnits(wndID);
  2312.         });
  2313.         /*
  2314.         $(wndID + '.unit_container a').on("click", function(){
  2315.             selectedUnitsArray[$(this).attr("id")] = $(wndID + '.unit_type_'+ $(this).attr("id")).val();  
  2316.             console.log($(this).attr("id"));
  2317.             console.log(selectedUnitsArray);                        
  2318.         });
  2319.         */
  2320.        
  2321.         $(wndID + '#btn_sent_units_reset').click(function(){
  2322.             // Overwrite old array
  2323.             sentUnitsArray[action] = {}; updateSentUnitsBox(wndID, action);
  2324.         });
  2325.        
  2326.         $(wndID + '.attack_support_window .button').click(function(){
  2327.             getSentUnits(wndID, action, selectedUnitsArray);
  2328.         });
  2329.         $(wndID + '#btn_attack_town').click(function(){
  2330.             getSentUnits(wndID, action, selectedUnitsArray);
  2331.         });
  2332.     }
  2333. }
  2334.  
  2335. function getSelectUnits(wndID){
  2336.     var selectedUnitsArray = {};
  2337.     for(var u in unitVal){
  2338.         if(unitVal.hasOwnProperty(u)){
  2339.             var a = parseInt($(wndID + '.unit_type_'+ u).val(), 10);
  2340.            
  2341.             if(a > 0){ selectedUnitsArray[u] = parseInt(a, 10); } else { delete selectedUnitsArray[u]; }
  2342.         }
  2343.     }
  2344.     return selectedUnitsArray;
  2345. }
  2346.  
  2347. function getSentUnits(wndID, action, selectedUnitsArray){
  2348.     var sentSuccess = true, capaShip = 0, capaUnit = 0, popUnit = 0, seaMovement = false;
  2349.     var u = 0;
  2350.     if(!$('#human_message').get(0)){
  2351.         $('body').append('<div id="human_message" class="human_message human_message_success" style="display: none; opacity: 0;"></div>');
  2352.     }
  2353.     // check if sending was successful
  2354.     var human_message = new MutationObserver(function(mutations) {
  2355.         mutations.forEach(function(mutation) {
  2356.             if(u == 0){
  2357.                 if($('#human_message').attr("class").split(" ")[1] === "human_message_success"){
  2358.                     // Add selected units to sent units
  2359.                     for(var t in selectedUnitsArray){
  2360.                         if(selectedUnitsArray.hasOwnProperty(t)){
  2361.                             sentUnitsArray[action][t] = sentUnitsArray[action][t] || 0;
  2362.                             sentUnitsArray[action][t] += selectedUnitsArray[t];
  2363.                         }
  2364.                     }
  2365.                     updateSentUnitsBox(wndID, action);
  2366.                 }
  2367.             }
  2368.             u++; human_message.disconnect();
  2369.         });    
  2370.     });
  2371.     human_message.observe($('#human_message').get(0), { attributes: true, childList: false, characterData: false, attributeFilter: ["style"] });
  2372. }
  2373.  
  2374. function updateSentUnitsBox(wndID, action){
  2375.     // Remove old unit list
  2376.     $(wndID +'.sent_units_box .units_list').get(0).innerHTML = "";
  2377.     // Add new unit list
  2378.     for(var x in sentUnitsArray[action]){
  2379.         if(sentUnitsArray[action].hasOwnProperty(x)){
  2380.             if((sentUnitsArray[action][x] || 0) > 0){
  2381.                 $('<div class="unit_icon25x25 '+ x + (sentUnitsArray[action][x] >= 1000  ? (sentUnitsArray[action][x] >= 10000  ? " five_digit_number" : " four_digit_number") : "") +'">'+
  2382.                   '<span class="count text_shadow">'+ sentUnitsArray[action][x] +'</span>'+
  2383.                   '</div>').appendTo(wndID +'.sent_units_box .units_list');
  2384.             }
  2385.         }
  2386.     }
  2387.     setTimeout(function(){
  2388.         GM_setValue(WID +"_sentUnitsArray", JSON.stringify(sentUnitsArray));
  2389.     }, 0);
  2390. }
  2391.  
  2392. /*******************************************************************************************************************************
  2393.  * ● Short duration
  2394.  *******************************************************************************************************************************/
  2395. function addShortDuration(wndID){
  2396.     $(wndID + '.way_duration').after('<span class="short_duration">0:00:00</span>');
  2397.     /*
  2398.     $(wndID + '.arrival_time').after('<span class="short_arrival">'+ $('.server_time_area').get(0).innerHTML.split(" ")[0] +'</span>');
  2399.    
  2400.     setInterval(function(){
  2401.         var t = $(wndID + '.short_arrival').get(0).innerHTML.split(":"), s, m, h;
  2402.        
  2403.         s = parseInt((parseInt(t[2], 10) + 1) % 60, 10);
  2404.        
  2405.         m = parseInt((parseInt(t[1], 10) + (parseInt(t[2],10) + 1) / 60) % 60, 10);
  2406.        
  2407.         h = parseInt((parseInt(t[0], 10) + (parseInt(t[1], 10) + (parseInt(t[2],10) + 1) / 60) / 60) % 24, 10);
  2408.        
  2409.         $(wndID + '.short_arrival').get(0).innerHTML = h + ":" + m + ":" + s;
  2410.     }, 1000);
  2411.     */
  2412.    
  2413.     $(wndID + '.short_duration').tooltip("Verbesserte Truppenbewegung");
  2414.    
  2415.     changeShortDuration(wndID);
  2416.    
  2417.     // Style
  2418.     $(wndID + '.duration_container').css({
  2419.         width:'390px'
  2420.     });
  2421.     $(wndID + '.short_duration').css({
  2422.         position: 'relative',
  2423.         float: 'left',
  2424.         color: 'darkgreen',
  2425.         padding: '6px 3px 6px 30px',
  2426.         background: 'url(http://666kb.com/i/ck2c7eohpyfa3yczt.png) no-repeat',
  2427.         backgroundSize: '28px',
  2428.         backgroundPosition: '4px 2px'
  2429.     });
  2430. }
  2431.  
  2432. function changeShortDuration(wndID){
  2433.     var duration = new MutationObserver(function(mutations) {
  2434.         mutations.forEach(function(mutation) {
  2435.             if(mutation.addedNodes[0]){
  2436.                 calcShortDuration(wndID);
  2437.             }
  2438.         });    
  2439.     });
  2440.     duration.observe($(wndID + '.way_duration').get(0), { attributes: false, childList: true, characterData: false});
  2441. }
  2442.  
  2443. function calcShortDuration(wndID){
  2444.     var speed = uw.Game.game_speed, setupTime = 900/speed,
  2445.         time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~","").split(":"),
  2446.         h,m,s;
  2447.    
  2448.     time = (((parseInt(time[0], 10)*60 + parseInt(time[1], 10))*60 + parseInt(time[2], 10) - setupTime) / 1.3) + setupTime;
  2449.    
  2450.     h = Math.floor(time/3600);
  2451.     m = Math.floor((time - h*3600)/60);
  2452.     s = Math.floor(time - h*3600 - m*60);
  2453.    
  2454.     if(m < 10) { m = "0" + m; }
  2455.     if(s < 10) { s = "0" + s; }
  2456.    
  2457.     $(wndID + '.short_duration').get(0).innerHTML = "[~"+ h +":" + m + ":" + s + "]";
  2458. }
  2459.  
  2460. /*******************************************************************************************************************************
  2461.  * ● Dropdown menu
  2462.  *******************************************************************************************************************************/
  2463.  
  2464. // Preload images for drop down arrow buttons
  2465. var drop_over = new Image(); drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
  2466. var drop_out = new Image(); drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
  2467.  
  2468. function changeDropDownButton(){
  2469.     /*
  2470.     $('<style type="text/css">' +
  2471.       '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
  2472.       'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
  2473.       'position: absolute; top: 2px !important; right: 3px;' +
  2474.       '</style>').appendTo('head');
  2475.     */
  2476.    
  2477.    
  2478.     $('.arrow').css({
  2479.         width: '18px',
  2480.         height: '17px',
  2481.         background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  2482.         position: 'absolute',
  2483.         top: '2px',
  2484.         right: '3px'
  2485.     });
  2486. }
  2487.  
  2488. var o = 1;
  2489.  
  2490. /*******************************************************************************************************************************
  2491.  * ● Recruiting Trade
  2492.  *******************************************************************************************************************************/
  2493. var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
  2494.  
  2495. function addRecTrade(wndID){
  2496.     var max_amount;
  2497.    
  2498.     $('<div class="rec_trade">'+
  2499.       // DropDown-Button for unit
  2500.       '<div class="drop_rec_unit dropdown default">'+
  2501.       '<div class="border-left"></div>'+
  2502.       '<div class="border-right"></div>'+
  2503.       '<div class="caption" name="'+ unit +'">'+ unit +'</div>'+
  2504.       '<div class="arrow"></div>'+
  2505.       '</div>'+
  2506.       '<div class="drop_rec_perc dropdown default">'+
  2507.       // DropDown-Button for ratio
  2508.       '<div class="border-left"></div>'+
  2509.       '<div class="border-right"></div>'+
  2510.       '<div class="caption" name="'+ percent +'">'+ Math.round(percent * 100)+'%</div>'+
  2511.       '<div class="arrow"></div>'+
  2512.       '</div></div><span class="rec_count" style="top:30px">('+ trade_count +')</span>').appendTo(wndID + ".content");
  2513.    
  2514.     // Select boxes for unit and ratio
  2515.     $('<div class="select_rec_unit dropdown-list default active">'+
  2516.       '<div class="item-list">'+
  2517.       '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>'+
  2518.       '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>'+
  2519.       '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>'+
  2520.       '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>'+
  2521.       '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>'+
  2522.       '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>'+
  2523.       '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>'+
  2524.       '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>'+
  2525.       '</div></div>').appendTo(wndID + ".rec_trade");
  2526.     $('<div class="select_rec_perc dropdown-list default inactive">'+
  2527.       '<div class="item-list">'+
  2528.       '<div class="option sel" name="0.0">&nbsp;&nbsp;0%</div>'+
  2529.       '<div class="option" name="0.05">&nbsp;&nbsp;5%</div>'+
  2530.       '<div class="option" name="0.1">10%</div>'+
  2531.       '<div class="option" name="0.16666">17%</div>'+
  2532.       '<div class="option" name="0.2">20%</div>'+
  2533.       '<div class="option" name="0.25">25%</div>'+
  2534.       '<div class="option" name="0.33">33%</div>'+
  2535.       '<div class="option" name="0.5">50%</div>'+
  2536.       '</div></div>').appendTo(wndID + ".rec_trade");
  2537.    
  2538.     $(wndID + ".rec_trade [name='"+ unit +"']").toggleClass("sel");
  2539.    
  2540.     // Styles
  2541.     $(wndID + '.rec_trade').css({ position: 'absolute', left: '30px', top: '70px' });
  2542.     $(wndID + '.select_rec_unit').css({
  2543.         position: 'absolute',
  2544.         top: '20px',
  2545.         width: '84px',
  2546.         display: "none"
  2547.     });
  2548.     $(wndID + '.select_rec_perc').css({
  2549.         position: 'absolute',
  2550.         left: '50px',
  2551.         top: '20px',
  2552.         width: '50px',
  2553.         display: "none"
  2554.     });
  2555.     $(wndID + '.item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  2556.    
  2557.     $(wndID + '.arrow').css({
  2558.         width: '18px',
  2559.         height: '18px',
  2560.         background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  2561.         position: 'absolute',
  2562.     });
  2563.    
  2564.     $(wndID + '.option_s').css({
  2565.         WebkitFilter: "grayscale(100%)",
  2566.         filter: "url(#GrayScale)",
  2567.         cursor: 'pointer',
  2568.         color: 'black',
  2569.         lineHeight: '14px',
  2570.         float: 'left',
  2571.        
  2572.         position: 'relative',
  2573.         width: '40px',
  2574.         margin: '0px',
  2575.         padding: '0px'
  2576.     });
  2577.    
  2578.     $('.select_rec_unit .sel').css({"-webkit-filter" : "sepia(100%)", "filter": "url(#Sepia)"});
  2579.    
  2580.     // hover effects of the elements in the drop menus
  2581.     $(wndID + '.option_s').hover(
  2582.         function(){
  2583.             //console.log(this.className);
  2584.             $(this).css({"-webkit-filter" : "grayscale(0%) sepia(0%)", "filter": "none"});
  2585.             if(!($(this).hasClass("sel"))){
  2586.                 $('.option_s .sel').css({"-webkit-filter" : "grayscale(0%) sepia(100%)", "filter": "url(#Sepia)"});
  2587.             }
  2588.         },
  2589.         function(){
  2590.             $('.select_rec_unit .option_s').css({"-webkit-filter" : "grayscale(100%) sepia(0%)", "filter": "url(#GrayScale)"});
  2591.             $('.select_rec_unit .sel').css({"-webkit-filter" : "grayscale(0%) sepia(100%)", "filter": "url(#Sepia)"});
  2592.         }
  2593.     );
  2594.     $(wndID + '.option').hover(
  2595.         function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  2596.         function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  2597.     );
  2598.    
  2599.     // click events of the drop menu
  2600.     $(wndID + ' .select_rec_unit .option_s').each(function(){
  2601.         $(this).click(function(e){
  2602.             $(".select_rec_unit .sel").toggleClass("sel");
  2603.             $("." + this.className.split(" ")[4]).toggleClass("sel");
  2604.            
  2605.             unit = $(this).attr("name");
  2606.             $('.drop_rec_unit .caption').attr("name", unit);
  2607.             $('.drop_rec_unit .caption').each(function(){
  2608.                 $(this).get(0).innerHTML = unit;
  2609.             });
  2610.             $(this).parent().parent().get(0).style.display = "none";
  2611.             $('.drop_rec_unit .caption').change();
  2612.         });
  2613.     });
  2614.     $(wndID + ' .select_rec_perc .option').each(function(){
  2615.         $(this).click(function(e){
  2616.             $(this).parent().find(".sel").toggleClass("sel");
  2617.             $(this).toggleClass("sel");
  2618.            
  2619.             percent = $(this).attr("name");
  2620.             $('.drop_rec_perc .caption').attr("name", percent);
  2621.             $('.drop_rec_perc .caption').each(function(){
  2622.                 $(this).get(0).innerHTML = Math.round(percent * 100)+"%";
  2623.             });
  2624.             $(this).parent().parent().get(0).style.display = "none";
  2625.             $('.drop_rec_perc .caption').change();
  2626.         });
  2627.     });
  2628.    
  2629.     // show & hide drop menus on click
  2630.     $(wndID + '.drop_rec_perc').click(function(e){
  2631.         if($(e.target)[0].parentNode.parentNode.childNodes[3].style.display === "none"){
  2632.             $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "block";
  2633.             $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  2634.         } else {
  2635.             $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  2636.         }
  2637.     });
  2638.     $(wndID + '.drop_rec_unit').click(function(e){
  2639.         if($(e.target)[0].parentNode.parentNode.childNodes[2].style.display === "none"){
  2640.             $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "block";
  2641.             $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  2642.         } else {
  2643.             $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  2644.         }
  2645.     });
  2646.    
  2647.     $(wndID).click(function(e){
  2648.         var clicked = $(e.target);
  2649.         if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown")){
  2650.             $('#' + this.id + ' .select_rec_unit').get(0).style.display = "none";
  2651.         }
  2652.     });
  2653.    
  2654.     // hover arrow change
  2655.     $(wndID + '.dropdown').hover(function(e){
  2656.         $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  2657.     }, function(e){
  2658.         $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  2659.     });
  2660.    
  2661.     $(wndID + ".drop_rec_unit .caption").attr("name", unit);
  2662.     $(wndID + ".drop_rec_perc .caption").attr("name",percent);
  2663.    
  2664.     $(wndID + '.drop_rec_unit').tooltip(LANG[LID].trd.uni);
  2665.     $(wndID + '.drop_rec_perc').tooltip(LANG[LID].trd.rat);
  2666.    
  2667.     var ratio = {NO: {w:0,      s: 0,       i: 0        },
  2668.                  FS: {w:1,      s: 0.2308,  i: 0.6154   },
  2669.                  BI: {w:1,      s: 0.8750,  i: 0.2250   },
  2670.                  SL: {w:0.55,   s: 1,       i: 0.4      },
  2671.                  RE: {w:0.6666, s: 0.3333,  i: 1        },
  2672.                  SK: {w:1,      s: 0,       i: 0.8947   },  
  2673.                  HO: {w:0,      s: 0.5,     i: 1        },
  2674.                  BS: {w:1,      s: 0,       i: 0.6250   },  
  2675.                  SW: {w:0.4545, s: 1,       i: 0.7273   }
  2676.                 };
  2677.    
  2678.    
  2679.     if($('#town_capacity_wood .max').get(0)){
  2680.         max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
  2681.     } else {
  2682.         max_amount = 25500;
  2683.     }
  2684.    
  2685.     $(wndID + '.caption').change(function(e){
  2686.         //console.log($(this).attr('name') + ", " + unit + "; " + percent);
  2687.         if(!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))){
  2688.             //trade_count = 0;
  2689.             $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  2690.         }
  2691.        
  2692.         var tmp = $(this).attr('name');
  2693.        
  2694.         if($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit"){
  2695.             unit = tmp;
  2696.         } else {
  2697.             percent = tmp;
  2698.         }
  2699.         var max = (max_amount - 100)/1000;
  2700.         addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
  2701.        
  2702.         var part = (max_amount - 1000) * parseFloat(percent); // -1000 als Puffer (sonst Überlauf wegen Restressies, die nicht eingesetzt werden können, vorallem bei FS und Biremen)
  2703.         var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
  2704.         var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
  2705.        
  2706.         var wood = ratio[unit].w * part;
  2707.         var stone= ratio[unit].s * part;
  2708.         var iron = ratio[unit].i * part;
  2709.        
  2710.         if((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
  2711.             wood = stone = iron = 0;
  2712.             $('.drop_rec_perc .caption').css({color:'#f00'});
  2713.             //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
  2714.             //$('.select_rec_perc .sel').css({color:'#f00'});
  2715.         } else {
  2716.             $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color:'#000'});
  2717.         }
  2718.         $("#trade_type_wood [type='text']").select().val(wood).blur();
  2719.         $("#trade_type_stone [type='text']").select().val(stone).blur();
  2720.         $("#trade_type_iron [type='text']").select().val(iron).blur();
  2721.     });
  2722.    
  2723.     $('#trade_button').click(function(){
  2724.         trade_count++;
  2725.         $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  2726.        
  2727.     });
  2728.    
  2729.     $(wndID + '.rec_count').css({
  2730.         position: 'absolute',
  2731.         display: 'block',
  2732.         left: '33px',
  2733.         top: '95px',
  2734.         width: '20px'
  2735.     });
  2736.     $(wndID + '.drop_rec_unit').css({
  2737.         position: 'absolute',
  2738.         display: 'block',
  2739.         width: '50px',
  2740.         overflow: 'visible'
  2741.     });
  2742.     $(wndID + '.drop_rec_perc').css({
  2743.         position: 'absolute',
  2744.         display: 'block',
  2745.         left: '49px',
  2746.         width: '55px',
  2747.         color:'#000'
  2748.     });
  2749.     $(wndID + '.drop_rec_perc .caption').change();
  2750. }
  2751. /*******************************************************************************************************************************
  2752.  * ● Ressources marks
  2753.  *******************************************************************************************************************************/
  2754. function addTradeMarks(woodmark, stonemark, ironmark, color){
  2755.     var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
  2756.     for(var e in wndArray){
  2757.         if(wndArray.hasOwnProperty(e)){
  2758.             wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2759.             if($(wndID + '.town-capacity-indicator').get(0)){
  2760.                
  2761.                 max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
  2762.                
  2763.                 $('#trade_tab .c_'+ color).each(function(){
  2764.                     $(this).get(0).remove();
  2765.                 });
  2766.                 $('#trade_tab .progress').each(function(){
  2767.                     if($("p", this).length < 3) {
  2768.                         if($(this).parent().get(0).id != "big_progressbar"){
  2769.                             limit = 1000 * (242 / parseInt(max_amount, 10));
  2770.                            
  2771.                             switch($(this).parent().get(0).id.split("_")[2]){
  2772.                                 case "wood":    limit = limit * woodmark; break;
  2773.                                 case "stone":   limit = limit * stonemark; break;
  2774.                                 case "iron":    limit = limit * ironmark; break;
  2775.                             }
  2776.                             $('<p class="c_'+ color +'"style="position:absolute;left: '+ limit +'px; background:'+ color +';width:2px;height:100%;margin:0px"></p>').appendTo(this);
  2777.                         }
  2778.                     }  
  2779.                 });
  2780.             }
  2781.         }
  2782.     }
  2783. }
  2784.  
  2785. /*******************************************************************************************************************************
  2786.  * ● Percentual Trade
  2787.  *******************************************************************************************************************************/
  2788. var rest_count = 0;
  2789.  
  2790. function addPercentTrade(wndID, ww){
  2791.    
  2792.     var a = ""; var content = wndID + ".content";
  2793.     if(ww) {
  2794.         a = "ww_";
  2795.         content = wndID + '.trade .send_res';
  2796.     }
  2797.     $('<div class="btn btn_trade"><a class="button" href="#">'+
  2798.       '<span class="left"><span class="right">'+
  2799.       '<span class="middle mid">'+
  2800.       '<span class="img_trade"></span></span></span></span>'+
  2801.       '<span style="clear:both;"></span>'+
  2802.       '</a></div>').prependTo(content);
  2803.    
  2804.     $(wndID + '.btn_trade').tooltip(LANG[LID].trd.prc);
  2805.    
  2806.     setPercentTrade(wndID, ww);
  2807.    
  2808.     $(wndID + '.btn').css({ width: '20px', overflow: 'visible', position: 'absolute', display: 'block' });
  2809.    
  2810.     if(!ww){ $(wndID + '.content').css({ height: '320px' }); }
  2811.    
  2812.     if(ww){
  2813.         $(wndID + '.btn_trade').css({ left: '678px', top: '154px' });
  2814.     } else {
  2815.         $(wndID + '.btn_trade').css({ left: '336px', top: '135px' });
  2816.     }
  2817.    
  2818.     $(wndID + '.mid').css({ minWidth: '26px' });
  2819.    
  2820.     $(wndID + '.img_trade').css({
  2821.         width: '27px',
  2822.         height: '27px',
  2823.         top: '-3px',
  2824.         float: 'left',
  2825.         position: 'relative',
  2826.         background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
  2827.     });
  2828.    
  2829. }
  2830.  
  2831. var res = {};
  2832. function setPercentTrade(wndID, ww){
  2833.     var a = ""; if(ww) a = "ww_";
  2834.    
  2835.     $(wndID + '.btn_trade').toggle(function(){
  2836.         res.wood = {}; res.stone = {}; res.iron = {}; res.sum = {};
  2837.        
  2838.         res.sum.amount = 0;
  2839.         // Rohstoffmenge 0 setzen
  2840.         setAmount(true, a, wndID);
  2841.         // Rohstoffmenge insgesamt // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
  2842.         for(var e in res){
  2843.             if(res.hasOwnProperty(e) && e != "sum") {
  2844.                 res[e].rest = false;
  2845.                 res[e].amount = parseInt($('.ui_resources_bar .'+ e +' .amount').get(0).innerHTML, 10);
  2846.                 res.sum.amount += res[e].amount;
  2847.             }
  2848.         }
  2849.         // Prozentualer Anteil der Rohstoffe insgesamt
  2850.         res.wood.percent = 100/res.sum.amount * res.wood.amount;
  2851.         res.stone.percent = 100/res.sum.amount * res.stone.amount;
  2852.         res.iron.percent = 100/res.sum.amount * res.iron.amount;
  2853.        
  2854.         // Handelsmenge insgesamt
  2855.         res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
  2856.         res.sum.max = parseInt($(wndID + '#' + a + 'big_progressbar .caption .max').get(0).innerHTML, 10) - res.sum.cur;
  2857.        
  2858.         // Menge der Rohstoffe am prozentualen Anteil der Handelsmenge (%)
  2859.         res.wood.part =  parseInt(res.sum.max/100 * res.wood.percent, 10);
  2860.         res.stone.part =  parseInt(res.sum.max/100 * res.stone.percent, 10);
  2861.         res.iron.part =  parseInt(res.sum.max/100 * res.iron.percent, 10);
  2862.        
  2863.         for(var f in res){
  2864.             if(res.hasOwnProperty(f) && f != "sum") {
  2865.                 if(!ww){
  2866.                     var i = 0;
  2867.                     $(wndID + '#town_capacity_'+ f +' .amounts span').each(function(){
  2868.                         res[f][i] = parseInt(this.innerHTML.replace('+', '').trim(), 10);
  2869.                        
  2870.                         if(isNaN(res[f][i])) { res[f][i] = 0; }
  2871.                         i++;
  2872.                     });
  2873.                     res[f].cur = res[f][0] + res[f][1];
  2874.                     res[f].max = res[f][3] - res[f].cur;
  2875.                    
  2876.                     if(res[f].max < 0) { res[f].max = 0; }
  2877.                 } else {
  2878.                     res[f].max = 30000;
  2879.                 }
  2880.             }
  2881.         }
  2882.         // Rest von Bruchrechnung (0-2 Einheiten) zur Steinmenge addieren
  2883.         res.stone.part += res.sum.max - (res.wood.part + res.stone.part + res.iron.part);
  2884.        
  2885.         res.sum.rest = 0;
  2886.         rest_count = 0;
  2887.         calcRestAmount();
  2888.         setAmount(false, a, wndID);
  2889.     }, function(){
  2890.         setAmount(true, a, wndID);
  2891.     });
  2892. }
  2893.  
  2894. function calcRestAmount(){
  2895.     // Rest aufteilen
  2896.     if(res.sum.rest > 0){
  2897.         for(var e in res){
  2898.             if(res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
  2899.                 res[e].part += res.sum.rest/(3 - rest_count);
  2900.             }
  2901.         }
  2902.         res.sum.rest = 0;
  2903.     }
  2904.     // neuen Rest berechnen
  2905.     for(var f in res){
  2906.         if(res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
  2907.             if(res[f].max <= res[f].part) {
  2908.                 res[f].rest = true;
  2909.                 res.sum.rest += res[f].part - res[f].max;
  2910.                 rest_count += 1;
  2911.                 res[f].part = res[f].max;
  2912.             }
  2913.         }
  2914.     }
  2915.     // Rekursion
  2916.     if(res.sum.rest > 0 && rest_count < 3){
  2917.         calcRestAmount();
  2918.     }
  2919. }
  2920.  
  2921. function setAmount(clear, a, wndID){
  2922.     for(var e in res){
  2923.         if(res.hasOwnProperty(e) && e != "sum") {
  2924.             if(clear == true) { res[e].part = 0; }
  2925.             $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
  2926.         }
  2927.     }
  2928. }
  2929.  
  2930. /*******************************************************************************************************************************
  2931.  * Unit strength (blunt/sharp/distance) and Transport Capacity
  2932.  * ----------------------------------------------------------------------------------------------------------------------------
  2933.  * | ● Unit strength: Unit menu
  2934.  * |    - Switching of def/off display with buttons
  2935.  * |    - Possible Selection of certain unit types
  2936.  * | ● Unit strength: Siege
  2937.  * | ● Unit strength: Barracks
  2938.  * | ● Transport capacity: Unit menu
  2939.  * |    - Switching of transporter speed (+/- big transporter)
  2940.  * ----------------------------------------------------------------------------------------------------------------------------
  2941.  *******************************************************************************************************************************/
  2942.  
  2943. var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
  2944.  
  2945. function getSelectedUnitsMenu(){
  2946.     var units = [];
  2947.     if($(".units_land .units_wrapper .selected").length > 0){
  2948.         $(".units_land .units_wrapper .selected").each(function(){
  2949.             units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  2950.         });
  2951.     } else {
  2952.         $(".units_land .units_wrapper .unit").each(function(){
  2953.             units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  2954.         });
  2955.     }
  2956.     return units;
  2957. }
  2958.  
  2959. // Calculate defensive strength
  2960. function calcDef(units){
  2961.     var e; blunt = sharp = dist = 0;
  2962.     for(e in units) {
  2963.         if(units.hasOwnProperty(e)) {
  2964.             blunt += units[e] * unitVal[e].def_hack;
  2965.             sharp += units[e] * unitVal[e].def_pierce;
  2966.             dist  += units[e] * unitVal[e].def_distance;
  2967.         }
  2968.     }
  2969. }
  2970. // Calculate offensive strength
  2971. function calcOff(units, selectedUnits){
  2972.     var e; blunt = sharp = dist = 0;
  2973.     for(e in selectedUnits) {
  2974.         if(selectedUnits.hasOwnProperty(e)) {
  2975.             var attack = (units[e] || 0) * unitVal[e].attack;
  2976.             switch(unitVal[e].attack_type){
  2977.                 case 'hack':    blunt += attack;    break;
  2978.                 case 'pierce':  sharp += attack;    break;
  2979.                 case 'distance':dist  += attack;    break;
  2980.             }
  2981.         }
  2982.     }
  2983. }
  2984.  
  2985. /*******************************************************************************************************************************
  2986.  * ● Unit strength: Unit menu
  2987.  *******************************************************************************************************************************/
  2988. function setStrengthMenu() {
  2989.     var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(),
  2990.         e, units = getSelectedUnitsMenu();
  2991.    
  2992.     // Calculation
  2993.     if(def==true){
  2994.         calcDef(units);
  2995.     } else {
  2996.         calcOff(unitsIn, units);
  2997.     }
  2998.     $('#blunt').get(0).innerHTML = blunt;
  2999.     $('#sharp').get(0).innerHTML = sharp;
  3000.     $('#dist').get(0).innerHTML = dist;
  3001.    
  3002.     setTransportCapacity(units);
  3003. }
  3004.  
  3005. function addStrengthMenu(){
  3006.     $('<hr><div id="strength" class="cont_left"><span id="str_font" class="bold text_shadow" style="color:#FFCC66;font-size: 0.8em;">'+
  3007.       '<table style="margin:0px;">'+
  3008.       '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>'+
  3009.       '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>'+
  3010.       '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>'+
  3011.       '</table>'+
  3012.       '</span></div>'+
  3013.       '<div class="cont_right">'+
  3014.       '<img id="def" class="img" src="http://de.cdn.grepolis.com/images/game/unit_overview/support.png">'+
  3015.       '<img id="off" class="img" src="http://de.cdn.grepolis.com/images/game/unit_overview/attack.png">'+
  3016.       '</div>').appendTo('.units_land .content');
  3017.    
  3018.     // transporter display
  3019.     $('<div id="transporter" class="cont" style="height:25px;">'+
  3020.       '<table style=" margin:0px;"><tr align="center" >'+
  3021.       '<td><img id="ship_img" class="ico" src="' + img_small_transp + '"></td>'+
  3022.       '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;"></span></td>'+
  3023.       '</tr></table>'+
  3024.       '</div>').appendTo('.units_naval .content');
  3025.    
  3026.     // Styles
  3027.     $('.ico').css({
  3028.         height: '20px',
  3029.         width: '20px'
  3030.     });
  3031.     $('.units_info_sprite').css({
  3032.         background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3033.         backgroundSize: '100%'
  3034.     });
  3035.     $('.img_pierce').css({ backgroundPosition: '0px -20px' });
  3036.     $('.img_dist').css({ backgroundPosition: '0px -40px' });
  3037.     $('hr').css({
  3038.         margin: '0px',
  3039.         backgroundColor: '#5F5242',
  3040.         height: '2px',
  3041.         border: '0px solid'
  3042.     });
  3043.     $('.cont_left').css({
  3044.         background: 'url(http://de.cdn.grepolis.com/images/game/layout/layout_units_nav_border.png)',
  3045.         width:'65%',
  3046.         display: 'table-cell'
  3047.     });
  3048.     $('.cont').css({
  3049.         background:'url("http://gpde.innogamescdn.com/images/game/layout/layout_2.56_compressed.png") no-repeat -270px -354px'
  3050.     });
  3051.     $('.cont_right').css({
  3052.         background:'url(http://de.cdn.grepolis.com/images/game/layout/layout_units_nav_border.png)',
  3053.         width:'30%',
  3054.         display: 'table-cell',
  3055.         verticalAlign:'middle'
  3056.     });
  3057.     $('.img').css({
  3058.         float:'right',
  3059.         background:'none',
  3060.         margin:'2px 8px 2px 0px'
  3061.     });
  3062.    
  3063.     $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function(){
  3064.         setTimeout(function(){
  3065.             setStrengthMenu();
  3066.         }, 100);
  3067.     });
  3068.    
  3069.     $('#off').css({"-webkit-filter" : "grayscale(80%)",
  3070.                    "filter": "url(#GrayScale)"});
  3071.    
  3072.     // Buttons
  3073.     $('#off').click(function(){
  3074.         $('#strength .img_hack').get(0).style.backgroundPosition = '0% 36%';
  3075.         $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 27%';
  3076.         $('#strength .img_dist').get(0).style.backgroundPosition = '0% 45%';
  3077.        
  3078.         $('#str_font').get(0).style.color = "#edb";
  3079.        
  3080.         // TODO: doesn't work in FF yet
  3081.         $(this).css({"-webkit-filter" : "grayscale(0%)",
  3082.                      "filter": "none",
  3083.                     });
  3084.        
  3085.         $('#def').css({"-webkit-filter" : "grayscale(80%)",
  3086.                        "filter": "url(#GrayScale)",
  3087.                       });
  3088.         def = false;
  3089.         setStrengthMenu();
  3090.     });
  3091.     $('#def').click(function(){
  3092.         $('#strength .img_hack').get(0).style.backgroundPosition = '0% 0%';
  3093.         $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 9%';
  3094.         $('#strength .img_dist').get(0).style.backgroundPosition = '0% 18%';
  3095.        
  3096.         $('#str_font').get(0).style.color = "#fc6";
  3097.        
  3098.         $(this).css({"-webkit-filter" : "grayscale(0%)",
  3099.                      "filter": "none"
  3100.                     });
  3101.         $('#off').css({"-webkit-filter" : "grayscale(80%)",
  3102.                        "filter": "url(#GrayScale)",
  3103.                       });
  3104.         def = true;
  3105.         setStrengthMenu();
  3106.     });
  3107.     $('#def,#off,#transporter').hover(function() {  
  3108.         $(this).css('cursor','pointer');
  3109.     });
  3110.     $('#transporter').toggle(
  3111.         function(){
  3112.             $('#ship_img').get(0).src = img_big_transp;
  3113.             shipsize = !shipsize;
  3114.             setStrengthMenu();
  3115.         },
  3116.         function(){
  3117.             $('#ship_img').get(0).src = img_small_transp;
  3118.             shipsize = !shipsize;  
  3119.             setStrengthMenu();
  3120.         }
  3121.     );
  3122.     data = uw.GameData;
  3123.    
  3124.     unitVal = data.units;
  3125. }
  3126.  
  3127. /*******************************************************************************************************************************
  3128.  * ● Unit strength: Siege
  3129.  *******************************************************************************************************************************/
  3130. function addStrengthConquest(){
  3131.     var units = [], str;
  3132.    
  3133.     // units of the siege
  3134.     $('#conqueror_units_in_town .unit').each(function(){
  3135.         str = $(this).attr("class").split(" ")[4];
  3136.         if(!unitVal[str].is_naval){
  3137.             units[str] = parseInt($(this).get(0).children[0].innerHTML, 10);
  3138.             //console.log($(this).attr("class").split(" ")[4]);
  3139.         }
  3140.     });
  3141.     // calculation
  3142.     calcDef(units);
  3143.    
  3144.     $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">'+
  3145.       '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3146.       '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3147.       '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3148.       '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3149.       '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3150.       '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>'+
  3151.       '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>'+
  3152.       '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>'+
  3153.       '</table></span>'+
  3154.       '</div>').appendTo('#conqueror_units_in_town');
  3155.    
  3156.     $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
  3157.    
  3158.     $('#strength_eo .ico').css({
  3159.         height: '20px',
  3160.         width: '20px'
  3161.     });
  3162.     $('#strength_eo .units_info_sprite').css({
  3163.         background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3164.         backgroundSize: '100%'
  3165.     });
  3166.     $('#strength_eo .img_pierce').css({ backgroundPosition: '0% 9%' });
  3167.     $('#strength_eo .img_dist').css({ backgroundPosition: '0% 18%' });
  3168.    
  3169.    
  3170.     $('#bl').get(0).innerHTML = blunt;
  3171.     $('#sh').get(0).innerHTML = sharp;
  3172.     $('#di').get(0).innerHTML = dist;
  3173. }
  3174.  
  3175. /*******************************************************************************************************************************
  3176.  * ● Unit strength: Barracks
  3177.  *******************************************************************************************************************************/
  3178. function setStrengthBarracks(){
  3179.     if(!$('#strength_baracks').get(0)){
  3180.         var units = [], pop = 0;
  3181.        
  3182.         // whole units of the town
  3183.         $('#units .unit_order_total').each(function(){
  3184.             units[$(this).parent().parent().attr("id")] = $(this).get(0).innerHTML;
  3185.         });
  3186.         // calculation
  3187.         calcDef(units);
  3188.        
  3189.         // population space of the units
  3190.         for(var e in units) {
  3191.             if(units.hasOwnProperty(e)) {
  3192.                 pop += units[e] * unitVal[e].population;
  3193.             }
  3194.         }
  3195.         $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">'+
  3196.           '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3197.           '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3198.           '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3199.           '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3200.           '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3201.           '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>'+
  3202.           '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>'+
  3203.           '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>'+
  3204.           '</table></span>'+
  3205.           '</div>').appendTo('.ui-dialog #units');
  3206.        
  3207.         $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">'+
  3208.           '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3209.           '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3210.           '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3211.           '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3212.           '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3213.           '<tr><td width="1%"><img class="ico" src="http://de.cdn.grepolis.com/images/game/res/pop.png"></td><td id="p" align="center" width="100%">0</td></tr>'+
  3214.           '</table></span>'+
  3215.           '</div>').appendTo('.ui-dialog #units');
  3216.        
  3217.         $('.ui-dialog #units .ico').css({
  3218.             height: '20px',
  3219.             width: '20px'
  3220.         });
  3221.         $('.ui-dialog #units .units_info_sprite').css({
  3222.             background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3223.             backgroundSize: '100%'
  3224.         });
  3225.         $('.ui-dialog #units .img_pierce').css({ backgroundPosition: '0% 9%' });
  3226.         $('.ui-dialog #units .img_dist').css({ backgroundPosition: '0% 18%' });
  3227.        
  3228.         $('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
  3229.         $('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
  3230.        
  3231.         $('#b').get(0).innerHTML = blunt;
  3232.         $('#s').get(0).innerHTML = sharp;
  3233.         $('#d').get(0).innerHTML = dist;
  3234.         $('#p').get(0).innerHTML = pop;
  3235.     }
  3236. }
  3237.  
  3238. /*******************************************************************************************************************************
  3239.  * ● Transporter capacity
  3240.  *******************************************************************************************************************************/
  3241. function setTransportCapacity(){
  3242.     var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
  3243.     // Ship space (available)
  3244.     smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
  3245.     if(isNaN(smallTransp)) smallTransp = 0;
  3246.     if(shipsize){
  3247.         bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
  3248.         if(isNaN(bigTransp)) bigTransp = 0;
  3249.     }
  3250.    
  3251.     // Checking: Research berth
  3252.     berth = 0;
  3253.     if(uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()){
  3254.         berth = 6;
  3255.     }
  3256.     ship = bigTransp*(20 + berth) + smallTransp*(10 + berth);
  3257.    
  3258.     units = uw.ITowns.getTown(uw.Game.townId).units();
  3259.    
  3260.     // Ship space (required)
  3261.     for(var e in units) {
  3262.         if(units.hasOwnProperty(e)) {
  3263.             if(unitVal[e]){ // without Heroes
  3264.                 if(!(unitVal[e].is_naval || unitVal[e].flying)){
  3265.                     pop += units[e] * unitVal[e].population;
  3266.                 }
  3267.             }
  3268.         }
  3269.     }
  3270.     $('#ship').get(0).innerHTML = pop + "/" + ship;
  3271. }
  3272.  
  3273.  
  3274. /*******************************************************************************************************************************
  3275.  * Simulator
  3276.  * ----------------------------------------------------------------------------------------------------------------------------
  3277.  * | ● Layout adjustment
  3278.  * | ● Permanent display of the extended modifier box
  3279.  * | ● Unit strength for entered units (without modificator influence yet)
  3280.  * ----------------------------------------------------------------------------------------------------------------------------
  3281.  *******************************************************************************************************************************/
  3282.  
  3283. function changeSimulatorLayout(){
  3284.     $('#place_simulator .game_body').css({
  3285.         height: '457px'
  3286.     });
  3287.     // AutoFillIn
  3288.     $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  3289.     //$('.place_insert_field[name="sim[mods][att][morale]"]').get(0).value = 100;
  3290.    
  3291.     // Mods
  3292.     $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  3293.     $('.place_sim_wrap_mods').css({
  3294.         position: 'absolute',
  3295.         right: '-17px'
  3296.     });
  3297.     $('.place_sim_wrap_mods .place_simulator_table .left_border').css({
  3298.         width: '47px'
  3299.     });
  3300.    
  3301.     // Erweiterte Modulator-Box
  3302.     $('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  3303.     $('.place_sim_wrap_mods_extend').appendTo('.place_sim_wrap_mods');
  3304.     $('.place_sim_wrap_mods_extend').css({
  3305.         display: 'table',
  3306.         position: 'relative',
  3307.         width: '100px',
  3308.         paddingTop: '6px'
  3309.     });
  3310.     $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  3311.     $('.place_sim_showhide').remove();
  3312.     $('.place_image').css({
  3313.         width: '20px',
  3314.         height:'20px',
  3315.         backgroundSize: '100%',
  3316.         margin: '1px'
  3317.     });
  3318.     $('.place_sim_wrap_mods_extend .place_image').each(function(){
  3319.         var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  3320.         $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  3321.     });
  3322.     $('.place_checkbox_field').each(function(){
  3323.         $(this).click(function(){
  3324.             $('.place_sim_bonuses_more_confirm').get(0).click();
  3325.         });
  3326.     });
  3327.    
  3328.     // Einheitencontainer
  3329.     $('#simulator_body .unit_container').css({
  3330.         height: '50px',
  3331.         width: '50px',
  3332.         margin: '0px 3px 0px 1px'
  3333.     });
  3334.     $('.place_simulator_odd, .place_simulator_even').css({
  3335.         textAlign: 'center'
  3336.     });
  3337.     $('.place_insert_field').css({
  3338.         margin: '0px'
  3339.     });
  3340.    
  3341.     // Seeeinheiten-Box
  3342.     $('.place_sim_sea_wrap h4').css({
  3343.         float: 'left'
  3344.     });
  3345.     $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  3346.     $('.place_sim_select_strategies select').css({
  3347.         width: '95px'
  3348.     });
  3349.     $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  3350.     $('.place_sim_select_strategies select').get(0).children[0].innerHTML ="Standard";
  3351.     $('.place_sim_select_strategies select').get(0).children[2].remove();
  3352.     $('.place_sim_select_strategies').css({
  3353.         marginLeft: '99px'
  3354.     });
  3355.    
  3356.     // Einheiten-Box
  3357.     $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  3358.     $('#place_sim_wrap_units').css({
  3359.         position: 'absolute',
  3360.         bottom: '35px'
  3361.     });
  3362.     $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  3363.     $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  3364.     $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  3365.     $('#place_sim_wrap_units h4').css({
  3366.         float: 'left'
  3367.     });
  3368.    
  3369.     // Selectboxen
  3370.     $('.place_sim_select_gods select').each(function(){
  3371.         //$(this).get(0)[0].innerHTML = "Gottheit";
  3372.     });
  3373.     $('.place_sim_select_gods').css({
  3374.         width: '105px'
  3375.     });
  3376.     $('.place_sim_select_gods select').css({
  3377.         width: '80px'
  3378.     });  
  3379.     $('.place_sim_select_gods_wrap').css({
  3380.         padding: '0px'
  3381.     });
  3382.     $('#select_insert_units').css({
  3383.         width: '130px'
  3384.     });  
  3385.     //$('#select_insert_units').get(0)[1].innerHTML ="Angriff";
  3386.     //$('#select_insert_units').get(0)[2].innerHTML ="Verteidigung";
  3387.     $('.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol').css({
  3388.         margin: '3px 2px 0px 5px'
  3389.     });
  3390.     $('.place_sim_insert_units .place_symbol').css({
  3391.         background: 'url(http://de.cdn.grepolis.com/images/game/towninfo/traveltime.png)',
  3392.         backgroundSize: '140%',
  3393.         backgroundPositionY: '-4px'
  3394.     });
  3395.     $('.place_attack').css({
  3396.         float: 'left'
  3397.     });
  3398.     $('#simulator_body .att').css({
  3399.         marginLeft: '19px'
  3400.     });
  3401.    
  3402.     // -> Heldenwelt
  3403.     if(uw.Game.is_hero_world){
  3404.         $('.place_sim_wrap_mods_extend tr').each(function(){
  3405.             $(this).get(0).children[1].style.borderLeft = "none";
  3406.             $(this).get(0).children[0].remove();
  3407.         });
  3408.         $('.place_sim_wrap_mods_extend').get(0).style.left = "-29px";
  3409.     }
  3410.    
  3411.     // -> Helden
  3412.     if($('.place_sim_heroes_container').get(0)){
  3413.         $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  3414.         $('#place_simulator h4:eq(2)').get(0).remove();
  3415.         //$('<tr></tr>').appendTo(".place_sim_heroes_container tbody");
  3416.         //$('.place_sim_heroes_container td:eq(2), .place_sim_heroes_container td:eq(3)').appendTo(".place_sim_heroes_container tr:eq(1)");
  3417.         $('.place_sim_heroes_container').css({
  3418.             position: 'absolute',
  3419.             right: '26px',
  3420.             paddingTop: '6px'
  3421.         });
  3422.     }
  3423.     $('<style type="text/css"> #q_place_sim_lost_res { display: none; } </style>').appendTo('head');   
  3424.    
  3425.     setStrengthSimulator();
  3426. }
  3427.  
  3428. function afterSimulation(){
  3429.     var lossArray = { att : { res: 0, fav: 0, pop: 0 }, def : { res: 0, fav: 0, pop: 0 } };
  3430.    
  3431.     $('#place_sim_wrap_units .place_losses, #place_sim_naval_units .place_losses').each(function(){
  3432.         var loss = parseInt($(this).get(0).innerHTML, 10) || 0;
  3433.         if(loss > 0){
  3434.             var unit = this.id.substring(26);
  3435.             var side = this.id.split("_")[2];
  3436.             lossArray[side].res += loss *(unitVal[unit].resources.wood + unitVal[unit].resources.stone + unitVal[unit].resources.iron);
  3437.             lossArray[side].fav += loss * unitVal[unit].favor;
  3438.             lossArray[side].pop += loss * unitVal[unit].population;
  3439.         }
  3440.     });
  3441.     for(var x in lossArray){
  3442.         if(lossArray.hasOwnProperty(x)){
  3443.             for(var z in lossArray[x]){
  3444.                 if(lossArray[x].hasOwnProperty(z)){
  3445.                     $("#"+ x +"_"+ z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000))? (Math.round(lossArray[x][z]/1000)+"k"):lossArray[x][z];
  3446.                 }
  3447.             }
  3448.         }
  3449.     }
  3450. }
  3451.  
  3452. // Stärkeanzeige: Simulator
  3453. var unitsGround = { att: {}, def: {} }, unitsNaval = { att: {}, def: {} }, name ="";
  3454.  
  3455. function setStrengthSimulator() {
  3456.     $('<div id="simu_table" style="position:relative; align:center;font-size: 0.8em; margin-top:6px; margin-right:39%;">'+
  3457.       '<div style="float:left; margin-right:12px;"><h4>'+ LANG[LID].sim.str +'</h4>'+
  3458.       '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  3459.       '<tr>'+
  3460.       '<td class="place_simulator_even"></td>'+
  3461.       '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>'+
  3462.       '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>'+
  3463.       '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>'+
  3464.       '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>'+
  3465.       '</tr><tr>'+
  3466.       '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  3467.       '<td class="left_border place_simulator_odd" id="att_b">0</td>'+
  3468.       '<td class="left_border place_simulator_even" id="att_s">0</td>'+
  3469.       '<td class="left_border place_simulator_odd" id="att_d">0</td>'+
  3470.       '<td class="left_border place_simulator_even" id="att_ship">0</td>'+
  3471.       '</tr><tr>'+
  3472.       '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  3473.       '<td class="left_border place_simulator_odd" id="def_b">0</td>'+
  3474.       '<td class="left_border place_simulator_even" id="def_s">0</td>'+
  3475.       '<td class="left_border place_simulator_odd" id="def_d">0</td>'+
  3476.       '<td class="left_border place_simulator_even" id="def_ship">0</td>'+
  3477.       '</tr>'+
  3478.       '</table>'+
  3479.       '</div><div><h4>'+ LANG[LID].sim.los +'</h4>'+
  3480.       '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  3481.       '<tr>'+
  3482.       '<td class="place_simulator_even"></td>'+
  3483.       '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>'+
  3484.       '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>'+
  3485.       '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>'+
  3486.       '</tr><tr>'+
  3487.       '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  3488.       '<td class="left_border place_simulator_odd" id="att_res">0</td>'+
  3489.       '<td class="left_border place_simulator_even" id="att_fav">0</td>'+
  3490.       '<td class="left_border place_simulator_odd" id="att_pop">0</td>'+
  3491.       '</tr><tr>'+
  3492.       '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  3493.       '<td class="left_border place_simulator_odd" id="def_res">0</td>'+
  3494.       '<td class="left_border place_simulator_even" id="def_fav">0</td>'+
  3495.       '<td class="left_border place_simulator_odd" id="def_pop">0</td>'+
  3496.       '</tr>'+
  3497.       '</table>'+
  3498.       '</div></div>').appendTo('#simulator_body');
  3499.    
  3500.     $('#simu_table .ico').css({
  3501.         height: '20px',
  3502.         width: '20px'
  3503.     });
  3504.     $('#simu_table .units_info_sprite').css({
  3505.         background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3506.         backgroundSize: '100%'
  3507.     });
  3508.     $('#simu_table .img_hack').css({ backgroundPosition: '0% 36%' });
  3509.     $('#simu_table .img_pierce').css({ backgroundPosition: '0% 27%' });
  3510.     $('#simu_table .img_dist').css({ backgroundPosition: '0% 45%' });
  3511.     $('#simu_table .img_ship').css({ backgroundPosition: '0% 72%' });
  3512.     $('#simu_table .img_fav').css({ background: 'url(http://gpde.innogamescdn.com/images/game/res/favor.png)', backgroundSize: '100%' });
  3513.     $('#simu_table .img_res').css({ background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png) 0% 54%', backgroundSize: '100%' });
  3514.     $('#simu_table .img_pop').css({ background: 'url(http://gpde.innogamescdn.com/images/game/res/pop.png)', backgroundSize: '100%' });
  3515.    
  3516.    
  3517.    
  3518.     $('#simu_table .left_border').css({
  3519.         width: '54px'
  3520.     });
  3521.     $('#simu_table .left_border').each(function(){
  3522.         $(this)[0].align = 'center';
  3523.     });
  3524.    
  3525.     $('#simu_table .strength').tooltip(LANG[LID].sim.str + " (" + LANG[LID].sim.mod +")");
  3526.     $('#simu_table .loss').tooltip(LANG[LID].sim.los);
  3527.    
  3528.     // Klick auf Einheitenbild
  3529.     $('.index_unit').click(function(){
  3530.         var type = $(this).attr('class').split(" ")[4];
  3531.         $('.place_insert_field[name="sim[units][att]['+type+']"]').change();
  3532.     });
  3533.    
  3534.     $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function(){
  3535.         name = $(this).attr("name").replace(/\]/g, "").split("[");
  3536.         var str = this;
  3537.         //console.log(str);
  3538.         setTimeout(function(){
  3539.             var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  3540.                 val, e;
  3541.            
  3542.             val = parseInt($(str).val(), 10);
  3543.             val = val || 0;
  3544.            
  3545.             if(unit_type == "ground"){
  3546.                 unitsGround[name[2]][name[3]] = val;
  3547.                
  3548.                 if(name[2] == "def"){
  3549.                     calcDef(unitsGround.def);
  3550.                 } else {
  3551.                     calcOff(unitsGround.att, unitsGround.att);
  3552.                 }
  3553.                 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
  3554.                 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
  3555.                 $('#' + name[2] + '_d').get(0).innerHTML = dist;
  3556.                
  3557.             } else {
  3558.                 var att = 0, def = 0;
  3559.                 unitsNaval[name[2]][name[3]] = val;
  3560.                
  3561.                 if(name[2] == "def"){
  3562.                     for(e in unitsNaval.def) {
  3563.                         if(unitsNaval.def.hasOwnProperty(e)) {
  3564.                             def += unitsNaval.def[e] * unitVal[e].defense;
  3565.                         }
  3566.                     }
  3567.                     $('#def_ship').get(0).innerHTML = def;
  3568.                 } else {
  3569.                     for(e in unitsNaval.att) {
  3570.                         if(unitsNaval.att.hasOwnProperty(e)) {
  3571.                             att += unitsNaval.att[e] * unitVal[e].attack;
  3572.                         }
  3573.                     }
  3574.                     $('#att_ship').get(0).innerHTML = att;
  3575.                 }
  3576.             }
  3577.         }, 100);
  3578.     });
  3579.    
  3580.     // Abfrage wegen eventueller Spionageweiterleitung
  3581.     getUnitInputs();
  3582.     setTimeout(function(){
  3583.         setChangeUnitInputs("def");
  3584.     }, 100);
  3585.    
  3586.     $('#select_insert_units').change(function(){
  3587.         var side = $(this).find('option:selected').val();
  3588.         setTimeout(function(){
  3589.             getUnitInputs();
  3590.             if(side === "att" || side === "def"){
  3591.                 setChangeUnitInputs(side);  
  3592.             }
  3593.         }, 200);
  3594.     });
  3595. }
  3596.  
  3597. function getUnitInputs(){
  3598.     $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function(){
  3599.         name = $(this).attr("name").replace(/\]/g, "").split("[");
  3600.         var str = this;
  3601.         var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  3602.             val, e;
  3603.         val = parseInt($(str).val(), 10);
  3604.         val = val || 0;
  3605.         if(unit_type === "ground"){
  3606.             unitsGround[name[2]][name[3]] = val;
  3607.         } else {
  3608.             var att = 0, def = 0;
  3609.             unitsNaval[name[2]][name[3]] = val;
  3610.         }
  3611.     });
  3612. }
  3613.  
  3614. function setChangeUnitInputs(side){
  3615.     $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
  3616.     setTimeout(function(){
  3617.         $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
  3618.     }, 100);
  3619. }
  3620.  
  3621. /*******************************************************************************************************************************
  3622.  * Defensive form
  3623.  * ----------------------------------------------------------------------------------------------------------------------------
  3624.  * | ● Adds a defensive form to the bbcode bar
  3625.  * ----------------------------------------------------------------------------------------------------------------------------
  3626.  *******************************************************************************************************************************/
  3627.  
  3628. // Funktion aufteilen...
  3629. function addForm(e){
  3630.     var textareaId = "", bbcodeBarId = "";
  3631.    
  3632.     switch (e) {
  3633.         case "/alliance_forum/forum":
  3634.             textareaId = "#forum_post_textarea";
  3635.             bbcodeBarId = "#forum";
  3636.             break;
  3637.         case "/message/forward":
  3638.             textareaId = "#message_message";
  3639.             bbcodeBarId = "#message_bbcodes";
  3640.             break;
  3641.         case "/message/new":
  3642.             textareaId = "#message_new_message";
  3643.             bbcodeBarId = "#message_bbcodes";
  3644.             break;
  3645.         case "/message/view":
  3646.             textareaId = "#message_reply_message";
  3647.             bbcodeBarId = "#message_bbcodes";
  3648.             break;
  3649.         case "/player_memo/load_memo_content":
  3650.             textareaId = "#memo_text_area";
  3651.             bbcodeBarId = "#memo_edit";
  3652.             break;  
  3653.     }
  3654.    
  3655.     $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  3656.    
  3657.     $('.def_form_button').css({
  3658.         cursor: 'pointer',
  3659.         marginTop:'3px'
  3660.     });
  3661.    
  3662.     $(bbcodeBarId + ' .dio_bbcode_option').css({
  3663.         background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
  3664.         display: 'block',
  3665.         float: 'left',
  3666.         width: '22px',
  3667.         height: '23px',
  3668.         margin: '0 3px 0 0',
  3669.         position: 'relative',
  3670.     });
  3671.     $(bbcodeBarId + ' .def_form').css({
  3672.         backgroundPosition: '-89px 0px'
  3673.     });
  3674.     var imgArray = {
  3675.         wall:   'http://de.cdn.grepolis.com/images/game/main/wall.png',
  3676.         tower:  'http://de.cdn.grepolis.com/images/game/main/tower.png',
  3677.         hide:   'http://de.cdn.grepolis.com/images/game/main/hide.png',
  3678.        
  3679.         spy:    'http://s7.directupload.net/images/140114/yr993xwc.png',
  3680.         pop:    'http://s7.directupload.net/images/140114/4d6xktxm.png',
  3681.        
  3682.         rev1:   'http://s7.directupload.net/images/140115/9cv6otiu.png',
  3683.         rev0:   'http://s7.directupload.net/images/140115/aue4rg6i.png',
  3684.         eo1:    'http://s1.directupload.net/images/140115/fkzlipyh.png',
  3685.         eo0:    'http://s1.directupload.net/images/140115/hs2kg59c.png',
  3686.         att:    'http://s1.directupload.net/images/140115/3t6uy4te.png',
  3687.         sup:    'http://s7.directupload.net/images/140115/ty6szerx.png',
  3688.        
  3689.         zeus:       'http://s1.directupload.net/images/140114/cdxecrpu.png',
  3690.         hera:       'http://s1.directupload.net/images/140114/mve54v2o.png',
  3691.         athena:     'http://s14.directupload.net/images/140114/kyqyedhe.png',
  3692.         poseidon:   'http://s7.directupload.net/images/140114/tusr9oyi.png',
  3693.         hades:      'http://s7.directupload.net/images/140114/huins2gn.png',
  3694.         artemis:    'http://s7.directupload.net/images/140114/kghjhko8.png',
  3695.         nogod:      'http://s1.directupload.net/images/140114/e7vmvfap.png',
  3696.        
  3697.         captain:    'http://s14.directupload.net/images/140114/88gg75rc.png',
  3698.         commander:  'http://s14.directupload.net/images/140114/slbst52o.png',
  3699.         priest:     'http://s1.directupload.net/images/140114/glptekkx.png',
  3700.        
  3701.         phalanx:    'http://s7.directupload.net/images/140114/e97wby6z.png',
  3702.         ram:        'http://s7.directupload.net/images/140114/s854ds3w.png',
  3703.        
  3704.         militia:    'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
  3705.         sword:      'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
  3706.         slinger:    'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
  3707.         archer:     'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
  3708.         hoplite:    'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
  3709.         rider:      'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
  3710.         chariot:    'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
  3711.         catapult:   'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
  3712.         godsent:    'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
  3713.        
  3714.         def_sum:    'http://s14.directupload.net/images/140127/6cxnis9r.png',
  3715.        
  3716.         minotaur:   'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
  3717.         manticore:  'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
  3718.         zyclop:     'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
  3719.         sea_monster:'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
  3720.         harpy:      'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
  3721.         medusa:     'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
  3722.         centaur:    'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
  3723.         pegasus:    'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
  3724.         cerberus:   'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
  3725.         fury:       'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
  3726.         griffin:    'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
  3727.         calydonian_boar:    'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
  3728.        
  3729.         big_transporter:    'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
  3730.         bireme:             'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
  3731.         attack_ship:        'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
  3732.         demolition_ship:    'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
  3733.         small_transporter:  'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
  3734.         trireme:            'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
  3735.         colonize_ship:      'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
  3736.        
  3737.         move_icon:  'http://de.cdn.grepolis.com/images/game/unit_overview/',
  3738.        
  3739.         bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
  3740.     };
  3741.    
  3742.     $('<div class="bb_def_chooser">'+
  3743.       '<div class="bbcode_box middle_center">'+
  3744.       '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>'+
  3745.       '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>'+
  3746.       '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  3747.       '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>'+
  3748.       '<div class="bbcode_box content clearfix" style="padding:5px">'+
  3749.       '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[0] +'</div></div><br><br>'+
  3750.       '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[1] +'</div></div><br><br>'+
  3751.       '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[2] +'</div></div><br><br>'+
  3752.       '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[3] +'</div></div><br><br>'+
  3753.       '<div><a class="button" id="dio_insert" href="#"><span class="left"><span class="right"><span class="middle"><small>'+ LANG[LID].bbc.but +'</small></span></span></span><span></span></a></div>'+
  3754.       '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  3755.    
  3756.     $('.bb_def_chooser').css({
  3757.         display: 'none',
  3758.         top: '38px',
  3759.         left: '510px',
  3760.         position: 'absolute',
  3761.         width: '190px',
  3762.         zIndex: 10000
  3763.     });
  3764.    
  3765.     $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
  3766.         $(this).toggleClass("checked");
  3767.     });
  3768.    
  3769.     $(bbcodeBarId + ' .def_form').toggle(function(){
  3770.         $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
  3771.     }, function(){
  3772.         $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
  3773.     });
  3774.    
  3775.     $(bbcodeBarId + ' #dio_insert').click(function(){
  3776.         var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
  3777.        
  3778.         $('.def_form').get(0).click();
  3779.        
  3780.         if($('#f_uni').hasClass("checked")){
  3781.             $('.units_land .unit, .units_naval .unit').each(function(){
  3782.                 troop_img   += separator + '[img]'      + imgArray[this.className.split(" ")[1]]    + '[/img]';
  3783.                 troop_count += separator + '[center]'   + $(this).find(".value").get(0).innerHTML   + '[/center]';
  3784.                 separator = "[||]";
  3785.             });
  3786.         } else {
  3787.             $('.units_land .unit').each(function(){
  3788.                 var a = this.className.split(" ")[1], def = (unitVal[a].def_hack + unitVal[a].def_pierce + unitVal[a].def_distance)/(3 * unitVal[a].population);
  3789.                 if(def > 10){
  3790.                     landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * unitVal[a].population * ((def > 20) ? 2 : 1);
  3791.                 }
  3792.             });
  3793.             landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100))/10) + "k" : landunit_sum;
  3794.            
  3795.             troop_img   += '[img]'+ imgArray.def_sum +'[/img]';
  3796.             troop_count += '[center]'+ landunit_sum +'[/center]';
  3797.             separator = "[||]";
  3798.             $('.units_naval .unit').each(function(){
  3799.                 troop_img   += separator + '[img]'      + imgArray[this.className.split(" ")[1]]    + '[/img]';
  3800.                 troop_count += separator + '[center]'   + $(this).find(".value").get(0).innerHTML   + '[/center]';
  3801.             });
  3802.         }
  3803.         if(troop_img !== ""){ troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n"; }
  3804.        
  3805.         var str = '[img]'+ imgArray.bordure + '[/img]'+
  3806.             '\n\n[color=#006B00][size=12][u][b]'+ LANG[LID].bbc.ttl +' ([url="http://adf.ly/eDM1y"]©DIO-Tools[/url])[/b][/u][/size][/color]\n\n'+
  3807.             //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
  3808.             '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]'+ uw.Game.player_name +'[/player])[/size]'+
  3809.             //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
  3810.             '\n\n[i][b]'+ LANG[LID].bbc.inf +'[/b][/i]' + troop_table +
  3811.             '[table][*]'+
  3812.             '[img]'+ imgArray.wall      +'[/img][|]\n'+
  3813.             '[img]'+ imgArray.tower     +'[/img][|]\n'+
  3814.             '[img]'+ imgArray.phalanx   +'[/img][|]\n'+
  3815.             '[img]'+ imgArray.ram       +'[/img][|]\n'+
  3816.             ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.commander  +'[/img][|]\n' : ' ')+
  3817.             ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.captain    +'[/img][|]\n' : ' ')+
  3818.             ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.priest +'[/img][|]\n' : ' ')+
  3819.             ($('#f_sil').hasClass("checked") ? '[center][img]'+imgArray.spy+'[/img][/center][|]\n' : ' ')+
  3820.             '[img]'+ imgArray.pop       +'[/img][|]\n'+
  3821.             '[img]'+ imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] +'[/img][/*]\n'+
  3822.             '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall")+ '[/center][||]'+
  3823.             '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower")+ '[/center][||]'+
  3824.             '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx? '+' : '-') + '[/center][||]'+
  3825.             '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram? '+' : '-')+ '[/center][||]'+
  3826.             ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  3827.             ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now())? '+' : '-')+ '[/center][||]' : ' ')+
  3828.             ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  3829.             ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage()/1000) + 'k[/center][||]': ' ')+
  3830.             '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]'+
  3831.             '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]'+
  3832.             '[/**][/table]';
  3833.        
  3834.         var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
  3835.        
  3836.         var i = 0;
  3837.         if($('#f_mov').hasClass("checked")){
  3838.             move_table += '\n[i][b]'+ LANG[LID].bbc.mov +'[/b][/i]\n[table]';
  3839.            
  3840.             $('#toolbar_activity_commands').mouseover();
  3841.            
  3842.             $('#toolbar_activity_commands_list .content .command').each(function(){
  3843.                 var cl = $(this).children()[0].className.split(" ");
  3844.                 if((cl[cl.length-1] === "returning" || cl[cl.length-1] === "revolt_arising" || cl[cl.length-1] === "revolt_running") && ((bb_count_str + bb_count_move) < 480)) {
  3845.                     move_table += (i%1) ? "" : "[**]";
  3846.                     i++;
  3847.                     move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
  3848.                     move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
  3849.                     move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
  3850.                     move_table += (i%1) ? "[||]" : "[/**]";
  3851.                 }
  3852.                 bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
  3853.             });
  3854.             if((bb_count_str + bb_count_move) > 480){
  3855.                 move_table += '[**]...[/**]';
  3856.             }
  3857.            
  3858.             $('#toolbar_activity_commands').mouseout();
  3859.            
  3860.             //console.log((bb_count_str + bb_count_move));
  3861.             move_table += (i%1) ? "[/**]" : "";
  3862.             move_table += "[*][|][color=#800000][size=6][i] ("+ LANG[LID].bbc.dev +": ±1s)[/i][/size][/color][/*][/table]\n";
  3863.         }
  3864.        
  3865.         str += move_table + '[img]'+ imgArray.bordure + '[/img]';
  3866.        
  3867.        
  3868.        
  3869.         $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
  3870.     });
  3871. }
  3872.  
  3873. function getArrivalTime(duration_time){
  3874.     var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
  3875.     duration_time = duration_time.split(":");
  3876.    
  3877.     s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
  3878.     m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  3879.     h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  3880.    
  3881.     s = s%60; m = m%60; h = h%24;
  3882.    
  3883.     s = ((s<10) ? "0" : "") + s;
  3884.     m = ((m<10) ? "0" : "") + m;
  3885.     h = ((h<10) ? "0" : "") + h;
  3886.    
  3887.     arrival_time = h + ":" + m + ":" + s;
  3888.    
  3889.     return arrival_time;
  3890. }
  3891.  
  3892.  
  3893. /*******************************************************************************************************************************
  3894.  * Smiley box
  3895.  * ----------------------------------------------------------------------------------------------------------------------------
  3896.  * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
  3897.  * | ● Used smileys: http://www.greensmilies.com/smilie-album/
  3898.  * | + Own Grepolis smileys
  3899.  * ----------------------------------------------------------------------------------------------------------------------------
  3900.  *******************************************************************************************************************************/
  3901.  
  3902. var smileyArray =  { "standard": {}, "nature": {}, "grepolis": {}, "people": {}, "other":{} };
  3903.  
  3904. // smiley categories
  3905. smileyArray.button = [ "rollsmiliey", "smile" ];
  3906.  
  3907. smileyArray.standard = [
  3908.     "smilenew", "i/cnfy7elqh8dotnsdp", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
  3909.     "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
  3910.     "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
  3911.     "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
  3912. ];
  3913. smileyArray.nature = [
  3914.     "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
  3915.     "insel", "fliegeschnappen", "i/cifohy0y1cl7nckzw", /* Spinne */ "i/cifogx34asrswrcjw", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"  
  3916. ];
  3917. smileyArray.grepolis = [
  3918.     "mttao_wassermann", "i/cigrmpfofys5xtiks", /* Hera */ "i/cifvfsu3e2sdiipn0", /* Medusa */ "i/cigmv8wnffb3v0ifg", /* Mantikor */ "i/cigrqlp2odi2kqo24", /* Zyklop */
  3919.     "i/cj1l9gndtu3nduyvi", /* Minotaurus */ "i/cj2byjendffymp88t", /* Pegasus */ "i/cj2ccmi2x8mhcoikd", /* Hydra */
  3920.     "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "i/cifojb85jytq5h07g", // Wikinger
  3921.     "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "i/cifohielywpedbyh8", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
  3922. ];
  3923. smileyArray.people = [
  3924.     "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
  3925.     "i/cifoqe3geok0jco5o", // Ägypter
  3926.     "i/ciforgs313z0ae1cc", // Hippie
  3927.     "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
  3928. ];
  3929. smileyArray.other = [
  3930.     "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
  3931.     "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party","dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
  3932. ];
  3933.  
  3934. // Replace german sign smilies
  3935. if(LID !== "de"){
  3936.     smileyArray.other[17] = "dagegen2";
  3937.     smileyArray.other[19] = "dafuer2";
  3938. }
  3939. // Forum: extra smiley
  3940. if($(".editor_textbox_container").get(0)){
  3941.     smileyArray.grepolis.push("i/ckajscggscw4s2u60");
  3942. }
  3943.  
  3944. var id = 0, error_count = 0;
  3945.  
  3946. var er = false;
  3947. // preload images
  3948. function loadSmileys(){
  3949.     for(var e in smileyArray){
  3950.         if(smileyArray.hasOwnProperty(e)) {
  3951.             for(var f in smileyArray[e]){
  3952.                 if(smileyArray[e].hasOwnProperty(f)) {
  3953.                     var src = smileyArray[e][f];
  3954.                     smileyArray[e][f] = new Image();
  3955.                     smileyArray[e][f].className = "smiley" + (id++);
  3956.                     smileyArray[e][f].style.margin = '3px';
  3957.                     smileyArray[e][f].style.maxHeight = '35px';
  3958.                     smileyArray[e][f].style.cursor = 'pointer';
  3959.                     if(src.substring(0,2) == "i/" ) {
  3960.                         smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
  3961.                     } else {
  3962.                         if(er == false){
  3963.                             smileyArray[e][f].src = "http://www.greensmilies.com/smile/smiley_emoticons_" + src + ".gif";
  3964.                         } else {
  3965.                             smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  3966.                         }
  3967.                     }
  3968.                     smileyArray[e][f].onerror = function () {
  3969.                         this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  3970.                     };
  3971.                 }
  3972.             }
  3973.         }
  3974.     }
  3975. }
  3976.  
  3977. // Forum smilies
  3978. if($(".editor_textbox_container").get(0)){
  3979.     loadSmileys();
  3980.     changeForumEditorLayout();
  3981.     addSmileyBoxForum();
  3982. }
  3983.  
  3984. function changeForumEditorLayout(){
  3985.     $('.blockrow').css({ border: "none" });
  3986.    
  3987.     // Subject/Title
  3988.     $($('.section div label[for="title"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  3989.     $($('.section div label[for="subject"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  3990.    
  3991.     $('.section div input').eq(0).css({ marginBottom: "-10px", marginTop: "10px"});
  3992.     $('#display_posticon').remove();
  3993.    
  3994.     // Posticons
  3995.     $('.posticons table').css({ width: "50%", /*marginTop: "-16px"*/});
  3996.     $('.posticons').css({ marginBottom: "-16px" });
  3997.     $('.posticons').insertAfter($('.section div label[for="title"]').parent());
  3998.     $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
  3999.     // Posticons hint
  4000.     $('.posticons p').remove();
  4001.     // Posticons: No Icon - radio button
  4002.     $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
  4003.     $(".posticons [colspan='14']").children().wrap("<nobr></nobr>")
  4004.     $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
  4005.     $(".posticons [colspan='4']").remove();
  4006. }
  4007.  
  4008. function addSmileyBoxForum(){
  4009.     $('<div class="smiley_box"><div>'+
  4010.       '<div align="center" style="float:left">'+
  4011.       '<a class="group" name="standard">'+  LANG[LID].sml.std +'</a>'+
  4012.       '<a class="group" name="grepolis">'+  LANG[LID].sml.gre +'</a>'+
  4013.       '<a class="group" name="nature">'+    LANG[LID].sml.nat +'</a>'+
  4014.       '<a class="group" name="people">'+    LANG[LID].sml.ppl +'</a>'+
  4015.       '<a class="group" name="other">'+     LANG[LID].sml.oth +'</a>'+
  4016.       '</div><div align="right" style="margin-top:2px;"><a class="smiley_link" href="http://adf.ly/eDbBl" target="_blank">WWW.GREENSMILIES.COM</a></div>'+
  4017.       '<hr class="smiley_hr">'+
  4018.       '<div class="smiley_box_cont" style="overflow: hidden;"><hr class="smiley_hr"></div>'+
  4019.       '</div></div><br>').insertAfter(".texteditor");
  4020.    
  4021.     addSmileys("standard", "");    
  4022.    
  4023.     $('.smiley_hr').css({ margin: '3px 0px 0px 0px', color: '#086b18', border: '1px solid' });
  4024.     $('.smiley_link').css({ color: '#0c450c' });
  4025.     $('.smiley_link').hover(
  4026.         function(){$(this).css({ color: '#14999E' });},
  4027.         function(){$(this).css({ color: '#0c450c' });}
  4028.     );
  4029.     $('.smiley_box').css({ maxHeight: '90px', marginLeft: "5px", width: "99%", minHeight:"10px" });
  4030.     $('.smiley_box_cont').css({ height: '100px', overflow: 'overlay' });
  4031.    
  4032.     $('.group').css({ color:'#0c450c', marginRight: '10px', cursor:"pointer"}); $('.group[name="standard"]').css({ color:'#089421' });
  4033.    
  4034.     $('.group').click(function(){
  4035.         $('.group').each(function(){
  4036.             $(this).get(0).style.color = '#0c450c';
  4037.         });
  4038.         $(this).get(0).style.color = '#089421';
  4039.         // change smiley group
  4040.         addSmileys($(this).get(0).name, "");
  4041.     });
  4042. }
  4043.  
  4044.  
  4045. // insert smileys from arrays into smiley box
  4046. function addSmileys(type, bbcodeBarId){
  4047.     // reset smilies
  4048.     if($(bbcodeBarId + " .smiley_box_cont").get(0)) {$(bbcodeBarId + " .smiley_box_cont").get(0).innerHTML='';}
  4049.     // add smilies
  4050.     for(var e in smileyArray[type]){
  4051.         if(smileyArray[type].hasOwnProperty(e)) {
  4052.             $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .smiley_box_cont");
  4053.             $(bbcodeBarId +" ."+ smileyArray[type][e].className).click(function(){
  4054.                 var textarea;
  4055.                 if(uw.location.pathname === "/game/index"){
  4056.                     // hide smiley box
  4057.                     $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
  4058.                     // find textarea
  4059.                     textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
  4060.                 } else {
  4061.                    
  4062.                     if($('.editor_textbox_container').get(0)) {
  4063.                         textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
  4064.                     } else {
  4065.                         $(this).appendTo('iframe .forum');
  4066.                     }
  4067.                     //$(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  4068.                 }
  4069.                 var text = $(textarea).val();
  4070.                 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  4071.             });
  4072.         }
  4073.     }
  4074. }
  4075.  
  4076. // add smiley box
  4077. function addSmileyBox(e){
  4078.     var bbcodeBarId = "";
  4079.     switch (e) {
  4080.         case "/alliance_forum/forum":   bbcodeBarId = "#forum";
  4081.             break;
  4082.         case "/message/forward":        bbcodeBarId = "#message_bbcodes";
  4083.             break;
  4084.         case "/message/new":            bbcodeBarId = "#message_bbcodes";
  4085.             break;
  4086.         case "/message/view":           bbcodeBarId = "#message_bbcodes";
  4087.             break;
  4088.         case "/player_memo/load_memo_content":  bbcodeBarId = "#memo_edit";
  4089.             break;  
  4090.     }
  4091.     if(($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367){
  4092.         $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
  4093.     }
  4094.     $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4095.    
  4096.     $('<div class="smiley_box">'+
  4097.       '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  4098.       '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  4099.       '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4100.       '<div align="center" style="width:100%;">'+
  4101.       '<a class="group" name="standard" href="">'+  LANG[LID].sml.std +'</a>'+
  4102.       '<a class="group" name="grepolis" href="">'+  LANG[LID].sml.gre +'</a>'+
  4103.       '<a class="group" name="nature" href="">'+    LANG[LID].sml.nat +'</a>'+
  4104.       '<a class="group" name="people" href="">'+    LANG[LID].sml.ppl +'</a>'+
  4105.       '<a class="group" name="other" href="">'+     LANG[LID].sml.oth +'</a>'+
  4106.       '</div>'+
  4107.       '<hr class="smiley_hr">'+
  4108.       '<div class="smiley_box_cont" style="overflow: hidden;"></div>'+
  4109.       '<hr class="smiley_hr">'+
  4110.       '<div align="center" style="margin-top:2px;"><a href="http://adf.ly/eDbBl" target="_blank"><span class="smiley_link">WWW.GREENSMILIES.COM</span></a></div>'+
  4111.       '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4112.    
  4113.     $(bbcodeBarId + ' .smiley_button').css({
  4114.         cursor: 'pointer',
  4115.         margin:'3px 2px 2px 2px'
  4116.     });
  4117.     $(bbcodeBarId + ' .smiley_box').css({
  4118.         zIndex: '5000',
  4119.         position: 'absolute',
  4120.         top: '27px',
  4121.         left: '430px',
  4122.         width: '300px',
  4123.         display: 'none'
  4124.     });
  4125.     $(bbcodeBarId + ' .smiley_link').css({
  4126.         color: '#086b18',
  4127.         fontSize: '0.6em'
  4128.     });
  4129.     $(bbcodeBarId + ' .smiley_hr').css({
  4130.         margin: '3px 0px 0px 0px',
  4131.         color:  '#086b18',
  4132.         border: '1px solid'
  4133.     });
  4134.     $(bbcodeBarId + ' .group').css({
  4135.         color:'#0c450c'
  4136.     });
  4137.     $(bbcodeBarId + ' .group[name="standard"]').css({
  4138.         color:'#089421'
  4139.     });
  4140.     $(bbcodeBarId + ' .group').click(function(){
  4141.         $("#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id +' .group').each(function(){
  4142.             $(this).get(0).style.color = '#0c450c';
  4143.         });
  4144.         $(this).get(0).style.color = '#089421';
  4145.         // change smiley group
  4146.         addSmileys($(this).get(0).name, "#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id);
  4147.     });
  4148.    
  4149.     addSmileys("standard", bbcodeBarId);
  4150.    
  4151.     // smiley box toggle
  4152.     $(bbcodeBarId + " .smiley_button").toggle(
  4153.         function(){
  4154.             $(this).get(0).src = smileyArray.button[0].src;
  4155.             $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";  
  4156.         },
  4157.         function(){
  4158.             $(this).get(0).src = smileyArray.button[1].src;
  4159.             $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";  
  4160.         }
  4161.     );
  4162. }
  4163.  
  4164.  
  4165. /*******************************************************************************************************************************
  4166.  * Biremes counter
  4167.  * ----------------------------------------------------------------------------------------------------------------------------
  4168.  * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
  4169.  * ----------------------------------------------------------------------------------------------------------------------------
  4170.  *******************************************************************************************************************************/
  4171. var count, townId, biriArray = JSON.parse(GM_getValue(WID + "_biri_data", "{}"));
  4172.  
  4173. function updateBiriCount(){
  4174.     var sum =0, e;
  4175.     for(e in biriArray) {
  4176.         if(biriArray.hasOwnProperty(e)) {
  4177.             sum += parseInt(biriArray[e], 10);
  4178.         }
  4179.     }
  4180.     if(options.bir){
  4181.         sum = sum.toString();
  4182.         var str ="", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
  4183.        
  4184.         for(i = 0; i<sum.length; i++){
  4185.             str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
  4186.         }
  4187.         $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
  4188.     }
  4189. }
  4190.  
  4191. function getBiri(){
  4192.     var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
  4193.         biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
  4194.     if(isNaN(biremeIn)) biremeIn = 0;
  4195.     if(isNaN(biremeOut)) biremeOut = 0;
  4196.     if(!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
  4197.         biriArray[uw.Game.townId] = biremeIn;
  4198.     }
  4199.     updateBiriCount();
  4200.     saveBiri();
  4201. }
  4202.  
  4203. function getBiriDocks(){
  4204.     var windowID = uw.BuildingWindowFactory.getWnd().getID(),
  4205.         biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
  4206.    
  4207.     if(!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
  4208.     updateBiriCount();
  4209.     saveBiri();
  4210. }
  4211.  
  4212. function getBiriAgora(){
  4213.     var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
  4214.     if(isNaN(biremeTotal)) biremeTotal = 0;
  4215.    
  4216.     $('#units_beyond_list .bireme').each(function(){
  4217.         biremeTotal += parseInt($(this).get(0).children[0].innerHTML, 10);
  4218.     });
  4219.     biriArray[uw.Game.townId] = biremeTotal;
  4220.     updateBiriCount();
  4221.     saveBiri();
  4222. }
  4223.  
  4224. function saveBiri(){
  4225.     setTimeout(function(){
  4226.         GM_setValue(WID + "_biri_data", JSON.stringify(biriArray));
  4227.     }, 0);
  4228. }
  4229.  
  4230. function initBiri() {
  4231.     $(".picomap_container").prepend("<div id='unit_count'><div id='bi_count'></div></div>");
  4232.    
  4233.     updateBiriCount();
  4234.    
  4235.     $('#unit_count').css({
  4236.         background: 'url(http://de.cdn.grepolis.com/images/game/units/units_sprite_90x90_compressed.jpg)',
  4237.         height: '90px',
  4238.         width: '90px',
  4239.         position: 'relative',
  4240.         margin: '5px 28px 0px 28px',
  4241.         backgroundPosition: '-270px 0px'
  4242.     });
  4243.    
  4244.     $('#sea_id').css({
  4245.         background: 'none',
  4246.         fontSize: '25px',
  4247.         cursor: 'auto',
  4248.         height: '50px',
  4249.         width: '50px',
  4250.         position: 'relative'
  4251.     });
  4252.     if($('#tutorial_quest_container').get(0)){
  4253.         $('#sea_id').prependTo('#tutorial_quest_container');
  4254.     } else {
  4255.         $('#sea_id').appendTo('#ui_box');
  4256.         $('#sea_id').css({
  4257.             position: 'absolute',
  4258.             top:  '75px',
  4259.             left: '157px'
  4260.         });
  4261.     }
  4262.     $('#bi_count').css({
  4263.         color: '#826021',
  4264.         position: 'relative',
  4265.         top: '28px',
  4266.         fontStyle: 'italic',
  4267.         width: '79px'
  4268.     });    
  4269.     $('.picomap_overlayer').tooltip(LANG[LID].set.bir[0]);
  4270. }
  4271.  
  4272.  
  4273. /*******************************************************************************************************************************
  4274.  * Popups
  4275.  * ----------------------------------------------------------------------------------------------------------------------------
  4276.  * | ● Available units (no supporting or outer units)
  4277.  * | ● Improved favor
  4278.  * | ● getTownTypes
  4279.  * ----------------------------------------------------------------------------------------------------------------------------
  4280.  *******************************************************************************************************************************/
  4281. var groupUnitArray = {};
  4282. // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
  4283. function getAllUnits(){
  4284.     var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroups(),
  4285.        
  4286.         unitArray = {"sword":0, "archer":0, "hoplite":0, "chariot":0, "godsent":0, "rider":0, "slinger":0, "catapult":0, "small_transporter":0, "big_transporter":0,
  4287.                      "manticore":0, "harpy":0, "pegasus":0, "cerberus":0, "minotaur":0, "medusa":0, "zyklop":0, "centaur":0, "fury":0, "sea_monster":0 },
  4288.        
  4289.         unitArraySea = {"bireme":0, "trireme":0, "attack_ship":0, "demolition_ship":0, "colonize_ship":0 };
  4290.    
  4291.     if(uw.Game.is_hero_world){
  4292.         unitArray = $.extend(unitArray, {"griffin":0, "calydonian_boar":0});
  4293.     }
  4294.     unitArray = $.extend(unitArray, unitArraySea);
  4295.    
  4296.    
  4297.     for(var group in groupArray){
  4298.         if(groupArray.hasOwnProperty(group)){
  4299.             // clone Object "unitArray"
  4300.             groupUnitArray[group] = Object.create(unitArray);
  4301.            
  4302.             for(var town in groupArray[group]["towns"]){
  4303.                 if(groupArray[group]["towns"].hasOwnProperty(town)){
  4304.                     var type = { lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0 }; // Type for TownList
  4305.                    
  4306.                     for(var unit in unitArray){
  4307.                         if(unitArray.hasOwnProperty(unit)){
  4308.                             // All Groups: Available units
  4309.                             var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
  4310.                             groupUnitArray[group][unit] +=  tmp || 0;
  4311.                             // Only for group "All"
  4312.                             if(group == -1){
  4313.                                 //Bireme counter
  4314.                                 if( unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
  4315.                                     biriArray[townArray[town].id] = tmp;    
  4316.                                 }
  4317.                                 //TownTypes
  4318.                                 if(!unitVal[unit].is_naval){
  4319.                                     if(unitVal[unit].flying){
  4320.                                         type.fd += ((unitVal[unit].def_hack + unitVal[unit].def_pierce + unitVal[unit].def_distance)/3 * (tmp || 0));
  4321.                                         type.fo += (unitVal[unit].attack * (tmp || 0));
  4322.                                     } else {
  4323.                                         type.ld += ((unitVal[unit].def_hack + unitVal[unit].def_pierce + unitVal[unit].def_distance)/3 * (tmp || 0));
  4324.                                         type.lo += (unitVal[unit].attack * (tmp || 0));
  4325.                                     }
  4326.                                 } else {
  4327.                                     type.sd += (unitVal[unit].defense * (tmp || 0));
  4328.                                     type.so += (unitVal[unit].attack * (tmp || 0));
  4329.                                 }
  4330.                             }
  4331.                         }
  4332.                     }
  4333.                     // Only for group "All"
  4334.                     if(group == -1){
  4335.                         // Icon: DEF or OFF?
  4336.                         var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
  4337.                             temp = 0;
  4338.                        
  4339.                         for(var t in type){
  4340.                             if(type.hasOwnProperty(t)){
  4341.                                 // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
  4342.                                 if(temp < type[t]){
  4343.                                     autoTownTypes[townArray[town].id] = t[0] + z;
  4344.                                     temp = type[t];
  4345.                                 }
  4346.                                 // Icon: Troops Outside (overwrite)
  4347.                                 if(temp < 1000){
  4348.                                     autoTownTypes[townArray[town].id] = "no";
  4349.                                 }
  4350.                             }
  4351.                         }
  4352.                         // Icon: Empty Town (overwrite)
  4353.                         var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
  4354.                             popTotal = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
  4355.                             popPlow = townArray[town].researches().attributes.plow ? 200 : 0,
  4356.                             popFactor = townArray[town].buildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
  4357.                             popExtra = townArray[town].getPopulationExtra();
  4358.                         for(var b in levelArray){
  4359.                             if(levelArray.hasOwnProperty(b)){
  4360.                                 popBuilding += Math.round(buildVal[b].pop * Math.pow(townArray[town].buildings().getBuildingLevel(b), buildVal[b].pop_factor));
  4361.                             }
  4362.                         }
  4363.                         townPopulation[town] = popTotal * popFactor + popPlow + popExtra - (popBuilding + townArray[town].getAvailablePopulation());
  4364.                         if((popTotal * popFactor + popPlow + popExtra - (popBuilding + townArray[town].getAvailablePopulation())) < 300){
  4365.                             autoTownTypes[townArray[town].id] = "po";
  4366.                         }
  4367.                         // Icon: Farm Incomplete
  4368.                         if(townArray[town].buildings().getBuildingLevel("farm") < 40){
  4369.                             //autoTownTypes[townArray[town].id] = "bu";
  4370.                         }
  4371.                     }
  4372.                 }
  4373.             }
  4374.         }
  4375.     }
  4376.     updateBiriCount();
  4377.     saveBiri();
  4378.    
  4379.     //if(options.pop)   {
  4380.     updateAvailableUnitsBox(groupUnitArray[-1]);
  4381.     //}
  4382. }
  4383.  
  4384. function addAvailableUnitsBox(){
  4385.     var groupArray = uw.ITowns.townGroups.getGroups();
  4386.    
  4387.     $('<div id="available_units_box" class="ui-dialog">'+
  4388.       '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  4389.       '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  4390.       '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4391.       '<h4><nobr>'+ LANG[LID].uni + '</nobr></h4>'+
  4392.       '<div class="drop_box">'+
  4393.       '<div class="drop_group dropdown default">'+
  4394.       '<div class="border-left"></div><div class="border-right"></div>'+
  4395.       '<div class="caption" name="'+ groupArray[-1].id +'">'+ groupArray[-1].name +'</div>'+
  4396.       '<div class="arrow"></div>'+
  4397.       '</div>'+
  4398.       '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>'+
  4399.       '</div><hr>'+
  4400.       '<div class="box_content"></div>'+
  4401.       '</div>').appendTo('body');
  4402.    
  4403.     for(var group in groupArray){
  4404.         if(groupArray.hasOwnProperty(group)){
  4405.             $('<div class="option'+ (group == -1 ? " sel" : "") +'" name="'+ group +'">'+ groupArray[group].name +'</div>').appendTo('#available_units_box .item-list');
  4406.         }
  4407.     }
  4408.    
  4409.     // Styles
  4410.     $('#available_units_box .drop_box').css({
  4411.         float: 'left',
  4412.         position: 'absolute',
  4413.         top: '1px',
  4414.         right: '0px',
  4415.         width: '90px',
  4416.         zIndex: '1'
  4417.     });
  4418.     $('#available_units_box h4').css({
  4419.         color: 'rgb(128, 64, 0)',
  4420.         width: '10px',
  4421.         height: '25px',
  4422.         marginLeft: '4px',
  4423.         lineHeight: '1.9'
  4424.     });
  4425.     $('#available_units_box .drop_group').css({
  4426.         width: '84px'
  4427.     });
  4428.     $('#available_units_box .select_group').css({
  4429.         position: 'absolute',
  4430.         width: '80px',
  4431.         display: "none",
  4432.         right: '3px'
  4433.     });
  4434.     //$('#available_units_box .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  4435.    
  4436.     $('#available_units_box .arrow').css({
  4437.         width: '18px',
  4438.         height: '18px',
  4439.         background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  4440.         position: 'absolute'
  4441.     });
  4442.    
  4443.     // hover effects of the elements in the drop menu
  4444.     $('#available_units_box .option').hover(
  4445.         function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  4446.         function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  4447.     );
  4448.    
  4449.     // click events of the drop menu
  4450.     $('#available_units_box .select_group .option').each(function(){
  4451.         $(this).click(function(e){
  4452.             $(this).parent().find(".sel").toggleClass("sel");
  4453.             $(this).toggleClass("sel");
  4454.            
  4455.             $('#available_units_box .drop_group .caption').attr("name", $(this).attr("name"));
  4456.             $('#available_units_box .drop_group .caption').get(0).innerHTML = $(this).get(0).innerHTML;
  4457.             $('#available_units_box .select_group')[0].style.display = "none";
  4458.            
  4459.             updateAvailableUnitsBox(groupUnitArray[$(this).attr("name")]);
  4460.             //$('#available_units_box .drop_group .caption').change();
  4461.         });
  4462.     });
  4463.     // show & hide drop menu on click
  4464.     $('#available_units_box .drop_group').click(function(){
  4465.         if($('#available_units_box .select_group')[0].style.display === "none"){
  4466.             $('#available_units_box .select_group')[0].style.display = "block";
  4467.         } else {
  4468.             $('#available_units_box .select_group')[0].style.display = "none";
  4469.         }
  4470.     });
  4471.    
  4472.     $('#available_units_box').click(function(e){
  4473.         var clicked = $(e.target);
  4474.         if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown")){
  4475.             $('#available_units_box .select_group').get(0).style.display = "none";
  4476.         }
  4477.     });
  4478.    
  4479.     // hover arrow change
  4480.     $('#available_units_box .dropdown').hover(function(e){
  4481.         $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  4482.     }, function(e){
  4483.         $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  4484.     });
  4485.    
  4486.     //$("#available_units_box .drop_group .caption").attr("name", "All");
  4487.     //$('#available_units_box .drop_group').tooltip();
  4488.    
  4489.     $('#available_units_box').draggable({
  4490.         containment: "body",
  4491.         snap: "body",
  4492.     });
  4493.     $('#available_units_box').css({
  4494.         color: 'rgb(12, 69, 12)',
  4495.         position: 'absolute',
  4496.         top: '100px',
  4497.         left: '200px',
  4498.         zIndex: getMaxZIndex() + 1,
  4499.         display: 'none'
  4500.     });
  4501.     $('#available_units_box .box_content').css({
  4502.         background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  4503.         backgroundSize: '140px'
  4504.     });
  4505.    
  4506.     $('#available_units_box').bind("mousedown",function(){
  4507.         $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  4508.     });
  4509.    
  4510.     $('#available_units_box hr').css({ margin: '3px 0px 0px', border: '1px solid', color: 'rgb(128, 64, 0)'});
  4511. }
  4512.  
  4513. function updateAvailableUnitsBox(unitArray){
  4514.     var i = 0, content = '<table><tr><td>';
  4515.     for(var u in unitArray){
  4516.         if(unitArray.hasOwnProperty(u)){
  4517.             if(((i%5 == 0) && (i!== 25)) || u == "bireme") {
  4518.                 content += "</td></tr><tr><td>";
  4519.             }
  4520.             content += '<div class="unit index_unit bold unit_icon40x40 ' + u + ' " ><span style="font-size:0.9em">' + unitArray[u] + '</span></div> ';
  4521.             i++;
  4522.         }
  4523.     }
  4524.     content += '</td></tr></table>';
  4525.     $('#available_units_box .box_content').get(0).innerHTML = "";
  4526.     $('#available_units_box .box_content').append(content);
  4527.     /*
  4528.     $('#united_units').css({
  4529.         height: '300px',
  4530.         width: '300px',
  4531.         position: 'relative'
  4532.     });
  4533.     */
  4534. }
  4535.  
  4536. function unbindFavorPopup(){
  4537.     $('.gods_favor_button_area, #favor_circular_progress').mouseover();
  4538.    
  4539.     $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function(){
  4540.         return false;
  4541.     });
  4542.     $('.gods_area').bind('mouseover', function(){
  4543.         setFavorPopup();
  4544.     });
  4545. }
  4546.  
  4547. var godArray = {
  4548.     zeus:       '   0px', //'http://s1.directupload.net/images/140116/mkhzwush.png',
  4549.     hera:       '-152px', //'http://s1.directupload.net/images/140116/58ob8z82.png',
  4550.     poseidon:   '-101px', //'http://s1.directupload.net/images/140116/dkfxrw2f.png',
  4551.     athena:     ' -50px', //'http://s14.directupload.net/images/140116/iprgopak.png',
  4552.     hades:      '-203px', //'http://s14.directupload.net/images/140116/c9juk95y.png',
  4553.     artemis:    '-305px', //'http://s14.directupload.net/images/140116/pdc8vxe2.png'
  4554. };
  4555.  
  4556. var godImg = new Image(); godImg.src = "http://s7.directupload.net/images/140118/j5gzsghx.png";
  4557.  
  4558. function setFavorPopup(){
  4559.     var pic_row = "",
  4560.         fav_row = "",
  4561.         prod_row = "";
  4562.    
  4563.     for(var g in godArray){
  4564.         if(godArray.hasOwnProperty(g)){
  4565.             if(uw.ITowns.player_gods.attributes.temples_for_gods[g]){
  4566.                 pic_row += '<td><div style="width:50px;height:51px;background:url('+ godImg.src +');background-position: 0px '+ godArray[g] +';"></td>';
  4567.                 fav_row += '<td class="bold" style="color:blue">'+ uw.ITowns.player_gods.attributes[g + "_favor"] +'</td>';
  4568.                 prod_row += '<td class="bold">'+ uw.ITowns.player_gods.attributes.production_overview[g].production +'</td>';
  4569.             }
  4570.         }
  4571.     }
  4572.     var tool_element = $('<table><tr><td></td>'+ pic_row +'</tr>'+
  4573.                          '<tr align="center"><td><img src="http://de.cdn.grepolis.com/images/game/res/favor.png"></td>'+ fav_row +'</tr>'+
  4574.                          '<tr align="center"><td>+</td>'+ prod_row +'</tr>'+
  4575.                          '</table>');
  4576.    
  4577.     $('.gods_favor_button_area, #favor_circular_progress').tooltip(tool_element);
  4578. }
  4579.  
  4580.  
  4581. /*******************************************************************************************************************************
  4582.  * GUI Optimization
  4583.  * ----------------------------------------------------------------------------------------------------------------------------
  4584.  * | ● Modified spell box (smaller, moveable & position memory)
  4585.  * | ● Larger taskbar and minimize daily reward-window on startup
  4586.  * | ● Modify chat
  4587.  * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
  4588.  * ----------------------------------------------------------------------------------------------------------------------------
  4589.  *******************************************************************************************************************************/
  4590.  
  4591. // Spellbox
  4592. function catchSpellBox(){
  4593.     var observer = new MutationObserver(function(mutations) {
  4594.         mutations.forEach(function(mutation) {
  4595.             //console.log(mutation);
  4596.             if(mutation.addedNodes[0]){
  4597.                 //console.log(mutation.addedNodes[0] + "   " + mutation.attributeName);
  4598.                 changeSpellBox();
  4599.             }
  4600.             // Löschen...
  4601.             if(mutation.addedNodes[0]){
  4602.                 if(mutation.addedNodes[0].id == "town_groups_list"){
  4603.                     $('#town_groups_list .inner_column').css({
  4604.                         width: '150px',
  4605.                         textAlign: 'left'                
  4606.                     });
  4607.                 }
  4608.             }
  4609.         });    
  4610.     });
  4611.     observer.observe($('.gods_spells_menu .content').get(0), { attributes: false, childList: true, characterData: false });
  4612. }
  4613.  
  4614. function initSpellBox(){
  4615.     var spellbox_top, spellbox_left, spellbox_show;
  4616.    
  4617.     $('<style type="text/css">'+
  4618.       '.gods_spells_active .nui_right_box {'+
  4619.       'height: 158px !important;'+
  4620.       '</style>').appendTo('head');
  4621.    
  4622.     setTimeout(function(){
  4623.         spellbox_show = GM_getValue("spellbox_show", false);
  4624.        
  4625.         // Timeout nicht optimal!!!
  4626.         setTimeout(function(){
  4627.             if(spellbox_show) {
  4628.                 $('.btn_gods_spells').click();
  4629.             }
  4630.         }, 2500);
  4631.     }, 0);
  4632.    
  4633.     $('.btn_gods_spells').click(function(){
  4634.         spellbox_show = !spellbox_show;
  4635.         setTimeout(function(){
  4636.             GM_setValue("spellbox_show", spellbox_show);
  4637.         }, 0);
  4638.     });
  4639.    
  4640.     $('.nui_units_box').css({
  4641.         display: 'block',
  4642.         marginTop: '-8px',
  4643.         position: 'relative'
  4644.     });
  4645.     $('.nui_right_box').css({
  4646.         height: '158px'
  4647.     });
  4648.     $('.nui_units_box .bottom_ornament').css({
  4649.         marginTop: '-28px',
  4650.         position: 'relative'
  4651.     });
  4652.     $('.gods_spells_menu .top').css({
  4653.         //marginTop: '-28px',
  4654.         //backgroundPosition: 'right -232px'
  4655.     });
  4656.     $('.gods_area').css({
  4657.         height: '170px'
  4658.     });
  4659.    
  4660.     $(".gods_spells_menu").draggable({
  4661.         containment: "body",  
  4662.         distance: 10 ,
  4663.         snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
  4664.         opacity: 0.7,
  4665.         stop : function(){
  4666.             spellbox_top = this.style.top;
  4667.             spellbox_left = this.style.left;
  4668.             setTimeout(function(){
  4669.                 GM_setValue("spellbox_top", spellbox_top);
  4670.                 GM_setValue("spellbox_left", spellbox_left);
  4671.             }, 0);
  4672.             //console.log(spellbox_top + "  " + spellbox_left);
  4673.         }
  4674.     });
  4675.     $(".gods_area .gods_spells_menu").before($('.nui_units_box'));
  4676.    
  4677.     setTimeout(function(){
  4678.         spellbox_top = GM_getValue("spellbox_top", "23%");
  4679.         spellbox_left = GM_getValue("spellbox_left", "-150%");
  4680.        
  4681.         //console.log(spellbox_top + "   " + spellbox_left);
  4682.        
  4683.         $('.gods_spells_menu').css({
  4684.             position:   'absolute',
  4685.             left:       spellbox_left,
  4686.             top:        spellbox_top,
  4687.             zIndex:     '5000',
  4688.             padding:    '30px 0px 0px -4px'
  4689.         });
  4690.     }, 0);
  4691. }
  4692. function changeSpellBox(){
  4693.     $('.god_container[data-god_id="zeus"]').css({
  4694.         width: '43px',
  4695.         float: 'left'
  4696.     });
  4697.     $('.god_container[data-god_id="zeus"] .powers_container').css({
  4698.         background: 'none'
  4699.     });
  4700.     $('.god_container[data-god_id="athena"]').css({
  4701.         width: '85px',
  4702.         float: 'left'
  4703.     });
  4704.     $('.god_container[data-god_id="athena"] .powers_container').css({
  4705.         background: 'none'
  4706.     });
  4707.     $('.content .title').each(function(){
  4708.         $(this).get(0).remove();
  4709.     });
  4710.     //$('.gods_spells_menu .god_container[data-god_id="zeus"]').before('.god_container[data-god_id="poseidon"]');
  4711.     if($('.bolt').get(0)) $('.bolt').get(0).remove();
  4712.     if($('.earthquake').get(0)) $('.earthquake').get(0).remove();
  4713.     if($('.pest').get(0)) $('.pest').get(0).remove();
  4714. }
  4715.  
  4716. // Minimize Daily reward window on startup
  4717. function minimizeDailyReward(){
  4718.     var startup, daily_reward_minimized = false, town_window = false;
  4719.     startup = new MutationObserver(function(mutations) {
  4720.         mutations.forEach(function(mutation) {
  4721.             if(mutation.addedNodes[0]){
  4722.                 if($('#new_daily_reward').get(0) && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()){
  4723.                     uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
  4724.                 }
  4725.             }
  4726.         });    
  4727.     });
  4728.     startup.observe($('body').get(0), { attributes: false, childList: true, characterData: false});
  4729.    
  4730.     setTimeout(function(){ startup.disconnect();}, 3000);
  4731. }
  4732.  
  4733. // Larger taskbar
  4734. function scaleTaskbar(){
  4735.     $('.minimized_windows_area').get(0).style.width= "150%";
  4736.     $('.minimized_windows_area').get(0).style.left= "-25%";
  4737. }
  4738. // hide fade out buttons => only for myself
  4739. function hideNavElements() {
  4740.     if((PID == 84367) && (uw.Game.premium_features.curator<=uw.Timestamp.now())){
  4741.         $('.nav').each(function() {
  4742.             $(this).get(0).style.display = "none";
  4743.         });
  4744.     }
  4745. }
  4746.  
  4747. /*******************************************************************************************************************************
  4748.  * Modify Chat
  4749.  *******************************************************************************************************************************/
  4750. function popupChatUser(){
  4751.     setTimeout(function(){
  4752.         GM_xmlhttpRequest({
  4753.             method: "POST",
  4754.             url: "http://wwwapi.iz-smart.net/modules.php?name=Chaninfo&file=nicks&chan=Grepolis"+ uw.Game.market_id.toUpperCase(),
  4755.             onload: function(response) {
  4756.                 //$('.nui_main_menu .chat .indicator').get(0).innerHTML =
  4757.                 //console.log(response.responseText);
  4758.                 //$('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  4759.             }
  4760.         });
  4761.     }, 0);
  4762. }
  4763.  
  4764. function initChatUser(){
  4765.     $('.nui_main_menu .chat .button, .nui_main_menu .chat .name_wrapper').css({
  4766.         WebkitFilter: 'hue-rotate(65deg)',
  4767.         filter: 'url(#Hue1)'
  4768.     });
  4769.     updateChatUser();
  4770.     setInterval(function(){ updateChatUser(); }, 300000);
  4771.     $('.nui_main_menu .chat').mouseover(function(){
  4772.         //popupChatUser();
  4773.     });
  4774.     if($('.nui_main_menu .chat').hasClass('disabled')){ $('.nui_main_menu .chat').removeClass('disabled');}
  4775. }
  4776.  
  4777. function updateChatUser(){
  4778.     var market = uw.Game.market_id;
  4779.     //if(uw.Game.market_id !== 'fr'){
  4780.     setTimeout(function(){
  4781.         GM_xmlhttpRequest({
  4782.             method: "POST",
  4783.             url: "http://api.relay-chat.de/compteur_js.php?chan="+ (market === "de" ? "Grepolis" + uw.Game.market_id.toUpperCase() : "GREPO"),
  4784.             onload: function(response) {
  4785.                 $('.nui_main_menu .chat .indicator').get(0).innerHTML = response.responseText.split("'")[1];
  4786.                 $('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  4787.             }
  4788.         });
  4789.     }, 0);
  4790.     //}
  4791. }
  4792.  
  4793. // Modify chat window
  4794. var chat_is_hidden = false, chatwnd_id;
  4795. function modifyChat() {
  4796.     var host = { fr: 'irc.quakenet.org', def: 'flash.afterworkchat.de'}, market = uw.Game.market_id;
  4797.     setTimeout(function(){ updateChatUser(); }, 10000); setTimeout(function(){ updateChatUser(); }, 30000);
  4798.    
  4799.     //uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_CHAT);
  4800.    
  4801.     //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setWidth(300);
  4802.     //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(0);
  4803.     //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  4804.    
  4805.     //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT));
  4806.    
  4807.     chatwnd_id = '#gpwnd_' + uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).getID();
  4808.     //$(chatwnd_id).parent().children('.gpwindow_left').remove();
  4809.     //$(chatwnd_id).parent().children('.gpwindow_right').remove();
  4810.     //$(chatwnd_id).parent().children('.gpwindow_top').remove();
  4811.     //$(chatwnd_id).parent().children('.gpwindow_bottom').remove();
  4812.     //$(chatwnd_id).parent().parent().children('.ui-dialog-titlebar').remove();
  4813.    
  4814.     var nickname = uw.Game.player_name.replace(/[.,:,+,*]/g,"").replace(/[=,\ ,-]/g,"_").replace(/ö/gi,"oe").replace(/ä/gi,"ae").replace(/ü/gi,"ue").replace(/ß/g,"ss");
  4815.    
  4816.     $('#chat').get(0).innerHTML = "";
  4817.    
  4818.     $('<iframe src="http://flash.afterworkchat.de/1.0/FlashChat.swf'+ //http://grepodio.heliohost.org/lightIRC/index.php'+
  4819.       '?host='+ host.def + //( market === 'fr' ? host.fr : host.def ) +
  4820.       '&policyPort=9000'+
  4821.       //'&port=6667'+
  4822.       '&languagePath=http://flash.afterworkchat.de/1.0/language/'+
  4823.       '&styleURL=http://grepodio.heliohost.org/lightIRC/css/green2.css'+ //http://grepodio.heliohost.org/style.css'+ //
  4824.       '&emoticonPath=http://grepodio.heliohost.org/lightIRC/emoticons/'+ //http://www.greensmilies.com/smile/smiley_emoticons_'+
  4825.       '&emoticonList='+
  4826.       ':)->happy.png,'+
  4827.       ':(->sad.png,'+
  4828.       ':O->baby2.swf,'+
  4829.       //';)->thumbs-up_new.gif,'+
  4830.       ':D->biggrin.png,'+
  4831.       '~D->coffee2.swf,'+
  4832.       ':P->tongue.swf,'+
  4833.       '8)->cool.png,'+
  4834.       ':|->neutral.png,'+
  4835.       'X)->drunk.swf,'+
  4836.       '%5e%5e->grins.png,'+
  4837.       ':{->frown2.swf,'+
  4838.       ':S->verlegen.png,'+
  4839.       ':$->blush.swf,'+
  4840.       ////':S->unsure.gif,'+
  4841.       ':]->lol2.swf,'+
  4842.       ':*->bussi.swf,'+
  4843.       ':[->fluch.swf'+
  4844.       '&accessKey=54a2846a460ae1703ac690d21551b997'+
  4845.       '&nick='+ nickname +
  4846.       '&nickAlternate='+ nickname +'_'+
  4847.       '&autojoin='+ (market === "de" ? '%23GREPO,%23' + uw.Game.world_id + ',%23Grepolis'+ market.toUpperCase() : '%23Grepolis'+ market.toUpperCase() + ",%23GREPO") +
  4848.       //( market === 'fr' ? '%23Grepolis.fr' : '%23Grepolis'+ market.toUpperCase() ) +
  4849.       '&showNavigation=true'+
  4850.       '&navigationPosition=top'+
  4851.       '&showNickSelection=false'+
  4852.       '&showIdentifySelection=false'+
  4853.       '&language='+ market +
  4854.       '&quitMessage=CYA'+
  4855.       '&showChannelHeader=false'+
  4856.       //'&useUserListIcons=true'+
  4857.       '&userListWidth=100'+
  4858.       '&soundAlerts=true'+
  4859.       '&soundOnNewChannelMessage=false'+
  4860.       '&showServerWindow=false'+
  4861.       '&fontSize=9'+
  4862.       '&showJoinPartMessages=false'+
  4863.       '&showMenuButton=false'+
  4864.       '&showTranslationButton=false'+
  4865.       '&showTimestamps=true'+
  4866.       //'&showInfoMessages=false'+
  4867.       '&showRegisterNicknameButton=false'+
  4868.       '&showRichTextControls=false'+
  4869.       //'&useUserListIcons=true'+
  4870.       '&showUserListInformationPopup=false'+
  4871.       '&showNickChangeButton=false'+
  4872.       '&showChannelCentral=false'+
  4873.       '&showOptionsButton=false'+
  4874.       '&showEmoticonsButton=true'+
  4875.       '&rememberNickname=false'+
  4876.       '" style="width:518px; height:357px; border:0px;"></iframe>').appendTo("#chat");
  4877.    
  4878.     //$('<iframe name="web" src="http://webchat.quakenet.org/?nick=Diony&channels=GrepolisDE&uio=Mz1mYWxzZSY5PXRydWUmMTA9dHJ1ZSYxMT00MSYxMz1mYWxzZQf0" width="500" height="400"></iframe>').appendTo("#chat");
  4879.     //$('<iframe src="http://flash.afterworkchat.de/1.0/FlashChat.swf?host=flash.afterworkchat.de&languagePath=http://flash.afterworkchat.de/1.0/language/&emoticonPath=http://flash.afterworkchat.de/1.0/emoticons/&accessKey=54a2846a460ae1703ac690d21551b997&policyPort=9000&nick=Chat-Besucher%25&realname=http://www.AfterWorkChat.de&autojoin=%23GrepolisDE&showNickSelection=false&showIdentifySelection=false&language=de&quitMessage=&soundAlerts=false&fontSize=9&showJoinPartMessages=false&showTimestamps=true&showRegisterNicknameButton=false&showNickChangeButton=false&showOptionsButton=false&rememberNickname=false&styleURL=http://flash.afterworkchat.de/1.0/css/black.css" style="width:800px; height:400px;"></iframe>').appendTo("#chat");
  4880.    
  4881.     //$('<style type="text/css"> #ircui { background-color: black !important;} </style>').appendTo('head');
  4882.     /*
  4883.         setTimeout(function(){
  4884.             console.log("bla");
  4885.             window.frames[0].document.getElementById('ircui').append("I was modified by JS!");
  4886.             //$("iframe").contents().find("body").append("I was modified by JS!");
  4887.             console.log(document.getElementById('web'));
  4888.             console.log(document.getElementById('ircui'));
  4889.             var li = document.createElement('li');
  4890.  
  4891.            
  4892.         }, 5000);
  4893.        
  4894.         */
  4895.     /*
  4896.     $('.chat_left').css({
  4897.         height: '190px',
  4898.         width: '20px',
  4899.         position: 'absolute',
  4900.         right: '0px',
  4901.         //background: 'url(http://s7.directupload.net/images/140410/m8n9eafe.png) no-repeat 2px 50%',
  4902.         //backgroundSize: '19px 130%'
  4903.     });
  4904.     */
  4905.     //$(chatwnd_id).animate({ width: "300px"}, 800);
  4906.     //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(200);
  4907.     //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  4908.     //$('#chat_controls').remove();
  4909.    
  4910.     /*
  4911.         $('.btn_hide_chat').toggle(function(){
  4912.             $(chatwnd_id).parent().parent().animate({ width: "140px", left: "-120px"}, 800);
  4913.             $(chatwnd_id).animate({ width: "140px"}, 800);
  4914.             setTimeout(function(){
  4915.                 $('.btn_hide_chat').removeClass('left'); $('.btn_hide_chat').addClass('right');
  4916.             }, 800);
  4917.             chat_is_hidden = true;
  4918.         }, function(){
  4919.             $(chatwnd_id).parent().parent().animate({ width: "300px", left:"0px"}, 800);
  4920.             $(chatwnd_id).animate({ width: "300px"}, 800);
  4921.             setTimeout(function(){
  4922.                 $('.btn_hide_chat').removeClass('right'); $('.btn_hide_chat').addClass('left');
  4923.             }, 800);
  4924.             chat_is_hidden = false;
  4925.         });
  4926.         */
  4927.    
  4928.     //appendTo('.chat_elements');
  4929.     /*
  4930.     $('<style type="text/css"> '+ chatwnd_id +' { left: 0px !important;top: 0px;overflow: visible;right: -15px;top: 0px;} </style>').appendTo('head');
  4931.    
  4932.     $('<style type="text/css"> #chat_roominfo { width: 25% !important; font-size: 0.8em;right:20px;overflow: hidden; border-right: 1px solid #D1BF91;} </style>').appendTo('head');
  4933.     $('<style type="text/css"> #chat_history_bg, #chat_message_text { width: 68% !important; font-size: 0.7em;} </style>').appendTo('head');
  4934.     $('<style type="text/css"> #chat_history_bg { bottom: 20px !important;} </style>').appendTo('head');
  4935.     $('<style type="text/css"> #chat { background: url(http://gpde.innogamescdn.com/images/game/layout/gpwindow_bg.jpg) 0 0 repeat; border: 4px inset rgb(109, 87, 59); overflow: hidden !important;border: 3px inset rgb(59, 109, 59);border-radius: 10px;} </style>').appendTo('head');
  4936.    
  4937.     $('<style type="text/css"> #chat_history .chat_line_date { position: relative !important; float: left; margin: 2px 5px 0px -2px !important; font-size: 0.8em !important;} </style>').appendTo('head');
  4938.    
  4939.     $('<style type="text/css"> #chat_history .chat_line { padding: 1px 0px 0px 0px;} </style>').appendTo('head');
  4940.    
  4941.     $('<style type="text/css"> #chat_history .chat_line_sender { color: #0A5700 !important;} </style>').appendTo('head');
  4942.    
  4943.     //$('<style type="text/css"> #chat_history { word-break: break-all;} </style>').appendTo('head');
  4944.    
  4945.     $('<style type="text/css"> #chat_history .chat_line_notification .chat_line_message { margin: 0px 0px 0px 0px !important; color: rgb(68, 0, 0);} </style>').appendTo('head');
  4946.    
  4947.     $('<style type="text/css"> #chat_message_text { height: 16px !important;} </style>').appendTo('head');
  4948.    
  4949.     */
  4950.    
  4951.     //uw.Layout.playerProfile.open('Diony');
  4952.    
  4953.     //uw.Layout.allianceProfile.open(69);
  4954.    
  4955.    
  4956.     // Hide Chat in the menu
  4957.     /*
  4958.     setTimeout(function(){
  4959.         $('.chat').get(0).remove();
  4960.         $('.nui_main_menu .content ul').get(0).style.height = ($('.nui_main_menu .content ul').height() - 34) + "px";
  4961.     },0);
  4962.     */
  4963. }
  4964.  
  4965. /*
  4966. $(window).resize(function() {
  4967.     //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition(['0px','bottom']);
  4968.     if(chat_is_hidden){
  4969.         //$(chatwnd_id).parent().parent().css({ left:"-120px"});
  4970.     } else {
  4971.         //$(chatwnd_id).parent().parent().css({ left:"0px"});
  4972.     }
  4973. });
  4974. */
  4975.  
  4976. /*******************************************************************************************************************************
  4977.  * Activity boxes
  4978.  * ----------------------------------------------------------------------------------------------------------------------------
  4979.  * | ● Show troops and trade activity boxes
  4980.  * | ● Boxes are magnetic & movable (position memory)
  4981.  * ----------------------------------------------------------------------------------------------------------------------------
  4982.  *******************************************************************************************************************************/
  4983.  
  4984. var box_standard = { trade: { top: 55, left: 450 }, commands : { top: 55, left: 250 } }, mut_toolbar, mut_command, mut_trade;
  4985.  
  4986. box = JSON.parse(GM_getValue("box", JSON.stringify(box_standard)));
  4987.  
  4988. function checkToolbarAtStart(){
  4989.     if(parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0){
  4990.         $('#toolbar_activity_commands_list').get(0).style.display = "block";
  4991.     } else {
  4992.         $('#toolbar_activity_commands_list').get(0).style.display = "none";
  4993.     }
  4994.     if(parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0){
  4995.         $('#toolbar_activity_trades_list').get(0).style.display = "block";
  4996.     } else {
  4997.         $('#toolbar_activity_trades_list').get(0).style.display = "none";
  4998.     }
  4999. }
  5000.  
  5001. function catchToolbarEvents(){
  5002.     mut_toolbar = new MutationObserver(function(mutations) {
  5003.         mutations.forEach(function(mutation) {
  5004.             if(mutation.addedNodes[0]){
  5005.                 //console.log(mutation);
  5006.                 if(mutation.target.id === "toolbar_activity_trades_list"){
  5007.                     draggableTradeBox();
  5008.                 } else {
  5009.                     draggableCommandBox();
  5010.                 }
  5011.                 mutation.addedNodes[0].remove();
  5012.             }
  5013.         });    
  5014.     });
  5015.     mut_command = new MutationObserver(function(mutations) {
  5016.         mutations.forEach(function(mutation) {
  5017.             if(mutation.addedNodes[0]){
  5018.                 if(mutation.addedNodes[0].nodeValue > 0){
  5019.                     $('#toolbar_activity_commands_list').get(0).style.display = "block";
  5020.                 } else {
  5021.                     $('#toolbar_activity_commands_list').get(0).style.display = "none";
  5022.                 }
  5023.             }
  5024.         });    
  5025.     });
  5026.     mut_trade = new MutationObserver(function(mutations) {
  5027.         mutations.forEach(function(mutation) {
  5028.             if(mutation.addedNodes[0]){
  5029.                 if(mutation.addedNodes[0].nodeValue > 0){
  5030.                     $('#toolbar_activity_trades_list').get(0).style.display = "block";
  5031.                 } else {
  5032.                     $('#toolbar_activity_trades_list').get(0).style.display = "none";
  5033.                 }
  5034.             }
  5035.         });    
  5036.     });
  5037. }
  5038.  
  5039. // moveable boxes
  5040. function draggableTradeBox(){
  5041.     $("#toolbar_activity_trades_list").draggable({
  5042.         containment: "body",
  5043.         distance: 20,
  5044.         snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  5045.         opacity: 0.7,
  5046.         start : function () {
  5047.             $("#fix_trade").remove();
  5048.         },
  5049.         stop : function () {
  5050.             var pos = $('#toolbar_activity_trades_list').position();
  5051.             box.trade.left = pos.left;
  5052.             box.trade.top = pos.top;
  5053.             setTimeout(function(){
  5054.                 GM_setValue("box", JSON.stringify(box));
  5055.             }, 0);
  5056.            
  5057.             $('<style id="fix_trade" type="text/css">'+
  5058.               '#toolbar_activity_trades_list {'+
  5059.               'left:' + box.trade.left  + 'px !important;'+
  5060.               'top: ' + box.trade.top   + 'px !important}'+
  5061.               '</style>').appendTo('head');
  5062.         }
  5063.     });
  5064. }
  5065.  
  5066. function draggableCommandBox(){
  5067.     $("#toolbar_activity_commands_list").draggable({
  5068.         containment: "body",
  5069.         distance: 20,
  5070.         snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  5071.         opacity: 0.7,
  5072.         stop : function () {
  5073.             var pos = $('#toolbar_activity_commands_list').position();
  5074.             box.commands.left = pos.left;
  5075.             box.commands.top = pos.top;
  5076.             setTimeout(function(){
  5077.                 GM_setValue("box", JSON.stringify(box));
  5078.             }, 0);
  5079.         }
  5080.     });
  5081. }
  5082.  
  5083. function showCommandsAndTrades(){
  5084.     var observe_options = { attributes: false, childList: true, characterData: false};
  5085.    
  5086.     catchToolbarEvents();
  5087.    
  5088.     mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
  5089.     mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
  5090.    
  5091.     mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options );
  5092.     mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options );
  5093.    
  5094.     $('#toolbar_activity_commands').mouseover();
  5095.     $('#toolbar_activity_trades').mouseover();
  5096.     $('#toolbar_activity_commands, #toolbar_activity_trades').unbind("mouseover");
  5097.     $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').unbind("mouseout");
  5098.     $('#toolbar_activity_trades_list').unbind("click");
  5099.    
  5100.     checkToolbarAtStart();
  5101.    
  5102.     $('#toolbar_activity_commands_list').css({
  5103.         left:   box.commands.left   + "px",
  5104.         top:    box.commands.top    + "px"
  5105.     });
  5106.    
  5107.     $('<style id="fix_lists" type="text/css">'+
  5108.       '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}'+
  5109.       '.dropdown-list .content { max-height: 329px}'+
  5110.       '</style>'+
  5111.       '<style id="fix_trade" type="text/css">'+
  5112.       '#toolbar_activity_trades_list {'+
  5113.       'left:' + box.trade.left  + 'px !important;'+
  5114.       'top: ' + box.trade.top   + 'px !important}'+
  5115.       '</style>').appendTo('head');
  5116.    
  5117.     draggableCommandBox();
  5118.     draggableTradeBox();
  5119.    
  5120.     $('.toolbar_activities .commands').mouseover(function(){
  5121.         $('#toolbar_activity_commands_list').get(0).style.display = "block";
  5122.     });
  5123.     $('.toolbar_activities .trades').mouseover(function(){
  5124.         $('#toolbar_activity_trades_list').get(0).style.display = "block";
  5125.     });
  5126. }
  5127.  
  5128. /*******************************************************************************************************************************
  5129.  * Other stuff
  5130.  *******************************************************************************************************************************/
  5131.  
  5132. function counter(time){
  5133.     var type = "", today, counted, year, month, day;
  5134.     if(uw.Game.market_id !== "zz"){
  5135.         setTimeout(function(){
  5136.             counted = JSON.parse(GM_getValue("Counter",'[ "00000000", false ]'));
  5137.             today = new Date((time + 7200) * 1000);
  5138.             year = today.getUTCFullYear();
  5139.             month = ((today.getUTCMonth()+1) < 10 ? "0" : "") + (today.getUTCMonth()+1);
  5140.             day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
  5141.             today = year + month + day;
  5142.             console.log(today);
  5143.             if(counted[0] !== today){type += "d"; }
  5144.             if(counted[1] == false){ type += "t"; }
  5145.             if(type !== ""){
  5146.                 setTimeout(function(){
  5147.                     GM_xmlhttpRequest({
  5148.                         method: "GET",
  5149.                         url: "http://grepodio.heliohost.org/count.php?type="+ type + "&market="+ uw.Game.market_id + "&date="+ today,
  5150.                         onload: function(response) {
  5151.                             //console.log(response.responseText);
  5152.                             if(response.responseText.indexOf("tot") > -1){
  5153.                                 counted[1] = true;
  5154.                             }
  5155.                             if(response.responseText.indexOf("dly") > -1){
  5156.                                 counted[0] = today;
  5157.                             }
  5158.                             setTimeout(function(){
  5159.                                 GM_setValue("Counter", JSON.stringify(counted));
  5160.                             }, 0);  
  5161.                         }
  5162.                     });
  5163.                 }, 0);
  5164.             }
  5165.         },0);
  5166.     }
  5167. }
  5168.  
  5169. /*
  5170. function xmas(){
  5171.     $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="xmas"></div></a>').appendTo('#ui_box');
  5172.     $('#xmas').css({
  5173.         background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
  5174.         height: '51px',
  5175.         width: '61px',
  5176.         position:'absolute',
  5177.         bottom:'10px',
  5178.         left:'60px',
  5179.         zIndex:'2000'
  5180.     });
  5181.     $('#xmas').tooltip("HO HO HO, Frohe Weihnachten!");  
  5182. }
  5183.  
  5184. function silvester(){
  5185.     $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="silv">'+
  5186.       '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
  5187.       '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
  5188.       '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
  5189.       '<img src="http://www.greensmilies.com/smile/sign2_4.gif">'+
  5190.       '</div></a>').appendTo('#ui_box');
  5191.     $('#silv').css({
  5192.         //background: 'url("http://www.greensmilies.com/smile/buchstaben_0.gif") no-repeat',
  5193.         //height: '57px',
  5194.         //width: '34px',
  5195.         position:'absolute',
  5196.         bottom:'10px',
  5197.         left:'70px',
  5198.         zIndex:'10'
  5199.     });
  5200.     $('#silv').tooltip("Frohes Neues!");  
  5201. }
  5202.  
  5203. function joke(){
  5204.     setTimeout(function(){
  5205.         if($('#grcgrc').get(0)){
  5206.             $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="fight"></div></a>').appendTo('#ui_box');
  5207.             $('#fight').css({
  5208.                 background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_hoplit_speer4.gif") no-repeat',
  5209.                 height: '51px',
  5210.                 width: '61px',
  5211.                 position:'absolute',
  5212.                 bottom:'10px',
  5213.                 left:'39px',
  5214.                 zIndex:'2000'
  5215.             });
  5216.             $('#fight').tooltip("WWW.GREENSMILIES.COM");
  5217.         }
  5218.     }, 5000);
  5219. }
  5220. */
Add Comment
Please, Sign In to add comment