Travian Mod Kit 1.8

By IRoll11!~s Last update Sep 3, 2007 — Installed 131,966 times.

Add Syntax Highlighting (this will take a few seconds, probably freezing your browser while it works)

// ==UserScript==
// @name		Travian Mod Kit 1.8
// @namespace	Travian
// @description	Various Travian Modifications
// @include	*travian*
// @version	1.8.2
// ==/UserScript==

// fixed troop timing bug
// added button flash and updating troop number each time a troop is actually completed
// added button to add existing troop upgrades to timers
// modified popups to appear under village when on top of page and over village when on bottom of page to avoid scroll bars appearing

// global variables
var imgpath = '';
var Prefs = '';
var infoDIV = addDiv('TMpopup','TMpopup','',false);
var User, Server, UniqueID, Page, ActiveVillage, VillageNumber;
var VillageIDs = new Array();
var VillageLinks = new Array();
var VillageNames = new Array();
var VillageCoords= new Array();

var Xnull = "data:image/gif,GIF89a%0A%00%0A%00%E6R%00%07.f%F5%F6%F9%EF%F1%F5Zt%99)K%7F%0B2i%89%9C%B7%0B1i%0E4k%0A0i%09%2Fg%5Bu%9B%1DBy%138p%EE%F0%F4%0E3k%20Dx7Z%8E%03%2Bd%08.g%85%98%B4%138o'M%85%F8%FA%FB.S%89%5Bt%9ATr%9E%08%2Fg%B1%BC%CF%0E4l%3B_%94%3Fb%97%F7%F8%FA%19%3DrNo%9F%C2%CE%DD%0B1h%AC%BB%D2%080i3U%88%88%9E%BD%AC%B9%CC%C3%CE%DC%07-f'L%82%1DBw%BC%C8%D9%05-e%00%25_%24Hy%AD%BA%CD%0F5k%1A%3Ft%06.hCe%96%3Ea%95%116l'L%81%00'a%0A1i3W%8C%137nCd%952V%8C4Y%8F%0E3j%06-f%091h%18%3Ds%AB%B8%CC%B2%BD%D0Mn%9Dx%90%B2%07.g%0D3j%20E%7C%24Gy(L%81%03)c%1B%40wz%92%B3%5Ey%A1%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00R%00%2C%00%00%00%00%0A%00%0A%00%00%07e%80R%20*(QGH.%0ER%17%25%1A%3E%1E%3FK%10%06%01%23%22%1F7%3CM-%07%3D)P%40%11%189O%1D%000%036%16%2C%0C%15%26%2B%13%1BL'4%0D%095%00%0A%3B%071%03%3A%00B%0AC%05%08%2F%0BEAN%24%05J3%09!2%01%148%12%0F%08ID%94R%02%1C%19%04%04%0BF%02R%81%00%3B";
var Xdone = "data:image/gif,GIF89a%0A%00%0A%00%E6W%00%DD%C5%24%D8%BB%06%D8%BC%07%FD%FB%EC%D8%BC%06%E5%D3Z%FE%FC%F5%F2%EB%B2%D9%BE%0F%FC%F6%CE%D7%BB%04%FD%F6%CB%FD%E6N%FE%E48%FA%EA%7F%D6%BA%03%FD%E7R%D8%BC%0A%D8%BB%04%DA%BE%12%F7%DD-%FE%FD%F5%D6%B9%00%D8%BB%03%F1%D5%1F%D9%BD%0E%E5%D3X%D8%BC%08%F2%E9%AA%FE%E47%D7%BA%07%E3%C6%07%E7%CE.%DD%C0%06%D7%BB%03%D9%BC%00%D7%BB%02%FE%E7I%FF%FE%F9%FB%E0*%D9%BB%00%DA%BF%12%E4%C8%0D%D9%BC%01%D7%B9%00%F2%E9%AE%D8%BD%09%FD%E47%F2%D6!%D9%BD%0B%EE%DF%7F%EE%E1%83%E6%C9%0D%F4%ED%B5%D5%B8%00%FD%FB%EB%DD%C5%23%F2%E9%AD%EA%D9j%DD%C1%05%ED%DF~%D8%BA%03%E5%D3%5B%F0%D4%1F%DD%C0%04%D8%BC%0E%E5%D3Y%FE%FD%F3%F7%E1N%F4%D9%25%F1%DB%3D%E2%C9)%D8%BD%0A%EF%D2%1B%DA%BD%03%E5%C9%12%DA%BC%01%E2%C9%1E%F7%DD%2B%FD%EF%8C%FC%E35%F0%D81%E5%CB%22%FD%E5%3C%FD%F3%AB%E7%CC%14%D8%BD%0B%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00W%00%2C%00%00%00%00%0A%00%0A%00%00%07e%80W%15%09O%10D%3A5%03W%26T%0C%1D%2FQRG3%06%0B%25S%0DN%18M%1E%199%0E'P%14%3FU!%0F6%1AFE0I4%3B%23%22%178%20K*%1F%40L%12%04%02%00B(J%2B%0A%01%1BH%24%3E%1CA%16%BB.1%01%13-C2%08%2C%11V%3D)%3C%06W%03%07%05%00%00%05%077W%81%00%3B";
var Xon = "data:image/gif,GIF89a%0A%00%0A%00%E6%00%00%FF%FF%FF%F5%FA%F5%EF%F6%EF%13%87%13U%AAV%B1%D7%B1%01~%01%0A%82%0A%25%93%25%00%7B%00%02~%02%04~%04%2F%9C%2F%EE%F6%EE%10%85%10%04%84%04%02~%01.%A4.w%C2w%15%8F%156%AA6%AC%D5%AC%2B%A2%2B%0F%8A%0F%06%80%05%06%81%06%AB%D4%AB%06%80%07%10%84%10%07%81%09S%B6Su%BFu1%A11%83%C0%83W%AAW%3F%AF%3F%C0%E4%C0%01%7D%01%C3%E5%C3%19%8D%193%A93%1D%91%1D%04%7F%04%0B%81%0CV%AAWV%ABW%1E%8F%1E%86%CC%86%3C%A8%3C%F7%FB%F7%03~%03%0F%8C%0F%05%7F%06%06%7F%06%07%81%08P%AAP%86%C1%86%1B%8D%1B%13%91%13%07%80%08%1D%8F%1D%1F%99%1F%06%80%06%07%81%07%AB%D5%AB%00y%00%19%94%19%84%C1%84%26%9D%26%00%7D%00%01%7F%01%03%81%03%3C%AC%3C%1C%97%1C%02%81%02%F9%FC%F9%3C%AE%3C%AC%DC%AC.%A2.(%9B(I%B3I%BB%DF%BBM%B5M%0A%82%0B%0A%84%0A%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%00%00%00%00%00%2C%00%00%00%00%0A%00%0A%00%00%07f%80%001%26%2F%1E7%1FQ%0D%00KMR%23H%20)9C%01%24PL%14NO'%19%1C%40%12%11(%16I%3AT%0AA%040D%3DB3G%062%0B%3C%0C%13%17%0FJ%06*5%1B.%04EF%10%0B4%3B%07%25-%1A%2B%09%3E%3F%1DS%18%03%15%01!%0E%096%07%0A%038%01%00%02%05%2C%08%08%22%05%02%00%81%00%3B";
var XonX = "data:image/gif,GIF89a%0A%00%0A%00%E6%00%00%00%00%00%FF%FF%FF%F5%FA%F5%EF%F6%EF%25%93%25U%AAV%B1%D7%B1%13%87%13%04~%04%0A%82%0A%00%7B%00%02~%02%04%7F%04%BB%DF%BB%2F%9C%2F%10%85%10%3C%A8%3CS%B6S%0A%82%0B%0A%84%0A%86%CC%86%07%81%09%06%7F%06%00y%00%06%80%07%AC%DC%AC%19%8D%19%06%81%06%1E%8F%1E%10%84%10V%ABW%86%C1%86%07%81%08%02~%01%AB%D4%AB%C0%E4%C0%AB%D5%AB%00%7D%00M%B5M%3F%AF%3Fw%C2w1%A11(%9B(%01%7F%01P%AAP%EE%F6%EE%1F%99%1F%03~%03%13%91%133%A936%AA6%04%84%04%1C%97%1C%05%7F%06%07%80%08%0B%81%0CV%AAW%84%C1%84%06%80%05u%BFu%3C%AE%3CW%AAW%06%80%06%1B%8D%1B%07%81%07%1D%8F%1D%01~%01%AC%D5%AC%0F%8A%0F%19%94%19%1D%91%1D%15%8F%15%83%C0%83%C3%E5%C3%3C%AC%3C%26%9D%26I%B3I.%A4.%F7%FB%F7%F9%FC%F9%01%7D%01.%A2.%2B%A2%2B%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%00%00%00%00%00%2C%00%00%00%00%0A%00%0A%00%00%07e%80%01NI%14%11%2C%3B%0D-%01O%19%26'J)F%3F9%02%23L%3C2Q*%1A%1B%1D%24(M1R40%13%0B%17%05%10K.E%00%00B%2F%08A%0EGD3%AE%0C%16%18%1C%05%25%2B!%0856%09P%1E%227%0A%3E%40%15%12%3A%07C%02H%0F%0A%20%09%0B%07%1F%02%01%03%068%04%04%3D%06%03%01%81%00%3B";
var XRed = "data:image/gif,GIF89a%0A%00%0A%00%E6S%00%C4%04%04%FD%F5%F5%E5..%C8%15%15%FB%EF%EF%C4%01%01%C5%0D%0D%C4%06%06%D8ZZ%C2%00%00%EDJJ%D7%17%17%C4%07%07%D3%14%14%C6%0A%0A%D1((%F3%88%88%C6%02%02%C4%00%00%C3%02%02%E1%82%83%C5%09%09%EA%40%40%C5%07%07%CF%26%26%CC%22%22%DC%26%26%CF%1B%1B%D8Z%5B%E6%8A%8A%C4%08%08%EBNN%F9%C5%C5%F6%AC%AC%C6%0E%0E%D2%10%10%C5%08%08%C1%00%00%FE%F9%F9%EE%B1%B1%CA%05%05%CB%09%09%EC%AB%AC%EDSS%ECyy%DA%1F%1F%E4nn%C9%02%02%EC%AE%AE%EE%B2%B2%CC%04%04%C5%0B%0B%EA%3C%3C%E9%3A%3A%FC%EF%EF%D8%1D%1D%DA%2C%2C%D7UU%C4%05%05%CB%20%20%D1%18%18%D0%1A%1A%C5%06%06%C5%01%01%C5%0A%0A%C3%01%01%C4%03%03%C4%02%02%EF%B3%B3%E877%E8AA%E2..%C3%06%06%D7%25%25%ECMM%FA%C3%C3%D2%0D%0D%EC%AC%AC%FD%F6%F6%D6YY%CC!%22%E7%2C%2C%E3%89%89%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00S%00%2C%00%00%00%00%0A%00%0A%00%00%07f%80SN%20%10%2B%1F.D6S%26!J%164%02%3D%0F%1D%01K%0A5EGI%1BH%06M%2CQ%02%027%3C)C%259F%1A-%0BL(%05B%00%3B8%0D%232%2F%05%00%3E%17PO%12%3F%11%00%07%1E%0EA%1C*%06%09%07%0C%153%3A%030%01%14%22%09%24%40%13%03R%01S%04'%08%19%18%081%04S%81%00%3B";
var Xarrow = "data:image/gif,GIF89a%07%00%0A%00%D5%00%00%FF%FF%FFG%3E%3ERIIC99E%3C%3C%3E55JBB%F4%F4%F4%F4%F3%F3%BE%BA%BA%FB%FB%FBB88%84~~g__ULL%E7%E6%E6%B5%B2%B2%FD%FD%FDMDDvppC%3A%3AF%3D%3D%DE%DC%DC%4066G%3D%3DaYYKBB%97%92%92%C9%C8%C8%E6%E5%E5%BC%B8%B8%A2%9D%9Dyrr%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%00%00%00%00%00%2C%00%00%00%00%07%00%0A%00%00%060%40%80p%08%98p%0ED%03%05%F4%88%08%05%95%81a%D3%01%08%02%01%C2%C5%01%B9%060%8B%02%E3J%18d%3C%0AIA%93%40%08%1B%1F%0Bq.%0C%02%00%3B";
var Xg0 = "data:image/gif,GIF89a%2F%00%3F%00%B3%00%00%19%16%0D%FB%F4%C9%9E%9D%7F%CF%CB%AA%83%84m%DB%F5%FD%FA%FA%E3%E3%EE%D1%CC%D4%C3fdR%AE%AE%94%C0%BF%A4GC0%A8%B8%B9%CE%E6%F7%E2%E3%C4!%F9%04%00%00%00%00%00%2C%00%00%00%00%2F%00%3F%00%00%04%FF%90%9D9%CD%23H%09%13%BA%7F%09!2D%970%1A%C1%00%8Ca%01%40%E2%22%0C%93TK%96%08G%C0%05%0FO%87%90(%92%024%80F%A1H%00z%83gb!%C0%3CxD%81f%23%F4u%2F%A7%C4c%E1D%09%B4E%97%80%81%98%0A%06%88%C1%E0%BA%F0%BA%82%1D%7C7px%0CB%08%04J%5BE%08%02%2C%22D*%04%03%5Ez%7B%90%01%03%3C%08%07%06%0B%88%0A%0B%2B0%83%18%0A%93%0Fx%8F%91%5D%07%3B%14%96%2B6N1dl%06%07%04%06%08%08%3F%A5%90%1A%0F%A9%13%0E6%0A*Jj%12T%8C6g%7B%A4x%0B%A7%3C%BC%7D%00%04K%00%0B.%0Dl%22U%06%0A5%90ck%99%04%3D%7D%CF%07%00gZ%D1%96%022%02%08%D5%07%0CU%5DU%ABD06%CC%BC%BB%07%08%D1L%87f%19(%82I%01%ADh%EC%3C%18%88%02C%DA%82%05%03%80%C1%A8Dn%02%3Fyg%14%9C%8Bu.%83%80%071%FF%0E%B0%D3%A3%B1F'y'%60l%B0H%B1%D6%0Et%1B%0550%10L%DC%95)%1EFV%E9%C4%A2%01%26%19%7D%1E%D4%82%B3i%07%95%1A%9C0%C0P%D0o%80%08%05%1E%88%3C%94%E3%C4%9D%8F%15%8Cj1ar%AD%A1%A0%18%06%0E%ADp'g%00F%0FE%06%2C%00u%82%C3%01L%8A%D6n%91%88%CF%89%8C%00%0DXhy(%60%93%08%20%01lD%84%D8%F6%C1%25%00%B6%E2l9S%A3A%93%15%D5%0E%13%C88%D9A%B4%12%1DH%C8yh%C3B%00L%8D.%60%04%C7%C0%B0F%00%A2D%FD%AB%22%C0A%81%CB%1E%1A%82%FA3%CB%07%E8%0E%11%D9%7D%8D%91%12%B5%0B%8DU%084pmy%CD%94%92%0D%C9%18%3C%C0%0D5%10%3F%0B%26%2B!%C2%F4%1A%01%A15D4(%C0%FD%F5%BD%86%11W%9D%23%93%3C%CF%F3%82%93BX%A8%A9%A0%01%82%02%AE%B9%B38%81%B4%06%FD%22!B%B0%0A%A2%C7%A8Z%15%06%BD%B2%1D%FF%7C%DD%BD%96%1F~%F5%25%D8I%11%98y%20%0F0%9A%90%91%80-*%08P%20w%BF%A0%A3%E1%86U%EC%A0%DF-%0F%A0%90H_N%C9CK!%DD9%F0%CAe%22%E0%87%60J%F6%85%80G%19%2C%20%02%D1%1FS%9CH%80%03%AE%FD1%96%10D%D8%97%C7%7C%B3%B0%B3%06%09'h%A2%C2%2F%93%1CQ%C0%1AJ%D1%07%C2%25%3BpS%83%0B*L%A1%02%02!*qB%03%D2%D4%13%C6%1B'T%23%1A%11meiKQ2%FC4Ex%E2h4%99tZ%B0%A1%03%03k%A18%13%7D%16p%A9%89Xl4%E7%10a%0C%CC%01%60%02%06%B1S%83%16%B4%95X%1B%9F%7D%240%D3n-%80%C4H%84M%16%89h%90%D2d)RZ%12%3EV%DA%40%1B%0C%14%02b%071R%96Z%DC%DC%00%02%01%0B40!%0D%8A%86%85%A8S%F4%8D%AA%00%974%E5%17%8B%3Fh2%F8F%89%03%F4%FA%9D%04%17%B8%03%60%B1H%F9%40%84%FFa%FA%01%05W%08-%DA%00%2B7%B3%B4%E1F%11%60%1E%B3%89AH%A5%F6F%60%C6%DD%11%CD%3B%0D%A4%0Bf%85%3EN%EAa1%EFl%80%ADI%16p%10%0B%09%9D%25q%ADc%02%A8%DB%AAS%60%91%C1)%06R%AD%B2B%99%5C%C6%03%E5!%E7%A0%D3%9Ec%EA%CAz%5C%0D%95%C4%20%C8%819%1C)O%22.p%92It%FC%BA%17q%BA*%3Ct%C2%1A%D5%E4U%0D%AC%1D_y%ED%05%D14%16%08%11%3C%D6%8C%00%C4%EA.%DB%84W%1D-b%80Ic%C8%02C%03%7D%C0%91B%02%DC%11%C7%E3%C8%DD%3ED%9EI%D1%E1i%0B%BD%25%7D%24%14%AB%EF%EDx!%7C7%8F%5C%B2%1CY%BA%A2%89A%16c%C5%A5%1F%11!%EA%1A%03%5B'%5D%CB%C8%F2%A8%85%89%7D%BB%C2%20K%18%13%40%14%A1p%3C%16%C06%01%5B%DB%1C%F1%1AJ%FE%FD%D1%09%99Vc%C8%1B~%B4%D6%B7%2F*%14%18%1F%7CL%EFP%22MK%1AF%8D%FF(ji%81%40%DF%F0%D5%CCZ%E0n%3B%D0u%C9D%0C%14%12%10%5C%82%1D%C2%02%F1%D5%5Cs%DBI'%BDt%D7x%A6q%04%60h%B3%F6y%E8%B2%138y%DB%B2%AB%AB%9F8%85%DE%22%87%06%EF%01%3F%3B%ED%A4%DB%DC%17%BE%0A%84%F8H%15%ED%C9%FE%3C%F4%17%C6%CE%A3!'%A80Fi%40%0E%A7%FD%F0%DC%A7%98%A2%E93%DB%C0%C6%1A%8F(%0Dz%FA%F4%3F%C0%04%E0_%D9%20D%10%A1%D3O%3Fq%E0s%C6%3Bb%60%98.p%CF%05%B6%A3%DF%CD%F6%C2%8FX%AC%25%16%06%AC%1D%F1%E6G%BB~%00%C3%19%E5p%8A%00%3E%80%BE%02%18%C0%83%C0%E3%5E%11%82%A3%89%7DP%C0~%A0%F8H%00%B6%F6%C1%DAu%B0%3BaP%82%3BxQ%8B%B3Q%80J%06%B9P%0B%B5%B7%B5%E3%05cB'L%85P(B%81%0C(%A0%3B-t%5E%DBh%B0%24%064%C083%E1%87%10%CB%F1%0E%10%DA%8E%82%F1%A9E%3DxS%06'x%92C%8A%E5%90%E2%15%B7%D7%9D6%D4%C0%01%B2%B2%D6*%F0%F3%0C~%B81%15%3C%94%5Cw%60%80%20%1B%98%B1%06%1A(%0D%18%CB%01G%0A%B6-%1A%D4%1A%C1%A2.%16%BE%8ALq%1F%F3Kb%8A%EAa%9F%EC%7C%C9C%2C%F0%22%0D%17%B0%C7%03%80%10%81%92%ABE%B5%843%96E!%C5b6%F9b%0D%F5qC%2Bv%E7%00%E9%E2L%90%60d%04%24%8D%A5%0D%7B%E4%07%11'%10%01%00%3B";
var Xg1 = "data:image/gif,GIF89a%2F%00%3F%00%B3%00%00x%AA%3E%F9%F8%C9%94%CFK%D9%E6%C8Is%1D6Z%11%9F%A7%8A%60%863%16.%06%BF%CD%A8%89%60%1Bfo%AA%7C%84b-D%105%3ClR%604!%F9%04%00%00%00%00%00%2C%00%00%00%00%2F%00%3F%00%00%04%FFPI9F%08%CC%06k%A6W%CD%C3%18%86e%26Y%B5UCb0%DE%C3%0E%C6u6%D3%A30L%92%5C%AB%84%25%F1%B0%B16%24%18(%F4%5B%D14%06%9FP%B5%09%F8%9C%1CY%25%B3%1A%F1%24%A5%20%23%D4c%3C%1E%B5j%EB2Ro%1E%0E%5BC%95%2Ci%A8%8CC%01%40h%1C%08gBl%0C%17%0Bi3%0DsV%08C(a%2B%5D%0D%00%93%05%07%93%00%05%22%16%0B%84%03%0D%0E%15%82%9E%0D%19%06%0DB5%23-w-%0F%04%97%B0%972%01g%1B%89%15%0E%3F%06%08%0D%8C%A6%255%03%0FD4%0E)%0C%B1%B1%07s%03%99-%BDQ%08%3F%0C%08%05%08%22!%03%5C-%80%C3%1Ay%C9%B02%09%BC%DA%BC%0F%CB5%D6%89%08%D5%0D%01%2Fl%7Fh%2F%CB%96%93%96%AF%94%84%0C%05%0D%06%0F%D8U%EB%C1%CB_%AF%3E5H%60%00%A0'%0A%BA%7B%94zY%D2C(%11%01%5E%0D%D6%CDs%D7%AB%80G%04%09%FF%851D%87%02%22%AC%89%7D2d%F4W%B0%9A%1E%8E%1D%09%F4)be%0FE%0C%95%18bZVi%D9%B8%95%EDx!%90%B9.cA%02%1E%1B%2C%D0%26%E9%E6%86%03.1%06%CC%E6%A9%80L%81%0Dd%22%C5X%ADO%D6%5E%092%1E8p%26%8AC%11Jx%A8%08k%D5%DF%C7JH%2F%F6%1A*w%EB%83%B6%01%85%3A%B0c%E5%13%8F1%242%12%DD*S%8F%CC%A0I%ABYC%F0gn%08%AF%3Fh%DC%FDz%C0A%A2%B6D%ADj%D5%DA%CE%EA%C1DY%E7%11%18K%14%CD%5D%01%02%00%A4%C6%D4%15s%D7%3FZ%AD%11%EDu9%ABV%D8%A3%2F%1E%40%CD%FB%D2E%C5%9E%BB%C6%5Efq%5DA%DB%B0%FFlT%DD%5BV%88%80g%EE%BA%3AL%40%C0%E8v%97y!%0D%1D%82tc%E6%BC%F5d%E2q%08%C5%19%7D%BBQ%03%A0%1D%B3%A8%F6%D1d%11%80%9F%14%3D%0D%90%FB%06%C82%40%3D%96%3F%BB%B8%D6%D8%04%D7%FF%03%ED%A47%DA%19%5C%DC%A7%A0%15f%B4%25%DFz%B4%B9uQu%17e%D2Y%5C%DD%24%B8%A0%82%DA%044V%01%02%B0d%94U%0F6%E6%D1XzH%12%C8%86%2C%12%F1%00C%08%84%88%5DF%2B%5D%02%D5%1E%93%A46%16%1A%2C%F6H%84%25%7B%B0%E3Qf%BEeb%23Cc%F5%A8%A4%02%1F%CA%98%95GC%DA%A8%C7%3D)%8A%A0d%8F%F9%01%E0JGm%7D%24%25%8E%E24q%E5%82Dh%89%DDl%A9%95%88TN%E2h0%A6%82D%D0%D6N%5CCQ%C2%D35H%5D%92%C9%9B%2C%DE%15%94%3BV%F1%E6N%8E%EBU%92%C90%7Cr%F8%40%9A%D8Y%93%9E%001%CE%C7PV%7C%88%99%A8%15%8BZ%C7%CB%8E9%09%D0%40o%EA%AD%A7%DA%01%F6%5Dj%06suN%E2%07Q%EA%05%AA%E3D%07%5C%0A%C4%18%A8%F9%01%E6%1E!%EE%86%E4h%7C%F4%A7e%A9o%02%84%CEh%D6M%12%97%00%E91%87%0Ffc%F5%90h%FF%9CI%A1F%94%7C%BCU%BB%EC%2B%CA%E9%E7%A6%92((%40%A0a!N%05js%80(%A3%A5%02%96nh%1Et%5D%3D%87B%22zT%3BS2%D6%B8B*%96dEG%E9z%08dp%06)%E8%2C%BB%AF%8D%F0%F1%A0C%0F'%C0p%06l%DA%8DD%8D%B02%10h%11%1F%60%E2%23%09%C1%F9Fw%E8C%17%05%FC%CF%00%BC%00%E6%22%92%C6%CAdc%C5%BC%E2C%96%AD%7D%5C%F7%22%00%D7%8C%81%80%03%20%11%A8%8F%8D%8A%E5S%B12S%19iU%40%99%10%A7%F05%961p3%3E%2F%F6%F1!D%C9%F5%23VO%86JL%CA'8x%0B%92'%E1PR%F1%90%83%F9alcwY%03F%40%12P%83.9T%C2%82%2C%98%D8%EAy%10%3E%98%24b%A6%B7.%80%20%C10%3Ex%DD%F2%D1l%A6%3Ci%D0%B0X%88%24%18B%E8%B0C%0B%09%1C%89%14DV%E1%93r%8AG%97%8C4%1A-(%81w%E2%CA%98%04%E6%FFX%A0e%E2%D1I'%E3%80%B0%C2%19%F8p%12n%0CU%92Zu%3AY%92Z%E3%A9%A3%F7o%01%3E%C0%90%8D%E9%8EK8%1A%8D6%2B%7B%F2%CD9%7D%C8D%B7%A4%AC%A2%B2Uc%AD%C7.%81%AE%F2%84%92o%AB%06%22D%B7%87W%B0%AB%DF%A3%D9%F4%C7%18%AAIn%B2%94%7F%D0.%85%E1)%24%90%5BF%99%AB%2C%5Es0%1A%E98YR%8Cq7%0D%EE0%E6%16%2C%DF%93V%5D%B5%CB%D4%D9Sn%3D%A8%DD%0B%A6%F7%AF%3F%F4%8AM%A4%F9%1Fcz%B38%5E%E9%06l%AB0%C1%10%3Ea%12%E2%9C%A40%C7%B2%8EW%08%D6%8Dk%CC%60%06(p%C0%02t%B2%AC%9D%A9%ECb%9FK%9E%D6%A0%82%14o%84%C2%0C4%13%E1%02%16%87%8Fk%84%23%7B(%BA%A1%60%F0A%9EO8%E0%87%0B%10a~%A6%04!%AF%1D%A91%AF3%D7%A4xU%80%05%04Q%86Ntb%09%F4%94%40%CD%B0%0EE%AFx%DD%FF%FA%C6%18%B2%208%11%88%0B%F0%C6%050%F7%3E%A8%D4%88%0F%87%E1O%EA%D0G)%AD%60b%04S%B0B%EDF%10%01%00%3B";
var Xg4 = "data:image/gif,GIF89a%2F%00%3F%00%B3%00%00%F1%F5%D3%E7%98Z%8EP%0E%FA%EB%8D%3F!%0B%B6%8BQ%9D%A0x%D2%DF%BF%E7%BB_JT%83%8EyD%99%A0%E7%C9j%14rZ0%B9%BF%9Eov%BA!%F9%04%00%00%00%00%00%2C%00%00%00%00%2F%00%3F%00%00%04%FFp%18%A3*%ADV%CD%8CkQ%85%11~%88%81%0Ch%AAJ%A0%88Q%8D%F6*%F1L%15%DF-%2B%E7%9A%82-YcB!%3A%1C%86%A3%82%D0%18%C6%8A2%5C%CE%E4%03~%5E%C9%A3%E3%C0%EDj%89%3B%DD%C8%A5%E9%A1d%97%EC%B6%CBn%7B'%CE4%D03%E9%01'%C76%60%CF%EF%1F%00l%0Eh%19W%1E%16!%1A%06l~%7F%80%7C%07H%5B%7BoI%83%2F%1F%05CI%5D%80%7F%8D%93%5C%06MM%04%0E%8E%9DZh5s%14y%5C%7D%A8%174%02%0A%02%0C%0C%0D%A6%B0%5CG%1BO%87%15%AF~%0D%09%A3%02%C7%B7%C7%B6%B4%0D%BCy%93%B1%1B%1D%0A%8E%C2K%0D%B7%C9%B4%CB%CB%0C%04%0F%0B%09%E2%04%E2%0A%09%1A%BC%D2%18%D0%7B%0B%04%08%05%CA%DB%C81%CB%0D%E0%E2%0F%09%04%FC%E2%E3%5Dph%C0r%C0%04%01%82%06%CAj-S%C8%C0V%B3G%E9%16%3C%D0%97%A0%13%A4%23%09%8E%2CpP%CC%20%82Z%08%FF%132%A8%D5p%24%ADH%00%264%92(%0E%E2%1E%7F%E3%02xD%90pa%B2%0A%B6%08%80%F8%20%A0%C9%16%03%E0%C8%AD%E9%A2o%22%81%023i*%E4Fk%24%81%9E%B6%02%04X%A6S%01Gp%14a2%F9%40%40%A6L%83%F1%14%8C4%26%80%DF%BB%06R%03%94%2C%8B%C1A%D6%AC%09%0A%A4%05%A2%D3%E3%D3%06f%F1%06%C0%DB%E0%A3%DC%A9%D9%CAf2%00hB%82%07%13%1EH%ADu%14%AF%00%B08%CC%9A%3D%C8d%80%00%B9%24%93%F1%0BP%0A%16%9F%00%05%9E%5E%BE%E6Q%01%E7%C9%04D%C4%98*%D5V%E0%86RDh%894%F5i%D5%BA%F0%22%F3%C3%FB%EE%04%CD%9E%8E%B5!K%2B%15%93%87%BD%F5%96%3CF%A0%16%C1d%03G%CB%22%2C%19O%DE-%E2%D8%8B%13%07%DE%00%E9G%E8%FC%80%2BW%88%16%BB%DC%BF%D9%D3%A2%07%0DO%A1%07%B3%0E%0EJ1Oc%D4(%1C%E9%F3%17%97%97%17avQOH%02%00%FF%12M%80%20%15l%FA1%80%DD%12G%C9G%5C%26V%C12%00%1F%82%D4%D0%DD1%FAa%C7%1BN%0Fv%F7%09%00%13%EE%02aq%E5eH%A2N%990p%DE%10%8D%84%C8G%88%13%1E%40%83%14%F1%98(%CFe%99%D8%93%CB%1E.%BA%B8K%05*%C6%B3%5Eu%CAd%D3Pc%AE%0D%C1%A3g%13%C2%B8%87%03%DD%15%B7%5E%91F%26%83T%3C%0DQ%E3%23%88%12%C2%12ezU%BE%C6%0FN%0D%11%B6%A4%8F%5Br)JzX%26sdx%3C%84%D6%13%02%5CvYg%9D%03%1CP%E2%83%E1%95%D5%A7%9F1%DC%F5a%9AK%F61%C0%9E%C4yc%D6%8D%C70%07%1C%A1N%1A%CAGy%F8%11%C7%98m%FC%5D%26(%97%91%F6(%E9%9E%EB%A9%17%8Fh%FC%C8%C5%17%9D%9E%A5z'%94%26%AA'%D9%AB1H%DA%E5%96%1F%80%C9%A6%9F%AF2Q%E8%99%B3%02P%01%9B%26Vw%97%92%2F29%D0%97l%86%9A%DD_%C1%DC%E9l%FF%9Dz%22%DA%AA~%99%14%80%E6%AE%3C%D2%60%E0%B4%AD%0E%06)%972%C6%A0%A0v%A0%E5G%23%0E*%9A%F7%04%A1%03j%BB%60!%E7a%A7%60%01A*%FBA%801%12%D8%84%B2%D5x%E2%40%A5%A2%8E%DA%D5%B28%D9W%60~%1F6r%40~k%09%C0mu%CA%06PM%1F%BF%9A%87%0C%5B%0F3%7CJ%23%ACfWRC%18r%CB%265%1B%03%22-%60%C2%95*%B2y~%F0%F1%40%81-%B4%A9%CDn%2Bcw%0A%3B%80%20%F1%076U%22C%C0%B85%07p%C0%02%9E%E0%CC%87%01%AE%85yLW%00s%FB%A4%C2%9D8%E2%40%D2a%DE%A2%13%80%D3J%A1%EA%23%82T%7D%23%3A%82%B4%DA%C1.%8FL%22%8AX%20%ABX%B0%22%5Clk%DE%15I(Bv%D9o%CC%B6H%D4n%17W%C1P%5BO%5C%B6gP%1F%DD%C4-W%E8%D2%F2%D6D%B7%1C8%D4%0A%23a%C09%86%17%DD%F7%93%25O%2C%B9%AA%9F0.L%1F%DF%89%F7%5D%F4%2B%97%07%3E9%E07%83n9%E9%93%ACq%F3%E8%A0l%FE%E1%E1%9F%EB%01%40%04%00%3B";
var Xg2 = "data:image/gif,GIF89a%2F%00%3F%00%B3%00%00%FE%FE%FE%23%3E%10%9D%A2%A3%FD%F8%C2%D6%DF%B0%CD%D2%D7%D7%DB%E3%3Ei%11%B0%B3%B9%8A%8F%8CX%5DY%E5%E9%ED%B8%C0%99%BF%C3%C9%E5%EE%D3szs!%F9%04%00%00%00%00%00%2C%00%00%00%00%2F%00%3F%00%00%04%FF%F0%C8%13%AA%0C%13'%C0%81r%5D(%8Ed%86a%13Um%5C%11%14d%2C%03We%A5(%0B%08%01%D3-%82%C5Lf%BA%14)B%DAA%F7H(%0C%C9a%A8F%AD%06%0C%80%82D!4%24%0A%0A%81tdEQ2%20%C1E%9C%40%14%9C%D11%C0%96%CA%D4%15%CA%09%E2%E1%15%3C%F0r%1Ct8*F%01%0Fv%2F%40%0F%02%0A%0D%81%00%0F%888%83T%09%13%7F%0B%0B%7B%7B0%81%97f%85G7%14%08%9A%0D%09%09%8C%90%A4Gug%07%88%05%9A%5EN%01%08%9Ft%16%AD%86fP%9A%02%7B%0A%0F%81%93('%A1f7%C4%B4%0D%05%8C%5Cr%B1%B0E%15%0A%CA%18%A6%B4%06%B5%0Fq3%12%0F%A15%8E%CF%C8%87%9A%E9%0D%06%02pr%93F%26A%0D%08%D76%08P%BF%EB%08%8D%815%AD%01%B8%BC%F1c%E3%09%B7_%05%F6y%7Bw%E6D%06%01%DC%F6%F0%A0%10dA%01%7Dn%F6%3C%1A%C3%2BC%03Mo%FF%10%D8h%82%EF%E26%04%09%C4p%ECx%E0%C9%02%03%09%EB)%90%F9%E0%E2An%0D%FC%C8%A9%94!%C1%CB%97%A8%04%5C%94%E8%86%5B%81%8B%09%89%8D%11g%A3i%00%88%10%8F%B6%B18%B0%E8M%03%0D%94J%91%A4%E0%DA5I_%5E%C2l%B0%0E%E6%A6%07%08%CA%3A%C1g%A0I%B4%19b%1C%A4j%E7%20%EB%D1%83%1F%C5%0EE%80%2F%AB%93%8F%22%D1%0E%09%E3%A0%B0%03%02%87%7D%E2%FBi%F1*%BDg%09%82rK%A95%86%9F%26%AA%1E0%40k%60q%BE%C66%B1%D6%23%9Bsl%A3o%22%140%20%C0%60%F5%00%02%DE%C4%DE%0C%3D%B9%09%DA%B4lQ)%F0%14c%F30F%0C%DA%CC%A2j%F1%8FO(%0D%BA%06%7C%40%F6%CBQ%3F%3AH8%18p%98%BA%9F%C67%DB%25o%E7'-%D7%20%FC%16%D0%DB3%C3%B0a%E6%DBp%CE%7C%13%B0%02sz%92%B0%AEK%A8%AA%BC%F9g%B4%C5%87%C9%D9%F5%0F*%DC%8D%945T%FF%7D2%98%B7%03Dfe5LZ%0B8%91%09%3F%05%08%D0NIF5Q%DE%02%048S%13%5E%8C%A8RTf%3E%DD%85%9BUdI%12D%0C%0E%3CsM%10w%05%C3M0%FCt%25%E30)%F1%E3%CCE%1A%AA%06%82ta%5C%87%14%3D%07%F9A%A3%1B%87%B1%F6%07%23%19%B5AOW%3E%90%D0%0E%10%02%16%E0%C6%3A%9710%C0%95Xb%E9%5B%020EF%96%8C%04%90%C0%07%3F%B3%D9%D4H%02%04d%A9%E6%95%048%81%60L%8C%B4%89%1A%97%ED%5C%15%91%02h%AE%A9g%9B%1Dz%99%C0!%0C%14%B0c%07%10%E54%DCMM%A4%A9%E7%9EM%00IO%23%AA%250(%00%A6D%F8%CBA%F5X%B9%E8%A2%0C%A8%26%803%7C5%D2Z%93Y%7C%84J%3E%07%A92%DD%A6%8B2%E2b%84%999%C0%C0%23%0DB%81R%3AG-%A0%19%AB%9Bn%26%DB%1E%AA%10%00%1B%03%B5%C2%A4%0DV%82%AA%C6%2B%A7%5Cp%A8%CA%FFj%AC%ED%91N%17Xi%A2%C0%B2%9B~%F0%92T%8D%08%BBY%7C%D3%8E%B5%80%03%D7b%AB%A7%B68%A5t%00%B4%0C%04%C0ez%DC%BC%A4%80%A2%E6bI%C0n%DB%8Aw%99%B0%7F%F2%A1%D7l%CA%D6%AB%E5n%07%1D%C5%CF%01%02%B4%2B%01%AA%B4%B5%25%80%C0X%AA%82%23%14p%0Es%02%C3W%A9%02%F1%95%92%E4%0A%13N%F5%DC%60%D4%5D%05w%AAi%BDjD%F51L%09M%B4%F0UwI%D9%15%BD%CB%F2Y%94M%5D%7D*%CE%04%CE%18%15%AFhg%D2%BC%A9%03%7F%F0e%D4%22%0E*%90Ah%B3%7C%9C%10%3B%89%F2J%40%23B%B1%C5M%A3%7F%86%C22RN%24%B4%CE%22%9A%09%AD%E5%1F%81v%C5%25L%12B%83%C3x%25%FE%F6%E7%BB%C1%D1%E8%1AkBj%06F%1BaXDO*%7F%A6pd%8C%7C%05%E4%87I%60%0C3%A3%DC%B3%98%D8%9F%B1%25%8Ad%C60B%CD%84%CA-%C9%DD%84g%3B%05%10p%F4%97K%7Btf%F8%C49%A9%7B%82%B0S%7B%A3%9Bw%95%B6%95%0A%1F%2BK%F8F%88%5C%B1%C5yZ%3C%04%E4-%C1%BA%D5%C4H%3E%26~%91%AA%8C%1BF(%89g%8C%F3%C7%C0%01%C3%D2%92JZN%40%F1%87%8C%C7u'L%3E%7Bp%06RR%B6M%EDk%3A(%C5%D4%23s%B6%F0%91%15i%92%A8%A3JEF9%F1%15%03DW%04%94Pd%F1%B0%DB%97%01%E1F%95%60%9C%DB%F6%13L%B7%0D%D3ZM%E9%18%0B%5E%CA%C1%88%23%7D%CD%00u%F1%C6%C7P%A1%8Am%B1%8C%1Fd%8B%00%00%3B";
var Xg3 = "data:image/gif,GIF89a%2F%00%3F%00%B3%00%00%FD%ED%8B%FD%F9%C2%E4%D6%7F%A8%9BW%F4%E7%9DS%3D%12%C9%B3_xe-%F1%E1%83%CC%DA%AF%A9%AE%7F%DC%C8p%B6%C5%9C%E0%ED%CF%8F%83I%C5%C0%85!%F9%04%00%00%00%00%00%2C%00%00%00%00%2F%00%3F%00%00%04%FF%B0%B1F%93M%8C%BD%E1%FA8%07%93Pd%83)%0E%CA%7D%DD%E1%1C%DF%A1%1CRP%DE%26%A3(%838%8E7K%26%93%F28%06%ACO%C3%05%C4%05%2F%D0f%053%CC%CCV%83%99m%D7P4%BF%89%DDQ%E3%B5%3C%2C%26%92%90*F%CD%12%01%5BW%A7%A8%3C%18%03%82%80%80%40%00%04%02%00%08%02Y%0AC%86%88%3B%18P%192pq%01a%3B%0B%0B%00%96~%96%99%9A%99%02%08%0B%04%0F%80%0F%1B)R%5D%0E%3A%22%A1%7C%9B%AD%AE%9B%98%96z%3Ca%3A%25%09%0F%04%99%B1%AF%BA%AE%BC%9B%01%3B%1Cu%24%0C%82%AF%BB%C9%C8%9A%C0%08%04%03%15%12%0A%C0%CB%9A%9D%BE%D6%9A%0B)u%0F%06%DA%AF%06%06%9D%E1%99%04%5E%0D%04%AC%D5%C9%BA%04%0B%7B%EB%F3%E1%0B%18%E6%00%F3%FA%FB%FC%D6%08(%EDd%F1%1BHP%19%2CK%0F%1C%1C%CC%F7%8E%A0%C3u%98%0C%0C%08%E4%8A%D2%9Fj%0F3%0A%0A%00%00I%C0A%D0%FF%02%F1%12%60%60%C1%B3%8C%EBz%25C%40%CE%405%03%A3%1E%F6%E9%23(%E0%2B%04%03%FE%B4Z%A0%40%1E%C1%04z%F8%CC%B4%D9%0C%40%00%8A%CCj~%9A'o%03%88%A7.%1C%18%E0%D3%89W%ACX%84z%3D%93'%20%A1%0BC%C6P%B8xP%93%A8%25%A4%CDf%EE%110%23%05%A4%B76%BCN%BCH3)%A6jC%B1%7D%18%F0%08.%24%13%7B%FB%88%1CJ%B8%DDP%02%06%3A4%F0%CB%B8A%07j%85%23%AF%EC%F3b1%E3%C6%1D%3Ai%8E%5Cn%D9%83%10%97C%7FVPv%90%E9%AAu%05%98%DC%C4!th%C7%A4%FDD%9Ey%B6C%A5%5Dn%5D_%06xi%F6%5Dr%AD%0E%3C%D0%7D9%C1%81%DE%85%AB%22%C3%F4.%1F%0D%E2%8C%09%1C%F0%A5%D6%B4%E9M)%E7%1D%80%DE%F88r%C9%07%B5%F7%E5%1EG%FA%D5%D9*%A5%8F'%CF%C0%7BRm4)%2B%20%FF%16%85.%C3%BF%04%0F%FA%40%1F%D2%11%7C%DF%F5%01%0A%FFh%F4%CD%90%CB%25%00%9ED%40%02%1D%AC%E7%1A%83%D3%01%88%1D%20%03F%E3%1A%01q0X%40%01%F3%F9%E3%0Ab%DF%00r%C5p%AE%25T%00%08%05%F8%91%0D%2C%B7%ED%E2%C9%00%E3%98%04%0D%0C%0FX%E6%D7%0CP%15%A0%D0%8A%08%EA%04%0B%3C%A8%F5%C1%C0%0B4%C2%01%CA%07'B%E5%40%01-%86%23%5Ba%82H%E7%C2%01I%26%09U%8EdI(%CED%25%09%B0!THZY%00ZZnB%C9%02%25%19%20%E6%86%2F%B4%09NQeZ%82%26%95%0E%A0%F9%A5%0B0%C6(%91%8F%AD%98%B5%93%9A%1B%26%96g%8C%03l8'%12%9D%5D%E3%A4j%12%15j%A8T%0B%7C%C9%CD%860%9E%88%E8%2F%DA%90D%24%8A%05HT%D2%97%E3%B0%F9%02%12%03%B4C%A6%2B%24%C1%04%A3%A3%E3%1CA%E7%11c%B2T%89Mu%F2%08%CB%20%F1%C4%23%C0%A80H%14%15%0Ch%D9j%C9%01%06%04%40%94leI%A4Z%3E%0B%20%01%A6%AEA%ADdv%9BM%C8%D6%D4%23bW%3E%40T%07%0E%24%1Ag%3EH%BCpb%B7%C9pK%AE%9F7%5D%23%AE%8E%09%BC%C2-%0C%C2j%E9%C7%1D_%8E%89Z%26%ED%81%F0%C2%A9%D0%F6%B6%89f%9F%200V%AF%25%C5%A2C%9B%2F%AC%D6gi%7D%E4%1A%CF%5E%0B%84%E8%8B%B0%18l%FA%C1%B4%B2%08%06%08%25%84%8C%E31%8C%B4i%23%02%8E%FA%8Er%09%20%8Cz%5C%92%AEfM%9CO%269%EC%40e%92H%8C3%A8%AE%F7%F6%CBPC%FB%00P%C1%C1K%CA%B0lYp%F6%82%D2%3Aj%E8%E0lN%3D%E2%F3%10P%FA%DC%A2%C83%DF%3A%F4M.%10E%00%00%3B";
var Bulldozer1 = "data:image/gif;base64,R0lGODlhMgAuAMQfAPPcGgUEA2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BDs30hsGAAIIMbQRYX%2FQf5gBEKQ42usPqEoaDnGh8IHCCCW3z9%2BM5TafIHw%2FjMyfP0FcQ6IDTKiyPQ9AywUuo7wMAAEEMuvn38YXnz8DdXwH6SOgRGkghFiIyMDItB%2B%2F%2FzNABBALL9%2B%2FGKYcYQDqoqBIdrkG8QCqKKlZ7ggHEaQ6B8GgABiRI8Hx7b4%2F2Em38FmrzrDwbC%2FaiFKPAAEEEaw%2FgE68ftvkCH%2FgE7ADCWAAMIM1j9%2F4ey%2Fv%2F%2BiSzMABBCWiPvLsOIQAwMkqDA1AAQYAACIahTU1BszAAAAAElFTkSuQmCC";

var O = 0;
var T = A();
var Timer = new Object();var TimerCount = 1;
var RelayTimer = new Object();var RelayTimerCount = 1;

// ›› Event listener starts things off once the page is done loading.
window.addEventListener("load",init,false);

// ›› Execution logic loop
function init() {
		if (GM_getValue("InActive")){						inactivestub();}else{
		if (!(/travian/.exec(document.domain))) {	offsitestub();}else{
		var SS1 = TM_searchDOM('//a[@class="active_vl"]');
		var SS2 = TM_searchDOM('//a[@href="logout.php"]')
		if (SS1.snapshotItem(0) && SS2.snapshotItem(0)){
			var X1 = /(\d+)/.exec(SS2.snapshotItem(0).previousSibling.getAttribute("href"));
			var X2 = /newdid=(\d+)/.exec(SS1.snapshotItem(0).getAttribute("href"));
			User = X1[1];
			ActiveVillage = X2[1];
			Server = document.domain;
			UniqueID = Server + '.' + User + '.';
			Page = window.location.href;
			var SS3 = TM_searchDOM('//td[@class="nbr"]//a')
			var SS4 = TM_searchDOM('//table[@class="dtbl"]//td[@class]')
			VillageNumber = SS3.snapshotLength;
			for ( var i=0 ; i < SS3.snapshotLength; i++ ) {
				var X3 = /newdid=(\d+)/.exec(SS3.snapshotItem(i).getAttribute("href"));
				var X4 = /(-*\d+)/.exec(SS4.snapshotItem(i*3).innerHTML);
				var X5 = /(-*\d+)/.exec(SS4.snapshotItem(i*3+2).innerHTML);
				VillageIDs[i] = X3[1];
				VillageLinks[i] = SS3.snapshotItem(i).getAttribute("href");
				VillageNames[i] = SS3.snapshotItem(i).innerHTML;
				VillageCoords[i] = X4[1] + '|' +  X5[1];
			}
			var SS5 = TM_searchDOM('//link[@rel="stylesheet"]')
			for (var i=0;i<SS5.snapshotLength;i++){var str=SS5.snapshotItem(i);var pos=str.href.indexOf('unx.css');if(pos!=-1){imgpath=str.href.substring(0,pos);}} // tnx MexoaN =]
			if (!GM_getValue(UniqueID+ActiveVillage+".TimedEvents")){GM_setValue(UniqueID+ActiveVillage+'.TimedEvents','9/9999/2185000000/NULL/0');}
			if (!GM_getValue(UniqueID+"Prefs")){GM_setValue(UniqueID+"Prefs",'0.1.1.0.0.T.S');}
			Prefs = GM_getValue(UniqueID+"Prefs").split('.');
			makeDefaultCSS();
			scripts();
			}}}}
			// ›› Inactive stub.
			function inactivestub (){alert('Bad news =[  No place to save preferences.  Firefox required.  If you have Firefox, your version of Greasemonkey might be too old.  If this is the case... UPGRADE NOW. There are SERIOUS security issues with older versions of Greasemonkey!');}
			// ›› Offsite stub.
			function offsitestub() {}
			// ›› Back to drawing board on redirect.
			function redirect() {}
// ›› Individual scripts.
function scripts() {
	TM_GetResourceInfo();
	TM_ShowTotalProduction();
	TM_GetBuildInfo();
	TM_RemoveOldEvents(ActiveVillage);
	TM_AddListener();
	TM_ShowEvents();
	TM_ShowMainBuildingNumbers();
	TM_CreateMenu();
	TM_AddManualListeners(TM_searchDOM('//span[@id="timer1"]'));
	TM_AddManualListeners(TM_searchDOM('//span[@id="timer2"]'));
	TM_AddTroopListener(TM_searchDOM('//span[@id="timer1"]'))
	//TM_CalculateMarket();
	//TM_FillMarket();
}

// EVENT /////////// This function only adds onclick and other events to existing DOM elements, it does not create any additional (except warning div).
// ›› Add listeners that store events. It needs a CLOCK to function. Do not use for specific pages.
function TM_AddListener(){
	var EventType = "0";
	var EventInfo = "";
	var EventDuration = "0";
	var ClockCount = 0;
	var CLOCK = TM_searchDOM('//img[@class="clock"]')
	if (CLOCK.snapshotItem(0)){ // a clock is necessary for any timed event addition. so far.

		// Grab every link on the page.
		var SS1 = TM_searchDOM('//a[@href]')
		for (var i=0;i<SS1.snapshotLength;i++) {
			var xA = SS1.snapshotItem(i);
			
			// Upgrade existing building links.
			var X = /\?a=(\d+)&c=/.exec(xA.getAttribute("href"));
			if  (X){
				var BuildSpot = X[1];
				(X[1]<19?EventType = "1":EventType = "2")
				var OOO = GM_getValue(UniqueID + ActiveVillage + '.Dorf' + EventType);
				if (OOO){
					var OO = OOO.split(':');
					for ( var j=0 ; j < OO.length; j++ ) {O = OO[j].split('/');if (O[0] == BuildSpot){var EventInfo = OO[j];}}
					xA.setAttribute('TMDuration',CLOCK.snapshotItem(CLOCK.snapshotLength-1).nextSibling.nodeValue); // should be last clock on the page. maybe.
					xA.setAttribute('TMEventType',EventType);
					xA.setAttribute('TMEvent',EventInfo);
					xA.addEventListener('click', function() {
						TM_StoreNewEvent(this.getAttribute('TMDuration'),
													this.getAttribute('TMEventType'),
													this.getAttribute('TMEvent'));}, true);
				}else{ // possibility this doesn't exist yet, if not give warning that event wil not be recorded
					var warn = addDiv('TMWarn' + i,'TMmain','I do not know this village yet.<br>' +
					'Please go to <a href="dorf1.php">your fields<a/> and <a href="dorf2.php"> your village</a> 1st.<br>' + 
					'You only need this once so I know what is built.',false);
					warn.style.right = '25px';
				}
			}
			// Construct new building links.
			var X = /\?a=(\d+)&id=\d+&c=/.exec(xA.getAttribute("href"));
			if  (X){
				xA.setAttribute('TMDuration',CLOCK.snapshotItem(ClockCount).nextSibling.nodeValue); // one clock per matching link
				xA.setAttribute('TMEventType','2');
				xA.setAttribute('TMEvent','0/g00/0/??');
				xA.addEventListener('click', function() {
					TM_StoreNewEvent(this.getAttribute('TMDuration'),
												this.getAttribute('TMEventType'),
												this.getAttribute('TMEvent')
												);}, true);
			ClockCount++;
			}
		}
		EventType = "0";
		
		// The following snapshot appears on BARRACKS, STABLE, ARMORY, BLACKSMITH, ACADEMY, MARKET, TOWNHALL, and I assume Great Barracks and Great Stable
		var SS1 = TM_searchDOM('//input[@name="id"]')
		if (SS1.snapshotItem(0)){	
			// this holds our building spot
			var BuildID = SS1.snapshotItem(0).getAttribute("value");
			// we have a record of what is built there
			var OOO = GM_getValue(UniqueID + ActiveVillage + '.Dorf2')
			if (OOO){
				var OO = OOO.split(':');
				for ( var i=0 ; i < OO.length; i++ ) {
					var O = OO[i].split('/');
					if (O[0] == BuildID){
						if (O[1] == 'g19'){EventType = '3';} // g19 is barracks
						if (O[1] == 'g20'){EventType = '4';} // g20 is stable
					}
				}
			}else{ // possibility this doesn't exist yet, if not give warning that event wil not be recorded
				var warn = addDiv('TMWarn' + i,'TMmain','I do not know this village yet.<br>' +
				'Please go to <a href="dorf1.php">your fields<a/> and <a href="dorf2.php"> your village</a> 1st.<br>' + 
				'You only need this once so I know what is built.',false);
				warn.style.right = '25px';
			}
			
			// only interested in barracks and stable at the moment
			if (EventType == 3 || EventType == 4){
				var SS1 = TM_searchDOM('//input[@name="s1"]')
				var xINPUT = SS1.snapshotItem(0);
				xINPUT.setAttribute('TMEventType',EventType);
				xINPUT.addEventListener('click', function() {
					var SS2 = TM_searchDOM('//input[@size]')
					for ( var i=0 ; i < SS2.snapshotLength; i++ ) {
						if (SS2.snapshotItem(i).value > 0){
							var TroopNumber = SS2.snapshotItem(i).value;
							var CLOCK = TM_searchDOM('//img[@class="clock"]')
							var SingleTroopDuration = Z(CLOCK.snapshotItem(i).nextSibling.nodeValue);
							var EventDuration = Y(SingleTroopDuration * TroopNumber);// total duration
							var X = CLOCK.snapshotItem(i).parentNode.parentNode.previousSibling.previousSibling.firstChild.nextSibling.firstChild.getAttribute('src').split('/');
							var TroopImage = /(\d+)/.exec(X[X.length-1])[0];
							var TroopDesc = CLOCK.snapshotItem(i).parentNode.parentNode.previousSibling.previousSibling.firstChild.nextSibling.nextSibling.nextSibling.firstChild.firstChild.innerHTML;
							xINPUT.setAttribute('TMEvent',SingleTroopDuration+'/'+TroopImage+'/'+TroopNumber+'/'+escape(TroopDesc));
							TM_StoreNewEvent(EventDuration,this.getAttribute('TMEventType'),this.getAttribute('TMEvent'));
						}}}, true);
			}
		}
	} //end clocks
	
	// special case demolish building, no timer until next page.
	var SS1 = TM_searchDOM('//select[@name="abriss"]')
	if (SS1.snapshotItem(0)){
		var SS2 = TM_searchDOM('//input[@name="ok"]')
		var xINPUT = SS2.snapshotItem(0);
		xINPUT.setAttribute('TMEventType','0');
		xINPUT.setAttribute('TMEventDuration',Y(99999));
		xINPUT.setAttribute('TMEvent','Demolition');
		xINPUT.addEventListener('click', function() {TM_StoreNewEvent(this.getAttribute('TMEventDuration'),this.getAttribute('TMEventType'),this.getAttribute('TMEvent'));}, true);
	}
}

function TM_AddTroopListener(X){
	if(X.snapshotItem(0)){
		var XXX=X.snapshotItem(0);
		if(/build/.exec(Page)&&Prefs[6]=='S'){
			var YY = TM_searchDOM('//input[@name="id"]').snapshotItem(0);
			if(WhatIsBuiltHere(pI(YY.getAttribute('value'))).split('/')[1]=='g19'){var Type='3'}
			if(WhatIsBuiltHere(pI(YY.getAttribute('value'))).split('/')[1]=='g20'){var Type='4'}
			if(Type){
				IMG = addImg(false,false,Xadd,false);
				IMG.style.cursor='pointer';
				IMG.style.left='3px';
				IMG.setAttribute('TMType',Type);
				IMG.addEventListener('click', function() {
					TM_UpdateEvent(this.getAttribute('TMType'),2,0);
					TM_RemoveOldEvents(ActiveVillage);
					var TMEvent;
					var SubtractTime = 0;
					var YYY = TM_searchDOM('//span[@id]');
					for (var i=0;i<YYY.snapshotLength;i++) { 
						if(XX = /timer(\d+)/.exec(YYY.snapshotItem(i).getAttribute('id'))){
							if(XX[1]&&XX[1]>1){
								var TroopNumber = /(\d+)/.exec(YYY.snapshotItem(i).parentNode.previousSibling.previousSibling.previousSibling.previousSibling.innerHTML)[1];
								var EventDuration = Z(YYY.snapshotItem(i).innerHTML);
								var SingleTroopDuration = pI(pI(EventDuration-SubtractTime-Z(XXX.innerHTML))/pI(TroopNumber-1));
								if(XX[1]>2){SingleTroopDuration = pI(pI(EventDuration-SubtractTime)/pI(TroopNumber));}
								var XXXX = YYY.snapshotItem(i).parentNode.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.firstChild.getAttribute('src').split('/');
								var TroopImage = /(\d+)/.exec(XXXX[XXXX.length-1])[1];
								var TroopDesc =  YYY.snapshotItem(i).parentNode.previousSibling.previousSibling.innerHTML
								var Event = SingleTroopDuration+'/'+TroopImage+'/'+TroopNumber+'/'+escape(TroopDesc);
								TM_StoreNewEvent(Y(EventDuration-SubtractTime),this.getAttribute('TMType'),Event);
								SubtractTime=EventDuration;
							}}}
					window.location.href=window.location.href;
				}, true);
				XXX.parentNode.appendChild(IMG);
			}}}}

function TM_AddManualListeners(X){
	if(X.snapshotItem(0)){
		XX = X.snapshotItem(0);
		if (/dorf/.exec(Page)&&Prefs[6]=='S'){
			var Name = XX.parentNode.previousSibling.innerHTML.slice(0,5);
			var Lvl = parseInt(/(\d+)/.exec(XX.parentNode.previousSibling.innerHTML)[1])-1;
			var OO=GM_getValue(UniqueID + ActiveVillage + '.Dorf1').split(':');
				for (var i=0;i<OO.length;i++){
					var O=OO[i].split('/');
					if(unescape(O[3]).slice(0,5)==Name){
						O[3]=unescape(O[3]);
						O[2]=Lvl;OO[i]=O.join('/');
						var Event=OO[i];
						var Type='1';}}
			var OO=GM_getValue(UniqueID + ActiveVillage + '.Dorf2').split(':');
				for (var i=0;i<OO.length;i++){
					var O=OO[i].split('/');
					if(unescape(O[3]).slice(0,5)==Name){
						O[3]=unescape(O[3]);
						O[2]=Lvl;OO[i]=O.join('/');
						var Event=OO[i];
						var Type='2';}}}
		if (Event&&Type){
			IMG = addImg(false,false,Xadd,false);
			IMG.style.cursor='pointer';
			IMG.style.left='3px';
			IMG.setAttribute('TMduration',XX.innerHTML);
			IMG.setAttribute('TMtype',Type);
			IMG.setAttribute('TMevent',Event);
			IMG.addEventListener('click', function() {
				TM_UpdateEvent(this.getAttribute('TMtype'),2,0);
				TM_RemoveOldEvents(ActiveVillage);
				TM_StoreNewEvent(this.getAttribute('TMduration'),this.getAttribute('TMtype'),this.getAttribute('TMevent'));
				window.location.href=window.location.href;
				}, true);
			XX.parentNode.appendChild(IMG);
		}}}
// EVENT \\\\\\\\\\\

function WhatIsBuiltHere(id){
	var OO=GM_getValue(UniqueID + ActiveVillage + '.Dorf2').split(':');
	for (var i=0;i<OO.length;i++){
	var O=OO[i].split('/');if(O[0]==id){return OO[i];}}}

// DISPLAY /////////// These functions visibily alter the page.
// ›› Settings menu.
function TM_CreateMenu(){
	var M,MENU,MM=new Array();
	M = addDiv('TMmenutrigger','TMmain','',false);
	if(Prefs[6]=='S'){
		M.style.backgroundColor = 'green';
		M.style.cursor = 'pointer';
		M.addEventListener('click', function() {
			MENU = addDiv('TMmenu','TMmain','',false);
			MENU.style.right = "30px";
				MM[0] =addDiv('TMmm0','TMdisplay','[]','TMmenu');
				MM[0].style.backgroundColor = (Prefs[0]=='0')?'red':'green';
				MM[0].addEventListener('click', function() {
					this.style.backgroundColor = (Prefs[0]=='0')?'green':'red';
					Prefs[0]=(Prefs[0]=='0')?'M':'0';
					}, true);
			for (var i=1;i<5;i++){
				MM[i] = addDiv('TMmm' + i,'TMdisplay','','TMmenu');
					IMG = addImg('TMcolumn'+i,'TMnull',false,'TMmm' + i);
					IMG.src=(Prefs[i]=='1')?Xon:XRed;
					IMG.setAttribute('TMcount',i)
					IMG.addEventListener('click', function() {
						Prefs[this.getAttribute('TMcount')] = (this.src==Xon)?'0':'1';
						this.src = (this.src==Xon)?XRed:Xon;
						}, true);
			}
				MM[5] = addDiv('TMmm5','TMdisplay','00:00:00','TMmenu');
				MM[5].style.backgroundColor =(Prefs[5]=='0')?'red':'green';
				MM[5].addEventListener('click', function() {
					this.style.backgroundColor = (Prefs[5]=='0')?'green':'red';
					Prefs[5] = (Prefs[5]=='0')?'T':'0';}, true);
				MM[6] = addDiv('TMgo','TMdisplay','X','TMmenu');
				MM[6].style.backgroundColor = 'green';
				MM[6].addEventListener('click', function() {
					GM_setValue(UniqueID+"Prefs",Prefs.join('.'));
					window.location.href=window.location.href;
					}, true);
				MM[7] = addDiv('TMstop','TMdisplay','X','TMmenu');
				MM[7].style.backgroundColor = 'red';
				MM[7].addEventListener('click', function() {
					Prefs = GM_getValue(UniqueID+"Prefs").split('.');
					document.getElementById('TMmenu').parentNode.removeChild(document.getElementById('TMmenu'));}, true);}, true);
	}else{M.style.backgroundColor = 'red';}
}

// ›› Show bulldozer icon for timing a building demolish. Temporarily disabled.
function TM_ShowDemolish(O){
		if(O[1] == '99999'){
			O[1] = Z(document.getElementById('timer1').innerHTML);
			TM_UpdateEvent('0',1,O[1]);
		}
		var newtime = parseInt(O[1])+parseInt(O[2])-A();
		if(!Timer[0]){
			DIV = addDiv('TMdemo','TMdemo',false,false);
			IMG = addImg('TMtimer0','TMtimer',Bulldozer0,'TMdemo');
			//AttachTimer(0,IMG,parseInt(O[1])+parseInt(O[2])-A(),'IMG',Bulldozer1);
		}else{
			if(newtime < Timer[0].duration){Timer[0].duration = newtime;}
		}
}

// ›› Show total Village resource production, overlayed over left menu bar.
function TM_ShowTotalProduction(){
	var j = 0;
	var ResourceValues1 = "";
	var ResourceValues2 = "";
	var wood1 = 0;var clay1 = 0;var iron1 = 0;var crop1 = 0;
	var wood2 = 0;var clay2 = 0;var iron2 = 0;var crop2 = 0;
	var wood3 = 0;var clay3 = 0;var iron3 = 0;var crop3 = 0;
	for (var i = 0; i < VillageIDs.length; i++) {
		if (GM_getValue(UniqueID + VillageIDs[i] + '.Resources')){
			ResourceValues1 = GM_getValue(UniqueID + VillageIDs[i] + '.Resources').split(":");
				ResourceValues2 = ResourceValues1[0].split("/");
				wood1 = wood1 + parseInt(ResourceValues2[0]);
				wood2 = wood2 + parseInt(ResourceValues2[1]);
				wood3 = wood3 + parseInt(ResourceValues2[2]);
				ResourceValues2 = ResourceValues1[1].split("/");
				clay1 = clay1 + parseInt(ResourceValues2[0]);
				clay2 = clay2 + parseInt(ResourceValues2[1]);
				clay3 = clay3 + parseInt(ResourceValues2[2]);
				ResourceValues2 = ResourceValues1[2].split("/");
				iron1 = iron1 + parseInt(ResourceValues2[0]);
				iron2 = iron2 + parseInt(ResourceValues2[1]);
				iron3 = iron3 + parseInt(ResourceValues2[2]);
				ResourceValues2 = ResourceValues1[3].split("/");
				crop1 = crop1 + parseInt(ResourceValues2[0]);
				crop2 = crop2 + parseInt(ResourceValues2[1]);
				crop3 = crop3 + parseInt(ResourceValues2[2]);
				j++;
		}
	}
	var HTML =  '<table width="100%" cellpadding="4" cellspacing="0" border="0">'
			if (j != VillageIDs.length){HTML += '<tr><td colspan=2 align="center">' + j + '/' + (VillageIDs.length) + ' Villages</td></tr>';}		
			HTML += '<tr><td colspan=2 align="center">++ Production</td></tr>' + 
			'<tr style="background:#DDEEDD;"><td>Wood</td><td class="right">' + wood1 +  '</td></tr>' +
			'<tr style="background:#FFCD8E;"><td>Clay</td><td class="right">' + clay1 +  '</td></tr>' +
			'<tr style="background:#DEE3E9;"><td>Iron</td><td class="right">' + iron1 +  '</td></tr>' +
			'<tr style="background:#FDF8C1;"><td>Crop</td><td class="right">' + crop1 +  '</td></tr>' +
			'<tr><td colspan=2 align="center">++ Resources</td></tr>' + 
			'<tr style="background:#DDEEDD;"><td>Wood</td><td class="right">' + wood2 + '</td></tr>' +
			'<tr style="background:#FFCD8E;"><td>Clay</td><td class="right">' + clay2 + '</td></tr>' +
			'<tr style="background:#DEE3E9;"><td>Iron</td><td class="right">' + iron2 + '</td></tr>' +
			'<tr style="background:#FDF8C1;"><td>Crop</td><td class="right">' + crop2 + '</td></tr>' +
			'<tr><td colspan=2 align="center">++ Storage</td></tr>' +
			'<tr style="background:#DDEEDD;"><td>All</td><td class="right">' + wood3 + '</td></tr>' +
			'<tr style="background:#FDF8C1;"><td>Crop</td><td class="right">' + crop3 + '</td></tr>' +
			'</table>'

	DIV = addDiv('TMleftmenu','TMleftmenu',HTML,'lmidlc');
	DIV.addEventListener('click', function() {
		this.parentNode.removeChild(this);}, true);
}

// ›› Show building numbers in village center.
function TM_ShowMainBuildingNumbers(){
var map1Element = document.getElementsByName('map1')[0];
if (map1Element){var x=152;var y=160;buildArr1=new Array(21);buildArr2=new Array(21);
	buildArr1[0] = 318 + x;buildArr1[1] = 121 + x;buildArr1[2] = 204 + x;
	buildArr1[3] = 264 + x;buildArr1[4] = 338 + x;buildArr1[5] = 394 + x;
	buildArr1[6] = 86 + x;buildArr1[7] = 167 + x;buildArr1[8] = 253 + x;
	buildArr1[9] = 401 + x;buildArr1[10] = 72 + x;buildArr1[11] = 198 + x;
	buildArr1[12] = 161 + x;buildArr1[13] = 408 + x;buildArr1[14] = 90 + x;
	buildArr1[15] = 233 + x;buildArr1[16] = 360 + x;buildArr1[17] = 164 + x;
	buildArr1[18] = 292 + x;buildArr1[19] = 150 + x;buildArr1[20] = 266 + x;
	buildArr1[21] = 290 + x;
	buildArr2[0] = 166 + y;buildArr2[1] = 82 + y;buildArr2[2] = 57 + y;
	buildArr2[3] = 47 + y;buildArr2[4] = 62 + y;buildArr2[5] = 111 + y;
	buildArr2[6] = 121 + y;buildArr2[7] = 128 + y;buildArr2[8] = 111 + y;
	buildArr2[9] = 152 + y;buildArr2[10] = 191 + y;buildArr2[11] = 156 + y;
	buildArr2[12] = 182 + y;buildArr2[13] = 210 + y;buildArr2[14] = 230 + y;
	buildArr2[15] = 226 + y;buildArr2[16] = 243 + y;buildArr2[17] = 266 + y;
	buildArr2[18] = 260 + y;buildArr2[19] = 297 + y;buildArr2[20] = 306 + y;
	buildArr2[21] = 356 + y;
	// ›› Map1 ONLY has area children. 
	var BuildingLevel, BuildingURL, DIV;
	var areaElements = map1Element.childNodes;		
	for (var i = 0; i < 22; i++) {
		if (BuildingLevel =/(\d+)/.exec(areaElements[i].getAttribute("title"))){ // ›› Only show spots with buildings on them.
			DIV = addDiv('TMbuildingtag' + i,'TMbuildingtags',BuildingLevel[0],false);
			DIV.style.top = buildArr2[i] + 'px';
			DIV.style.left = buildArr1[i] + 'px';
			DIV.style.visibility = "visible";
			DIV.setAttribute('goto',areaElements[i].getAttribute("href"));
			DIV.addEventListener('click', function() {window.location.href = this.getAttribute('goto');}, true);}}}}

// ›› Modifies the Village list by adding the event information.
function TM_ShowEvents(){
	var IMG = new Array();
	var SS1 = TM_searchDOM('//div[@id="lright1"]/table/tbody/tr')

	// These 3 lines are for determining the number of columns in a finished table row in order to set the colspan for the timer rows.
	var L=1;for (var i=1;i<5;i++) {if (Prefs[i]=="1"){L++;}}
	var SS2 = TM_searchDOM('//div[@id="lright1"]/table/tbody/tr/td');							
	var Colspan = (SS2.snapshotLength/VillageNumber) + L;if (Prefs[0]=='M'){Colspan--;}

	// [--1--] For every table row.
	for ( var i=0 ; i < SS1.snapshotLength; i++ ) {
		var TimersPerRow = 0; 			// ued to determine start and end numbers for the timers in this row
		var xTR = SS1.snapshotItem(i);
		var xTD = SS1.snapshotItem(i).firstChild;
		xTD.removeChild(xTD.firstChild);xTD.removeChild(xTD.firstChild); // remove the span with the small indicator dot
		var TD = document.createElement('TD');if (VillageIDs[i]==ActiveVillage){TD.innerHTML = '<img src="'+Xarrow+'">';}xTR.insertBefore(TD,xTD); // replace it with the arrow

		// [--2--] show a column for each active display
		for (var j=1;j<5;j++){
			if (Prefs[j]=='1'){
				var m=j;
				if((Prefs[0]=='M')&&(j==2)&&(Prefs[1]=="1")){m=j-1;}
				if (m==j){
					var TD = document.createElement('TD');
					IMG[m] = document.createElement('IMG');
					IMG[m].src = Xnull;
					if((!GM_getValue(UniqueID+VillageIDs[i]+".Dorf1")&&j==1)||(!GM_getValue(UniqueID+VillageIDs[i]+".Dorf2")&&j==2)){IMG[m].src = XRed;Prefs[6]='0'}
					IMG[m].setAttribute('TMsrcDefault',Xnull);
					IMG[m].setAttribute('TMsrcOn',Xon);
					IMG[m].setAttribute('TMsrcOnMore',XonX);
					IMG[m].setAttribute('TMsrcDone',Xdone);
					IMG[m].addEventListener('mouseover',function(e){TM_ShowEventPopup(e,this);},true);
					IMG[m].addEventListener('mouseout',function(e){infoDIV.innerHTML='';infoDIV.style.visibility = 'hidden';},true);
				}
					
				// [--3--] Loop through timed events to see if this image should be activated and assigned a timer.
				OOO = GM_getValue(UniqueID+VillageIDs[i]+".TimedEvents")
				if(OOO){
					OO = OOO.split(':');
					var VCETimer = false;
					var VCERelayTimer = false;
					for (var k=0;k<OO.length;k++) {
						var O = OO[k].split('/');
						//if (parseInt(O[0]) == 0){TM_ShowDemolish(O)};
						if (parseInt(O[0]) == j){
							// [--4--] Create or update timers for this event.  Reassign pass-control based on duration.
							var Duration = pI(O[1])+pI(O[2])-A(); // duration of the timer adjusted for the current time
							if(Duration>0){
								if (!VCETimer){
									if(pI(O[0])>2){	TM_Timer(TimerCount,VillageIDs[i],m,true,Duration,pI(O[3]),IMG[m],false,false,false,false);VCETimer=true;TimersPerRow++;}
									else{				TM_Timer(TimerCount,VillageIDs[i],m,true,Duration,false,IMG[m],false,false,false,false);VCETimer=true;TimersPerRow++;}
									IMG[m].src = IMG[m].getAttribute('TMsrcOn');
									IMG[m].setAttribute('TMsrcDefault',IMG[m].getAttribute('TMsrcOn'));
									IMG[m].id = 'TMtimer' + TimerCount;
									IMG[m].setAttribute('TMinfo',OO[k]);
								}else{
									IMG[m].setAttribute('TMinfo',IMG[m].getAttribute('TMinfo') + ':' + OO[k]); 			//update the build info
									if(!VCERelayTimer){
										Timer[TimerCount-1].pass_control_duration = Timer[TimerCount-1].duration; //register a pass control duration
										Timer[TimerCount-1].relay_timer = TM_RelayTimer(RelayTimerCount,parseInt(O[1]),false);VCERelayTimer=true;
									}else{
										RelayTimer[RelayTimerCount-1].relay_timer = TM_RelayTimer(RelayTimerCount,parseInt(O[1]),false);
									}
									Timer[TimerCount-1].duration = Duration; 														//update the total timer for this column
								}
							}else{
								IMG[m].src = IMG[m].getAttribute('TMsrcDone');
								IMG[m].id = 'TMtimerexpired' + TimerCount;
								IMG[m].setAttribute('TMinfo',OO[k]);
							}}}}
				if (m==j){
					TD.appendChild(IMG[m]);
					xTR.insertBefore(TD,xTD);
				}}}
		// if timers are shown add a row
		 if (Prefs[5]=='T'){
			var ST = 36000000; //Shortest Timer
			var STC =false;		// Shortest Timer Count
			if (TimersPerRow!=0){
				for (var g=TimerCount-TimersPerRow; g<TimerCount; g++) {if(Timer[g].duration<ST && Timer[g].duration>0){ST=Timer[g].duration;STC=g;}}
				if(STC){
					var TR = document.createElement('TR');
					var TD =  document.createElement('TD');
					TD.setAttribute('colspan',Colspan);
					TM_CreateTimerRow(STC,TD);
					Timer[STC].pass_column = TimerCount-TimersPerRow + ':' + TimerCount;
					TR.appendChild(TD);
					xTR.parentNode.insertBefore(TR,xTR.nextSibling);
				}}}}
	setInterval(TM_ActivateTimers,1000);
}

// ›› Timer Row, created with the shortest timed event.
function TM_CreateTimerRow(STC,TD){
	TD.innerHTML='';
	var DIV = addDiv('TMrow' + STC,'TMtimers',Y(Timer[STC].duration),false);TD.appendChild(DIV);
	Timer[STC].image_element.src = Timer[STC].image_element.getAttribute('TMsrcOnMore');
	Timer[STC].image_element.setAttribute('TMsrcDefault',Timer[STC].image_element.getAttribute('TMsrcOnMore'));
	Timer[STC].text_element = DIV;
	var XX =Timer[STC].image_element.getAttribute('TMinfo').split(':');var X = XX[0].split('/');
	if (unescape(X[6])=='Tournament square'){X[6]=escape('Tourn. Square');}
	var Troopcount = Math.floor((pI(X[1])-(A()-pI(X[2])))/pI(X[3]))+1; // <-- ugly eh?
	switch(X[0]){ // what is syntax for condensed cases? like: case '1' and case '2'
		case '1':	var DIV = addDiv('TMdesc'+STC,'TMtimers',unescape(X[6])+' - '+(parseInt(X[5])+1),false);TD.appendChild(DIV);break;
		case '2':	var DIV = addDiv('TMdesc'+STC,'TMtimers',unescape(X[6])+' - '+(parseInt(X[5])+1),false);TD.appendChild(DIV);break;
		case '3':	var DIV = addDiv('TMtroopcount'+STC,'TMtimers',Troopcount,false);TD.appendChild(DIV);
						Timer[STC].troop_element = DIV;
						var DIV = addDiv('TMdesc'+STC,'TMtimers',' '+unescape(X[6]),false);TD.appendChild(DIV);
						Timer[STC].desc_element = DIV;break;
		case '4':	var DIV = addDiv('TMtroopcount'+STC,'TMtimers',Troopcount,false);TD.appendChild(DIV);
						Timer[STC].troop_element = DIV;
						var DIV = addDiv('TMdesc'+STC,'TMtimers',' '+unescape(X[6]),false);TD.appendChild(DIV);
						Timer[STC].desc_element = DIV;break;
		default:}
}

// ›› Popup Info
function TM_ShowEventPopup(e,that){
	if(that.getAttribute('TMInfo')){
		var info = that.getAttribute('TMInfo').split(':');var X = info[0].split('/');
		if (X[0]=='3'||X[0]=='4'){
			TABLE = document.createElement('TABLE');
			TABLE.className='tbg';
			TABLE.setAttribute('cellspacing','1');
			TABLE.setAttribute('cellspadding','1');
			infoDIV.appendChild(TABLE);
		}
		for (var i=0 ;i<info.length;i++) {
			var X = info[i].split('/');
				if (X[0]=='1'||X[0]=='2'){
				var IMG = addImg('TMpopimg'+i,'TMnull',false,'TMpopup');
				var testStr = "g0g1g2g3g4";var Srch = new RegExp(X[4]); //g0 = city wall, g1-g4 resources
				if (testStr.search(Srch) > -1){
					IMG.src = eval('X' + X[4]);
					IMG.style.padding = "27px 14px 10px 14px";
				}else{
					IMG.src = imgpath + 'img/un/g/' + X[4] + '.gif';
					if (X[4] == "g16"){IMG.style.padding = "31px 8px 10px 8px";}	
				}
				addDiv('TMpoptext'+i,'TMdisplay',(parseInt(X[5])+1)+'<BR>'+ unescape(X[6]),'TMpopup');
			}
			if (X[0]=='3'||X[0]=='4'){
				TR=document.createElement('TR');TABLE.appendChild(TR);
				TD=document.createElement('TD');TR.appendChild(TD);
					IMG= document.createElement('IMG');TD.appendChild(IMG);
					IMG.src = imgpath + 'img/un/u/' + X[4] + '.gif';
					IMG.className='unit';
				TD=document.createElement('TD');TR.appendChild(TD);
					var TroopCount=(i==0)?Math.floor((pI(X[1])-(A()-pI(X[2])))/pI(X[3]))+1:X[5];
					TEXT = document.createTextNode(TroopCount);TD.appendChild(TEXT);
				TD=document.createElement('TD');
				TD.className='s7';TR.appendChild(TD);
				TEXT = document.createTextNode(unescape(X[6]));TD.appendChild(TEXT);
			}
		}
		infoDIV.style.top='';infoDIV.style.bottom='';
		infoDIV.style.visibility = 'visible';
		e.pageY>parseInt(window.innerHeight/2)?infoDIV.style.bottom=window.innerHeight-e.pageY+10+'px':infoDIV.style.top=e.pageY+10+'px';
		infoDIV.style.left = e.pageX+10+'px';
	}
}

// ›› Fill the marketplace with predetermined values.
function TM_FillMarket(){
	if(GM_getValue('Xfer')){
		var OO = GM_getValue('Xfer');
		var O = OO.split(':');
		var P = VillageIDs.indexOf(O[0]);var PP = VillageCoords[P];var PPP = PP.split('|');
		var SS5 = TM_searchDOM('//input[@class="fm"]')
		if (SS5.snapshotItem(0)){
			SS5.snapshotItem(0).setAttribute("value",O[1]); //resources
			SS5.snapshotItem(1).setAttribute("value",O[2]);
			SS5.snapshotItem(2).setAttribute("value",O[3]);
			SS5.snapshotItem(3).setAttribute("value",O[4]);
			SS5.snapshotItem(5).setAttribute("value",PPP[0]); //coords
			SS5.snapshotItem(6).setAttribute("value",PPP[1]);
		}
	}
}
// DISPLAY \\\\\\\\\\\



// INFORMATION /////////// Information gathering/storing/sorting etc. functions. Does not alter DOM.
// ›› Get hourly production, current totals and total storage for the current Active Village.
function TM_GetResourceInfo(){
	var VillageResources = new Array();
	var SS1 = TM_searchDOM('//div[@id="lres0"]//td[@title]')
	// next line is for Polish Speed server and possibly German speed server.  
	if (!SS1.snapshotItem(0)){var SS1 = TM_searchDOM('//div[@id="lres"]//td[@title]')}
	for ( var i=0 ; i < SS1.snapshotLength; i++ ) {
		var xTD = SS1.snapshotItem(i);
		VillageResources[i] = xTD.getAttribute("title") + "/" + xTD.firstChild.nodeValue;
	}
	if (VillageResources.length > 0){GM_setValue(UniqueID + ActiveVillage + '.Resources',VillageResources.join(':'));}
}

// ›› Get building info dorf1 and dorf2.
function TM_GetBuildInfo(){
	var VillageLayout = new Array();
	var ResourceIdentifiers = [2,3,14,15]; // wood/iron/crop/clay These are the build spots that are always the same regardless of village fields (4446,5346,9,15 cropper etc.)
	var SS1 = TM_searchDOM('//map[@name="rx"]//area')
	if (SS1.snapshotItem(0)) {
		for (var i=0 ; i < SS1.snapshotLength - 1; i++) {
			for (var j=0 ; j < ResourceIdentifiers.length; j++)  {
				if(i == ResourceIdentifiers[j]){ResourceIdentifiers[j] = SS1.snapshotItem(i).getAttribute("title").slice(0,8);}}}
		if(ResourceIdentifiers[1]==ResourceIdentifiers[3]){ResourceIdentifiers[1]=SS1.snapshotItem(10).getAttribute("title").slice(0,8);} // if iron is clay 4,5,3,6 village fix
		for (var i=0 ; i < SS1.snapshotLength - 1; i++) {
			var xTITLE = SS1.snapshotItem(i).getAttribute("title");
			var ResourceIdentifier = xTITLE.slice(0,8);
			var BuildingLevel = /(\d+)/.exec(xTITLE);
			var BuildingName = /([^]*)\s[^]+\s\d+$/.exec(xTITLE);
			if (BuildingLevel){
				if(ResourceIdentifier == ResourceIdentifiers[0]){VillageLayout[i] = (i+1) + '/g1/' + BuildingLevel[1] + '/' + escape(BuildingName[1]);}
				if(ResourceIdentifier == ResourceIdentifiers[1]){VillageLayout[i] = (i+1) + '/g2/' + BuildingLevel[1] + '/' + escape(BuildingName[1]);}
				if(ResourceIdentifier == ResourceIdentifiers[2]){VillageLayout[i] = (i+1) + '/g3/' + BuildingLevel[1] + '/' + escape(BuildingName[1]);}
				if(ResourceIdentifier == ResourceIdentifiers[3]){VillageLayout[i] = (i+1) + '/g4/' + BuildingLevel[1] + '/' + escape(BuildingName[1]);}
			}else{
				VillageLayout[i] = (i+1) + '/g00/0/NULL';
			}
		}
		GM_setValue(UniqueID + ActiveVillage + '.Dorf1',VillageLayout.join(':'));
	}
	var VillageLayout = new Array();
	var SS1 = TM_searchDOM('//map[@name="map1"]//area')
	if (SS1.snapshotItem(0)) {
		var SS2 = TM_searchDOM('//img[@class="d1"]/self::* | //img[@class="d1"]/following-sibling::*')	
		for ( var i=0 ; i < SS1.snapshotLength - 2; i++ ) { //  -2 because of duplicate earth walls.
			var xTITLE = SS1.snapshotItem(i).getAttribute("title");
			var BuildingLevel = /(\d+)/.exec(xTITLE);
			if (BuildingLevel){
				var BuildingName = /([^]*)\s[^]+\s\d+$/.exec(xTITLE); // still not quite right, but close
				switch(i){
					case 0:	VillageLayout[i] = '39/g16/' + BuildingLevel[1] + '/' + escape(BuildingName[1]);break;
					case 21:	VillageLayout[i] = '40/g0/' + BuildingLevel[1] + '/' + escape(BuildingName[1]);break;
					default:	var BuildingGIF = /(\d+)/.exec(SS2.snapshotItem(i-1).getAttribute("src"));
									VillageLayout[i] = (i+18) + '/g' + BuildingGIF[1] + '/' + BuildingLevel[1] + '/' + escape(BuildingName[1]);}
			}else{
				VillageLayout[i] = (i+18)  + '/g00/0/NULL';
			}
		}
		GM_setValue(UniqueID + ActiveVillage + '.Dorf2',VillageLayout.join(':'));
	}
}

// ›› Store a new event.
function TM_StoreNewEvent(EventDuration,EventType,Event){
	var StartTime=A();
	var EventDuration = Z(EventDuration);
	var OOO = GM_getValue(UniqueID + ActiveVillage + ".TimedEvents");
	if (OOO){var OO = OOO.split(':');
		for (var i=0;i<OO.length;i++){
			var O=OO[i].split('/');
			// there can be multiple matches. the last match should have the longest end time however and is what we want
			if (O[0]==EventType){var StartTime=pI(O[1])+pI(O[2]);}
		}
		OO.push(EventType+'/'+EventDuration+'/'+StartTime+'/'+Event);
		GM_setValue(UniqueID+ActiveVillage+".TimedEvents",OO.join(':'));
	}
}

// ›› Update an existing event. Replaces all events of that type with the new value at that index.
function TM_UpdateEvent(EventType,index,newvalue){
	var OOO = GM_getValue(UniqueID + ActiveVillage + ".TimedEvents");
	if (OOO){
		var OO = OOO.split(':');
		for (var i=0;i<OO.length;i++) {
			var O = OO[i].split('/');
			if (O[0] == EventType){
				O[index] = newvalue;
				OO[i] = O.join('/');
				GM_setValue(UniqueID + ActiveVillage + ".TimedEvents",OO.join(':'));
			}}}}

// ›› Filter on time left less than 5 seconds to remove any completed or almost completed events.
function TM_RemoveOldEvents(village){
	var TimedEvents = GM_getValue(UniqueID + village + ".TimedEvents").split(':');
	var newTimedEvents = TimedEvents.filter(function (element,index,array){
											var TimedEvent = element.split('/');
											return (parseInt(TimedEvent[1])+parseInt(TimedEvent[2])-A() > 5);});
	GM_setValue(UniqueID + village + ".TimedEvents",newTimedEvents.join(':'));
}

// ›› Not functional yet. Need to work on interface
function TM_CalculateMarket(){
	var MID = document.getElementById('lmid2').firstChild;
	if (MID){MID.id = 'testttt';MID.firstChild.style.cssFloat='left';
	var DIV = addDiv('TM_Ship','TMtimer',false,'testttt');
	var INPUT = document.createElement('INPUT');
	INPUT.setAttribute('size','6');
	INPUT.setAttribute('maxlength','6');
	INPUT.type = 'text';
	INPUT.id='TM_ShipWare';
	DIV.appendChild(INPUT);
	var INPUT = document.createElement('INPUT');
	INPUT.size = '6';
	INPUT.maxlength = '6';
	INPUT.type = 'text';
	INPUT.id='TM_ShipGran';
	DIV.appendChild(INPUT);
	var IMG = addImg('TM_ShipTo','TMtimer',Xnull,'TM_Ship');if (GM_getValue('Xfer')){IMG.src = XRed;}
	IMG.setAttribute('TMvillage',ActiveVillage);
	IMG.style.cursor = 'pointer';
	IMG.addEventListener('click', function(event) {
			if (!GM_getValue('Xfer')){
				var xFer = new Array();
				var QQQ = GM_getValue(UniqueID + this.getAttribute('TMvillage') + ".Resources");
				var QQ = QQQ.split(':');for (var i=0;i<QQ.length;i++) {var Q=QQ[i].split('/');
					xFer[i] = parseInt(document.getElementById('TM_ShipWare').value) - parseInt(Q[1]);
					if  (xFer[i] < 0){xFer[i] = 0;}
				}
				GM_setValue('Xfer',this.getAttribute('TMvillage') + ':' + xFer.join(':'));
				this.src = XRed;
			}else{
				GM_setValue('Xfer',false);
				this.src = Xnull;
			}}, true);}
}
// INFORMATION \\\\\\\\\\\



// TIMER ///////////
function W(i){Timer[i].image_element.src = Timer[i].image_element.getAttribute('TMsrcOnMore');}
function A(){return Math.round(new Date().getTime()/1000);}
function Z(FormattedTime){
	p = FormattedTime.split(":");
	aY=p[0]*3600+p[1]*60+p[2]*1;
	return aY;}
function Y(Seconds){
	if (Seconds<0){Seconds = Seconds*-1;}
	az=Math.floor(Seconds/3600);
	an=Math.floor(Seconds/60)%60;if(an<10){an="0"+an;}
	af=Seconds%60;						if(af<10){af="0"+af;}
	t=az+':'+an+':'+af;
	return t;}

// ›› New timer functions.
function TM_Timer(a,v,c,s,d,p,i,t,r,x,pcd){
	if (!Timer[a]){Timer[a] = new Object();TimerCount++;}
	Timer[a].village =v;
	Timer[a].column = c;
	Timer[a].start = s;
	Timer[a].duration = d;
	Timer[a].periodic = p; // optional - secondary timer for troop image flashing
	Timer[a].image_element = i; // optional - both optional allows for 'hidden' timers
	Timer[a].text_element = t; // optional
	Timer[a].relay_timer = r; //optional
	Timer[a].pass_column = x; //optional
	Timer[a].pass_control_duration = pcd; //optional
	Timer[a].periodic_wait = d%p;
}

function TM_RelayTimer(a,d,x,p){
	RelayTimer[a] = new Object();
	RelayTimer[a].duration = d;
	RelayTimer[a].relay_timer = x;
	RelayTimer[a].periodic=p;
	RelayTimerCount++;
	return RelayTimer[a];
}

function TM_ActivateTimers(){
	for(i in Timer){if (Timer[i].start){
		secondsSincePageLoad = A() - T;
		var Countdown = Timer[i].duration - secondsSincePageLoad;
		// is the overall column timer expired?
		if (Countdown > 0){
			if (Timer[i].image_element&&Timer[i].periodic){
				if(secondsSincePageLoad==Timer[i].periodic_wait){
					Timer[i].periodic_wait+=Timer[i].periodic;
					Timer[i].image_element.src = Timer[i].image_element.getAttribute('TMsrcDone');
					if(Timer[i].troop_element){Timer[i].troop_element.innerHTML = pI(Timer[i].troop_element.innerHTML)-1;}
				}else{Timer[i].image_element.src = Timer[i].image_element.getAttribute('TMsrcDefault');}} 
			if (Timer[i].text_element){Timer[i].text_element.innerHTML = Y(Countdown);}
		}else{
			Timer[i].start = false;
			if (Timer[i].image_element){Timer[i].image_element.src = Timer[i].image_element.getAttribute('TMsrcDone');}
			if (!Timer[i].pass_column){
				if (Timer[i].text_element){Timer[i].text_element.parentNode.parentNode.parentNode.removeChild(Timer[i].text_element.parentNode.parentNode);}
			}else{
				var X = Timer[i].pass_column.split(':');
				var ST=false;for (var g=X[0];g<X[1];g++) {if(Timer[g].duration<3600000&&Timer[g].duration-secondsSincePageLoad>0){ST=Timer[g].duration;var STC=g;}}
				if(ST){
					TM_CreateTimerRow(STC,Timer[i].text_element.parentNode);
					Timer[STC].pass_column = Timer[i].pass_column;
					Timer[STC].image_element.src=Timer[STC].image_element.getAttribute('TMsrcOnMore');
					Timer[STC].image_element.setAttribute('TMsrcDefault',Timer[STC].image_element.src);
				}else{
					if (Timer[i].text_element){Timer[i].text_element.parentNode.parentNode.parentNode.removeChild(Timer[i].text_element.parentNode.parentNode);}
				}}}
		// do we have a pass control countdown?
		if(Timer[i].pass_control_duration){
			if (Timer[i].pass_control_duration-secondsSincePageLoad<1){
				Timer[i].image_element.src = Timer[i].image_element.getAttribute('TMsrcDefault');
				Timer[i].pass_control_duration = Timer[i].relay_timer.duration;
				Timer[i].periodic = Timer[i].relay_timer.periodic;	
				Timer[i].periodic_wait = Timer[i].relay_timer.periodic;
				var OOO = Timer[i].image_element.getAttribute('TMInfo');
				var OO = OOO.split(':');
				var XX = OO.slice(1);
				var X = XX[0].split('/');
				Timer[i].image_element.setAttribute('TMInfo',XX.join(':'));
				if(Timer[i].troop_element){Timer[i].troop_element.innerHTML = X[5];}
				if(Timer[i].desc_element){Timer[i].desc_element.innerHTML = ' '+unescape(X[6]);}
				TM_RemoveOldEvents(Timer[i].village);
				if(Timer[i].relay_timer.relay_timer){
					Timer[i].relay_timer = Timer[i].relay_timer.relay_timer;	
				}else{
					Timer[i].pass_control_duration = false;
					Timer[i].relay_timer = false;
					Timer[i].periodic=false;
				}}}}}}
// TIMER \\\\\\\\\\\


// UTILITY + CSS \\\\\\\\\\\
// ›› Wrappers.
function TM_searchDOM(X){return document.evaluate(X,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);}
function pI(X){return parseInt(X);}

// ›› Adds a generic div.
function addDiv(id,style,html,parent){
	var body, div;
	if (!parent){body = document.getElementsByTagName('body')[0];}else{body = document.getElementById(parent);}
	if (!body) {return false;}
	div = document.createElement('DIV');
	if (id)		{div.id = id;}
	if (style)	{div.className = style;}
	if (html)	{div.innerHTML = html;}
	body.appendChild(div);
	return div;
}

// ›› Adds a generic image.
function addImg(id,style,src,parent){
	var body, img;
	if (!parent){body = document.getElementsByTagName('body')[0];}else{body = document.getElementById(parent);}
	if (!body) {return false;}
	img = document.createElement('IMG');
	if(id)		{img.id = id};
	if(style)		{img.className = style};
	if(src)		{img.src = src};
	body.appendChild(img);
	return img;
}

// ›› Add generic CSS 
function addCSS(cssString) {
	var style = document.createElement('STYLE');
	style.type = 'text/css';style.innerHTML = cssString;
	document.getElementsByTagName('HEAD')[0].appendChild(style);
}

// ›› Make default CSS.
function makeDefaultCSS(){
	var cssString = "";
	addCSS('.TMnull{position:relative;}');
	cssString = '.TMpopup{' +
		'background-color:white;' + 
		'border:thin solid #000000;' +
		'font-family: Verdana, Arial, Helvetica, sans-serif;' +
		'font-size:8pt;' +
		'font-weight:bold;' +
		'padding-bottom:3px;' +
		'padding-left:3px;' + 
		'padding-right:3px;' + 
		'padding-top:3px;' + 
		'position:absolute;' +
		'visibility:hidden;' +
		'z-index:200;}';
	addCSS(cssString);
	cssString = '.TMdisplay{' +
		'cursor:pointer;' +
		'font-family: Verdana, Arial, Helvetica, sans-serif;' +
		'font-size:8pt;' +
		'float:left;' + 
		'margin:3px;' +
		'padding:3px;' + 
		'position:relative;}';
	addCSS(cssString);
	cssString = '.TMmain{' +
		'border:thin solid #000000;' +
		'bottom:5px;' +
		'font-family: Verdana, Arial, Helvetica, sans-serif;' +
		'font-size:8pt;' +
		'font-weight:bold;' +
		'padding-bottom:5px;' +
		'padding-left:5px;' + 
		'padding-right:5px;' + 
		'padding-top:5px;' + 
		'position:fixed;' +
		'right:8px;' +
		'z-index:50;}';
	addCSS(cssString);
	var cssString = '.TMbuildingtags{' +
		'background-color:#FDF8C1;' + 
		'border:thin solid #000000;' +
		'cursor:pointer;' +
		'font-family: Verdana, Arial, Helvetica, sans-serif;' +
		'font-size:8pt;' +
		'font-weight:bold;' +
		'height:14px;' +
		'position:absolute;' +
		'text-align:center;' +
		'visibility:hidden;' +
		'width:21px;' +
		'z-index:50;}';
	addCSS(cssString);
	cssString = '.TMtimers{' +
		'font-family: Verdana, Arial, Helvetica, sans-serif;' +
		'font-size:8pt;' +
		'float:left;' + 
		'padding-bottom:1px;' +
		'padding-left:15px;' +
		'position:relative;' +
		'z-index:50;}';
	addCSS(cssString);
	cssString = '.TMleftmenu{' +
		'background-color:white;' + 
		'cursor:pointer;' +
		'font-family: Verdana, Arial, Helvetica, sans-serif;' +
		'font-size:7pt;' +
		'font-weight:bold;' +
		'padding-bottom:5px;' +
		'padding-left:15px;' +
		'padding-right:15px;' +
		'position:absolute;' +
		'width:100px;' +
		'top:-17px;' + 
		'z-index:4;}';
	addCSS(cssString);
	cssString = '.TMdemo{' +
		'position:fixed;' +
		'top:108px;' +
		'right:8px;' + 
		'z-index:50;}';
	addCSS(cssString);
}