KoC BoTTols Original

By FaA Last update Jun 24, 2012 — Installed 1 time.

the source is over 100KB, syntax highlighting in the browser is too slow

// ==UserScript==
// @name           KoC BoTTols Original
// @version        7.3
// @namespace      Tiestoale & Dracul
// @description    KoC BoTTols Original by Tiestoale & Dracul
// @include        *kingdomsofcamelot.com/*main_src.php*
// @include        *kingdomsofcamelot.com/*fbLoginButton.php*
// @include        *kingdomsofcamelot.com/*standAlone.php*
// @include        *kingdomsofcamelot.com/*acceptToken_src.php*
// @include	       *kingdomsofcamelot.com/*helpFriend_src.php*
// @include        *apps.facebook.com/kingdomsofcamelot/*
// @include        *facebook.com/connect/uiserver.php*
// @include        *facebook.com/dialog/feed*
// @include	       *kabam.com/*
// @icon           http://www.tiestoale.x.gg/KoC/Icon.jpg
// @resource       avatars http://www.tiestoale.x.gg/KoC/avatars.js
// @resource       smileys http://www.tiestoale.x.gg/KoC/smileys.js
// ==/UserScript==
var IsChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
var Version = '7.3';
var ScriptName = 'KoC BoTTols Original';
var ScriptNameS = 'BoTTols Original';
var Autore = 'Tiestoale & DRACUL';
var DEBUG_TRACE = true;
var MAP_DELAY = 1300;
var DETECT_LEVEL_FS = false;
var URL_CASTLE_BUT = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAXCAYAAADk3wSdAAAACXBIWXMAAAsSAAALEgHS3X78AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQ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Xy3eYAxTzuAvpuAJXmAHDmEEroLmfYInaF42doIqUOM1ZmM4nmMGZmMGvuM7hmM3ZmA1xmM%2F5uM5juM1ll8n4F04jmArLoM1YIMyWGMYGIAf6NKxFQVRCAgAOw%3D%3D";
IsChrome&&(window.unsafeWindow||(unsafeWindow=function(){var a=document.createElement("p");a.setAttribute("onclick","return window;");return a.onclick()}()));
var JSON;if(!JSON){JSON={}}(function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];if(i&&typeof i==="object"&&typeof i.toJSON==="function"){i=i.toJSON(a)}if(typeof rep==="function"){i=rep.call(b,a,i)}switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i){return"null"}gap+=indent;h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1){h[c]=str(c,i)||"null"}e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]";gap=g;return e}if(rep&&typeof rep==="object"){f=rep.length;for(c=0;c<f;c+=1){if(typeof rep[c]==="string"){d=rep[c];e=str(d,i);if(e){h.push(quote(d)+(gap?": ":":")+e)}}}}else{for(d in i){if(Object.prototype.hasOwnProperty.call(i,d)){e=str(d,i);if(e){h.push(quote(d)+(gap?": ":":")+e)}}}}e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}";gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b==="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a){return a<10?"0"+a:a}"use strict";if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;if(typeof JSON.stringify!=="function"){JSON.stringify=function(a,b,c){var d;gap="";indent="";if(typeof c==="number"){for(d=0;d<c;d+=1){indent+=" "}}else if(typeof c==="string"){indent=c}rep=b;if(b&&typeof b!=="function"&&(typeof b!=="object"||typeof b.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":a})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e==="object"){for(c in e){if(Object.prototype.hasOwnProperty.call(e,c)){d=walk(e,c);if(d!==undefined){e[c]=d}else{delete e[c]}}}}return reviver.call(a,b,e)}var j;text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}})()
var JSON2 = JSON;
var TABLE_SCALE =0.66;
var butON='<img align=absmiddle src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQC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t19ZmMl5KqNAaAY+CVD86sYXURaIqBisUpB1Icq5i2Q6O6smCYbnd/lDVGUtZ4CavsoIypGuZZMWZUBNF6oHvYWzhMtRjc0bLJoI4FYjq0MUnja/DdItq/h/Z/3jPsP67lvwOjGG1S8vVScQAAAABJRU5ErkJggg%3D%3D" alt="OFF">';
var ResetAll=false,deleting=false;
var sitesupport="http://kocbottolsoriginal.host22.com";
var sitesupportsmall="kocbottolsoriginal.host22.com";
var URL_PROVINCE_MAP = "data:image/gif;base64,R0lGODlhxgLEAvcAAP%2F%2F%2F%2Ff%2F%2F%2Fv%2F8%2Ff3%2F%2Ff39%2Ff37%2F%2F%2Fpe%2F39%2F%2F%2FnO%2F37%2F%2F%2FlPf%2FnPf%2FlPHv9%2B%2Fv7%2F%2F3lO%2Fv5ubv7%2Ff3lPf3jO%2Fm7%2B%2F3jO%2F0lPfvlObm7%2Bb3jObm5u%2FvjN7m5ubvlObvjN7e5t3whN7e3ubmjObmhNbe1tbb3t7mjN7mhNbmhNbW1t7ehM7W1tTfe9TchM7O1s7OztbWe8XOzsXOxc7We8XWesXFzsXFxc7Oe73FxcXOe8XOc73Oc7XFtb69xdHYAL29vbW9vb3Fc7bGa7XFc7W1vbW1tbXSALW9a6rCY629a6yurq3KALXFAJjCWq21Y6uza6W1Y7W9AJy1Y6Okpa29AJ%2BtY621CJytWq21AJq9AKWwG5ucnJylWpSlWo2oUoylWpytAJSUlHyrSoyUlI%2BcWoycUoyUc4SeUoStAIyMlIyMjIyUUoSMjI2gAYSUUoSUSoSEjHuUSoSEhICEe3OhAHuEhHuMSoSUAHKOQnOMSmKYNHuUAHl7fHOEQmuSAGuEQnOMAHJzc3OEAGt7Omh7Qnt8AGN7Ompralp7Omt7AGNzOlpzOltzMVJ3MmN3AF9rOmFiY2trAEp6AFJrMUpsMSx%2BG1JrGVlbWmdjACh%2FAkprCEpjMUprAEpjKUJjKUJdQkpjCFBRU0hjAEJbOkJjCEJaKUdSRTpaOkJaGTpaKUJSOjp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mRzImsv4Li7IwTqIQ50ncB3cwwtrPdf%2FKC7Ao1KL4THzAdIKnb4GQsZvuO3WuVr4op0Og6FOYQhgyNz%2FaLc1r%2BLiQnarshjCNR%2FggjxM9rb%2FAyuowZ02QArQAy647CIufuOPqdJMwT%2BEAuJHLOVbvoQQwDoDPu7A9SH%2BkDwAnC0f1LYRkr7pRy89WIPVt7qnX0KpPqEN6EMoQDru2LmDA0AAsMKQejzvy4HHf688nKMRX3zGfxnHA38cL1AIPDTS1yUr5O0QpkAovC7bj00K4MIjMr01sMEAYEUawDEb1DytBMKHYsUPrDAuROkLVD8ico4T4oL8D8MUcjAcu6H9W0N004oa4IIrAAQuXMN%2BACiCSxyrHgAA2GAl7lIIhhMpVrQ4ccowcaFeMLThCqLEhiAjXjR5kmEISOKsqSEAQMMhlnJeNggkbtgUlDtNpsClhOEPhJA0MAQytChPpRMDXUq5suUAAA5kDgO6lOcWjZdSMFSi8ZADr2CtxWK9GGZrVwBoIZYYKy5QWbMmHQSyZm0MQw0rcRWEydfvXJMHIXYloMaaOEgitYrj81LwRQ2swlAMcUmcKxspMWuOTJEDri0UHYr7ybBEqIQdP%2B%2FUALn13NcVZ8dW6iDpRNy2lQbgAFsvb6Ua5OotLvwigdwMlSNvTvH5xOjIYR4nTvs4dejLAUzXjh289t3bK3pvPV43d%2FTUr1OsPfG9c%2FXzv5uMDxP49%2Fu1AwIAOw%3D%3D";
var provMapCoords = {imgWidth:710, imgHeight:708, mapWidth:670, mapHeight:670, leftMargin:31, topMargin:19};  
var DEFAULT_ALERT_SOUND_URL = 'http://www.universal-soundbank.com/mp3/sounds/261.mp3';
var SWF_PLAYER_URL = 'http://beworld.perso.sfr.fr/bao/miniplayer.swf';
var Options={Langue:'en',KDODef:0,KDOUser:{},AttackRunning:false,RangeSaveModeSetting:0,RangeSaveModeSetting2:0,RangeSaveModeSetting3:0,ThroneDeleteItems:false,NewTab:true,NewTabURL:"",NewTabName:"KoC",NewTab2:false,NewTabURL2:"http://www.devilalliance.org/",NewTabName2:"SupportFB",currentTab:null,currentTab2:"Overview1",reapprointerval:0,TSSrchFilter:0,BOTransparence:true,includeMarching:false,EnableFormation:false,showTroops:true,showPop:false,Smiley:true,showRes:true,checktournoi:false,SelQG:null,showProduction:true,showDefense:false,encRemaining:true,pbEveryEnable:true,pbEveryMins:60,pbChatOnRight:false,pbWideMap:false,pbKillFairie:true,maxIdlePop:true,ChatLearder:true,voirRaid:false,WhisperOn:true,WhisperRed:true,gmtClock:true,AttaqueOn:false,AttackCrest:false,EclaireurOn:false,srcSortBy:"level",EnableRefrechRapport:false,srcMinLevel:1,srcMaxLevel:10,srcTypeSelect:1,srcaDist:0,srcDist:20,Xrenfort:0,srcScoutAmt:1,PageReport:1,Yrenfort:0,icon_chat:false,URLicon:"http://www.france-lol.fr/francelol.tools/images/ip_points.png",filPuissance:0,filPuissanceMax:1e6,wildType:1,citySrchFilter:0,fixPageNav:true,mistedOnly:false,hostileOnly:false,fixTower:true,enhanceARpts:true,allowAlterAR:true,enableCheckTournoi:true,HauteurBoite:700,pbWinIsOpen:false,boTrackOpen:true,ptWin2IsOpen:false,ptWinDrag:true,ptWinPos:{},ptWin2Pos:{},enableFoodWarn:true,enableFoodWarnTchat:false,EnableReduireUnit:true,foodWarnHours:24,chatEnhance:true,fixKnightSelect:true,attackCityPicker:true,mapCoordsTop:true,dispBattleRounds:true,reportDeleteButton:true,arPageFrom:1,arPageTo:2,rptType:"alliance",rptAuto:false,alertSound:{enabled:true,soundUrl:DEFAULT_ALERT_SOUND_URL,repeat:true,playLength:20,repeatDelay:.5,volume:100,alarmActive:false,expireTime:0},alertConfig:{aChat:true,raid:false,aPrefix:"** Sono sotto attacco !! **",scouting:true,wilds:true,defence:true,minTroops:1,minTroops2:1,embassy:false,empennage:true,marechal:true,defBoost:true,ShowTrone:false,TroneRangeDebuff:false,TroneRange:false,mytroops:false,food:false,defense:true,MonQG:true,hq:"",sendEmail:false,emailAddress:"",token:"",sendasWhisper:false,sendtoAlly:true,showAttack:false,},URLson1:"http://www.universal-soundbank.com/mp3/sounds/684.mp3",URLson2:"http://www.universal-soundbank.com/mp3/sounds/217.mp3",URLson4:"http://www.universal-soundbank.com/mp3/sounds/2376.mp3",AttackHorloge:"21:00:00",AttackGoHorloge:null,AttackOnOff:false,AttackUnits:{},AttackFav:{0:{0:"200K Mil",1:0,2:2e5,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},1:{0:"200K Dada",1:0,2:0,3:0,4:0,5:0,6:0,7:2e5,8:0,9:0,10:0,11:0,12:0,13:0}},AttackFromCity:0,AttackCibleX:0,AttackCibleY:0,AttackKnight:0,TournoiLigne:25,AttackFSUnits:{1:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},2:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},3:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},4:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},5:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},6:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},7:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},8:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},9:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0},10:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0}},DeleteMsg:false,DeleteMgs5:false,DeleteMsgs0:false,DeleteMsgs1:false,DeleteMsgs2:false,DeleteMsgs3:false,DeleteTimerMinute:5,giftDomains:{valid:false,list:{}},giftDelete:"e",HelpRequest:true,ChatRules:false,DeleteRequest:true,MapShowExtra:false,transportinterval:60,minwagons:1e3,lasttransport:0,reassigninterval:60,lastreassign:0,RaidRunning:true,RaidReset:0,MsgInterval:1,foodreport:false,Foodstatus:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},
crestRunning:false,Crestinterval:5,CrestintervalAnd:7,CrestSlot:1,crestMarchError:0,CrestMsgInterval:24,Crest1Count:0,Crest2Count:0,crestreport:false,enhancedinbox : true,CrestLevel:0,CrestType:0,Creststatus:{1101:0,1102:0,1103:0,1104:0,1105:0,1106:0,1107:0,1108:0,1109:0,1110:0,1111:0,1112:0,1113:0,1114:0,1115:0,9:0,36:0,37:0,38:0,55:0,57:0,261:0,262:0,271:0,272:0,351:0,361:0,362:0,911:0,3000:0,3001:0,3002:0,3003:0,3007:0,3008:0,3009:0,3011:0,931:0,932:0},LastCrestReport:0,LastReport:0,SpamMode:{Spam:true,Avv:false},spamconfig:{aspam:false,spamvert:"Stiamo reclutando, entra da noi!",spammins:"10",atime:2,spamstate:"a",def:"DEFCON 5"}
,EffetRouge:0,AllEffet:false,salvageconfig:{running:false,CityCity:0,RepairCity:0,Repairrunning:false,},TroneInverse:true,pbGoldHappy:95,pbGoldEnable:false,enhanceViewMembers:true,postUpdate:false,};
var Colors ={ChatLeaders:'#C8C8C8',ChatVC:'#81EE81',ChatChancy:'#F8A151',ChatAtt:'#FF7D7D',ChatEcl:'#FFDD7D',ChatGlo:'#F9AAAA',};
var AttackOptions={Running:false,LastReport:0,MsgEnabled:true,MsgInterval:60,Method:"distance",SendInterval:8,MaxDistance:50,RallyClip:0,BarbsFailedKnight:0,BarbsFailedRP:0,BarbsFailedTraffic:0,BarbsFailedVaria:0,BarbsFailedMarais:0,BarbsFailedBog:0,BarbsTried:0,DeleteMsg:true,DeleteMsgs0:false,Foodstatus:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},MsgLevel:{1:true,2:true,3:true,4:true,5:true,6:true,7:true,8:true,9:true,10:true},BarbsDone:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},BarbNumber:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},Levels:{1:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},2:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},3:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},4:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},5:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},6:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},7:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false},8:{0:false,1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false,9:false,10:false}},Troops:{1:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},2:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},3:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},4:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},5:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},6:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},7:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},8:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},9:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0},10:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0}},MinDistance:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0},Distance:{1:750,2:750,3:750,4:750,5:750,6:750,7:750,8:750,9:750,10:750},Update:{1:[0,0],2:[0,0],3:[0,0],4:[0,0],5:[0,0],6:[0,0],7:[0,0],8:[0,0]},UpdateEnabled:true,UpdateInterval:30,stopsearch:1,knightselector:0}
var TrainOptions={Running:false,list:{},Item:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},listactif:{},listlabour:{},timelauch:60,unitemin:{},unitemax:{},listboost:{},UnitMixValue:100,Workers:{1:100,2:100,3:100,4:100,5:100,6:100,7:100,8:100},Keep:{1:{Food:0,Wood:0,Stone:0,Ore:0},2:{Food:0,Wood:0,Stone:0,Ore:0},3:{Food:0,Wood:0,Stone:0,Ore:0},4:{Food:0,Wood:0,Stone:0,Ore:0},5:{Food:0,Wood:0,Stone:0,Ore:0},6:{Food:0,Wood:0,Stone:0,Ore:0},7:{Food:0,Wood:0,Stone:0,Ore:0},8:{Food:0,Wood:0,Stone:0,Ore:0}},Resource:{1:true,2:true,3:true,4:true,5:true,6:true,7:true,8:true},CraftingRunning:false,CraftIntervallMin:3,CraftingActif:{221:false,3e3:false,3001:false,3002:false,3003:false,3004:false,3005:false,3006:false,3007:false,3008:false,3009:false,3010:false,3011:false,},CraftingNb:{221:0,3e3:0,3001:0,3002:0,3003:0,3004:0,3005:0,3006:0,3007:0,3008:0,3009:0,3010:0,3011:0,},doTraps:{1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},doCalrops:{1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},doSpikes:{1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},doXbows:{1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},doTrebu:{1:false,2:false,3:false,4:false,5:false,6:false,7:false,8:false},troopType:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},keepFood:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},keepWood:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},keepStone:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0},keepOre:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}}
var GlobalOptions={pbWatchdog:true,pbWideScreen:true,pbWideScreenStyle:"normal",autoPublishGamePopups:false,}

var upgradeData = {  active : false, Items: [],  retryInterval : 30, };
var AutoWall = {
	Bunker:false,
	Province:1,
	AttBunkerEnable:100,
	Fog:false,
	Preset:false,
	PresetSel:"",
	Esplo:false,
	EspShowTroops:true,
	EspShowTroopsSec:5,
	AttackerRange:0,
	MyRange:0,
	EspRangeReSec:5,
	EspRange:true,
	EspRangeMod1:true,
	EspRangeMod2:false,
	EspRangeModRan:10,
	EspRangeRe:true,
	EspPot:true,
	AttBunker:0,
	IDTruppa : 0,
	XArrivo : 0,
	YArrivo : 0,
	Rif : {
	Enable:false,
	SelTroop:1,
	Quantita:90000,
	SelCity : "",
	},
};
var ThroneOptions = {
    Active:false,
    Use20005:false,
    nexttries:100,
    IntervalMin:3,
    RepairTime:0,
	Tries:0,
    minStones : 100000,
	Good:0,
	Bad:0,
	Items: [],
	Salvage:{},
	Salvage2:{},
	Salvage3:{},
	XSaveXItems:false,
	saveXitems:10,
	SalvageQuality:0,
	SalvageAdvisor:false,SalvageBanner:false,SalvageChair:false,SalvageTable:false,SalvageWindow:false,SalvageTrophy:true,
};
var ApothecaryOptions = {
	Active : false,
	goldkeep : 0,
	city : {0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[]},
};
var FarmOptions = {
	RallyClip: 0,
    Running: false,
    MinMight: 0,
    MaxMight: 999999999,
    Interval: 0,
    SendInterval: 10,
    MaxDistance: 20,
    Inactive:30,
	DeleteReports:false,
	Troops: {1: 0,2: 0,3: 0,4: 0,5: 0,6: 0,7: 0,8: 0,9: 0,10: 0,11: 0,12: 0},
	FarmNumber: {1: 0,2: 0,3: 0,4: 0,5: 0,6: 0,7: 0,8: 0},
    CityEnable: {1: true,2: true,3: true,4: true,5: true,6: true,7: true,8: true},
    CityLevel: {0: true,1: true,2: true,3: true,4: true,5: true,6: true,7: true,8: true,9: true,10: true,11: true,12: true},
    Diplomacy: {friendly: true,hostile: true,friendlyToThem: true,friendlyToYou: true,neutral:true,unallied:true},
    FarmMarches: [],
    farmMarches: {},
    Attacks:0,
	Checks:0,
};
var CrestOptions = {
  Running   	: 	false,
  CrestCity 	: 	0,
  RoundOne  	: 	false,
  RoundTwo  	: 	true,
  lastRoundTwo 	: 	0,
  X				:	0,
  Y				:	0,
  R1ST			:	0,
  R1MM			:	0,
  R1Scout		:	0,
  R1Pike		:	0,
  R1Sword		:	0,
  R1Arch		:	0,
  R1LC			:	0,
  R1HC			:	0,
  R1SW			:	0,
  R1Ball		:	0,
  R1Ram			:	0,
  R1Cat			:	0,
  R2ST			:	0,
  R2MM			:	0,
  R2Scout		:	0,
  R2Pike		:	0,
  R2Sword		:	0,
  R2Arch		:	0,
  R2LC			:	0,
  R2HC			:	0,
  R2SW			:	0,
  R2Ball		:	0,
  R2Ram			:	0,
  R2Cat			:	0,
};
var CrestData = new Array();
function CrestFunc (Arr) {
		if (Arr == undefined)
			Arr = CrestOptions;

		this.Running 		=  	true;
  		this.active 		=  	Arr.active;
  		this.CrestCity 		= 	Arr.CrestCity;
		this.RoundOne 		= 	Arr.RoundOne;
		this.RoundTwo 		= 	true;
		this.lastRoundTwo 	= 	0;
		this.X 				= 	Arr.X;
		this.Y 				= 	Arr.Y;
		this.R1ST 			= 	Arr.R1ST;
		this.R1MM 			= 	Arr.R1MM;
		this.R1Scout 		= 	Arr.R1Scout;
		this.R1Pike 		= 	Arr.R1Pike;
		this.R1Sword 		= 	Arr.R1Sword;
		this.R1Arch 		= 	Arr.R1Arch;
		this.R1LC 			= 	Arr.R1LC;
		this.R1HC 			= 	Arr.R1HC;
		this.R1SW 			= 	Arr.R1SW;
		this.R1Ball 		= 	Arr.R1Ball;
		this.R1Ram 			= 	Arr.R1Ram;
		this.R1Cat 			= 	Arr.R1Cat;
		this.R2ST 			= 	Arr.R2ST;
		this.R2MM 			= 	Arr.R2MM;
		this.R2Scout 		= 	Arr.R2Scout;
		this.R2Pike 		= 	Arr.R2Pike;
		this.R2Sword 		= 	Arr.R2Sword;
		this.R2Arch 		= 	Arr.R2Arch;
		this.R2LC 			= 	Arr.R2LC;
		this.R2HC 			= 	Arr.R2HC;
		this.R2SW 			= 	Arr.R2SW;
		this.R2Ball 		= 	Arr.R2Ball;
		this.R2Ram 			= 	Arr.R2Ram;
		this.R2Cat 			= 	Arr.R2Cat;
};
readOptions();
/** SYSTEM MULTILANGUE **/
var culang= {
'en': {
StatLabel:'Statistic',
StatLabelattack:'attacks',
StatLabelTrone:'Trone',
StatLabelTournament:'tournament',
StatLabelOverview:'stocks',
StatLabelResources:'court',
StatLabelSpam:'Spam',
StatLabelinventory:'inventory',
StatLabelInfo:'Info',
StatLabelAlliance:'alliance',
StatLabelGift:'Gifts',
StatLabelTest:'Fake',
StatLabelLogs:'diary',
BoiteLabelApothecary:'pharmacy',
BoiteLabelResumer:'landscape',
BoiteLabelOptions:'options',
BoiteLabelCrest:'Crest',
pubbao:'Support tools, click on the advertising',
Tools:{
Loaded:'loaded',
Version:'version',
NewUpdate:'New version of the',
Available:'available',
},
General:{
tot:"Total",all:'all',none:'no',error:"error",new:'new',and:'e',or:'or',end:'finished',
hour:"hour",hours:"hours",mins:"mins",secs:"second",name:"name ",help:"Help",nom:"now",
dans:"in",now:"updating",cancelact:"Cancel updating",kocnotfound:"KoC BoTTols Original found that the game does not e\' loaded",Select:'Select',RefreshIn:'updating',
dialogRetry:"an error e\' was detected :",
Retry:"disapprove of ",myRetry:"error in TRY: 5 attempts, I stop",
BOUpdate:"Keep your Tools!",DetectionCaptcha:'detected CAPTCHA',source:'by',dest:'destination',EstimateT:'time esteemed',
delGift:"Clear Gifts",time:"time",edit:"modification",save:"Save",saved:"saved",delete:"Clear",deleted:"Cancelled",timeremi:"remaining time:",add:"Add",
Captcha:'NOTICE CAPTCHA! Troppe marce!<br><br>Cause',
},
Wilds:{
 done:'done',
},
Attaque:{
 title:"RAPID MOVEMENT OF TROOPS",
 scout:"exploration",
 attack:"attack",
 renforce:"reinforcement",
 renforcefood:"reinforcement + food",
 BOVilleProche:"Citta\' piu\' vicina",
 TimeAttack:"Tps attack",
 Timerenforce:"Tps reinforcement",
 option:"(optional)",
 BO_AT_Fav:"Unit\' save: ",
 BO_AT_Fav_Sup:"Delete",BO_AT_Fav_RESET:"Delete ALL",BO_AT_Fav_Nom:"Add",
 titleprog:"Schedule an attack",timeAr:"Arrival time: ",
 error1:"Put a name to save to favorites!",
 BOCompAttack:"ATTACK LAUNCHED",
 error2:"IMPOSSIBLE",
 BOCompAttackIn:"CONNECTION BETWEEN",
 error3:"Error Place of Meeting!",
 error4:"Bad clock format.",
 saved:"saved",
 error0:"<font color=red size='3px'><b>Errore, please start again!<b></font>",
 marche2:"reinforcement sent",
 marche3:"attack posted",
 marche4:"exploring sent",
},
GIFT:{
title:'SEND GIFTS TO ALLIANCE',
Gift:'gift',
Send:'Send gifts',
SelFriends:'Select Friends',
SendAll:'Send all',
Nothing:'Nothing to send',
SendGood:'Gifts sent',
ComeBack:'Come back tomorrow!<br><br>Your gifts are already\' been sent',
},
tournoi:{
 title:"INFORMATION ON HOW TO PREPARE FOR A TOURNAMENT",
 title2:"TOURNAMENT INFORMATION ON CURRENT",
 start:"Start",
 end:"ends",
 timeRem:"remaining time",
 training:"Training in progress",
 popdispo:"Pop dispo.",
 error:"load Error",
},
Resources:{
 title:"VISIT THE COURTS IN AUTOMATIC",
 pballlist:"members of alliance",
 pballlist2:"my Friends",
 cancel:"Cancel.",
 load1:"Searching for members of alliance...",
 load2:"Searching for friends...",
 check:"Can check whether...",
 title2:"LIST OF MEMBERS/FRIENDS",
 find:"Found",
 nothing:"No member/friends found!",
 collect:"Resources to collect: ",
 select:"Select members/friends:",
 accept:"Collect resources",
 error1:"Nothing Selected!",
 collecting:"Collection in progress",
 members:"members/friends :",
 stop:"Stop the collection",
 total:" total collected : ",
 alldone:"Collection building resource completed.",
 collecting2:"Collection building in progress... ",
},
Spam:{
 title:"SPAM - CONFIGURATION",
 pbSpamState1:"Alliance Chat",
 pbSpamState2:"Global Chat",
 pbSpamMin:"Post automatically ",
 pbSpamAd:"Spam",
 Defcon:{
 Def5:"Peacetime (which is placed at the exit for a few days of the war, then it goes without saying)",
 Def4:"Impending war or reprisals and the first explorations",
 Def3:"War in all respects, with attacks from both sides and bulwarks",
 Def2:"War heavy and unfortunate situation, which causes certain types of behaviors, such as pensions, troops in the sanctuary and ultimate defense",
 Def1:"The war \ 's lost, the command is not longer able to control the alliance, then you can' abandon the alliance in order to avoid further reprisals (The defcon 1 and \ 'the situation that usually precedes the dissolution of the alliance)",
 },
},
stock:{
 title:"INVENTORY OF ARTICLES",
 cat1:"General",
 cat2:"acceleration",
 cat3:"combat",
 cat4:"resources",
 cat5:"cash",
 cat6:"court",
 col1:"article",
 col2:"quantity",
 col3:"category",
 puitotal:"TOTAL OF ITEMS INVENTORY:",
},
info:{
 title1:"EXTERNAL LINKS",
 title2:"STATISTICS OF TROOPS",
 title3:"LEVELS OF RESEARCH",
 title4:"STIME - TRAINING OF TROOPS & CONSTRUCTION OF DEFENSE",
 tot:"Total",
 trainhour:"capacity to train all now",
 buildhour:"capacity to construct all now",
 row0:"Number of barracks",
 row1:"Level of barracks",
 row2:"points Marshal",
 row3:"Marshal of Combat",
 row5:"stable level",
 row24:"level workshop",
 row6:"level blacksmith",
 row25:"Number of cottage",
 title5:"DISTANCE CALCULATOR",
 title6:"MAP OF THE PROVINCE",
 title7:"CREST/SEALS REQUIRED FOR THE CITY\'",
 title8:"crest/Seals that have",
 ptdistout1:"distance from",
 ptdistout2:"to",
 ptdistout3:"and of",
},
ALLIANCE:{
title:'INFORMATION ON ALLIANCE',
list:'List of members of the alliance',
sort:'Sort by',
position:'position',
daypos:'Days at this position',
list:'List',
listdiplo:'Show diplomacys Alliance',
listdiplot:'diplomatic list',
joined:'created on',
resume:'ABSTRACT',
},
Trone:{
 title:"THE THRONE ROOM - INVENTORY MANAGEMENT",
 BOFiltre4ST:"Show All Effects",
 BOFiltre7ST:"Show broken objects",
 BOlisteeffets:"Effect (s) in red:",
 BOTroneCityCity:"Take the stone from the ethereal city",
 title2:"RESERVES STONE Etera",
 title3:"CURRENT EQUIPMENT",
 title4:"INVENTORY MANAGEMENT",
 BOTroneInverse:"Invert the sense",
 repair:"repair",
 repairing:"Repair work in progress",
 upgrade:"level",
 enhance:"quality\'",
 salvage:"Clear",
 equip:"equip",
 unequip:"unequip",
 norow:"not Available",
},
Overview:{
 col1:"Stock",
 col2:"Azione",
 nofey:"Fey Spire is not present in this city\'!",
 titlefey:"Fey Spire",
 opendate:"within the:",
 sum:"Total",
 includeMarching:"in March",
 EnableFormation:"in Training.",
 prodfood:"Food production at \ 'hours",prodwood:"Production of wood to \ 'hours",prodstone:"Production of all stones hours",prodore:"Production of minerals to hours",
 auton:"Aut.",def:"Def",march:"march",ts:"TS",knight:"Cav",knight1:"Knights available / Knight Hall",
 pop1:"Pop Max",pop2:"Pop Att.",pop3:"work",pop4:"inactive",pop5:"Dispo",
},
Rpt:{
  them:"their",pages:"pages",type:"type :",to:"to",
  us:"Us",both:"Both",end:"finished!",sum:"TOTAL:",
  idRptWhat:"happy:",idRptWhatNot:"different:",
  idRptFiltre1_1:"TS",idRptFiltre1_2:"FS",BOSyntheseAttack:"RIASS",
  BOresumeAT:"Summary of attacks",BOresumeDF:"summary ",
  pertes:"our losses",pertes2:"their losses",number:"Number",mes1:"Difference in Might :",mes2:"No loss on both sides",
  err1:"No reports found",title1:"Summary reports of d \ 'attack",
  itemfind:"Itemfind",report:"Report",noitem:"No item found",BODelAllDF:"Delete reports involved",
  title_popRapportDF:"Summary of report",noresult:"No results",nosubject:"No ssubjects",
  result:"result :",found:"Found :",
},
REASSIGN:{
Manu:'Manual',
Auto:'Automatic',
Manual:{
title:'Reassign troops from a town all other',
},
Automatic:{
title:'AUTOMATIC REASSIGNMENT - CONFIGURATION',
AddRoute:'Add route',
From:'By',
To:'to',
Delay:'assign each',
Block:'Block values ??of the troops',
Route:'Route',
},
},
marchs:{
 attackcol2:"Def",PR:"PR",
 targetTS:"TS",
 unknow:"unknown",
 nomarch:"No marching in progress...",level:"Lv",knight:"Knight",
 tot:"TOTAL",mycity:"My city\'",citylevel:"City\' Liv",barblevel:"Barb Lv",dflevel:"DF Liv",boglevel:"City\'/Barb Lv",
 title1:"List of troops sent to reinforce",
 title2:"List of troops stationed in your embassy",
 notroops:"No troops to reinforce current.",
 refcol1:"actions",refcol2:"coordinates",refcol3:"Send from",refcol5:"maintenance",foodh:"food / h",
 encRemaining:"Show the troops the original",comment:"NOTE: E\' Koc must update to see reinforcements.",
 find:"Found:",nofind:"Not Found",
},
Search:{
 PDetail:"Search details ...",Detail:"details:",between:"between",and:"e",
 PLeaderboard:"Search by rank...",
 PLb2:"<B>Classifica:</b> not found! (in mist?)",
 ANothing:"no",center:"Center",cancel:"SEARCH CANCELLED!",
 error:"ERROR:",stop:"Stop Search",
 err1:"X doit &ecirc;tre between 0 et 749",
 err2:"Y doit &ecirc;tre between 0 et 749",
 err3:"the distance mini doit &ecirc;tre sup&eacute;rieur &agrave; 0",
 err4:"the distance maxi doit &ecirc;tre sup&eacute;rieur &agrave; 1",
 err5:"the distance max doit &ecirc;tre sup&eacute;rieur &agrave; la distance mini",
 err6:"the distance max can not d&eacute;passer 375 ! the risk of p&ecirc;ter your browser",
 ShowHideOpts:"Mostra / Nascondi the opzioni (di vedere allows a pieno schermo)",
 minlevel:"Lv Min. :",maxlevel:"Lv Max. :",typewilderness:"Tip Wilderness ",filter:"Filter ",orderby:"Order by ",
 TS0:"All Wilderness",WS1:"only free",WS2:"hostile",WS3:"only neutral",WS4:"Only without alliance",
 coords:"Coords ",Cit0:"All Cities\'",Cit1:"only hostile",Cit2:"only in mist",Cit3:"only Allied",Cit4:"only friends",Cit5:"only neutral",Cit6:"only without  alliance",
 distance:"Dist",level:"Lv",more:"More info",status:"Status",connexion:"connection",
 notetable:"<FONT COLOR=#600000>NOT: The table shows only 500 of",notetable1:"risultati. Show \ 'all just finished.</font>",
 free:"Free...",
 exportKOCattack:"Export results",
 generateFSList:"attacks",
 generateScoutList:"List of exploration",find:"found:",
 numberCible:"Number of targets ",send:"send!",
 startattack:'lance',finishattack:"Finished!",sendto:"send to ",waitPR:"Pending the assembly point...",
 errFS1:"ERRORE: No coordinated selected",errFS2:"ERRORE: Coordinate invalide!",
 scoutTitle:"Auto scout",
},
TRAIN:{
EndTime:'End time',
EndTimeBet:'Now at the end of',
},
KNIGHT:{
Title:'Management of the Knights',
Default:'Assign to default',
Combat:'Be the fighting',
Foreman:'Foreman',
Marshall:'Marshall',
Alchemystic:'alchemical',
Steward:'Steward',
Role:'Role',
SetPoints:'Set points',
SetPoints2:'skill points\'',
Done:'Done',
Assign:'Assign',
Increase:'Increase experiance',
Boost:'Increase loyalty\' of 5% with gold',

},
AUTOFO:{
Title:'AUTO ATTACK IN THE DARK FOREST',
Title2:'STATISTICS OF THE DARK FOREST',
Title3:'OPTIONS FOR THE DARK FOREST',
Management:'FOREST MANAGEMENT',
Show:'Show',
Options:'Options',
Interval:'Interval attack',
DistanceMax:'Maximum distance to search',
Keep:'Keep',
Point:'free spot in really point',
ResearchEvery:'Research every',
SkipCity:'Skip city\' after',
Attempts:'attempts',
Methode:'Methode',
Methode1:'distance',
Methode2:'High levels',
Methode3:'Low levels of',
MeKnight:'Property Knight',
Prop1:'Points of combat low',
Prop2:'High points of combat',
ResetCounters:'Reset counters',
Reset:'Reset',
NoData:'No data',
CancelByUser:'Cacel by user',
Send:'Send',
Slots:'Slots',
Knights:'Knights',
Attempt:'Attempt',
TrafficError:'Traffic error',
PRError:'Error realy point',
KnightError:'Knight error',
MoreError:'More error',
Bug:'Bug',
},
TRANSP:{
Manu:'Manuale',
Auto:'Automatico',
Appros:'supply',
Manual:{
Title:'Carries a city all other',
From:'From',
To:'To',
Amount:'Amount\'',
ResTroops:'The quantity resource the maximum of troops selected',
AmountRes:'Quantity resources to carry',
Exceed:'The amount can not overcome',
ChoseRes:'Choose a resource type',
SameCity:'Unable to carry on the same city\'',
ErrorTroops:'Unable to carry troops, with 0',
ErrorDest:'Unable to carry coord 0,0',
TranspDone:'Trasport done',
ErrorTrasp:'Error, transport',
Tentative2:'Retrying in 2 seconds',
},
Automatic:{
Title1:'AUTO TRANSPORT - CONFIGURATION',
Title2:'OPTIONS',
Title3:'ADD A TRANSPORT',
Title4:'Automatic Transport saved',
TraspEvery:'Send any transport',
TraspIf:'Send transport with a minimum of',
ShowRoute:'Show transport',
AddRoute:'Add transport',
TraspManu:'Transport Manual',
From:'From',
To:'To',
TroopsNeeded:'troops needed',
Keep:'Keep',
PointFull:'Really point full',
Active:'Active',
Deactive:'Disactive',
},
Appro:{
From:'From',
To:'To',
Of:'Of',
Title1:'AUTO SUPPLY - CONFIGURATION',
Title2:'CONFIGURE YOUR CITY\'',
CityProv:'City supply',
ValuesAuto:'Values auto',
CulTime:'This time is only computed at each opening of the Koc BoTTols Original! E\' defined by the longer time between headquarters and the city secondary + 10 minutes',
Interval:'automatic range',
MinKeep:'Minimum to KEEP',
Explanation:'<u><b>instructions:</b></u><br>1. Choose your bunker (where you want to send resources)<br>2. Click on AUTOMATIC values??: Make sure that the carriage is automatically configured<br>2. Enter the quantity of resources to bear on your city \' secondary (eg 5kk 5kk of minerals and stone)<br>3. If the interval equal to 0, press update F5<br>4. Click on Activate to supply!',
LowRes:'Low of resources',
},
},
AUTOTRAIN:{
Options:'options',
Interval:'interval',
Refresh:'Update to apply changes',
Pop:'Percentage of population (total) to calculate the default',
BuildDefenses:'Automatically build a defense to reach a maximum of 5',
AutoDeleteT:'Automatic deletion of code training in progress ',
DeleteT:'Delete queues in progress',
Recalculate:'Recalculate all',
DelProgress:'Erase in progress',
Finished:'Finished ... Update the game and start training',
Again:'please start again',
ImpDelete:'Unable to cancel training...<br>Update the game and start again',
ErrorPopRes:'Population or resource - may be',
ErrorPop:'Resources - may be', 
},
crest:{
 title:"AUTO CREST - CRESTS / BARB",
  help:"Help",target:"To View",interval:"Interval attack:",
  sendrpt:"Send a report every ",keep:"Keep",keep2:"free spot in really point",
  add:"Add march",
  helpTitle:"Help on attachment to the wilderness - Crest",
  helpText:"<BR>L\'ARMS tab is made ??to attack continuously and automatically Wilderness.<BR>\
        This attack in two waves, the wilderness gives up and starts again if necessary.<BR>\
        Check that you have a free place in your castle for a wilderness to conquer.<BR>\
        Fill out the coordinates of a Savage Land and the troops and press ON !.<BR><BR>\
        Number of troops (KOC WIKI):<BR>\
        <A target=_tab href=http://koc.wikia.com/wiki/Wilderness>Plus d\'informations sur Koc Wikia</a>\
        <TABLE width=100%><TR><TD>Livello</td><TD>Onda 1</td><TD>Onda 2</td><TD>Perdite</td><TD>Emp. Min</td></tr>\
        <TR><TD>1</td><TD>n/a</td><TD>160 MM</td><TD>12 MM</td><TD>0</td></tr>\
        <TR><TD>1</td><TD>n/a</td><TD>80 archers</td><TD>Aucune</td><TD>1+</td></tr>\
        <TR><TD>2</td><TD>5 MM</td><TD>130 archers</td><TD>1ere Vague</td><TD>2+</td></tr>\
        <TR><TD>3</td><TD>10 MM</td><TD>520 archers</td><TD>1ere Vague</td><TD>3+</td></tr>\
        <TR><TD>4</td><TD>20 MM</td><TD>1600 archers</td><TD>1ere Vague</td><TD>4+</td></tr>\
        <TR><TD>5</td><TD>50 MM</td><TD>2200 archers</td><TD>1ere Vague</td><TD>6+</td></tr>\
        <TR><TD>6</td><TD>100 MM</td><TD>3000 archers</td><TD>1ere Vague</td><TD>7+</td></tr>\
        <TR><TD>7</td><TD>150 MM</td><TD>6000 archers</td><TD>1ere Vague</td><TD>8+</td></tr>\
        <TR><TD>8</td><TD>299 MM + 1Bal</td><TD>9000 archers + 900 Bal</td><TD>1ere Vague + 1 Archer</td><TD>9+</td></tr>\
        <TR><TD>9</td><TD>599 MM + 1Bal</td><TD>13000 archers + 900 Bal</td><TD>1ere Vague + 2 Archer</td><TD>10</td></tr>\
        <TR><TD>10</td><TD>1199 MM + 1Cat</td><TD>35000 archers + 2500 Cat</td><TD>1ere Vague + 6 Archer + 50 Cat</td><TD>10</td></tr></table><br><br>",
 nolocation:"No coordinated inserted!",popCrest:"To attack saved",
 active:"On",inactif:"Off",wave:"Wave",
 msg1:"Items Stats:",msg2:"Items Gained",msg3:"duration:",msg4:"Total Items gained:",msg5:"Numbers of 1st Wave send:",msg6:"Numbers of 2nd Wave send:",msg7:"Rapport Crest",
        
},
Options:{
welcome:"Welcome to",
conf:"configuration",
Langue:"language",
PostUpdateText:'Located in alliance chat updates '+ScriptNameS,
MoveW:"Move the window with the mouse",
Transp:"clear window",
reload:"Update Koc each",
prodshort:"Reduce the resource view",
WideScreen:"Turn on the enlarged screen",
TchatR:"Put the right chat",
Hauteur:"Height of Tools :",
WideMap:"Enlarge the map",
moremap:"Add more information on the map",
horlGMT:"Remove the time in Koc",
Watchdog:"Update Koc if not open within 1 minute",
autoPublishGamePopups:"Automatically publish on Facebook (All Domains)",
NewTab:"Enable the Custom Tab",
confres:"Configuration Tab Panorama :",
ShowTroops:"Show the troops",
ShowDefense:"Mostra le difese",
ShowRes:"Show stocks of resources",
ShowPop:"Displays information on the population",
ShowProduction:"Shows the production of resources",
includeMarching:"Include the troops on the march",
EnableFormation:"Include the troops in training",
foodWarm:"Show autonomy in red if the food is not enough to ",
confchat:"Configuring the chat :",
FoodWarnTchat:"Public chat in case of lack of food",
HelReq:"Automatically helps the construction / research of your members",
DelReq:"Auto Hide aid construction / research",
DelRules:"Hide the rules of the chat",
ChatStuff:"Enable improvements in chat (coord clickable, different colors . . .)",
WhisperOn:"Sound on whisper",
WhisperOnRed:"Shows in red the Whisper",
EclaireurOn:"Unmute if EXPLORATION (Alliance)",
AttaqueOn:"Enable audio in case of ATTACK (Alliance)",
StopRaidMes:'Stop if a crest is your ally attack (This not to clog the report)',
Smiley:"Enable smileys",
ChatLeader:"Activate the colors of Leaders",
ChatColor:"Colors of the chat :",
ChatGlo:"Background of the global chat :",
user_icon:"Change avatar in case of attack",
iconinfo:"<br>>> Image Requirements: 25px to 25px - <i>attention : The only visible to you</i>",
confrpt:"Configuring reports Koc:",
AllRpts:"Improved reports of alliance",
AllMembers:"Improves the players of the Alliance",
deleterpt:"Delete reports :",
intervrpt:"Interval :",
confdiv:"other configurations:",
alertHQ:"my main :",
SelQG:"Automatically selects the closest at the opening of the game",
GoldEnable:"Automatic collection of gold when the happiness and greater than",
AttackPicker:"Turn the dial of the city (Reinforce, reassign and transport)",
EnhanceMsging:"Improve the message handling (DC Field)",
CoordBoX:'Move linserimento coordinates above the chat',
conftower:"Configuration of the Tower Alert :",
alertEnable:"Activate the Tower",
SoundEnable:"Turn the sound in case of attack / SPIED",
Loadingswf:"Loading Flash Player",
soundFile:"File :",
SoundLoad:"load",
volume:"Volume :",
SoundStop:"stop",
soundLength:"sounds to",
SoundRepeat:"Repeat",
postAlert:"Post a message :",
alertPrefix:"Supplementary Message :",
alertSendToAlly:"Alliance Chat",
alertSendAsWhisper:"Whisper to me",
alertWild:"Warn : ",
alertTroops:"Minimum of troops : <br><i>(Message chat)",
alertDefend:"Shows whether or not to defend : ",
alertEmpennage:"Show my fletching :",
alertMarechal:"Shows the level of my Marshal (without boost) :",
alertShow:"show :",
alertFood:"Consumption of food :",
alertQG:"Disable my main :",
alertraid:"Stop when you get an attack :",
alertSendEmail:"Send email :",
defBoost:"State of the defense (Sanctuary / Defense)",
alertMytroops:"my troops",
alertEmbassy:"Allied troops encamped",
ResetALL:"Resets ALL menu options",
alertDefense:"my defenses",
CResetALL:"Reset colors",
RptGift:"Enables the elimination of gifts",
toyou:'To you',
you:'You',
received:'Received',
ShowThrone:'Show the cards of your throne ACTIVE',
AutoWall:{
TitleBunk:'PROTECTIVE BUNKER',
Note:'In the city there should be NO BUNKER raid and / or other gear',
EnableBunker:'Enables the use of a portal of Refuge in the case of the bunker EXPLORATION',
EnableBunkerA:'Move the bunker after',
EnableBunkerB:'attacks',
EnableFog:'Also active mists',
Title:'AUTO WALL',
Rischio:'We are not responsible for the use made of it and/or the consequences of this function',
Preset:'In the case of exploration active the throne room',
Esplo:'Walls in the case of exploration',
ShowTroops:'Out with the troops when there',
NoteShowTroops:'If you do not check anything, is out now',
RangeM1:'Range Control - Do not expose the troops:',
RangeMod1:'The attacker has a range greater than or equal to your',
RangeMod2:'If the attacker has more than',
RangeM2:'Recheck the range ',
RangeM21:'seconds before it gets to the scout',
PotereM1:'Do not put out the troops if the power of the attacker and equal to or greater than your',
},
},
SEARCH:{
all:'All',
filtre:'filter',
sort:'Ordina per',
found:'Found',
only:'Only',
type:'Type',
onlyfree:'Only free',
},
Apothecary:{
 label:"Apothecary",
 power:"Auto Heal",
 show:"Slots",
 options:"Options",
 gold:"Keep gold:",
 add:'Add',
 stat:'TROOPS IN WAITING',
 detail:'List of troops waiting',
 edit:'Apothecary - modification',
 delete:'Apothecary - delete',
},
AUTOSCOUT:{
title:'AUTO-SCOUT OF ALLIANCE',
interval:'Interval',
NumSp:'Quantity of scouts',
NotReady:'Not ready',
SearchComplete:'The research was completed',
Cityto:'City to explore',
InMist:'In mist',
Find:'Found',
ScoutSent:'Scout sent',
On:'On',
SendFail:'Error sending from',
Restriction:'restriction',
},
build:{
 buttonlabel:"construction",biglabel:"AutoConstruction",
 title:"AUTO-construction - CONFIGURATION",
 modebuild:"Mod construction", title2:"construction IN PROGRESS",
 ec:"Ec:",titleec:"In construction",
 err1:"Error for the destruction!",err2:"Lack of resources!!",err3:"Destruction in the tail!",
 err4:"The buildings of 10 + level must be done manually.",autoclose:"Automatically closed in 10 seconds...",
 optimize:"Order by time", queue:"Queue",
},
autoCraft:{
 title:"AUTO-CRAFTING - CONFIGURATION",
 stat:"STATISTIC",title2:"OPTIONS - DEFINING THE OBJECTS TO CREATE",
 col:"object",col1:"Quantity to be created",tot:"Total",
 notes:"<i><u>Note :</u> Have a minimum of 5 000 aeterstone</u></i> - <i>(*) Update the game after the settings.</i>",
},
PROD:{
title:'INVENTORY AND STOCKS',
},
RAID:{
 conf:"CONFIGURATION",
 stop:"Stop all",
 resume:"Resume all",
 delete:"Delete all",
 sendReport:"Submit a report on every raid",
 timer:"Time RAID",
 nothing:"No raid in the city",
 marches:"Active march",
 memory:"Save",
 nothingmemory:"No saved raid on this city",
 ResetTimer:'Time RAID reset'
},
SMYLE:{
chat:'Smilies',
title:'Smilies',
},
Food:{
 need:'need',
 rem:'It remains',
 prod:'production',
},
AUTOTRONE:{
 label:"AutoThrone",
 Autosalvage:"Autosalvage",
 AutoRepair:"AutoRepair",
  AutoRepair:"AutoRepair",
 Upgrade:"Upgrade/Enhance",
 Stats:"Statistics",
 quality:"Quality",
 level:"Level",
 Equiper:"Equip",
 history:"History",
 effet:'Efect',
 autosalvage:{
  title:"AUTO-SALVAGE : CLEAR THE OBJECTS OF THE THRONE",
  titleeffet:"LIST OF ITEMS TO BE SAVE",
  Save:'Keep the first',
  items:'Items',
  SalvageQuality:"KEEP THE ITEMS that have a quality",
  SalvageQuality2:"o higher",
  RangeSaveMode:"KEEP THE ITEMS with ",
  RangeSaveMode2:"",
  BOSType:"Types of objects to keep:",
  SalvageKeepEffects1:'least 1 of the 3 final effects',
  SalvageKeepEffects2:'at least 1 of the 2 final effects',
  SalvageKeepEffects3:'at least the top end effect',
  SalvageKeepEffects4:'at least the last 2 effects',
  SalvageKeepEffects5:'at least the last 3 effects',
  alert:"<u>It will not remove:</u><br>Equipped items, broken, or with a higher level than 0",
  col1:"Effects to keep",
  col2:"family",
  popHistory:"List of items automatically deleted - (Family of effect in brackets)",
  popCell0:"hour",
  popCell2:"action",
  titlelive:"PREVIEW OF ITEMS THAT WILL BE REMOVED",
  refresh:"UPDATE",
  nodelitem:"No items to delete.",
  actionlog1:"No items to be removed - something ",
  actionlog2:"Deleted ",
  Salvagelog1:"Echec Salvage :(",
 },
 upgrade:{
  title:"AUTO UPGRADE/ENHANCE/REPAIR",
  title2:"TAIL OF THE PROGRAM HOLD",
  items:"List of objects: ",
  title3:"STATE AND INFORMATION",
  title4:"TAIL OF WAITING",
  noitem:"No item in the queue!",
  waiting:"waiting...",
  retry:"retry: ",
  trying:"trying di",
  good:"Good requests: ",
  bad:"Bad requests: ",
  off:"Auto Upgrade/Enhance/Repair e\' OFF.",
  nothing:"No item in the queue!",
  letsgo:"Top of the object follows...",
  upgrade10:"Unable to upgrade than 10 !",
  enhance5:"Impossible to make a quality above superb (5) !",
  popHistory:"List of objects -Upgrade/Enhance- successful",
  popCell0:"Time",popCell1:"Name",popCell2:"Action",popCell3:"Tent.",popCell4:"Good Req.",popCell5:"Bad Req.",
  notenough:"not enough aeterstone",
  mptitleenhance:"ENHANCE SUCCESFUL ",
  mptitleupgrade:"UPGRADE SUCCESFUL ",
  fail:"fail",
  repairing:"repairing : ",
  timeleft:"time left : ",
  paintCol1:"in Progress",
  paintCol2:"next",
  bonexttries:"Number of attempts :",
  bonexttries1:"<i>(Then go to the next item)</i>",
  last:"Door at the end",
  },
equip:{
  title:"OBJECTS OF THE THRONE OF EQUIPMENT",
  equip:"equip",
  deequip:"unequip",
  preset:"Pre-set:",
  noitem:"No item ",
  itemavai:"available [:(] ",
  itemequip:"equipped!!!",
  preset2:"Pre-Set currently equipped:",
  title2:"ORGANIZATION OF CARDS",
  },
  stats:{
  title:"THE THRONE ROOM - STATISTICS",
  },
repair:{
  err1:"Impossible! Please remove auto repair.",
  err2:"Impossible! Yes please remove auto upgrade / Enhance.",
  repairing:"Repairs on hold...",
  title:"ONLY AUTO REPAIR",
  title2:"<i>Automatically repair broken objects.</i>",
  title3:"<i><font color=red>NON E\' CAN USE IT WITH AUTO UPGRADE / ENHANCE</font></i>",
  repairon:"Auto Repair = ON",
  repairoff:"Auto Repair = OFF",
 },
 },
},
'it': {
StatLabel:'Statistiche',
StatLabelAttaque:'Attacca',
StatLabelTrone:'Trone',
StatLabelTournoi:'Torneo',
StatLabelOverview:'Riserve',
StatLabelResources:'Corte',
StatLabelSpam:'Spam',
StatLabelInventaire:'Inventario',
StatLabelInfo:'Info',
StatLabelAlliance:'Alleanza',
StatLabelGift:'Regali',
StatLabelTest:'Fake',
StatLabelLogs:'Diario',
BoiteLabelApothecary:'Farmacia',
BoiteLabelResumer:'Panorama',
BoiteLabelOptions:'Opzioni',
BoiteLabelCrest:'Crest',
pubbao:'Supporta il tools, clicca sulla pubblicita\'',
Tools:{
Loaded:'Caricato',
Version:'Versione',
NewUpdate:'Nuova versione del',
Available:'disponibile',
},
General:{
tot:"Totale",all:'Tutto',none:'Nessuno',error:"Errore",new:'Nuovo',and:'e',or:'oppure',end:'Finito',
hour:"ora",hours:"ore",mins:"minuti",secs:"secondi",name:"Nome ",help:"Aiuto",nom:"Adesso",
dans:"in",now:"Aggiornamento",cancelact:"Annulla Aggiornamento",kocnotfound:"KoC BoTTols Original ha rilevato che il gioco non e\' stato caricato",Select:'Seleziona',RefreshIn:'Aggiornamento in',
dialogRetry:"Un errore e\' stato rilevato :",
Retry:"Riprovo tra ",myRetry:"ERRORE nel RIPROVARE: 5 tentativi, mi fermo",
BOUpdate:"Tieni aggiornato il tuo Tools!",DetectionCaptcha:'Rilevato CAPTCHA',source:'Da',dest:'Destinazione',EstimateT:'Tempo estimato',
delGift:"Cancella Regali",time:"Tempo",edit:"Modifica",save:"Salva",saved:"Salvato",delete:"Cancella",deleted:"Cancellato",timeremi:"Tempo rimanente:",add:"Aggiungi",
Captcha:'AVVISO CAPTCHA! Troppe marce!<br><br>Causa',
},
Wilds:{
 done:'Fatto',
},
Attaque:{
 title:"MOVIMENTO RAPIDO DELLE TRUPPE",
 scout:"Esplorazione",
 attack:"Attacco",
 renforce:"Rinforzo",
 renforcefood:"Rinforzo + Cibo",
 BOVilleProche:"Citta\' piu\' vicina",
 TimeAttack:"Tps Attacco",
 Timerenforce:"Tps Rinforzo",
 option:"(in opzione)",
 BO_AT_Fav:"Unita\' Salvate: ",
 BO_AT_Fav_Sup:"Elimina",BO_AT_Fav_RESET:"Elimina TUTTO",BO_AT_Fav_Nom:"Aggiungi",
 titleprog:"Programma un attacco",timeAr:"Ora di arrivo: ",
 error1:"Metti un nome per salvare in preferiti!",
 BOCompAttack:"ATTACCO LANCIATO",
 error2:"IMPOSSIBILE",
 BOCompAttackIn:"ATTACCO TRA",
 error3:"Errore Luogo di Riunione!",
 error4:"Formato cattivo dell'orologio.",
 saved:"salvato",
 error0:"<font color=red size='3px'><b>Errore, Perfavore ricomincia!<b></font>",
 marche2:"Rinforzo inviato",
 marche3:"Attacco inviato",
 marche4:"Esplorazione inviata",
},
GIFT:{
title:'INVIA REGALI ALL\'ALLEANZA',
Gift:'Regalo',
Send:'Invia regali',
SelFriends:'Seleziona Amici',
SendAll:'Invia a tutti',
Nothing:'Niente da inviare',
SendGood:'Regali inviati',
ComeBack:'Torna domani!<br><br>I vostri regali sono gia\' stati inviati',
},
tournoi:{
 title:"INFORMAZIONI SU COME PREPARARE UN TORNEO",
 title2:"INFORMAZIONI SUL TORNEO IN CORSO",
 start:"Inizia",
 end:"Finisce",
 timeRem:"Tempo rimanente",
 training:"Addestramento in corso",
 popdispo:"Pop Addestr.",
 error:"Errore caricamento",
},
Resources:{
 title:"VISITA LE CORTI IN AUTOMATICO",
 pballlist:"Membri dell\'alleanza",
 pballlist2:"Miei Amici",
 cancel:"Annulla.",
 load1:"Ricerca in corso dei membri dell\'alleanza...",
 load2:"Ricerca in corso degli amici...",
 check:"Verifico se possibile...",
 title2:"LISTA DEI MEMBRI/AMICI",
 find:"Trovati",
 nothing:"Nessun membro/amici trovato!",
 collect:"Risorse da collezionare: ",
 select:"Seleziona i membri/amici:",
 accept:"Colleziona le risorse",
 error1:"Niente di selezionato!",
 collecting:"Collezione in corso su",
 members:"membri/amici :",
 stop:"Ferma la collezione",
 total:" Totale collezionato : ",
 alldone:"Collezionamento delle risorse completato.",
 collecting2:"Collezionamento in corso... ",
},
Spam:{
 title:"SPAM - CONFIGURAZIONE",
 pbSpamState1:"Chat Alleanza",
 pbSpamState2:"Chat Globale",
 pbSpamMin:"Posta automaticamente ogni ",
 pbSpamAd:"Spam",
 Defcon:{
 Def5:"Tempo di pace (che viene messo per qualche giorno all'uscita della guerra, poi va sottinteso)",
 Def4:"Guerra imminente o prime rappresaglie ed esplorazioni",
 Def3:"Guerra a tutti gli effetti, con attacchi e murate da ambedue i lati",
 Def2:"Guerra pesante e situazione sfavorevole, che determina certi tipi di comportamenti, tipo quiescenza, truppe in santuario ed estrema difesa",
 Def1:"La guerra e\' persa, il comando non riesce piu a controllare l'alleanza, quindi si puo' abbandonare l'alleanza per evitare ulteriori rappresaglie (Il defcon 1 e\' la situazione che generalmente precede lo scioglimento dell'alleanza)",
 },
},
stock:{
 title:"INVENTARIO DEGLI ARTICOLI",
 cat1:"Generale",
 cat2:"Accelerazione",
 cat3:"Combattimento",
 cat4:"Risorse",
 cat5:"Cassa",
 cat6:"Corte",
 col1:"Articolo",
 col2:"Quantita\'",
 col3:"Categoria",
 puitotal:"TOTALE OGGETTI DELL\'INVENTARIO:",
},
info:{
 title1:"LINK ESTERNI",
 title2:"STATISTICHE DELLE TRUPPE",
 title3:"LIVELLI DELLE RICERCHE",
 title4:"STIME - FORMAZIONE DELLE TRUPPE & COSTRUZIONE DELLE DIFESE",
 tot:"Totale",
 trainhour:"Capacita\' di addestrare all\'ora",
 buildhour:"Capacita\' di costruire all\'ora",
 row0:"Numero delle caserme",
 row1:"Livello delle caserme",
 row2:"Punti Maresciallo",
 row3:"Maresciallo di combattimento",
 row5:"Livello scuderia",
 row24:"Livello officina",
 row6:"Livello fabbro",
 row25:"Numero di case",
 title5:"CALCOLATORE DISTANZA",
 title6:"MAPPA DELLA PROVINCIA",
 title7:"ELMI/SIGILLI NECESSARI PER LE CITTA\'",
 title8:"Elmi/Sigilli che possiedi",
 ptdistout1:"Distanza da",
 ptdistout2:"verso",
 ptdistout3:"e\' di",
},
ALLIANCE:{
title:'INFORMAZIONI SULL\'ALLEANZA',
list:'Elenco dei membri dell\'alleanza',
sort:'Ordina per',
position:'Posizione',
daypos:'Giorni in questa posizione',
list:'Lista',
listdiplo:'Mostra le diplomazie dell\'alleanza',
listdiplot:'Lista diplomazie',
joined:'Creata il',
resume:'RIASSUNTO',
},
Trone:{
 title:"SALA DEL TRONO - GESTIONE INVENTARIO",
 BOFiltre4ST:"Mostra tutti gli effetti",
 BOFiltre7ST:"Mostra gli oggetti rotti",
 BOlisteeffets:"Effetto(i) in rosso:",
 BOTroneCityCity:"Prendi la pietra eterea dalla citta\' ",
 title2:"RISERVE PIETRA ETERA",
 title3:"EQUIPAGGIAMENTO ATTUALE",
 title4:"GESTIONE INVENTARIO",
 BOTroneInverse:"Inverti il senso",
 repair:"Ripara",
 repairing:"Riparazione in corso",
 upgrade:"Livello",
 enhance:"Qualita\'",
 salvage:"Cancella",
 equip:"Equipaggia",
 unequip:"Disequipaggia",
 norow:"Non Disponibile",
},
Overview:{
 col1:"Stock",
 col2:"Azione",
 nofey:"Fey Spire non e\' presente in questa citta\'!",
 titlefey:"Fey Spire",
 opendate:"Entro le:",
 sum:"Totale",
 includeMarching:"In Marcia",
 EnableFormation:"In Addestr.",
 prodfood:"Produzione di cibo all\'ora",prodwood:"Produzione di legno all\'ora",prodstone:"Produzione di pietre all\'ora",prodore:"Produzione di minerali all\'ora",
 auton:"Aut.",def:"Dif",march:"Marcia",ts:"TS",knight:"Cav",knight1:"Cavalieri disponibili / Luogo di riunione",
 pop1:"Pop Max",pop2:"Pop Att.",pop3:"Lavoro",pop4:"Inattiva",pop5:"Dispo",
},
Rpt:{
  them:"Loro",pages:"Pagine",type:"Tipo :",to:"a",
  us:"Noi",both:"Tutti e due",end:"Finito!",sum:"TOTALE:",
  idRptWhat:"Contente:",idRptWhatNot:"Diverso:",
  idRptFiltre1_1:"TS",idRptFiltre1_2:"FS",BOSyntheseAttack:"RIASS",
  BOresumeAT:"riassunto degli attacchi",BOresumeDF:"riassiunto ",
  pertes:"Nostre perdite",pertes2:"Loro perdite",number:"Numero",mes1:"Differenza di potere :",mes2:"Nessuna perdita dalle due parti",
  err1:"Nessun rapporto trovato",title1:"Riassunto dei rapporti d\'attacco",
  itemfind:"Oggetto trovato",report:"Rapporto",noitem:"Nessun oggetto trovato",BODelAllDF:"Elimina i rapporti interessati",
  title_popRapportDF:"Riassunto dei report",noresult:"Nessun risultato",nosubject:"Senza oggetto",
  result:"Risultato :",found:"Trovati :",
},
REASSIGN:{
Manu:'Manuale',
Auto:'Automatico',
Manual:{
title:'Riassegna truppe da una citta\' all\'altra',
},
Automatic:{
title:'RIASSEGNAZIONE AUTOMATICA - CONFIGURAZIONE',
AddRoute:'Aggiungi percoso',
From:'Dalla',
To:'Alla',
Delay:'Riassegna ogni',
Block:'Blocca i valori delle truppe',
Route:'Percosi',
},
},
marchs:{
 attackcol2:"Def",PR:"PR",
 targetTS:"TS",
 unknow:"Sconosciuto",
 nomarch:"Nessuna marcia in corso...",level:"Liv",knight:"Cav",
 tot:"TOTALE",mycity:"La mia citta\'",citylevel:"Citta\' Liv",barblevel:"Barb Liv",folevel:"FS Liv",boglevel:"Citta\'/Barb Liv",
 title1:"Lista delle truppe inviate in rinforzo",
 title2:"Lista delle truppe in rinforzo nella vostra ambasciata",
 notroops:"Nessuna truppa in rinforzo attualmente.",
 refcol1:"Azioni",refcol2:"Coordinate",refcol3:"Inviato da",refcol5:"Manutenzione",foodh:"cibo / h",
 encRemaining:"Mostra le truppe originali",comment:"NOTA: E\' necessario aggiornare KoC per vedere nuovi rinforzi.",
 find:"Trovati:",nofind:"Non trovato",
},
Search:{
 PDetail:"Ricerca dettagli ...",Detail:"Dettagli:",between:"tra",and:"e",
 PLeaderboard:"Ricerca dalla classifica...",
 PLb2:"<B>Classifica:</b> Non trovata! (sotto le nebbie?)",
 ANothing:"Aucun",center:"Centre",cancel:"RICERCA ANNULLATA!",
 error:"ERRORE:",stop:"Ferma la ricerca",
 err1:"X doit &ecirc;tre entre 0 et 749",
 err2:"Y doit &ecirc;tre entre 0 et 749",
 err3:"La distance mini doit &ecirc;tre sup&eacute;rieur &agrave; 0",
 err4:"La distance maxi doit &ecirc;tre sup&eacute;rieur &agrave; 1",
 err5:"La distance max doit &ecirc;tre sup&eacute;rieur &agrave; la distance mini",
 err6:"La distance max ne peut d&eacute;passer 375 ! au risque de p&ecirc;ter votre navigateur",
 ShowHideOpts:"Mostra/Nascondi le opzioni (permette di vedere a pieno schermo)",
 minlevel:"Liv Min. :",maxlevel:"Liv Max. :",typewilderness:"Tipo TS ",filter:"Filtra ",orderby:"Trier par ",
 TS0:"Tutte le TS",TS1:"Solo libere",TS2:"Ostile",TS3:"Solo neutre",TS4:"Solo senza alleanza",
 coords:"Coords ",Cit0:"Tutte le citta\'",Cit1:"Solo ostile",Cit2:"Solo sotto la nebbia",Cit3:"Solo alleate",Cit4:"Solo amiche",Cit5:"Solo neutrali",Cit6:"Solo senza alleanza",
 distance:"Dist",level:"Liv",more:"Altre info",status:"Stato",connexion:"Connessione",
 notetable:"<FONT COLOR=#600000>NOTA: La tabella mostra solamente 500 dei",notetable1:"risultati. Li mostrera\' tutti appena finito.</font>",
 free:"Libera...",
 exportKOCattack:"Esporta i risultati",
 generateFSList:"Attacca",
 generateScoutList:"Lista di esplorazione",find:"Trovati:",
 numberCible:"Numero di bersagli ",send:"Inviato!",
 startattack:'Lancia',finishattack:"Finito!",sendto:"Inviato su ",waitPR:"In attesa del punto di raduno...",
 errFS1:"ERRORE: Nessuna coordinata selezionata",errFS2:"ERRORE: Coordinate invalide!",
 scoutTitle:"Opzioni di esplorazione automatica",
},
TRAIN:{
EndTime:'Ora di fine',
EndTimeBet:'Ora di fine tra',
},
KNIGHT:{
Title:'Gestione dei cavalieri',
Default:'Assegna per default',
Combat:'Assegna per combattimento',
Foreman:'Supervisore',
Marshall:'Maresciallo',
Alchemystic:'Alchimistico',
Steward:'Amministratore',
Role:'Ruolo',
SetPoints:'Assegnazione di',
SetPoints2:'punti abilita\'',
Done:'Fatto',
Assign:'Assegna un ruolo',
Increase:'Aumenta ESP',
Boost:'Aumenta la fedelta\' del 5% con l\'oro',

},
AUTOFO:{
Title:'ATTACCA IN AUTOMATICO LE FORESTE OSCURE',
Title2:'STATISTICHE DELLE FORESTE OSCURE',
Title3:'OPZIONI PER LE FORESTE OSCURE',
Management:'GESTIONE DELLE FORESTE',
Show:'Mostra',
Options:'Opzioni',
Interval:'Intervallo d\'attacco',
DistanceMax:'Distanza massima di ricerca',
Keep:'Tieni',
Point:'posto libero nel Luogo di Riunione',
ResearchEvery:'Ricerca ogni',
SkipCity:'Salta la citta\' dopo',
Attempts:'Tentativi',
Methode:'Metodo',
Methode1:'Distanza',
Methode2:'Livelli Alti',
Methode3:'Livelli Bassi',
MeKnight:'Proprieta\' del Cavaliere',
Prop1:'Punti di combattimento bassi',
Prop2:'Punti di combattimento alti',
ResetCounters:'Resetta i contatori',
Reset:'Resetta',
NoData:'Nessun Dato',
CancelByUser:'CANCELLATO DALL\'UTENTE',
Send:'Inviato',
Slots:'Slot del Luogo di Riunione non disponibili',
Knights:'Cavaliere non disponibile',
Attempt:'Tentativo',
TrafficError:'Errore di traffico',
PRError:'Errore Luogo di Riunione',
KnightError:'Errore Cavaliere',
MoreError:'Altro',
Bug:'Bug',
},
TRANSP:{
Manu:'Manuale',
Auto:'Automatico',
Appros:'Rifornimento',
Manual:{
Title:'Trasporta da una citta\' all\'altra',
From:'Da',
To:'A',
Amount:'Quantita\'',
ResTroops:'La quantita\' di risorse e\' il massimo delle truppe selezionate',
AmountRes:'Quantita\' delle risorse da trasportare',
Exceed:'L\'importo non puo\' superare',
ChoseRes:'Scegli un tipo di risorsa',
SameCity:'Impossibile trasportare sulla stessa citta\'',
ErrorTroops:'Impossibile trasportare con 0 truppe',
ErrorDest:'Impossibile trasportare alle coord 0,0',
TranspDone:'Trasporto effettuato',
ErrorTrasp:'Errore, per favore ricomincia',
Tentative2:'Tentativo tra 2 secondi',
},
Automatic:{
Title1:'TRASPORTO AUTOMATICO - CONFIGURAZIONE',
Title2:'OPZIONI',
Title3:'AGGIUNGI UN TRASPORTO',
Title4:'Trasporti automatici salvati',
TraspEvery:'Invia i trasporti ogni',
TraspIf:'Invia i trasporti con un minimo di',
ShowRoute:'Mostra trasporti',
AddRoute:'Aggiungi trasporto',
TraspManu:'Trasporto Manuale',
From:'Da',
To:'Verso',
TroopsNeeded:'Truppe necessarie',
Keep:'Tieni',
PointFull:'Luogo di Riunione pieno',
Active:'Attivo',
Deactive:'Disattivato',
},
Appro:{
From:'Da',
To:'Verso',
Of:'Di',
Title1:'RIFORNIMENTO AUTOMATICO - CONFIGURAZIONE',
Title2:'CONFIGURA LA TUA CITTA\'',
CityProv:'Citta\' di rifornimento',
ValuesAuto:'Valori AUTOMATICI',
CulTime:'Questo tempo viene ricalcolato solo ad ogni apertura del KoC BoTTols Original! E\' definito dal tempo maggiore tra la sede centrale e le citta\' secondarie + 10 minuti',
Interval:'Intervallo automatico',
MinKeep:'Minimo da TENERE',
Explanation:'<u><b>Istruzioni:</b></u><br>1. Scegli il tuo bunker (dove vuoi inviare le risorse)<br>2. Clicca su valori AUTOMATICI: Assicurati che il trasporto automatico sia configurato<br>2. Inserisci la quantita\' di risorse da tenere sulle vostre citta\' secondarie (ad esempio 5kk di minerali e 5kk di pietra)<br>3. Se l\'intervallo e\' pari a 0, aggiorna premendo F5<br>4. Clicca su Rifornimento per Attivare!',
LowRes:'Risorse insufficienti',
},
},
AUTOTRAIN:{
Options:'Opzioni',
Interval:'Intervallo',
Refresh:'Aggiornare per applicare le modifiche',
Pop:'Percentuale della popolazione (totale) predefinita per calcolare le',
BuildDefenses:'Costruzione automatica di una difesa per raggiungere un massimo di 5',
AutoDeleteT:'Cancellazione automatica delle code di addestramento in corso ',
DeleteT:'Cancella code in corso',
Recalculate:'Ricalcola tutto',
DelProgress:'Cancellazione in corso',
Finished:'Finito... Aggiornare il gioco e iniziare l\'addestramento',
Again:'Perfavore ricomincia',
ImpDelete:'Impossibile annullare l\'addestramento...<br>Aggiornare il gioco e ricominciare',
ErrorPopRes:'Popolazione o Risorsa - Potrebbe essere',
ErrorPop:'Risorse - Potrebbe essere', 
},
crest:{
 title:"AUTO CREST - ELMI / BARBARI",
  help:"Aiuto",target:"Mostra Onde",interval:"Intervallo d\'attacco:",
  sendrpt:"Invia un resoconto ogni ",keep:"Tieni",keep2:"posto libero nel Luogo di Riunione",
  add:"Aggiungi Onda",
  helpTitle:"Aiuto sull\'attacco alle terre selvagge - Elmi",
  helpText:"<BR>L\'onglet ARMOIRIES est fait pour attaquer continuellement et automatiquement une Terre sauvage.<BR>\
        Cela attaque en 2 vague, abandonne la terre si n&eacute;cessaire et recommence.<BR>\
        V&eacute;rifier que vous avez 1 place de libre dans votre chateau pour une terre sauvage &agrave; conquerir.<BR>\
        Remplisser les coordonnees d\'une Terre Sauvage et les troupes et appuyer sur ON !.<BR><BR>\
        Nombre de troupes (KOC WIKI):<BR>\
        <A target=_tab href=http://koc.wikia.com/wiki/Wilderness>Plus d\'informations sur Koc Wikia</a>\
        <TABLE width=100%><TR><TD>Livello</td><TD>Onda 1</td><TD>Onda 2</td><TD>Perdite</td><TD>Emp. Min</td></tr>\
        <TR><TD>1</td><TD>n/a</td><TD>160 MM</td><TD>12 MM</td><TD>0</td></tr>\
        <TR><TD>1</td><TD>n/a</td><TD>80 archers</td><TD>Aucune</td><TD>1+</td></tr>\
        <TR><TD>2</td><TD>5 MM</td><TD>130 archers</td><TD>1ere Vague</td><TD>2+</td></tr>\
        <TR><TD>3</td><TD>10 MM</td><TD>520 archers</td><TD>1ere Vague</td><TD>3+</td></tr>\
        <TR><TD>4</td><TD>20 MM</td><TD>1600 archers</td><TD>1ere Vague</td><TD>4+</td></tr>\
        <TR><TD>5</td><TD>50 MM</td><TD>2200 archers</td><TD>1ere Vague</td><TD>6+</td></tr>\
        <TR><TD>6</td><TD>100 MM</td><TD>3000 archers</td><TD>1ere Vague</td><TD>7+</td></tr>\
        <TR><TD>7</td><TD>150 MM</td><TD>6000 archers</td><TD>1ere Vague</td><TD>8+</td></tr>\
        <TR><TD>8</td><TD>299 MM + 1Bal</td><TD>9000 archers + 900 Bal</td><TD>1ere Vague + 1 Archer</td><TD>9+</td></tr>\
        <TR><TD>9</td><TD>599 MM + 1Bal</td><TD>13000 archers + 900 Bal</td><TD>1ere Vague + 2 Archer</td><TD>10</td></tr>\
        <TR><TD>10</td><TD>1199 MM + 1Cat</td><TD>35000 archers + 2500 Cat</td><TD>1ere Vague + 6 Archer + 50 Cat</td><TD>10</td></tr></table><br><br>",
 nolocation:"Nessuna coordinata inserita!",popCrest:"Onde d\'attacco salvate",
 actif:"Attiva",inactif:"Disattiva",wave:"Onda",
 msg1:"Items Stats:",msg2:"Items Gained",msg3:"Durata:",msg4:"Total Items gained:",msg5:"Numbers of 1st Wave send:",msg6:"Numbers of 2nd Wave send:",msg7:"Rapporto Crest",
        
},
Options:{
welcome:"Benvenuto su",
conf:"Configurazione",
Langue:"Lingua",
PostUpdateText:'Posta in chat alleanza gli aggiornamenti del '+ScriptNameS,
MoveW:"Muovi la finestra con il mouse",
Transp:"Finestra trasparente",
reload:"Aggiorna KoC ogni",
prodshort:"Riduci la visualizzazione delle risorse",
WideScreen:"Attiva schermo allargato",
TchatR:"Metti la chat a destra",
Hauteur:"Altezza del Tools :",
WideMap:"Allarga la mappa",
moremap:"Aggiungi altre informazioni sulla mappa",
horlGMT:"Togli l\'ora di KoC",
Watchdog:"Aggiorna KoC se non carica entro 1 minuto",
autoPublishGamePopups:"Pubblica automaticamente su Facebook (Tutti i domini)",
NewTab:"Attiva la Tab personalizzata",
confres:"Configurazione Tab Panorama :",
ShowTroops:"Mostra le truppe",
ShowDefense:"Mostra le difese",
ShowRes:"Mostra le scorte delle risorse",
ShowPop:"Mostra le informazioni sulla popolazione",
ShowProduction:"Mostra la produzione delle risorse",
includeMarching:"Includi le truppe in marcia",
EnableFormation:"Includi le truppe in addestramento",
foodWarm:"Mostra l\'autonomia in rosso del cibo se non basta per ",
confchat:"Configurazione della chat :",
FoodWarnTchat:"Pubblica in chat in caso di mancanza del cibo",
HelReq:"Aiuta automaticamente sulle costruzioni/ricerche dei tuoi membri",
DelReq:"Nascondi automaticamente gli aiuti di costruzioni/ricerche",
DelRules:"Nascondi le regole della chat",
ChatStuff:"Attiva miglioramenti in chat (coord cliccabili, colori diversi . . .)",
WhisperOn:"Audio sul bisbiglio",
WhisperOnRed:"Mostra in rosso il bisbiglio",
EclaireurOn:"Attiva audio in caso di ESPLORAZIONE (Alleanza)",
AttaqueOn:"Attiva audio in caso di ATTACCO (Alleanza)",
StopRaidMes:'Ferma crest se un tuo alleato viene attacco (Questo per non intasare i report)',
Smiley:"Attiva le faccine",
ChatLeader:"Attiva i colori dei Leaders",
ChatColor:"Colori della chat :",
ChatGlo:"Sfondo della chat globale :",
user_icon:"Cambia avatar in caso di attacco",
iconinfo:"<br>>> Requisiti immagine : 25px per 25px - <i>Attenzione : e\' visibile solo a voi</i>",
confrpt:"Configurazione dei rapporti KoC :",
AllRpts:"Migliora i rapporti dell\'alleanza",
AllMembers:"Migliora i giocatori dell\'alleanza",
deleterpt:"Elimina i rapporti :",
intervrpt:"Intervallo :",
confdiv:"Altre configurazioni:",
alertHQ:"Il mio bunker :",
SelQG:"Seleziona automaticamente la citta\' in occasione dell\'apertura del gioco",
GoldEnable:"Raccolta automatica di oro quando la felicita\' e\' maggiore di",
AttackPicker:"Attiva la selezione rapida delle citta\' (rinforza, riassegna e trasporta)",
EnhanceMsging:"Migliorare la gestione dei messaggi (Campo CC)",
CoordBoX:'Muovi l\'inserimento delle coordinate sopra la chat',
conftower:"Configurazione della Torre di Allerta :",
alertEnable:"Attiva la Torre",
SoundEnable:"Attiva il suono in caso di Attacco/Spiata",
Loadingswf:"Caricamento di Flash Player",
soundFile:"File :",
SoundLoad:"Carico",
volume:"Volume :",
SoundStop:"Ferma",
soundLength:"Suona per",
SoundRepeat:"Ripeti",
postAlert:"Posta il messaggio :",
alertPrefix:"Messaggio aggiuntivo :",
alertSendToAlly:"Chat Alleanza",
alertSendAsWhisper:"Bisbiglio a me",
alertWild:"Avvisa in caso di : ",
alertTroops:"Minimo di truppe : <br><i>(Messaggio in chat)",
alertDefend:"Mostra se difendo o meno : ",
alertEmpennage:"Mostra il mio piumaggio :",
alertMarechal:"Mostra il livello del mio maresciallo (senza boost) :",
alertShow:"Mostra :",
alertFood:"Consumo di cibo :",
alertQG:"Disattiva il bunker :",
alertraid:"Ferma quando ricevi un attacco :",
alertSendEmail:"Invia email :",
defBoost:"Stato della difesa (Santuario/Difesa)",
alertMytroops:"Mie truppe",
alertEmbassy:"Truppe alleate accampate",
ResetALL:"Resetta TUTTE le opzioni",
alertDefense:"Mie difese",
CResetALL:"Resetta i colori",
RptGift:"Attiva l\'auto eliminazione dei regali",
toyou:'Verso voi',
you:'Tue',
received:'Ricevute',
ShowThrone:'Mostra le carte del tuo trono ATTIVE',
AutoWall:{
TitleBunk:'PROTEZIONE BUNKER',
Note:'Nella citta\' BUNKER NON ci devono essere raid e/o altre marce',
EnableBunker:'Abilita l\'utilizzo di un Portale del Rifugio in caso di ESPLORAZIONE/ATTACCO al bunker',
EnableBunkerA:'Sposta il bunker dopo',
EnableBunkerB:'attacchi/esplorazioni',
EnableFog:'Inoltre attiva nebbie',
Title:'AUTO MURO',
Rischio:'Non ci riteniamo responsabili dell\'uso che ne viene fatto o delle conseguenze di questa funzione',
Preset:'In caso di Esplorazione attiva la sala del trono',
Esplo:'Mura in caso di esplorazione',
ShowTroops:'Metti fuori le truppe quando mancano',
NoteShowTroops:'se non selezioni niente, le fa uscire subito',
RangeM1:'Controllo range - Non esporre le truppe se:',
RangeMod1:'L\'attaccante ha il range superiore o uguale al tuo',
RangeMod2:'Se l\'attaccante ha piu\' di',
RangeM2:'Ricontrolla il range ',
RangeM21:'secondi prima che arrivi l\'esplorazione',
PotereM1:'Non mettere fuori le truppe se il potere dell\'attaccante e\' uguale o maggiore del tuo',
},
},
SEARCH:{
all:'Tutti i',
filtre:'Filtro',
sort:'Ordina per',
found:'Trovati',
only:'Solo',
type:'Tipo',
onlyfree:'Solo libere',
},
Apothecary:{
 label:"FARMACIA",
 power:"GUARIGIONE",
 show:"Code",
 options:"OPZIONI",
 gold:"Tieni oro:",
 add:'Aggiungi',
 stat:'TRUPPE IN ATTESA',
 detail:'Lista di truppe in attesa',
 edit:'Modifica',
 delete:'Elimina',
},
AUTOSCOUT:{
title:'AUTO-ESPLORAZIONE DI UN\'ALLEANZA',
interval:'Intervallo',
NumSp:'Quantita\' di esploratori',
NotReady:'Non pronto',
SearchComplete:'La ricerca e\' stata completata',
Cityto:'Citta\' da esplorare',
InMist:'In nebbia',
Find:'Trovati',
ScoutSent:'Esploratore inviato da',
On:'Su',
SendFail:'Errore invio da',
Restriction:'Restrizione',
},
build:{
 buttonlabel:"Costruzione",biglabel:"AutoCostruzione",
 title:"AUTO-COSTRUZIONE - CONFIGURAZIONE",
 modebuild:"Mod Costruzione", title2:"COSTRUZIONE IN CORSO",
 ec:"Ec:",titleec:"In costruzione",
 err1:"Errore per la distruzione!",err2:"Risorse insufficienti!!",err3:"Distruzione in coda!",
 err4:"Le costruzioni di livello 10+ devono essere fatte manualmente.",autoclose:"Chiusura automatica in 10 secondi...",
 optimize:"Riordina per tempo", queue:"Coda di",
},
autoCraft:{
 title:"AUTO-CRAFTING - CONFIGURAZIONE",
 stat:"STATISTICHE",title2:"OPZIONI - DEFINIRE GLI OGGETTI DA CREARE",
 col:"Oggetto",col1:"Quantita\' da creare",tot:"Totale",
 notes:"<i><u>Nota :</u> Avere un minimo di 5 000 Pietra Etera</u></i> - <i>(*) Aggiornare il gioco dopo le impostazioni.</i>",
},
PROD:{
title:'INVENTARIO E SCORTE',
},
RAID:{
 conf:"CONFIGURAZIONE",
 stop:"Ferma tutto",
 resume:"Riprendi tutto",
 delete:"Elimina tutto",
 sendReport:"Invia un rapporto sui raid ogni",
 timer:"Tempo RAID",
 nothing:"Nessun raid nella citta\'",
 marches:"MARCE ATTIVE",
 memory:"SALVATAGGIO",
 nothingmemory:"Nessun raid salvato su questa citta\'",
 ResetTimer:'Timer RAID resettato su'
},
SMYLE:{
chat:'Faccine',
title:'Le faccine',
},
Food:{
 need:'ha bisogno di',
 rem:'Ne rimane ancora',
 prod:'Produzione',
},
AUTOTRONE:{
 label:"AutoTrone",
 Autosalvage:"Elimina",
 AutoRepair:"Ripara",
  AutoRepair:"AutoRepair",
 Upgrade:"Upgrade/Enhance",
 Stats:"Statistiche",
 quality:"Qualita\'",
 level:"Livello",
 Equiper:"Equipaggia",
 history:"Storia",
 effet:'Effetto',
 autosalvage:{
  title:"AUTO-SALVAGE : CANCELLA GLI OGGETTI DEL TRONO",
  titleeffet:"LISTA DI OGGETTI DA TENERE",
  Save:'Tieni i primi',
  items:'oggetti',
  SalvageQuality:"CONSERVA GLI OGGETTI che hanno una qualita\'",
  SalvageQuality2:"o superiore",
  RangeSaveMode:"CONSERVA GLI OGGETTI con ",
  RangeSaveMode2:"",
  BOSType:"Tipi di oggetti da conservare:",
  SalvageKeepEffects1:'almeno 1 dei 3 effetti finali',
  SalvageKeepEffects2:'almeno 1 dei 2 effetti finali',
  SalvageKeepEffects3:'almeno l\'ultimo effetto finale',
  SalvageKeepEffects4:'almeno gli ultimi 2 effetti',
  SalvageKeepEffects5:'almeno gli ultimi 3 effetti',
  alert:"<u>Non verranno cancellati:</u><br>Gli oggetti equipaggiati, rotti o con un livello superiore a 0",
  col1:"Effetti da conservare",
  col2:"Famiglia",
  popHistory:"Lista degli oggetti automaticamente eliminati - (Famiglia d'effetto tra parantesi)",
  popCell0:"Ora",
  popCell2:"Azione",
  titlelive:"ANTEPRIMA DELLE VOCI CHE SARANNO RIMOSSI",
  refresh:"AGGIORNA",
  nodelitem:"Nessun oggetto da eliminare.",
  actionlog1:"Nessun oggetto da rimuovere - aspetto ",
  actionlog2:"Cancellati ",
  Salvagelog1:"Echec Salvage :(",
 },
 upgrade:{
  title:"AUTO UPGRADE/ENHANCE/REPAIR",
  title2:"PROGRAMMA LA CODA DI ATTESA",
  items:"Lista degli oggetti: ",
  title3:"STATO E INFORMAZIONI",
  title4:"CODA DI ATTESA",
  noitem:"Nessun oggetto in coda!",
  waiting:"In attesa...",
  retry:"Tentativi: ",
  trying:"Cerco di",
  good:"Good requests: ",
  bad:"Bad requests: ",
  off:"Auto Upgrade/Enhance/Repair e\' SPENTO.",
  nothing:"Nessun oggetto in coda!",
  letsgo:"Inizio dell\'oggetto seguente...",
  upgrade10:"Impossibile effettuare l'upgrade superiore a 10 !",
  enhance5:"Impossibile fare una qualita\' al di sopra di superba (5) !",
  popHistory:"Lista degli oggetti -Upgrade/Enhance- riusciti",
  popCell0:"Tempo",popCell1:"Nome",popCell2:"Azione",popCell3:"Tent.",popCell4:"Good Req.",popCell5:"Bad Req.",
  notenough:"Pietra Etera non sufficiente per",
  mptitleenhance:"ENHANCE RIUSCITO ",
  mptitleupgrade:"UPGRADE RIUSCITO ",
  fail:"Fallito",
  repairing:"Riparazione : ",
  timeleft:"Tempo rimanente : ",
  paintCol1:"Incorso",
  paintCol2:"Prossimo",
  bonexttries:"Numero di tentativi :",
  bonexttries1:"<i>(Poi passa all\'oggetto seguente)</i>",
  last:"Porta alla fine",
 },
 equip:{
  title:"EQUIPAGGIA GLI OGGETTI DEL TRONO",
  equip:"Equipaggia",
  deequip:"Disequipaggia",
  preset:"Pre-set:",
  noitem:"Nessun ",
  itemavai:"disponibile :(",
  itemequip:"equipaggiato!!!",
  preset2:"Pre-Set attualmente equipaggiato:",
  title2:"ORGANIZZAZIONE DELLE CARTE",
 },
 stats:{
  title:"SALA DEL TRONO - STATISTICHE", 
 },
 repair:{
  err1:"Impossibile! Si prega di togliere l\'auto riparazione.",
  err2:"Impossibile! SI prega di togliere l\'auto upgrade/enhance.",
  repairing:"Riparazione in attesa...",
  title:"SOLO AUTO RIPARAZIONE",
  title2:"<i>Ripara automaticamente gli oggetti rotti.</i>",
  title3:"<i><font color=red>NON E\' POSSIBILE UTILIZZARLA CON L'\AUTO UPGRADE / ENHANCE</font></i>",
  repairon:"Auto Riparazione = ON",
  repairoff:"Auto Riparazione = OFF",
 },
 },
}
}
var lang=culang[Options.Langue];
/** END MULTI **/
var avatars = {};
eval(GM_getResourceText("avatars"));
var Smileys = {};
eval(GM_getResourceText("smileys"));
var nHtml={FindByXPath:function(a,b,c){if(!c){c=XPathResult.FIRST_ORDERED_NODE_TYPE}try{var d=document.evaluate(b,a,null,c,null)}catch(e){GM_log("bad xpath:"+b)}if(c==XPathResult.FIRST_ORDERED_NODE_TYPE){if(d&&d.singleNodeValue){return d.singleNodeValue}}else{if(d){return d}}return null},ClickWin:function(a,b,c){var d=a.document.createEvent("MouseEvents");d.initMouseEvent(c,true,true,a,0,0,0,0,0,false,false,false,false,0,null);return!b.dispatchEvent(d)},Click:function(a){return this.ClickWin(window,a,"click")},ClickTimeout:function(a,b){window.setTimeout(function(){return nHtml.ClickWin(window,a,"click")},b+Math.floor(Math.random()*500))},SetSelect:function(a,b){for(var c=0;c<a.options.length;c++){if(b==a.options[c].value){a.options[c].selected=true;return true}}return false}}
function ById(id) {return document.getElementById(id);}
if (document.URL.search(/facebook.com\/4oh4.php/i) >= 0){
 setTimeout(function() {
   unsafeWindow.history.go(-1);
 },5000); 
 return;
}

if (document.URL.search(/kingdomsofcamelot.com\/fb\/e2\/fbLoginButton.php/i) >= 0){
 var test=document.URL;
 var testt = /s=([0-9]+)&/i.exec(test);
 if (testt) {
  setTimeout(function() {
  unsafeWindow.kraken.network.redirect("https://www.kabam.com/kingdoms-of-camelot/game.php?entrypt=kabamHome&lp=index&cb=moar&s="+testt[1]);  
  },5000);
 } 
 return;
}


if (document.URL.search(/kingdomsofcamelot.com\/fb\/e2\/src\/helpFriend_src.php/i) >= 0){ helpFriends (); return true;}
readGlobalOptions ();

if (document.URL.search(/apps.facebook.com\/kingdomsofcamelot/i) >= 0){
  setInterval(function() {
    var test=document.URL;
    var testt = /s=([0-9]+)/i.exec(test);
    if (testt) {
     unsafeWindow.window.document.title="KoC "+testt[1]+" (by "+Autore+")";
    }
    }, 10)
  facebookInstance ();
  return;
}
if (document.URL.search(/kabam.com\/kingdoms-of-camelot\/play/i) >= 0){
  setInterval(function() {
    var test=document.URL;
    var testt = /s=([0-9]+)/i.exec(test);
    if (testt) {
     unsafeWindow.window.document.title="Kabam.com "+testt[1]+" (by "+Autore+")";
    }
    }, 10)
  kabamStandAlone ();
  return;
}

if (document.URL.search(/facebook.com/i) >= 0){
	if(document.URL.search(/connect\/uiserver.php/i) >= 0 ||
	   document.URL.search(/serverfbml/i) >= 0 ||
	   document.URL.search(/dialog\/stream.publish/i) >= 0 ||
	   document.URL.search(/dialog\/apprequests/i) >= 0 ||
	   document.URL.search(/dialog\/feed/i) >= 0)
		HandlePublishPopup ();
  return;
}
if (document.URL.search(/kingdomsofcamelot.com/i) >= 0){

  kocWideScreen ();
}


function helpFriends(){function a(){var b=ById("claimhelpform");if(!b){setTimeout(a,1e3)}b.submit()}a()}

function readGlobalOptions (){ GlobalOptions = JSON2.parse (loadValue ('Options_??', '{}'));}
function kocWideScreen(){
  var fois=0;
  function setWideFb (){
	var kocFrame = parent.document.getElementById('kocIframes1');
	if (!kocFrame){
	  setTimeout (setWideFb, 1000);
	  return;
	}
	kocFrame.style.width = '100%';
	var style = document.createElement('style')
	style.innerHTML = 'body {margin:0; width:100%; !important;}';
	kocFrame.parentNode.appendChild(style);
	

  }
  function test() {
  	var alla = ById('kocinitloading');
  	if (alla) {
  	 if (alla.style.display!="none") {
  	  fois++;
  	  if (fois>23)  reloadKOC();
  	  setTimeout (test, 2500);
  	  return;
  	 }
	}
  
  }
  if(document.URL.match(/standalone=0/i)){
	  
	  test();
	  }
	  kocWatchdog ();
	  if (GlobalOptions.pbWideScreen)
			setWideFb();
  
}

function kabamStandAlone  (){
  function setWide (){
	var iFrames = ById('game_frame');
	if (!iFrames){
	  setTimeout (setWide, 1000);
	  return;
	}
	iFrames.style.width = '100%';
	while ( (iFrames=iFrames.parentNode) != null)
	  if (iFrames.tagName=='DIV')
		iFrames.style.width = '100%';
		
	//ById("main-nav").parentNode.removeChild(ById("main-nav"));
    //ById("main-header").parentNode.removeChild(ById("main-header"));
  }
  if (GlobalOptions.pbWideScreen)
    setWide();
}
function facebookInstance(){function a(){var b=ById("iframe_canvas");if(!b){setTimeout(a,1e3);return}b.style.width="100%";while((b=b.parentNode)!=null)if(b.tagName=="DIV")b.style.width="100%";ById("globalContainer").style.left="0px";try{ById("rightCol").parentNode.removeChild(ById("rightCol"));ById("leftColContainer").parentNode.removeChild(ById("leftColContainer"))}catch(c){}
var c=ById("mainContainer");
if(c){if(GlobalOptions.pbWideScreenStyle=="normal")
c.parentNode.style.minWidth="100%";
	var pied = document.getElementById('pagelet_canvas_footer_content');
	if(pied) { pied.parentNode.removeChild(pied); }
if(GlobalOptions.pbWideScreenStyle=="wide")c.parentNode.style.width="1520px";if(GlobalOptions.pbWideScreenStyle=="ultra")c.parentNode.style.width="2000px";for(i=0;i<c.childNodes.length;i++){if(c.childNodes[i].id=="contentCol"){c.childNodes[i].style.margin="0px";c.childNodes[i].style.paddingTop="0px";break}}}var c=ById("pageHead");if(c){c.style.width="80%";c.style.margin="0 10%"}var c=ById("bottomContent");if(c){c.style.padding="0px 0px 12px 0px"}}facebookWatchdog();if(GlobalOptions.pbWideScreen)a()}
function HandlePublishPopup() {
 if(GlobalOptions.autoPublishGamePopups){
		var FBInputForm = document.getElementById('uiserver_form');
		if(FBInputForm){
			var channel_input = nHtml.FindByXPath(FBInputForm,".//input[contains(@name,'channel')]");
			
			if(channel_input){
				var current_channel_url = channel_input.value;
					var publish_button = nHtml.FindByXPath(FBInputForm,".//input[@type='submit' and contains(@name,'publish')]");
					
					var test =ById("feedform_user_message");

					
					if(publish_button && test){ 
						setTimeout(function() {
						 nHtml.Click(publish_button);
						},2500);
					}
			}		
		}
    setTimeout(HandlePublishPopup, 5000);
   }
 
}
function facebookWatchdog(){function b(){try{if(ById("app_content_130402594779")==null){logit("KOC NOT FOUND!");KOCnotFound(5*60)}}catch(a){logit("KOC NOT FOUND!");KOCnotFound(4*60)}}var a=5e4;if(!GlobalOptions.pbWatchdog)return;setTimeout(b,a)}
function kocWatchdog(){function b(){if(ById("mod_maparea")==null){logit("KOC not loaded");KOCnotFound(20)}}var a=1e4;if(!GlobalOptions.pbWatchdog)return;setTimeout(b,a)}



var Cities = {};
var Seed = unsafeWindow.seed;
var uW = unsafeWindow;
var Tabs = {};
var my = {};
var myBO = {};
var researchLevels = [];
var crestname = {};
var CPopUpTopClass = 'pbPopTop';
var mainPop, mainPop2;
var ResetColors = false;
var Tabs2=[["Attaque",lang.StatLabelAttaque],["Trone",lang.StatLabelTrone],["Tournoi",lang.StatLabelTournoi],["Overview",lang.StatLabelOverview],["Resources",lang.StatLabelResources],["Spam",lang.StatLabelSpam],["Stock",lang.StatLabelInventaire],["Info",lang.StatLabelInfo],["Alliance",lang.StatLabelAlliance],["Gift",lang.StatLabelGift],["Test",lang.StatLabelTest],["ActionLog",lang.StatLabelLogs]]
var BOStartupTimer = null;
ptStartupErrorTimer = null;
var currentName2 = 'Attaque';
var myServerId = null;
function getServerId(){if(myServerId==null){var a=/^[a-zA-Z]+([0-9]+)\./.exec(document.location.hostname);if(a)myServerId=a[1];else myServerId="??"}return myServerId}
var tileNames = [];

function ptStartup (){
  clearTimeout (BOStartupTimer);
  if (unsafeWindow.BOLoaded)
    return;   
  var metc = getClientCoords(ById('main_engagement_tabs'));
  if (metc.width==null || metc.width==0){
    BOStartupTimer = setTimeout (ptStartup, 1000);
    return;
  }
  unsafeWindow.BOLoaded = Version;
  readOptions();
  readColors();  
  Seed = unsafeWindow.seed;
  tileNames = [uW.g_js_strings.commonstr.barbarians, uW.g_js_strings.commonstr.grassland, uW.g_js_strings.commonstr.lake, uW.g_js_strings.commonstr.woods, uW.g_js_strings.commonstr.hills, uW.g_js_strings.commonstr.mountain, uW.g_js_strings.commonstr.plain, uW.g_js_strings.commonstr.city, uW.g_js_strings.commonstr.bog, uW.g_js_strings.commonstr.darkForest];
  
  
  
  
var styles = '.xtab {padding-right: 5px; border:none; background:none; white-space:nowrap;}\
.tourny_list_table { padding: 10px; -moz-border-radius:5px; border:2px solid #000000; }\
    .hostile td { background:crimson; }.amicale td{background:lightblue; }.allie td{background:royalblue; }\
    .neutre td { background:lightgreen; }.unaligned td { background:gold; }\
    .xtabBR {padding-right: 5px; border:none; background:none;}\
    .boAide {height:20px;font-size:9px;font-weight:bold;}\
    div.ptDiv {background-color:none;}\
    table.ptTab tr td {border:none; background:none; white-space:nowrap;}\
    table.ptTabPad tr td {border:none; background:none; white-space:nowrap; padding: 2px 4px 2px 8px;}\
    table.ptTabBR tr td {border:none; background:none;}\
    table.pbTabLined tr td {border:1px none none solid none; padding: 2px 5px; white-space:nowrap;}\
    table.ptTabPad tr td.ptentry {background-color:#ffeecc; padding-left: 8px;}\
    table.ptTabOverview tr td {border-left:1px solid #ccc; white-space:nowrap; padding: 1px;   font-size:11px;}\
    table.ptNoPad tr td {border:none; background:none; white-space:nowrap; padding:0px}\
    .boStat {border:1px solid; border-color:#000000; font-weight:bold; padding-top:2px; padding-bottom:2px; text-align:center; color:#ffffff ; background-color:#357;  -moz-border-radius:5px;}\
    .ptOddrow {background-color:#eee}\
    .boStat {border: 0.5px solid #ffffff; -moz-border-radius:2px; -moz-box-shadow: inset 0px 0px 3px #ffffff; font-weight:bold; padding-top:2px; padding-bottom:2px; text-align:center; color:#ffffff;	background-color:#262}\
    .ptStatLight {color:#ddd}\
    .ptentry {padding: 7px; border:1px solid; border-color:#000000; background-color:#ffeecc; white-space:nowrap;}\
    .ptErrText {font-weight:bold; color:#600000}\
    .castleBut {outline:0px; margin-left:0px; margin-right:0px; width:24px; height:26px; font-size:12px; font-weight:bold;}\
    .castleBut:hover {border-size:3px; border-color:#000;}\
    	button::-moz-focus-inner, input[type="submit"]::-moz-focus-inner { color:#FFFFFF; border: none; -moz-border-radius:5px; }\
    	input[type="text"] { padding: 1px; border: 0.5px inset #141516;  -moz-border-radius:5px; }\
    	input[type="button"],input[type="submit"] { border: 1px outset #141516;  -moz-border-radius:3px; }\
	input[type="submit"]:hover,input[type="button"]:hover  { color: #600000; background-color:#FFFFFF; }\
    .ptChatWhisper {}\
    .ptChatWhisperRed {color: #FF0000;}\
    .ptChatAttack {color: #000; font-weight:bold; background-color: '+Colors.ChatAtt+'; }\
    .ptChatScout {color: #000; font-weight:bold; background-color: '+Colors.ChatEcl+'; }\
    .ptChatAlliance {}\
    .ptChatGlobal {background-color: #fdd}\
    .ptChatIcon {border: 0px inset black}\
    .ptChatScripter {font-weight:bold;}\
    .ptChatCHAN {color:#000; background-color:'+Colors.ChatChancy+';}\
    .ptChatVICE {color:#000; background-color:'+Colors.ChatVC+';}\
    .ptChatOFFI {color:#000; background-color:'+Colors.ChatLeaders+';}\
    input.BODefButOff {cursor:pointer; border:1px solid #45d183; -moz-box-shadow:inset 0px 1px 5px #3aef8b; -moz-border-radius:5px;}\
    input.BODefButOn {cursor:pointer; border:1px solid #f61646; -moz-box-shadow:inset 0px 1px 5px #f6375f; -moz-border-radius:5px;}\
    span.whiteOnRed {padding-left:3px; padding-right:3px; background-color:#700; color:white; font-weight:bold}\
    span.boldRed {color:#800; font-weight:bold}\
    span.oohfancy {color:#0000; font-weight:bold;text-shadow: 1px 1px 1px #AAA; font-variant:small-caps; text-align:center}\
    span.oohfancyi {color:#0000; font-style:italic;text-shadow: 1px 1px 1px #AAA; font-variant:small-caps; text-align:center}\
    .emoicon {width:19px !important;height:19px !important;float:none !important;}\
    .castleButNon {background-image:url("'+ URL_CASTLE_BUT +'")}\
    .castleButSel {background-image:url("'+ URL_CASTLE_BUT_SEL +'")}\
    span.boldDarkRed {color:#600; font-weight:bold}\
    a.ptButton20 {color:#ffff80}\
    input.bopbSubtab {cursor:pointer; width:10em; margin-right:15px;}\
    input.bopbSubtabSel {background-color:#444444; color:white; font-weight:bold; cursor:none !important}\
    matTab {}\
   .matTabNotSel { padding:0 0 0 20px;  color : #2F230E; font: bold 11px Georgia; white-space: nowrap; cursur:pointer; padding:0px;height: 17px; }\
   .matTabNotSel span { color : #2F230E; background: url("http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/nav/tab_unselected.png") no-repeat scroll left 0 transparent; display: inline-block;  height: 16px;    padding: 1px 2px 0 7px;    text-decoration: none;   }\
   .BOTabSel { color : #2F230E; font: bold 11px Georgia; white-space: nowrap; cursur:pointer; padding:0 0px 0 0;height: 17px;   }\
   .BOTabSel span { color : #2F230E; background: url("http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/nav/tab_selected.png") no-repeat scroll left top transparent; display: inline-block; width:74px;    height: 16px;    padding: 1px 2px 0 7px;    text-decoration: none;   }\
   .BOTabNotSel { padding:0 0 0 20px;  color : #2F230E; font: bold 11px Georgia; white-space: nowrap; cursur:pointer; padding:0px;height: 17px; }\
   .BOTabNotSel span { color : #2F230E; background: url("http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/nav/tab_unselected.png") no-repeat scroll left 0 transparent; display: inline-block; width:74px;   height: 16px;    padding: 1px 2px 0 7px;    text-decoration: none;   }\
   .matTabSel { color : #2F230E; font: bold 11px Georgia; white-space: nowrap; cursur:pointer; padding:0 0px 0 0;height: 17px;   }\
   .matTabSel span { color : #2F230E; background: url("http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/nav/tab_selected.png") no-repeat scroll left top transparent; display: inline-block;  height: 16px;    padding: 1px 2px 0 7px;    text-decoration: none;   }\
   tr.BOCPopupTop td { border:none; height: 15px;  padding:0px; }\
   .BOptretry_top { background-color:#a00; color:#fff; border:none; height: 21px; padding:0px; }\
   input.ptButCancel {background-color:#a00; font-weight:bold; color:#fff}\
   .BOCPopup .BOCPopMain {  opacity:0.9;-moz-box-shadow:inset 0px 0px 20px #006000; -moz-border-radius:3px; border:1px solid #141516; padding:3px; }\
   .idp_CPopup .idp2_CPopup { opacity:0.9; }\
   .trStat {border:1px solid; border-color:#000000; font-weight:bold; padding-top:2px; padding-bottom:2px; text-align:center; color:#ffffff ; background-color:#357;  -moz-border-radius:5px;}\
   table.trTabPad2 tr td { padding-left: 20px;}\
   table.trTab tr td {border:none; background:none; white-space:nowrap; padding:0px}\
   table.trTab#trDisplayTable tr th { border: 3px solid grey; font-size:1.5em;}\
   table.trStatTab tr td { background-color: #ffffff; white-space:nowrap; padding:5px; border-bottom:solid black 1px;}\
   table.trStatTab tr td:last-child { border-right:solid black 1px; }\
       table.trStatTab tr:first-child th { border-top:solid black 1px; }\
       table.trStatTab tr td.td1 { background-color: #eeeeee; }\
       table.trStatTab tr th {border:solid black 1px; border-top: none; background-color: #357; color: white; white-space:nowrap; padding:5px}\
       table.trStatTab tr:last-child td:first-child, table.trStatTab tr:last-child th:first-child { -moz-border-radius-bottomleft:10px; -webkit-border-bottom-left-radius:10px; border-bottom-left-radius:10px} \
       table.trStatTab tr:last-child td:last-child, table.trStatTab tr:last-child th:last-child { -moz-border-radius-bottomright:10px; -webkit-border-bottom-right-radius:10px; border-bottom-right-radius:10px} \
       table.trStatTab tr:first-child th:first-child { -moz-border-radius-topleft:10px; -webkit-border-top-left-radius:10px; border-top-left-radius:10px} \
       table.trStatTab tr:first-child th:last-child { -moz-border-radius-topright:10px; -webkit-border-top-right-radius:10px; border-top-right-radius:10px} \
 div.trCard div.description>div{width:70px;height:70px; }\
       div.trCard div.description div.briton.advisor{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/briton_advisor_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.briton.banner{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/briton_banner_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.briton.chair{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/briton_chair_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.briton.table{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/briton_table_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.briton.window{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/briton_window_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.briton.trophy{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/briton_trophy_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.druid.advisor{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/druid_advisor_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.druid.banner{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/druid_banner_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.druid.chair{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/druid_chair_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.druid.table{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/druid_table_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.druid.window{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/druid_window_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.druid.trophy{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/druid_trophy_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.fey.advisor{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/fey_advisor_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.fey.banner{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/fey_banner_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.fey.chair{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/fey_chair_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.fey.table{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/fey_table_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.fey.window{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/fey_window_normal_1.png") top left no-repeat;}\
       div.trCard div.description div.fey.trophy{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/70/fey_trophy_normal_1.png") top left no-repeat;}\
       div.trCard{font:bold 10px Georiga;overflow:hidden;}\
       div.trCard>div{float:left;border:1px solid #a56631;margin:3px;padding:3px;width:200px;background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/modal/modal_med_bg_4.png") -200px 0 no-repeat;}\
       div.trCard div.title{font:bold 14px Georgia;border-bottom:1px solid #703200;padding:4px 3px 5px 8px;background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/panel/modal/item_bg.png") -20px -100px no-repeat;}\
       div.trCard div.title span.icon{background:transparent url("http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/modal/equip.png") top right no-repeat;display:block;height:20px;width:20px;top:12px;right:12px;position:absolute;}\
       div.trCard .disabled{opacity:.5;}\   div.trCard ul{margin:3px 0;padding:0;list-style:none;}\
       div.trCard li{padding:3px 0 0 5px;color:#3f2300;font-weight:bold;font-size:14px;}\
       div.trCard div.description{overflow:hidden;border-bottom:1px solid #703200;padding:5px 0;}\
       div.trCard div.description div.portrait{float:left;}\
       div.trCard div.description div.portrait{border:3px solid #deaf69;margin-right:10px;}\
       div.trCard div.description>ul{float:left;margin:3px 0 0 0;padding:0;}\
       div.trCard div.description>ul li{padding:0;font-weight:bold;font-size:11px;text-transform:capitalize;}\
	div.indent25 {padding-left:25px}';
 
  setCities();
  readCrestData();
  readAttackOptions();
  readTrainingOptions();
  readFarmOptions();
  readApothecaryOptions();
  readAutoWall();
  readThroneOptions();
  if (Options.ptWinPos==null || Options.ptWinPos.x==null|| Options.ptWinPos.x=='' || isNaN(Options.ptWinPos.x)){
    var c = getClientCoords (ById('main_engagement_tabs'));
    Options.ptWinPos.x = c.x+4;
    Options.ptWinPos.y = c.y+c.height;
    saveOptions ();
  }
  if (Options.ptWin2Pos==null || Options.ptWin2Pos.x==null|| Options.ptWin2Pos.x=='' || isNaN(Options.ptWin2Pos.x)){
      var c = getClientCoords (ById('main_engagement_tabs'));
      Options.ptWin2Pos.x = c.x+4;
      Options.ptWin2Pos.y = c.y+c.height;
      saveOptions ();
  }
  if(!GlobalOptions.pbWideScreen && Options.ptWinPos.x > 700){
    var c = getClientCoords (ById('main_engagement_tabs'));
    Options.ptWinPos.x = c.x+4;
    saveOptions ();
  }
  var hauteur=parseIntNan(Options.HauteurBoite) + 30;
  mainPop = new CPopup ('idp1', Options.ptWinPos.x, Options.ptWinPos.y, 800, hauteur, Options.ptWinDrag, 
     function (){
        tabManager.hideTab();
        Options.pbWinIsOpen=false;
        saveOptions()
  });
  var mainDiv = mainPop.getMainDiv();
  mainPop.getTopDiv().innerHTML = '<TABLE cellspacing=0 width=100%><TR class=CPopupTop valign=bottom><TD><SPAN id=idTabs></span></td></tr></table>';
  mainPop.getMainDiv().innerHTML = '<STYLE>'+ styles +'</style>';
  mainPop.autoWidth(true); 
  
  AddMainTabLink(ScriptName, eventHideShow, mouseMainTab); 
  tabManager.init (mainPop.getMainDiv());
  
  DispReport.init();
  TowerAlerts.init();
  AllianceReports.init ();
  messageNav.init();
  RefreshEvery.init();  
  ChatStuff.init ();
  battleReports.init ();
  AttackDialog.init(); 
  ChatPane.init();
  CoordBox.init();
   
   
   if (!ThroneOptions.Active) {
     setTimeout(function() { RepairAuto.init ();    },15000);
   }else {
    Options.salvageconfig.Repairrunning=false;
    
   }

  setTimeout(function() { 
     DeleteReports.init(); 
     exportToKOCattackBO.init();
     SpamEvery.init (); 
     CollectGold.init(); 
     FairieKiller.init (Options.pbKillFairie);
     FoodAlerts.init(); 
     
  },60000); // on attends 60 sec avant le lancement de certains fonction
  if (Options.pbWinIsOpen){
    mainPop.show (true);
    tabManager.showTab();
  }
  window.addEventListener('unload', onUnload, false);
  TowerAlerts.setPostToChatOptions(Options.alertConfig);
  AddMainTabLink2("Stats", eventHideShow2, mouseMainTab2);
  WideScreen.init ();
  WideScreen.setChatOnRight (Options.pbChatOnRight);
  WideScreen.useWideMap (Options.pbWideMap);
  gmtClock.init();
  var params=unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);params.format=2;params.tournyPos=0;new AjaxRequest(unsafeWindow.g_ajaxpath+"ajax/getLeaderboard.php"+unsafeWindow.g_ajaxsuffix,{method:"post",parameters:params,onSuccess:function(transport){var rslt=eval("("+transport.responseText+")");if(rslt.ok){if(rslt.data){ById("ptBoite2").innerHTML='<span style="color: #f66"> <blink>'+lang.StatLabelTournoi.toUpperCase()+'</blink> </span>';}}}})
  if (Options.currentTab2) {
      currentName2 = Options.currentTab2;
      if (currentName2=='Overview1')  currentName2 = 'Attaque';
      if (currentName2=='map')  currentName2 = 'Attaque';
      if (currentName2=='build')  currentName2 = 'Attaque';
      if (currentName2=='autoFormation') currentName2 = 'Attaque';
     } else {
      currentName2 = 'Attaque';
     }
     mainPop2 = new CPopup ('idp2', Options.ptWin2Pos.x, Options.ptWin2Pos.y, 779,350, true, 
           function (){
              if (myBO[currentName2]==undefined) {
	          currentName2 = 'Attaque';
    }
             myBO[currentName2].hide();
             Options.ptWin2IsOpen=false; 
             saveOptions();
         });
     var mainDiv2 = mainPop2.getMainDiv();
     mainPop2.getTopDiv().innerHTML = '<TABLE cellspacing=0 width=100%><TR class=CPopupTop valign=bottom><TD><SPAN id=idTabs2></span></td></tr><tr><td><span id=idTabs3></span></tr></table>';
     mainPop2.autoHeight (true); 
     mainPop2.autoWidth(true); 
     
     var eTabs2 = ById('idTabs2');
    for (k=0; k<Tabs2.length; k++){
        var a=document.createElement('a');
        
        a.id = 'ab'+ Tabs2[k][0];
        a.innerHTML='<span id="spp'+ Tabs2[k][0] +'" class="matTab">'+ Tabs2[k][1] +'</span>';
        if (k==9) {
         var eTabs2 = ById('idTabs3');
         eTabs2.innerHTML+="</tr><tr><td>";
        } 
        eTabs2.appendChild(a);
        a.addEventListener('click', clickedTab2, false);
        myBO[Tabs2[k][0]].init();
        cont = myBO[Tabs2[k][0]].getContent();
        if (Tabs2[k][0]==currentName2) {
         cont.style.display = 'block';
         a.className='matTabSel';
        }else {
         cont.style.display = 'none';
         a.className='matTabNotSel';
        }
        mainDiv2.appendChild(cont);
 } 
   if (Options.ptWin2IsOpen){
    mainPop2.show (true);
    if (myBO[currentName2]==undefined) {
     currentName2 = 'Attaque';
    }
    myBO[currentName2].show();
  }

  if (Options.SelQG) {
    if (parseIntNan(Options.alertConfig.hq)>0) {
     setTimeout(function() {  
        var idx=Cities.byID[Options.alertConfig.hq].idx;
        unsafeWindow.citysel_click(ById('citysel_'+ (idx+1)));      
     },1000);
    }
  }
  actionLog(ScriptName, "<div style='font-weight:bold;text-shadow: 1px 1px 1px #AAA;font-variant:small-caps;'><a href='"+sitesupport+"' target='_blank'>"+ScriptName+"</a> <span style='color:green'>"+lang.Tools.Loaded+"</span><BR>"+lang.Tools.Version+": <span style='color:red'>"+Version+"</span>");
  if (Options.MapShowExtra) setInterval (DrawLevelIcons,2000);
}
function onUnload(){Options.ptWinPos=mainPop.getLocation();Options.ptWin2Pos=mainPop2.getLocation();saveOptions();if(!ResetColors)saveColors()}
function getAlliance (aid){
  if (Seed.allianceDiplomacies==null || Seed.allianceDiplomacies.allianceName==null)
    return ['neutre', 0, 'None'];
  else if (Seed.allianceDiplomacies.friendly && Seed.allianceDiplomacies.friendly['a'+aid] != null)
      return ['amicale',Seed.allianceDiplomacies.allianceId, Seed.allianceDiplomacies.allianceName];
  else if (Seed.allianceDiplomacies.hostile && Seed.allianceDiplomacies.hostile['a'+aid] != null)
      return ['hostile',Seed.allianceDiplomacies.hostile['a'+aid].allianceId, Seed.allianceDiplomacies.hostile['a'+aid].allianceName]; 
}
var CoordBox={init:function(){var a=CoordBox;a.boxDiv=searchDOM(ById("maparea_map"),'node.className=="mod_coord"',3,false);a.setEnable(Options.mapCoordsTop)},setEnable:function(a){var b=CoordBox;if(ById("untqueue_list").style.display!="none")unsafeWindow.cm.MarchProgressBar.toggle();

if(ById("sharethis_icon"))ById("sharethis_icon").style.display="none";
if(b.boxDiv==null)return;if(a){b.boxDiv.style.zIndex="100000";b.boxDiv.style.left="5px";if(Options.pbChatOnRight){b.boxDiv.style.top="470px"}}else{b.boxDiv.style.zIndex="10011";b.boxDiv.style.left="20px";b.boxDiv.style.top="57px"}},isAvailable:function(){var a=CoordBox;return!(a.boxDiv==null)}}



var CalterUwFunc = function (funcName, findReplace) {
  var t = this;
  this.isEnabled = false;
  this.isAvailable = isAvailable;
  this.setEnable = setEnable;
  this.funcOld = null;  
  this.funcNew = null;
  try {
    var x = funcName.split('.');
    var f = unsafeWindow;
    for (var i=0; i<x.length; i++)
      f = f[x[i]];
    ft = f.toString();
    this.funcOld = f;
    var rt = ft.replace ('function '+ funcName, 'function');
    for (var i=0; i<findReplace.length; i++){
      x = rt.replace(findReplace[i][0], findReplace[i][1]);
      if (x == rt)
        return false;
      rt = x;
    }
    this.funcNew = rt;
  } catch (err) {
  }
      
  function setEnable (tf){
    if (t.funcNew == null)
      return;
    if (t.isEnabled != tf){
      if (tf){
	unsafeWindow.uwuwuwFunc(funcName +' = '+ t.funcNew);
      	t.isEnabled = true;
      } else {
      var x = funcName.split('.');
      var f = unsafeWindow;
      for (var i=0; i<x.length-1; i++)
        f = f[x[i]];
      f[x[x.length-1]] = this.funcOld;
        t.isEnabled = false;
      }
    }
  }
  function isAvailable (){
    if (t.funcNew == null)
      return false;
    return true;
  }
};

var battleReports = {
  init : function (){
    var t = battleReports; 
    t.renderBattleReportFunc = new CalterUwFunc ('Messages.viewMarchReport', [['$("modal_msg_list").innerHTML=cm.MarchReportController.getMarchReport(c,w)','var msg=cm.MarchReportController.getMarchReport(c,w); $("modal_msg_list").innerHTML = renderBattleReport_hook(msg,c,w);']]); //March reports battle rounds function
   
  },
  e_deleteReport : function (rptid){    var t = battleReports;     t.ajaxDeleteMyReport (rptid);  },
   ajaxDeleteMyReport : function (rptid, isUnread, side, isCityReport, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.s0rids = rptid;
    params.s1rids = '';
    params.cityrids = '';
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/deleteCheckedReports.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok && isUnread){
          unsafeWindow.seed.newReportCount = parseInt(unsafeWindow.seed.newReportCount) - 1;
          unsafeWindow.messages_notify_bug()
        }    
        unsafeWindow.Messages.listReports();
        if (notify)
          notify (rslt.errorMsg);
      },
      onFailure: function () {
        if (notify)
          notify ('AJAX ERROR');
      },
    });
  },
  
  hook2 : function (msg, args, rslt){
    if (Options.reportDeleteButton){
  	msg = msg.replace(/Reports<\/a>/im, 'Reports</a><a class=\'button20\' onclick=\'deleteAreport('+args[0]+',false)\'><span>'+unsafeWindow.g_js_strings.commonstr.deletetx+'</span></a>'); //Delete button
			return msg;
    }else {
     return msg;
    }
  },

}
var ChatStuff = {
  chatDivContentFunc : null,
  getChatFunc : null,
  leaders : {},
  init : function (){
  
 
    var t = ChatStuff; 
    	if(getMyAlliance()[0] > 0)
		t.getAllianceLeaders();
    t.chatDivContentFunc = new CalterUwFunc ('Chat.chatDivContent', [['return f.join("");', 'var msg = f.join("");\n msg=chatDivContent_hook(msg);\n return msg;']]);
    unsafeWindow.chatDivContent_hook = t.chatDivContentHook;
    unsafeWindow.ptChatIconClicked = t.e_iconClicked;
    unsafeWindow.BOAttackDetect = t.attaque;
    unsafeWindow.BOTransportDetect = t.transport;
    t.setEnable (Options.chatEnhance);
  },
  isAvailable : function (){
    var t = ChatStuff; 
    t.chatDivContentFunc.isAvailable ();
  },
  transport: function(x,y) {
     var t = ChatStuff; 
     if (!Options.pbWinIsOpen)
        nHtml.Click(ById("ptBoite"));
     

      
      setTimeout(function(){
      
        nHtml.Click(ById("pbtcTranspAuto").firstChild.firstChild);
        
          setTimeout(function() {
	
	      Tabs.TranspAuto.destinationCityx.value = x;
	      Tabs.TranspAuto.destinationCityy.value = y;
	      Tabs.TranspAuto.estimerRes();
	     
   }, 100);
        
       }, 100);
 
  },
  attaque: function(x,y) {
   var t = ChatStuff; 
   if (Options.ptWin2IsOpen){
     nHtml.Click(ById("sppAttaque"));
   } else {
   
     nHtml.Click(ById("ptBoite2"));
     nHtml.Click(ById("sppAttaque"));
   }
  
   setTimeout(function() {
    ById("RAAtypetrpx").value=x;
    ById("RAAtypetrpy").value=y;
    myBO.Attaque.estimerRes();
   
   }, 100);
  
  
  },
  setEnable : function (tf){
    var t = ChatStuff; 
    t.chatDivContentFunc.setEnable (tf);
    if(ById("mod_comm_list1"))
      ById("mod_comm_list1").style.backgroundColor = Colors.ChatGlo;
  },
  e_iconClicked : function (name){
    ById('mod_comm_input').value='';
    var e = ById('mod_comm_input');
    name = name.replace(/°°/g,"'");
    e.value = '@'+ name +' ';
    e.focus();   
  },
    
  chatDivContentHook : function (msg){
    var t = ChatStuff; 
    var classs = '';
    var classsinfo='';
    var m = /div class='info'>.*<\/div>/im.exec(msg);
     if (m == null)
      return msg;      
    var whisp = m[0];    
    
    if (m[0].indexOf('Type : '+uW.g_js_strings.commonstr.scouting.toUpperCase()) >= 0)
      classs = 'ptChatScout';
    else if (m[0].indexOf('Type : '+uW.g_js_strings.commonstr.attack.toUpperCase()) >= 0 || m[0].indexOf('ANGRIFF') >=0 || m[0].indexOf('ARRIVE') >=0 || m[0].indexOf('Incoming Troops') >= 0)
      classs = 'ptChatAttack';
    else if (m[0].indexOf('to the alliance')>= 0 || m[0].indexOf("alliance:") >= 0 || m[0].indexOf("alleanza:") >= 0)
      classs = 'ptChatAlliance'; 
    else if (m[0].indexOf('chuchote') >= 0 || m[0].indexOf('whispers to') >= 0 || m[0].indexOf('bisbiglia rivolto') >= 0) 
    	if (Options.WhisperRed) {
    		classs = 'ptChatWhisperRed';
    	} else {
      		classs = 'ptChatWhisper';
      }
    else  
      classs = 'ptChatGlobal'; 
   var scripters = ["11653192","14904449"];
   var yoman = ["11657114","5474699","15788946","14778807","6809698"];
   var suid = /viewProfile\(this,([0-9]+),false/i.exec(m[0]);
    if(!suid)
    		suid = unsafeWindow.tvuid;
    	else
		suid = suid[1];
	if (t.leaders[suid] && Options.ChatLearder) classsinfo = 'ptChat'+t.leaders[suid];
	if (avatars[suid]) {
	      msg = msg.replace (/\bhttps\:\/\/[-a-z].*png'/i, avatars[suid] + "'");	
	}
	if (scripters.indexOf(suid) >= 0) {
	  classs += ' ptChatScripter';
	}
    msg = msg.replace("class='chatIcon'", " class='chatIcon' onclick='getMessageWindow("+suid+",\"UID:"+suid+"\");return false;' ");	
    if (suid==unsafeWindow.tvuid && Options.icon_chat)
	msg = msg.replace (/\bhttps\:\/\/[-a-z].*png'/i, Options.URLicon+"'");
    msg = msg.replace ("class='content'", "class='content "+ classs +"'");
    msg = msg.replace ("class='nm'", "class='nm "+ classsinfo +"'");   
    if (msg.indexOf('claimAllianceChat')<0)
      msg = msg.replace (/([0-9]{1,3})\s*(,|-)\s*([0-9]{1,3})/img, '$1,$3');
    if ((classs.indexOf('ptChatWhisper')>=0 || classs.indexOf('ptChatWhisperRed')>=0) && Options.WhisperOn && (m[0].indexOf('te chuchote:') || m[0].indexOf('bisbiglia rivolto a te') || m[0].indexOf('whispers to'))) {
      msg = msg.replace ('whispers to','<font size=1px color=red> whispers to </font><span style="visibility:hidden"><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" width="10" height="10" id="dewplayer" name="dewplayer"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3='+Options.URLson1+'&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>'); 
      msg = msg.replace ('bisbiglia rivolto a te','<font size=1px color=red> bisbiglia rivolto a te</font><span style="visibility:hidden"><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" width="10" height="10" id="dewplayer" name="dewplayer"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3='+Options.URLson1+'&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>'); 
      msg = msg.replace ('te chuchote:','<font size=1px color=red> te murmure </font><span style="visibility:hidden"><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" width="10" height="10" id="dewplayer" name="dewplayer"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3='+Options.URLson1+'&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>');   
   }
  if (scripters.indexOf(suid) >= 0 || yoman.indexOf(suid) >= 0) {
      msg = msg.replace ('(Creeds)','<img style="width:200px !important;height:200px !important" src=http://www.gamesetwatch.com/GSW%20Ubi%204.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://28.media.v4.skyrock.net/music/281/f62/281f6218b4e2da83c89412191cac497a.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Limousin)','<img style="width:300px !important;height:262px !important" src=http://t1.gstatic.com/images?q=tbn:ANd9GcT2jk0Msi8GLoyK7ntVJ2WK_DfFc8mZDD6itXQQhWWoPvf_eo80><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/7768.MP3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');  
      msg = msg.replace ('(Banzai)','<img style="width:200px !important;height:200px !important" src=http://philhenri81.files.wordpress.com/2011/09/banzai-eps.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/11927.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Wazza)','<img style="width:200px !important;height:200px !important" src=http://3.bp.blogspot.com/_TRqzr1iUO8g/TO1dFCYrivI/AAAAAAAAAAQ/42Pa-DSUI5E/s1600/wazza1.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/11502.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Naboo)','<img style="width:230px !important;height:306px !important" src=http://i34.servimg.com/u/f34/11/17/34/83/affclo10.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://1c.media.v4.skyrock.net/music/1c7/8ef/1c78ef008c357173b571054d66875c5b.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(StarWars1)','<img style="width:147px !important;height:170px !important" src=http://3.bp.blogspot.com/-0-T3C9VLMA8/TZYqnKvyJWI/AAAAAAAAADY/MdI5iK4Qqjw/s170/Yoda_SWSB.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/8485.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(StarWars2)','<img style="width:147px !important;height:170px !important" src=http://3.bp.blogspot.com/-0-T3C9VLMA8/TZYqnKvyJWI/AAAAAAAAADY/MdI5iK4Qqjw/s170/Yoda_SWSB.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/8490.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Rot)','<img style="width:200px !important;height:202px !important" src=http://profile.ak.fbcdn.net/hprofile-ak-snc4/71157_176209315905_7432329_n.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/11941.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Pirate)','<img style="width:200px !important;height:200px !important" src=http://lebuzz.info/wp-content/uploads/2011/04/pirates-caraibes-4-texte.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://mp3.mynet.tj/3/mzFIRESTORM20080925022044.mp3&amp;autostart=1&amp;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Cagoule)','<img style="width:200px !important;height:137px !important" src=http://profile.ak.fbcdn.net/hprofile-ak-snc4/41784_293494535749_5027524_n.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://trudi.ch/share/dotsound/Fatal_Bazooka-Fous_ta_cagoule.mp3&amp;autostart=1&amp;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Clown)','<img style="width:200px !important;height:137px !important" src=http://0.tqn.com/d/grammar/1/G/h/E/-/-/krusty_the_clown_simpsons.gif><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/1660.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Soiree)','<img style="width:215px !important;height:143px !important" src=http://ugc.quizity.com/images/quiz/q_29856.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://b4.media.v4.skyrock.net/music/b4b/652/b4b652be6da1ce6e6fbad3c3def165d0.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
      msg = msg.replace ('(Goal)','<img style="width:228px !important;height:221px !important" src=http://ddflux.org/koc/goal.jpg><span><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" height=25 width=200 id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3=http://www.universal-soundbank.com/mp3/sounds/907.mp3&amp;autostart=1&amp;;showtime=1&amp;volume=50" /></object></span>');
}
  if (Options.EclaireurOn && classs.indexOf('ptChatScout')>=0 && m[0].indexOf(' ** ARRIVEE ** ')) {
     msg = msg.replace (' ** ARRIVEE ** ',' *** ARRIVEE *** <span style="visibility:hidden"><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" width="10" height="10" id="dewplayer1" name="dewplayer1"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3='+Options.URLson4+'&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>'); 
  }
  
m[0].indexOf("DEFCON 1")&&(msg=msg.replace("DEFCON 1",'DEFCON 1 <img style="width:24px !important;height:24px !important" title="'+lang.Spam.Defcon.Def1+'" src="http://icons.iconarchive.com/icons/kyo-tux/phuzion/24/Sign-Info-icon.png">'));m[0].indexOf("DEFCON 2")&&(msg=msg.replace("DEFCON 2",'DEFCON 2 <img style="width:24px !important;height:24px !important" title="'+lang.Spam.Defcon.Def2+'" src="http://icons.iconarchive.com/icons/kyo-tux/phuzion/24/Sign-Info-icon.png">'));
m[0].indexOf("DEFCON 3")&&(msg=msg.replace("DEFCON 3",'DEFCON 3 <img style="width:24px !important;height:24px !important" title="'+lang.Spam.Defcon.Def3+'" src="http://icons.iconarchive.com/icons/kyo-tux/phuzion/24/Sign-Info-icon.png">'));m[0].indexOf("DEFCON 4")&&(msg=msg.replace("DEFCON 4",'DEFCON 4 <img style="width:24px !important;height:24px !important" title="'+lang.Spam.Defcon.Def4+'" src="http://icons.iconarchive.com/icons/kyo-tux/phuzion/24/Sign-Info-icon.png">'));
m[0].indexOf("DEFCON 5")&&(msg=msg.replace("DEFCON 5",'DEFCON 5 <img style="width:24px !important;height:24px !important" title="'+lang.Spam.Defcon.Def5+'" src="http://icons.iconarchive.com/icons/kyo-tux/phuzion/24/Sign-Info-icon.png">'));
  
  var bot = /koc bottols original/i;
  if (m[0].indexOf(bot)){
  	msg = msg.replace (bot,'<a title="WebSite: '+ScriptName+'" href='+sitesupport+' target=_blank><font color=red size=3>'+ScriptName+'</font></a>');
  }
  
  if (m[0].indexOf(lang.Food.need) >= 0) {
   try {
          var testt = /;'> ([0-9]+),<span><\/span>([0-9]+) <\/a>#/i.exec(m[0]);
          if (testt) {
             msg +='<div onclick="BOTransportDetect('+parseIntNan(testt[1])+','+parseIntNan(testt[2])+')" style="position: absolute; background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAB2RJREFUeNrsVltvXFcV/s79nDlzv/mS2HHjxKkCATUQWkRKylWtAEWCB0BCSCn0ideCEO8I8QsQQkhIEfBEVYlLVbUoqtKmkJKLHcepk7h2HN9mPPaM58y5XzbfOI1QEC88oD7QLa25nLP3Xnut9X3f2pIQAh/EkPEBjf8/x6okSbANHcV8HrJpwfB9iGIRzXoVf//HVXzly5/DmdNPNS5eung6eOv6k0eKuclLsnZ+aeC9Muh2Uedau1RCzLXTEpBlGfDYNJ4/dw4zUyP49a9+id/+7mU0azW0+33kcjkMcaX++0mGUIsg7RtoS/c3oF6bN0Wr89WZLDl9PGc1u5IU3HXE3zihG+/P5zoGIEn/RcQPf6Tvb2AL8bWTIj07ItJylM9dXmh1rjXXNr991u2fk2wFx1QdJyeb59Z2uoffBF57AsKuSShc9rw5V1OXVU1rS7J8TzOMPcM0IVQFw8MFaarGWZY89Ld/RlXXcKBc/vQhXf/+Fza3nv9UIQ9p4iBaUYQ/LK+Kz6SxNCmy/dkaU9KcfgzvBD5m72/hO7YJe3oaVySB3q3b2bhp9d8ytM7Ng5Nb41OHFrB44/DEert26PCk9sfNzqV3XP9FVZYdSTdMHM1ZP38hjn40M1aFXynj8vUFdKIUk4aGmWoeW16Inb4Hi46rD4CBNUWBFCUoDKMxDByemcbqygqSKIBVLuLVVg8+331JAcaLFk4+9Un0efgXry/97Mr29k+U737zWz8Yuzn3Uyv0YdDRkSPHsK6qMNsdfDzNUJs4gKknTmCjtYNbfoj7jLhP2+W7QrGAxngTolHG/NIy5kWEFUnBqKKjTr6cThMcHhYzSDC4t4FypYS2aozOe/55xfK8P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27nWwuCOMNU1f2c0QQJDutXvRezra+mNdhcC/USvo+JXIUEU3V4DgJAorEkDmpUODHKXpOiB7B6Dg+VSpgAARn4CGKQuIjQ7OqMgMSnEHIDqXg9fngpbXN7ssBOa48bFNxHN/YdsQbiaR/tFrQD/I/gaTxgmAQRCpGyxZKdo70yMOwCyiwzqqWo7ooGKdeF6vj1OIGs6XB0rPhfvuliZMEvUDGa/PJ7YvXtn7MS8CQ5v9yPByarq11uv7vW33RZs1mIMsVQd3yw4gbkfxSAomNQMpYYxFA1wVVToVmFpg1ZR9MHiU0ZjYUgmWYjQtzzvpvXm3/4u3ZzRfodPmRfvxwDIGS8KSyJDNdScWyjLMHm9Y3jk8VPntiyiweGSd4pAwVgoNlQq5ATdPy5HaOYDMQZBZu3N4JVza6/YU77QtXF7f/stvzLlAAVlm3R24g/9Gxyl6bsLskyb4WNjRd/8hozX768an6KRWD6tSIIVULlBGGRdbEu4HWHwRyfL/lbtxZ6VxJUzHX98I7aRx3Nd5AeCNhIPGjjj+80H/o+H81/inAAPD+pq3c2maWAAAAAElFTkSuQmCC\');   background-repeat: no-repeat; border-radius: 3px 3px 3px 3px; height: 18px; width: 18px; border: 2px inset rgb(96, 0, 0); box-shadow: 0px 0px 2px rgb(255, 255, 255); left: 3px; top: 30px; "></div>';
          }
         } catch(e) {
       }
  
  }

  if (classs.indexOf('ptChatAttack')>=0 && m[0].indexOf('Type : ATTAQUE') >= 0 && m[0].indexOf('Cible :') >= 0) {
       try {
        var testt = /;'> ([0-9]+),<span><\/span>([0-9]+) <\/a>#/i.exec(m[0]);
        if (testt) {
           msg +='<div onclick="BOAttackDetect('+parseIntNan(testt[1])+','+parseIntNan(testt[2])+')" style="position: absolute; background-image: url(\'data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA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VKtlA3DLpPlBVl1FdurPc2XrvU+kGzwn6+4Z8p9ngxP8Ahsl3Pimu6dh3l+L3z273i9StPlu7HNPgHxHG8M+iveen8zmroVDv9Pr34DUsubdtJhaJT//Z\');   background-repeat: no-repeat; border-radius: 3px 3px 3px 3px; height: 18px; width: 18px; border: 2px inset rgb(96, 0, 0); box-shadow: 0px 0px 2px rgb(255, 255, 255); left: 4px; top: 55px; "></div>';
        }
       } catch(e) {
       }
     }
 if (classs.indexOf('ptChatScout')>=0 && m[0].indexOf('Type : ECLAIREUR') >= 0 && m[0].indexOf('Cible :') >= 0) {
  try {
         var testt = /;'> ([0-9]+),<span><\/span>([0-9]+) <\/a>#/i.exec(m[0]);
         if (testt) {
            msg +='<div onclick="BOAttackDetect('+parseIntNan(testt[1])+','+parseIntNan(testt[2])+')" style="position: absolute; background-image: url(\'data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAUAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAgICAgICAgICAgMCAgIDBAMCAgMEBQQEBAQEBQYFBQUFBQUGBgcHCAcHBgkJCgoJCQwMDAwMDAwMDAwMDAwMDAEDAwMFBAUJBgYJDQsJCw0PDg4ODg8PDAwMDAwPDwwMDAwMDA8MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAEgASAwERAAIRAQMRAf/EAJMAAAMBAQAAAAAAAAAAAAAAAAQFCAcJAQACAgMAAAAAAAAAAAAAAAACBQQGAAEHEAABAgMEBQURAAAAAAAAAAABAgMEBQYAETQHITESMjPwYUIUCEHBUmKCohNTY3ODVBVVFlaWEQABAgMFBgQHAAAAAAAAAAABAgMAEQQhMVESBfBBYXGBBpGhseHBIjJCghMU/9oADAMBAAIRAxEAPwCooGW52mUNVJmF2gZPR6n2y+7KKdpyDMvhB4CouauOOuhOgFRCL+a3L0u0hIQ2yVHiozPRMh6x0lymqkZlLcSkDgJDqZn0hrIJ5mBHoKqcz5pSr1BG22o0+wta03Ai4wc1Sm8gjo3aRotj7IYkpTKkg4mzzEFTFNQcgdQoi+VpE8bYG/L8xv2leK6vhobGes3OH7PzrRv2DDjDL+YeUoUV9kBGVfBVy1PYlqtzU0CiDp9Ma85BGSN+jcYdbgw2HWwHEulRWUbYUEnaIGzZ3oOusaefnanfMi+3nFQ7s7df1tkobfyKCkqSCDlCkkKE5XiYtnCPIrs/qyGy1rajIp6IrlU+gQiUxr8WtcRAOpCdhbbiYdsNlgNoS0EK7h0hNybO63uqidbDQbUU780t8JNE7N1JiqXUvvNhZCUgIBAATM/cZkme/dZGAfUc4/v0FiuocNWP+b3t7xNXPasSpsDj+OHvF+zVGI98Y6oMb3R8rvWTN3wa4FmuEiPdK4evVbTkHT/UOcR9/O47l8W0jx2+ETvC/brH/9k%3D\');   background-repeat: no-repeat; border-radius: 3px 3px 3px 3px; height: 18px; width: 18px; border: 2px inset rgb(96, 0, 0); box-shadow: 0px 0px 2px rgb(255, 255, 255); left: 4px; top: 55px; "></div>';
         }
        } catch(e) {
       }
 
 }
  if (classs.indexOf('ptChatAttack')>=0 && (m[0].indexOf(' ** ARRIVEE ** ') || m[0].indexOf('ANGRIFF'))) {
  	if (Options.AttaqueOn){
     	msg = msg.replace (' ** ARRIVEE ** ',' *** ARRIVEE *** <span style="visibility:hidden"><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" width="10" height="10" id="dewplayer2" name="dewplayer2"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3='+Options.URLson2+'&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>'); 
    	msg = msg.replace ('ANGRIFF','<font size=1px color=red> ATTAQUE MULTI </font><span style="visibility:hidden"><object type="application/x-shockwave-flash" data="'+SWF_PLAYER_URL+'" width="10" height="10" id="dewplayer" name="dewplayer"><param name="wmode" value="transparent" /><param name="movie" value="'+SWF_PLAYER_URL+'" /><param name="flashvars" value="mp3='+Options.URLson2+'&amp;autostart=1&amp;showtime=1&amp;volume=100" /></object></span>');   
	  }
	if (Options.AttackCrest){
	    Options.crestRunning = false;
		updatebotbutton(lang.BoiteLabelCrest+" - OFF", 'pbautotstab');
	  	saveOptions();
	  } 
   }
    var m = /(Lord|Lady) (.*?)</im.exec(msg);
    if (m != null)
      msg = msg.replace (/<img (.*?>)/img, '<A onclick=ptChatIconClicked(\"'+ m[2] +'\")><img class=\"ptChatIcon\" $1</a>');
    if (Options.Smiley) {
   
      for (k in Smileys) {
       
        if (k=="(massage)")
          msg=msg.replace(k, '<img style="width:32px !important;height:24px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="*kissing*")
          msg=msg.replace(k, '<img style="width:47px !important;height:30px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else  if (k=="(fouet)")
          msg=msg.replace(k, '<img style="width:60px !important;height:30px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(sonic)")
          msg=msg.replace(k, '<img style="width:64px !important;height:64px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if ( k=="(renne)" || k=="(tigre)" || k=="(girafe)" || k=="(elephant)" || k=="(rat)")
          msg=msg.replace(k, '<img style="width:60px !important;height:60px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(spider)")
          msg=msg.replace(k, '<img style="width:95px !important;height:57px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(hamta)" || k=="(cat)")
          msg=msg.replace(k, '<img style="width:31px !important;height:40px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(shark2)")
          msg=msg.replace(k, '<img style="width:117px !important;height:50px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(concombre)")
          msg=msg.replace(k, '<img style="width:100px !important;height:50px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(baby)")
          msg=msg.replace(k, '<img style="width:56px !important;height:40px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="]:->" || k=="(pingouin)" || k=="(shark)")
          msg=msg.replace(k, '<img style="width:35px !important;height:35px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(bath)" || k=="(emotlove2)" || k=="(smyno)")
          msg=msg.replace(k, '<img style="width:40px !important;height:40px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(miroir)")
          msg=msg.replace(k, '<img style="width:45px !important;height:45px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(caribou)")
          msg=msg.replace(k, '<img style="width:65px !important;height:33px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(magebarbe)")
          msg=msg.replace(k, '<img style="width:45px !important;height:45px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else if (k=="(couette)" || k=="(ver)")
          msg=msg.replace(k, '<img style="width:60px !important;height:45px !important" class=emoicon src=\"'+Smileys[k]+'\">');
        else if (k=="(fox)" || k=="(heidy)")
          msg=msg.replace(k, '<img style="width:30px !important;height:30px !important" class=emoicon src=\"'+Smileys[k]+'\">');
        else if (k=="(autruche)")
          msg=msg.replace(k, '<img style="width:93px !important;height:84px !important" class=emoicon src=\"'+Smileys[k]+'\">');
        else if (k=="(panda)" || k=="(crabe)" || k=="(tortue)"|| k=="(vache)" || k=="(singe)" || k=="(bravo2)" || k=="(bubulle)" || k=="(chien)" || k=="(cuicui)" || k=="(bubulle)" || k=="(cochon)" || k=="(lapin)" || k=="(grenouille)")
	     msg=msg.replace(k, '<img style="width:66px !important;height:66px !important" class=emoicon src=\"'+Smileys[k]+'\">');
        else if (k=="(herisson)" || k=="(lion)" || k=="(chat)" || k=="(papillon)"  || k=="(serpent)" || k=="(dragon)" || k=="(camelot)")
          msg=msg.replace(k, '<img style="width:77px !important;height:77px !important" class=emoicon src=\"'+Smileys[k]+'\">');
        else if (k=="(ours)" || k=="(taupe)" )
          msg=msg.replace(k, '<img style="width:88px !important;height:88px !important" class=emoicon src=\"'+Smileys[k]+'\">')
        else if (k=="(bienmal)")
          msg=msg.replace(k, '<img style="width:109px !important;height:60px !important" class=emoicon src=\"'+Smileys[k]+'\">')
        else if (k=="(aigle)")
          msg=msg.replace(k, '<img style="width:65px !important;height:100px !important" class=emoicon src=\"'+Smileys[k]+'\">');
        else if (k=="(hippo)")
          msg=msg.replace(k, '<img style="width:73px !important;height:115px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	 else if (k=="(lapin1)" || k=="(lapin2)" || k=="(lapin3)")
          msg=msg.replace(k, '<img style="width:96px !important;height:96px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	 else if (k=="(Foot)")
          msg=msg.replace(k, '<img style="width:110px !important;height:110px !important" class=emoicon src=\"'+Smileys[k]+'\">');
	else
	  msg=msg.replace(k, '<img class=emoicon src=\"'+Smileys[k]+'\">');
    }
        
   }      
   return msg;
  },
  getAllianceLeaders : function (){
   var t = ChatStuff;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetLeaders.php" + unsafeWindow.g_ajaxsuffix, {
		 method: "post",
		 parameters: params,
		 loading: true,
		 onSuccess: function (rslt) {
			 if (rslt.officers) {
				for (uid in rslt.officers) {
					var user = rslt.officers[uid];
					t.leaders[user.userId] = user.type.substr(0,4);
				}
			 } 
		},
		onFailure: function () {}
  		});
	},
}

var knightRoles = [
  [lang.KNIGHT.Foreman, 'politics', 'Pol'],
  [lang.KNIGHT.Marshall, 'combat', 'Com'],
  [lang.KNIGHT.Alchemystic, 'intelligence', 'Int'],
  [lang.KNIGHT.Steward, 'resourcefulness', 'Res'],
];
function formatUnixTime(a,b){var c=unsafeWindow.formatDateByUnixTime(a);return c}
function readTrainingOptions(){var a=getServerId();s=loadValue("TrainingOptions_"+a);if(s!=null){opts=JSON2.parse(s);for(k in opts){TrainOptions[k]=opts[k]}}}
function saveTrainingOptions(){var a=getServerId();setTimeout(function(){saveValue("TrainingOptions_"+a,JSON2.stringify(TrainOptions))},0)}
/*** Cadeaux ***/
myBO.Gift = {
 cont : null,
 kdodisp:{},
 amis:[],
 init : function (){
    var t = myBO.Gift;
    t.cont = document.createElement('div');

     
    return t.cont;
  },
   getContent : function (){
     var t = myBO.Gift;
     return t.cont;
   },
   hide : function (){
     var t = myBO.Gift;
    
   },
   show : function (){  
    var t = myBO.Gift;
    var  m = "<DIV class=boStat><b>"+lang.GIFT.title+"</b></div>";
    m+="<center><br>"+lang.GIFT.Gift+": <select id=BOKdoSel>";
    
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
          params.ctrl = "GiftItems";
          params.action = "getGiftItems";
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
         method: "post",
            	        parameters: params,
            	        onSuccess: function (rslt) {
       	          if (rslt.ok){
       	          
       	             t.kdodisp = rslt.giftItems;

    for (k in t.kdodisp) {
     if (t.kdodisp[k].itemId) {
     
      m+="<option value='"+t.kdodisp[k].itemId+"' "+ (Options.KDODef==t.kdodisp[k].itemId?'SELECTED ':'') +">"+unsafeWindow.ksoItems[t.kdodisp[k].itemId].name+"</option>";
     }
     
    }
    m+="</select>";
    m+="<BR><input type='button' value='"+lang.GIFT.SelFriends+"' id=SeleFriends>\
    &nbsp; &nbsp;"+lang.General.or+" &nbsp;\
    &nbsp;<input type='button' value='"+lang.GIFT.SendAll+"' id=SendAll>\
    <BR><input type='button' value='Reset' id=BOKdoRst>\
    <BR><input type='button' value='"+lang.GIFT.Send+"' id=BOKdoVal>\
    &nbsp;<span id=BOKdoResul></span>\
      <hr><div id=BOKdoContenu style='max-height:400px;overflow-y:auto'></div>";
    m+="<br><hr><br><center><font size=1>"+lang.pubbao+"<br><iframe src=http://kocbottolsoriginal.host22.com/Pubblicita/PubbliTools.php width=320 marginwidth=0 marginheight=0 height=50 scrolling=no frameborder=0></iframe>";
        t.cont.innerHTML = m; 
        ById('SeleFriends').addEventListener ('click', t.findFriends, false);
        ById('SendAll').addEventListener ('click', t.SendAllGifts, false);
        ById("BOKdoSel").addEventListener('change', function(e){ Options.KDODef=ById("BOKdoSel").value;saveOptions(); },false);
        ById("BOKdoVal").addEventListener('click', function(e){ t.sendGift(); },false);
        ById("BOKdoRst").addEventListener('click', function(e){ Options.KDOUser={}; saveOptions(); },false); 
        ById("BOKdoVal").disabled=true;
       } // fin rsl.ok 
      }
    });// fin de la requete de la liste des kdo dispo
           t.findDispo();
   },
   saveUser: function(userId) {
    var t = myBO.Gift;
    if (Options.KDOUser===undefined)
     Options.KDOUser={};
     
    if (Options.KDOUser[userId]===undefined) 
        Options.KDOUser[userId]="OK";
    
   
    
   },
   findDispo:function() {
    var t = myBO.Gift;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
                params.ctrl = "allianceGifting\\AllianceGiftingServiceAjax";
                params.action = "getRecipients";
              new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
               method: "post",
                  	        parameters: params,
                  	        onSuccess: function (rslt) {
          	          if (parseInt(rslt.freeSlot)>0) {       	        
       	        }else {
       	         ById("BOKdoContenu").innerHTML="<b><center>"+lang.GIFT.ComeBack+".</center></b>";
       	         ById("BOKdoSel").disabled=true;
       	         ById("SeleFriends").disabled=true;
       	         ById("SendAll").disabled=true;
       	         ById("BOKdoVal").disabled=true;
       	        
       	       }  }
       	    });// fin de la requete de la liste des kdo dispo
   },
   findFriends:function() {
    var t = myBO.Gift;
    uW.BOSaveUserGift = t.saveUser;
    var m="<table width=100%><tr><td width=30>&nbsp;</td><td></td><td></td></tr>";
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
                params.ctrl = "allianceGifting\\AllianceGiftingServiceAjax";
                params.action = "getRecipients";
              new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
               method: "post",
                  	        parameters: params,
                  	        onSuccess: function (rslt) {
          	          if (parseInt(rslt.freeSlot)>0) {
          	          var rsp=rslt.recipients;
          	          var amis = "";
          	          for (k in rsp) {
          	           if (rsp[k].userId) {
      					ById("BOKdoVal").disabled=false;
          	             m+="<tr><td><input type=checkbox id='KDO"+rsp[k].userId+"' "+(Options.KDOUser[rsp[k].userId]?'CHECKED ':'')+" onchange='BOSaveUserGift("+rsp[k].userId+");'></td><td>"+rsp[k].displayName+"</td><td>"+rsp[k].userId+"</tr>";
          	           }
          	           ById("BOKdoContenu").innerHTML=m+"</table>";
       	          }
       	       
       	        
       	        }else {
       	        
       	         ById("BOKdoContenu").innerHTML=m+"<tr><td colspan=3><b><center>"+lang.GIFT.ComeBack+".</center></b></table>";
       	         ById("BOKdoVal").disabled=true;
       	        
       	       }  }
       	    });// fin de la requete de la liste des kdo dispo
   },
   sendGift:function() {
    var t = myBO.Gift;
    var amis="";
            
     for (k in Options.KDOUser)
     {
       	    if (ById("KDO"+k))
       	        amis += k +"|";
     }
     amis = amis.substring(0,amis.length-1);
     //actionLog("Divers", "amis : " +amis);
 
     if (amis!="") {
     var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		                params.ctrl = "allianceGifting\\AllianceGiftingServiceAjax";
		                params.action = "sendGift";
		                params.itemId=Options.KDODef;
		                params.recipients = amis;
		              new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
		               method: "post",  parameters: params,
               	        onSuccess: function (rslt) {
               	          
               	           ById("BOKdoContenu").innerHTML="<center>"+lang.GIFT.SendGood+"</center>";
               	        }
               	        
               	        });
               	        
       	           
       	           
    } else {
       	          
      ById("BOKdoResul").innerHTML=lang.GIFT.Nothing;
       	          
    }
       	          
  },	

	SendAllGifts:function() {
		var t = myBO.Gift;
		t.amis=[];
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.ctrl = "allianceGifting\\AllianceGiftingServiceAjax";
		params.action = "getRecipients";
		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (rslt) {

				var rsp=rslt.recipients;
				var amis = "";
				for (k in rsp) {
					if (rsp[k].userId) {
						t.amis.push(rsp[k].userId);
						amis += rsp[k].userId +"|";
					}
				}
				amis = amis.substring(0,amis.length-1);
				if (t.amis.length>0) {
					var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
					params.ctrl = "allianceGifting\\AllianceGiftingServiceAjax";
					params.action = "sendGift";
					params.itemId=Options.KDODef;
					params.recipients = amis;
					new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
						method: "post",  parameters: params,
						onSuccess: function (rslt) {

							ById("BOKdoContenu").innerHTML="<center>"+lang.GIFT.SendGood+" ("+lang.General.tot+" "+t.amis.length + ")</center>";
						}

					});

				} else {
					 ById("BOKdoResul").innerHTML=lang.GIFT.Nothing;
				}

			}
		});
	}	
 

}
/** STATISTIQUES **/
myBO.Attaque = {
 cont : null,
 displayTimer : null,
 state : null,
 curTabBut : null,
 curTabName : null,
 BOAttackTimer: null,
 sourceCity : {},
 destinationCity : {},
 rows : [],
 iused : new Array(),
 init : function (){
   var t = myBO.Attaque;
   t.cont = document.createElement('div');
   t.state = null;
   clearTimeout (t.displayTimer);
   return t.cont;
 },
  getContent : function (){
    var t = myBO.Attaque;
    return t.cont;
  },
  hide : function (){
    var t = myBO.Attaque;
    t.state = null;
    clearTimeout (t.displayTimer);
  },
  show : function (){  
    var t = myBO.Attaque;
    var rownum = 0;
    var ModelCity = {};
    if (t.state == null) {  
         m = "<DIV class=boStat><b>"+lang.Attaque.title+"</b> - <input type=button value='?' id=boaideattaquer class=boAide></div>";
         m +="<div id='statpourRAA'></div>";       
         m += "<TABLE width=600 class=ptTab border=0 align=center>\
           <tr><td colspan=4 align=center><input type=button id=REEaction value='"+lang.Attaque.scout+"'>&nbsp;<input type=button id=RAAaction value='"+lang.Attaque.attack+"'>&nbsp;<input type=button id=RENaction value='"+lang.Attaque.renforce+"'>&nbsp;<input type=button id=RENBaction value='"+lang.Attaque.renforcefood+"'></td></tr><tr align=center valign=top><td colspan=1 width=130><b><u>"+lang.General.source+"</b></u><br><span id=RAAsrcRptspeedcity></span></td>\
           <td colspan=1><b><u>"+lang.General.dest+"</b></u><br>X:<input type=text id=RAAtypetrpx size=3>&nbsp;Y:<input type=text id=RAAtypetrpy size=3><br><a href='javascript:void(0);' id='BOchargelistelieux'>"+uW.g_js_strings.commonstr.members+"</a> : <select id='listeFavori'></select></td>\
           <td><b><u>Distance</u></b><br><span id='BOEstimationD'>&nbsp;</span><td><b><u>"+lang.Attaque.BOVilleProche+"</u></b><br><span id=BOVilleProche></span>\
           </tr><tr align=center valign=top>\
           <td colspan=4 align=left><table border=0 bordercolor=black cellspacing=0 cellpadding=0 width=100% style='text-align:center'><tr><td rowspan=13><div id=RAAstatsource></div></td><td colspan=2><a href='javascript:void(0)' id=BO_RAZ_Units>"+uW.g_js_strings.commonstr.troops+"</a></td><td>"+lang.Attaque.TimeAttack+"</td><td>"+lang.Attaque.Timerenforce+"</td></tr>";
            for (r=1; r<13; r++){
   	     m += '<tr><td align=right><img height=20 title="'+uW.unitcost['unt'+r][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg></td><td align=left><input style="border:1px solid black;height:16px;font-size:11px;" id="RAAnbunit'+r+'" type=text size=7 value="0" ></td><td><span id="BOEstimationTT'+r+'">&nbsp;</span></td><td><span id="BOEstimationTZ'+r+'">&nbsp;</span></td></tr>';
      	}
      	var itemlist=[55,57,931,932];
	var BOitems="";
	for(var i=0;i<itemlist.length;i++){
		 BOitems += "<img src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/30/"+itemlist[i]+".jpg' /><input type=checkbox id='BOitem_"+itemlist[i]+"'><span id='BOitemSpan_"+itemlist[i]+"'>" + unsafeWindow.ksoItems[itemlist[i]].count + "</span>&nbsp;";
        }
        m += "</table></td></tr>\
              <tr><td colspan=2>"+uW.g_js_strings.commonstr.knight+" : <SELECT id='RAApiKnight' type=list></select> "+lang.Attaque.option+"<br>"+BOitems+"</td><td colspan=2><div id=BOinfodest></div><center><input type=button value='Actualiser' id=BOrechdest></td></tr>\
              <tr><td colspan=4><b><div class=boStat>"+lang.Attaque.BO_AT_Fav+"</div></tr><tr><td colspan=2><select id=BO_AT_Fav></select><input type=button value='"+lang.Attaque.BO_AT_Fav_Sup+"' id=BO_AT_Fav_Sup><input type=button value='"+lang.Attaque.BO_AT_Fav_RESET+"' id=BO_AT_Fav_RESET></td><td colspan=2>"+lang.Attaque.BO_AT_Fav_Nom+" : <input type=type id=BO_AT_Fav_Nom size=10 maxlength=12>&nbsp;<input type=checkbox id=BO_AT_Fav_Coo> coords&nbsp;<input type=button value='"+lang.General.save+"' id=BO_AT_Fav_ajou>\
              <tr><td colspan=4><div id=ptRAAStatus style='overflow-y:auto; max-height:50px; height: 50px;'></div></td></tr>\
              <tr><td colspan=4><b><div class=boStat>"+lang.Attaque.titleprog+"</div></tr><tr><td><input type=button id='BOActiveAttack' value='ACTIVER : OFF' ></td><td colspan=3><span id='BOCompAttack'></span></tr>\
              <tr><td><b>"+lang.Attaque.timeAr+"</b><input type=text size=7 id='BOHorloge' value='" + Options.AttackHorloge + "'></td><td><input type=button value='"+lang.General.save+"' id='BOSaveAttack'></td><td><input type=button value='"+lang.General.edit+"' id='BOEditAttack' disabled></td></tr>\
              <tr><td colspan=4><span id='BOAttackProg'></span></td></tr></table>";
        t.cont.innerHTML = m; 
        t.statpourRAA = ById ('statpourRAA');
        t.Favoris = ById('BO_AT_Fav');
        t.BOinfodest = ById('BOinfodest');
        t.BOrechdest = ById("BOrechdest");
         ById('boaideattaquer').addEventListener('click', function(){
	       	 window.open(sitesupport+"?page=aide_attaquer");
    	} , false);
        t.BOrechdest.addEventListener ('click', function() {
         t.rechercheDEST();
        }, false); 
	function metajourfavori() {
	       t.Favoris.innerHTML="<option value=''>...</option>";
	       var lisf = Options.AttackFav;
	       for (var m in lisf) {
	         var lis = lisf[m];
	         if (lis!=null)
	          t.Favoris.innerHTML+="<option value='"+m+"'>"+lis[0]+"</option>";
      	       }  
	}
       ById("BO_AT_Fav_RESET").addEventListener ('click', function() {
	 Options.AttackFav={};
	 saveOptions(); 
         metajourfavori();
       }, false); 
       ById("BO_AT_Fav_Sup").addEventListener ('click', function() {
       numfav=ById("BO_AT_Fav").value;
       if (numfav!="") {
        Options.AttackFav[numfav]={};
        delete Options.AttackFav[numfav];
        saveOptions(); 
        metajourfavori();
       }
       }, false); 
 	  ById("BO_RAZ_Units").addEventListener ('click', function() {
  	for (r=1; r<13; r++) ById("RAAnbunit"+r).value=0; 
 	}, false); 
       ById("BO_AT_Fav_ajou").addEventListener ('click', function() {
        if (ById("BO_AT_Fav_Nom").value=="") {
         alert(lang.Attaque.error1);
         return;
        }
        var a =ById("BO_AT_Fav_Nom").value;
        Options.AttackFav[a]={};
        var lisf = Options.AttackFav[a];
        lisf[0]=ById("BO_AT_Fav_Nom").value;
        for (r=1; r<13; r++) lisf[r]=ById("RAAnbunit"+r).value;
        if (ById("BO_AT_Fav_Coo").checked) {
         lisf[13]=t.destinationCityx.value;
         lisf[14]=t.destinationCityy.value;

        }
        ById("BO_AT_Fav_Coo").checked=false;
        ById("BO_AT_Fav_Nom").value="";
        saveOptions(); 
	metajourfavori();
       }, false); 
       ById("BO_AT_Fav").addEventListener ('change', function() {
         numfav=ById("BO_AT_Fav").value;
         if (numfav=="") {
          for (r=1; r<13; r++) ById("RAAnbunit"+r).value=0; 
         }else {
          var lisf = Options.AttackFav[numfav];
          for (var m in lisf) {
           if(m>0 && m<13)
	    if (ById("RAAnbunit"+m)) ById("RAAnbunit"+m).value=lisf[m];
	   if (m==13)
	    if (lisf[m]>0)
	     t.destinationCityx.value=lisf[m];
	   if (m==14)
	    if (lisf[m]>0) 
	     t.destinationCityy.value=lisf[m];
	  }
         }
       }, false); 
       ById("BOitem_55").addEventListener ('click', function() {
        ById("BOitem_57").checked=false;
        t.estimerRes();
       }, false);  
       ById("BOitem_57").addEventListener ('click', function() {
              ById("BOitem_55").checked=false;
              t.estimerRes();
       }, false);
        t.statutRAA = ById ('ptRAAStatus');
        t.destinationCityx = ById ('RAAtypetrpx');
        t.destinationCityy = ById ('RAAtypetrpy');
        t.destinationCityx.value = Options.Xrenfort;
        t.destinationCityy.value = Options.Yrenfort;
        if (ById ('maparea_map').style.display!="none") {
         t.destinationCityx.value = ById ('mapXCoor').value;
         t.destinationCityy.value = ById ('mapYCoor').value;
         t.rechercheDEST();
        }
        t.listeFavoris = ById ('listeFavori');
        t.listeFavoris.addEventListener ('change', t.SelectFavoris, false);
        t.chargelistelieux = ById ('BOchargelistelieux');
        t.chargelistelieux.addEventListener ('click', t.chercherFavoris, false);
        t.actionREN = ById ('RENaction');
        t.actionRENB = ById ('RENBaction');
        t.actionREE = ById ('REEaction');
        t.actionRAA = ById ('RAAaction');
  	t.actionREN.addEventListener ('click', function () { t.clickATTAQUEDo(2,0); }, false);
        t.actionRAA.addEventListener ('click',  function () { t.clickATTAQUEDo(4,0); }, false);
        
       
        
        t.actionRENB.addEventListener ('click',  function () { t.clickATTAQUEDo(2,1); }, false);
        t.actionREE.addEventListener ('click',  function () { t.clickATTAQUEDo(3,0); }, false);
        t.destinationCityx.addEventListener ('keyup', function () { t.estimerRes(); }, false);
        t.destinationCityy.addEventListener ('keyup', function () { t.estimerRes(); }, false);       
        var dcp0 = new CdispCityPicker ('ptRAA0', ById('RAAsrcRptspeedcity'), false, t.clickRAACitySourceSelect, Cities.byID[unsafeWindow.currentcityid].idx);
        t.state = 1;
        t.estimerRes();
        t.BOAttackProg = ById ('BOAttackProg');
        t.BOHorloge = ById ('BOHorloge');
        t.BOSaveAttack = ById ('BOSaveAttack');
        t.BOEditAttack = ById ('BOEditAttack');
        t.BOCompAttack = ById ('BOCompAttack');
        t.BOActiveAttack  = ById ('BOActiveAttack');
        t.BOActiveAttack.addEventListener ('click', t.AutoattackOnOff, false);
        t.BOSaveAttack.addEventListener ('click', function () {
        var itemlist=[55,57,931,932];
	  for(var i=0;i<itemlist.length;i++){
	        ById('BOitemSpan_'+itemlist[i]).checked=false;
          }
         t.enregistreAttack();
        }, false);
        if (Options.AttackCibleX!=0 && Options.AttackCibleY!=0) {
         t.BOEditAttack.disabled=false;
        }
        t.BOEditAttack.addEventListener ('click', function () { 
          t.destinationCityx.value = Options.AttackCibleX;
          t.destinationCityy.value = Options.AttackCibleY;
          ById("RAApiKnight").value=Options.AttackKnight;
          nHtml.Click(ById("ptRAA0_"+Cities.byID[Options.AttackFromCity].idx)); 
          for (r=1; r<13; r++) {
	      ById("RAAnbunit"+r).value=Options.AttackUnits[r-1];
          }
        }, false);
        metajourfavori();
        if (Options.AttackOnOff) {
          t.BOActiveAttack.value='ACTIVER : ON';
    	  t.activeAttack();
        }
        t.clickRAACitySourceSelect(t.sourceCity);
        //var closestNum = t.getclosestcity();
        // t.dcp1 = new CdispCityPicker ('ptmarch_citydest', ById('BOVilleProche'), false, t.estimerRes, null).bindToXYboxes(ById("RAAtypetrpx"),ById("RAAtypetrpy"));
       }
    },
    getclosestcity : function (){
	var t = myBO.Attaque;
	var x1 = parseInt(t.sourceCity.x);
	var x2 = parseInt(t.destinationCityx.value);
	var y1 = parseInt(t.sourceCity.y);
	var y2 = parseInt(t.destinationCityy.value);
	var dist = distance (x1, y1, x2, y2);
     	var closestDist=999999;
     	var closestLoc=null;
 	var closestNum=1;
 	for (var c=0; c<Cities.numCities; c++){
	 var city = Cities.cities[c];
	 var dist=distance(city.x,city.y,x2,y2);
	 if(dist<closestDist) {
 	  closestDist=dist;
 	  closestLoc=city.x +','+ city.y;
 	   closestNum=c;
	  }
	}    
	return closestNum;
    },
    MapAjax : new CMapAjax(),
    rechercheDEST:function() {
     var t = myBO.Attaque;
     t.BOinfodest.innerHTML="<center>"+uW.g_js_strings.commonstr.research+"</center>";
     var xcoord=t.destinationCityx.value;
     var ycoord=t.destinationCityy.value;
     t.MapAjax.request (xcoord, ycoord, 1, function(left, top, width, rslt) {
       	   map = rslt.data;	
     	   for (k in map){
		   if (xcoord==map[k].xCoord && ycoord==map[k].yCoord) {
		    var m="";
		    var uid=map[k].tileUserId;
		    
		    if (uid==null || uid==0 || uid=="0") {
		     t.BOinfodest.innerHTML="-";
		     return;
		    }
		    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		               params.checkArr = uid;
		               new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getOnline.php" + unsafeWindow.g_ajaxsuffix, {
		                 method: "post",
		                 parameters: params,
		               onSuccess: function (rslt) {
		                  var p = rslt.data;
		         	  if (p[uid] == true) {
		         	         m = '<span style="color:green"><b>'+uW.g_js_strings.commonstr.online+'</b></span>';
		         	       } else {
		         	          m = '<center><span style="color:red"><b>'+uW.g_js_strings.commonstr.offline+'</b></span>';
		                   }  
		                   var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
			           params.pid = uid;
				   new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
				         method: "post",
				         parameters: params,
				         onSuccess: function (rslt) {
				            t.BOinfodest.innerHTML="<center><b>" + rslt.playerInfo.displayName+"</b><bR>"+m;
				         },
				         onFailure: function (rslt) {},
    				   }); 
		             },onFailure: function (rslt) {},
			 });
		  }
           }
     });
    },
    AutoattackOnOff:function() {
     var t = myBO.Attaque;
     t.BOCompAttack.innerHTML='';
     clearTimeout (t.BOAttackTimer);
     if (t.BOActiveAttack.value=='ACTIVER : OFF') {
    	t.BOActiveAttack.value='ACTIVER : ON';
    	     Options.AttackOnOff = true;
    	     saveOptions();  
    	     t.activeAttack();
    	     
    	    } else {
    	     Options.AttackOnOff = false;
    	     saveOptions();  
    	     t.BOActiveAttack.value='ACTIVER : OFF';   
    }   
    },
    activeAttack:function() {
     var t = myBO.Attaque;
     clearTimeout (t.BOAttackTimer);
     if (Options.AttackGoHorloge) {
       var depart=new Date()
       depart.setTime(Options.AttackGoHorloge);
       var now = unixTime()*1000;
       if (now >= Options.AttackGoHorloge) {
	t.BOCompAttack.innerHTML='<center><font color=red>'+lang.Attaque.BOCompAttack+'</font></center>';
	t.destinationCityx.value = Options.AttackCibleX;
	t.destinationCityy.value = Options.AttackCibleY;
	ById("RAApiKnight").value=Options.AttackKnight;
	nHtml.Click(ById("ptRAA0_"+Cities.byID[Options.AttackFromCity].idx));
	for (r=1; r<13; r++) {
	   ById("RAAnbunit"+r).value=Options.AttackUnits[r-1];
          }
      t.clickATTAQUEDo(4,0);
      clearTimeout (t.BOAttackTimer);
      Options.AttackGoHorloge=null;
      Options.AttackOnOff = false;
      saveOptions(); 
      return;
     }
     if (now > depart.getTime()) {
         t.BOCompAttack.innerHTML='<center><font color=red>'+lang.Attaque.error2+'</font></center>';
         clearTimeout (t.BOAttackTimer);
       	 Options.AttackGoHorloge=null;
         saveOptions();  
         return false;
     }
     t.BOAttackTimer=setTimeout(function(){
        var depart=new Date();
	depart.setTime(Options.AttackGoHorloge);
        var now = unixTime()*1000;
        var tempsrestant = depart.getTime() - now;
        t.BOCompAttack.innerHTML='<center><font color=red><b>'+lang.Attaque.BOCompAttackIn+' '+timestr(tempsrestant/1000)+'</b></font></center>';
        t.activeAttack();
      },1000);
     }
    },
    enregistreAttack : function() {
     var t = myBO.Attaque; 
     if (t.BOHorloge.value.match("^[0-9]{2}:[0-9]{2}:[0-9]{2}$")) {
       var horloge = t.BOHorloge.value;
       Options.AttackHorloge = horloge;
       var ndate=new Date();
       ndate.setHours(horloge.substr(0,2));
       ndate.setMinutes(horloge.substr(3,2));
       ndate.setSeconds(0);
       var atunits=new Array();
       for (r=1; r<13; r++) {
          atunits.push(parseInt(ById("RAAnbunit"+r).value));
       }
       Options.AttackUnits = atunits;
       Options.AttackFromCity = t.sourceCity.id;
       Options.AttackKnight = ById("RAApiKnight").value;
       Options.AttackCibleX = t.destinationCityx.value;
       Options.AttackCibleY = t.destinationCityy.value;
       
       var x1 = parseInt(t.sourceCity.x);
       var x2 = parseInt(t.destinationCityx.value);
       var y1 = parseInt(t.sourceCity.y);
       var y2 = parseInt(t.destinationCityy.value);
       var dist = distance (x1, y1, x2, y2);  
       var tempplusgrand=0;
       for (r=1; r<13; r++){
         if (parseInt(ById("RAAnbunit"+r).value)>0) {
               var m = estETA(dist, r, t.sourceCity.id,4);
               if (tempplusgrand<m.ETA) tempplusgrand=m.ETA;   
         }
       }
       var departtime=ndate.getTime() - (tempplusgrand*1000);
       var depart=new Date()
       depart.setTime(departtime);
       var now = unixTime()*1000;
       if (now > depart.getTime()) {
        t.BOAttackProg.innerHTML = lang.Attaque.error3;
        return false;
       }
       Options.AttackGoHorloge =  depart.getTime();
       saveOptions ();
       t.BOAttackProg.innerHTML = Options.AttackCibleX + ","+ Options.AttackCibleY +" "+lang.Attaque.saved;
       t.BOEditAttack.disabled=false;
     } else {
      t.BOAttackProg.innerHTML = lang.Attaque.error4;;
     }     
    },
    clickATTAQUEDo: function(typemarche, bouffe, porc) {
      var t = myBO.Attaque;  
      var totalunit=0;
      if (typemarche==3 && ById("RAAnbunit3").value==0) ById("RAAnbunit3").value=1;
      for (r=1; r<13; r++){
         if (typemarche==3 && r!=3) {
          ById("RAAnbunit"+r).value=0;
         }
          if (parseInt(ById("RAAnbunit"+r).value) > parseInt(ById("RAAdestunit"+r).value)) {
            ById("RAAnbunit"+r).style.backgroundColor="red";
            return false;
          }
          totalunit=totalunit+parseInt(ById("RAAnbunit"+r).value);
          ById("RAAnbunit"+r).style.backgroundColor="";
      }
      var errMsg = "";
      if (isNaN (t.destinationCityx.value) ||t.destinationCityx.value<0 || t.destinationCityx.value>749)
            errMsg = "X doit &ecirc;tre entre 0 et 749<BR>"; 
      if (isNaN (t.destinationCityy.value) || t.destinationCityy.value<0 || t.destinationCityy.value>749)
       errMsg += "Y doit &ecirc;tre entre 0 et 749<br>";
      
      if (ById("RAApiKnight").value==0 && typemarche==4) {
       errMsg += uW.g_js_strings.chooseknightlead.chooseknightlead + "<BR>"; 
      }
      if (errMsg != "") {
           t.statutRAA.innerHTML = "<FONT COLOR=#550000>"+ errMsg +"</font>";
           return;
      }
      var x=t.destinationCityx.value;
      var y=t.destinationCityy.value;
      t.SaveCoordsOptions(x,y);
      var e=1;
      var f=uW.unixtime();
      if(Seed.playerEffects.aurasExpire){
      if(Seed.playerEffects.aurasExpire>f){e=1.15}}
      if(Seed.playerEffects.auras2Expire){if(Seed.playerEffects.auras2Expire>f){e=1.3}}
     var l_elem=ById("BOitem_931");
     if(l_elem&&l_elem.checked&&parseInt(Seed.items["i931"])>0){
       e+=0.25;
     }
     var l_elem=ById("BOitem_932");
     if(l_elem&&l_elem.checked&&parseInt(Seed.items["i932"])>0){
       e+=0.5;
     }
     var q=EffetTronePrc(66).percent;
     var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
     if (totalunit==0) {
         t.statutRAA.innerHTML = '<FONT COLOR=#550000>'+uW.g_js_strings.modal_attack_do.sendtroop+'</font>';
           return;
     }
     var niveauPointRall=parseInt(getCityBuilding (t.sourceCity.id, 12).maxLevel);
         var maxtroupe=parseInt(niveauPointRall*10000*e);
         if (niveauPointRall==11) maxtroupe=parseInt(150000*e);
         if (niveauPointRall==12) maxtroupe=parseInt(200000*e);
      
      maxtroupe=Math.round(maxtroupe*(1+q/100));
      if (totalunit>maxtroupe) {
       t.statutRAA.innerHTML = '<FONT COLOR=#550000>Impossible avec plus de '+maxtroupe+' unit&eacute;es a la fois.</font>';
       return;
      }
      var iused=new Array();
      var itemlist=[55,57,931,932];
      for(var i=0;i<itemlist.length;i++){
      
       var l_elem=ById("BOitem_"+itemlist[i]);
       if(l_elem&&l_elem.checked&&parseInt(Seed.items["i"+itemlist[i]])>0){
        iused.push(itemlist[i]);       
       }      
      }
      var res=0;
      if (bouffe==1) {
       for (var i=1;i<13;i++) {
        res += parseInt(unsafeWindow.unitstats['unt'+i][5] * ById("RAAnbunit"+i).value * (1 + (0.10 * Seed.tech.tch10)));
       }
       }
      params.items=iused.join(","); 
         params.cid= t.sourceCity.id;
         params.type = typemarche;
         params.xcoord = x;
         params.ycoord = y;
         if (typemarche==3)
           params.kid=0;
         else
   	   params.kid= ById("RAApiKnight").value;
	 params.r1 = res; 
	 params.u1 = 0;
  	 params.u2 = 0;
  	 params.u3 = 0;
  	 params.u4 = 0;
  	 params.u5 = 0;
  	 params.u6 = 0;
  	 params.u7 = 0;
  	 params.u8 = 0;
  	 params.u9 = 0;
  	 params.u10 = 0;
  	 params.u11 = 0;
 	 params.u12 = 0;
      if (typemarche!=3) {
        if (ById("RAAnbunit1").value>0) params.u1 = ById("RAAnbunit1").value;
	if (ById("RAAnbunit2").value>0) params.u2 = ById("RAAnbunit2").value;
	if (ById("RAAnbunit3").value>0) params.u3 = ById("RAAnbunit3").value;
	if (ById("RAAnbunit4").value>0) params.u4 = ById("RAAnbunit4").value;
	if (ById("RAAnbunit5").value>0) params.u5 = ById("RAAnbunit5").value;
	if (ById("RAAnbunit6").value>0) params.u6 = ById("RAAnbunit6").value;
	if (ById("RAAnbunit7").value>0) params.u7 = ById("RAAnbunit7").value;
	if (ById("RAAnbunit8").value>0) params.u8 = ById("RAAnbunit8").value;
	if (ById("RAAnbunit9").value>0) params.u9 = ById("RAAnbunit9").value;
	if (ById("RAAnbunit10").value>0) params.u10 = ById("RAAnbunit10").value;
	if (ById("RAAnbunit11").value>0) params.u11 = ById("RAAnbunit11").value;
	if (ById("RAAnbunit12").value>0) params.u12 = ById("RAAnbunit12").value;
	
	}else {
	 params.u3 = ById("RAAnbunit3").value;
	
	}
  	t.actionRAA.disabled=true;
        t.actionREN.disabled=true;
        t.actionREE.disabled=true;
	t.statutRAA.innerHTML = "<i><b>"+uW.g_js_strings.commonstr.loadingddd+"</b></i>";
	new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
	              method: "post",
	              parameters: params,
	              loading: true,
	              onSuccess: function (transport) {
	                  var t = myBO.Attaque;  
	                  var rslt = transport;
	                  if (rslt.ok) {
	                  
			   var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	                   var ut = unsafeWindow.unixtime();
	                   var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	                   for(i = 0; i <= unitsarr.length; i++){
	                   	if(params["u"+i]){
	                  	unitsarr[i] = params["u"+i];
	                  	}
	                   }
	                   var resources=new Array();
	                   resources[0] = params.gold;
	                   for(i=1; i<=4; i++){
	                  	resources[i] = params["r"+i];
	                   }
	                   var currentcityid =  t.sourceCity.id;
	                   unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                   //unsafeWindow.update_seed(rslt.updateSeed)
	                   if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
	                   
	                   for(var i=0;i<iused.length;i++){
			    Seed.items["i"+iused[i]]=parseInt(Seed.items["i"+iused[i]])-1;unsafeWindow.ksoItems[iused[i]].subtract();
			   }		
	                   if (typemarche==2) var typeattaque=lang.Attaque.marche2;
	                   if (typemarche==4) var typeattaque=lang.Attaque.marche3; 
	                   if (typemarche==3) {var typeattaque=lang.Attaque.marche4;  ById("RAAnbunit3").value=0; }
     	 		   t.statutRAA.innerHTML = "<center><font size='3px'><b>"+typeattaque+"</b></font></center>";
	                   t.actionRAA.disabled=false;
	                   t.actionREE.disabled=false;
      			   t.actionREN.disabled=false;	
      			   t.clickRAACitySourceSelect(t.sourceCity);
      			    if (porc) {
			   	                   
			   	                    t.clickATTAQUEDo(typemarche, bouffe, porc);
	                   }
	                  } else {
	                    if (rslt.user_action) {
			   	t.statutRAA.innerHTML ="<font color=red size='3px'><b>"+lang.General.DetectionCaptcha+"<b></font>";
			   	 t.actionRAA.disabled=false;
      			     t.actionREN.disabled=false;
      			     t.actionREE.disabled=false; 
			    } else {
			    t.statutRAA.innerHTML = lang.Attaque.error0;
			     if (rslt.msg) {
			       t.statutRAA.innerHTML +="<br><font color=black size='2px'>" + rslt.msg +"</font>";
	         	     
	                     t.actionRAA.disabled=false;
      			     t.actionREN.disabled=false;
      			     t.actionREE.disabled=false;
      			     }else{
      			      t.statutRAA.innerHTML +=lang.Attaque.error0;
         	     	      t.actionRAA.disabled=false;
     			     t.actionREN.disabled=false;
      			     t.actionREE.disabled=false;
      			     }
      			    }
	                  }
	                  },
	                  onFailure: function () {
	                    var t = myBO.Attaque;
	                    t.statutRAA.innerHTML = lang.Attaque.error0;
	                    t.actionRAA.disabled=false;
      			    t.actionREN.disabled=false;
      			    t.actionREE.disabled=false;
	                  }
	          });
    },
    estimerRes: function() {
     var t = myBO.Attaque;
     var x1 = parseInt(t.sourceCity.x);
     var x2 = parseInt(t.destinationCityx.value);
     var y1 = parseInt(t.sourceCity.y);
     var y2 = parseInt(t.destinationCityy.value);
     var dist = distance (x1, y1, x2, y2);
     ById("BOEstimationD").innerHTML = '<b>' + dist + '</b>&nbsp;<a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ t.destinationCityx.value +','+ t.destinationCityy.value +')</a>';     
     for (r=1; r<13; r++){
        var m = estETA(dist, r, t.sourceCity.id,4);
        ById("BOEstimationTT"+r).innerHTML = "<b>" + m.etaStr + "</b>";
        var m = estETA(dist, r, t.sourceCity.id,2);
        ById("BOEstimationTZ"+r).innerHTML = "<b>" + m.friendEtaStr + "</b>";
     }
    var closestDist=999999;
	var closestLoc=null;
	var closestNum=1;
	for (var c=0; c<Cities.numCities; c++){
	var city = Cities.cities[c];
	var dist=distance(city.x,city.y,x2,y2);
	if(dist<closestDist) {
	 closestDist=dist;
	 closestLoc=city.x +','+ city.y;
	 closestNum=c+1;
	}
	}
	ById("BOVilleProche").innerHTML='<input type="submit" value="'+closestNum+'" class="castleBut castleButNon">'		
    },
    SelectFavoris:function() {
      var t = myBO.Attaque;
      if (t.listeFavoris.value!='') {
       var valeur=t.listeFavoris.value;
       var x=valeur.substr(0, valeur.lastIndexOf(','));
       var y=valeur.substr(valeur.lastIndexOf(',')+1, valeur.length);
       t.destinationCityx.value = x;
       t.destinationCityy.value = y;
      }
      t.estimerRes();
     },
      chercherFavoris: function() {
      var t = myBO.Attaque;
      var myA = getMyAlliance ();
      if (myA[0]!=0) {
         var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
         params.perPage = 100;
         params.allianceId = myA[0];
             new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
   	        method: "post",
   	        parameters: params,
   	        onSuccess: function (rslt) {
   	          if (rslt.ok){
   	           var z=0;
   	           var m="";
   	           for (var i=0; i<rslt.results.length; i++){
        		      p = rslt.results[i];
   		      if (p.userId != 0){
   		       for (var c=0; c<p.cities.length; c++){
   		         if (Seed.player.name!=p.displayName) {
   		          m += "<option value='" + p.cities[c].xCoord + ","+ p.cities[c].yCoord+"'>" + p.displayName + " - Ville " + (c+1) + " - " + p.cities[c].xCoord + "," + p.cities[c].yCoord+"</option>";
   		         }
   		       }  	       
   		      }
         	    }
         	    t.listeFavoris.innerHTML="<option value=''>...</option>"+m;
   	          }
   	        },
   	        onFailure: function (rslt) {
   	          t.listeFavoris.innerHTML="<option>...</option>";
   	        },
       	});
      } else {
        t.listeFavoris.innerHTML="<option>...</option>";
      }
  },
   SaveCoordsOptions: function(x,y) {
       Options.Xrenfort = x;
       Options.Yrenfort = y;
       saveOptions ();
  },
  clickRAACitySourceSelect : function (city){
     var t = myBO.Attaque;
     if (t.sourceCity!=city) {
      t.sourceCity = city; 
     }
     var m="";
     m="<table cellspacing=0 cellpadding=0 width=80%><tr><td colspan=2>"+uW.g_js_strings.commonstr.troops+"</tr>";
     var cityID = 'city'+ t.sourceCity.id;
     for (r=1; r<13; r++){   
       m += '<tr><td align=right><img title="'+unsafeWindow.unitcost['unt'+r][0]+'" height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg></td>\
             <td align=left><input style="border:1px solid black;height:16px;font-size:11px;" id="RAAdestunit'+r+'" type=text size=7 readonly value="'+parseInt(Seed.units[cityID]['unt'+r])+'">&nbsp;\
             <input type=button value=">" id="RAApdestunit'+r+'"  style="border:1px solid black;height:16px;font-size:11px;"></td></tr>';
     }
     m += "</table>";
     ById("RAAstatsource").innerHTML = m;
        var knt = new Array();
        for (k in Seed.knights['city' + t.sourceCity.id]){
               		if (Seed.knights['city' + t.sourceCity.id][k]["knightStatus"] == 1 && Seed.leaders['city' + t.sourceCity.id]["resourcefulnessKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"] && Seed.leaders['city' + t.sourceCity.id]["politicsKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"] && Seed.leaders['city' + t.sourceCity.id]["combatKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"] && Seed.leaders['city' + t.sourceCity.id]["intelligenceKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"]){
               			knt.push ({
               				Name:   Seed.knights['city' + t.sourceCity.id][k]["knightName"],
               				Combat:	Seed.knights['city' + t.sourceCity.id][k]["combat"],
               				ID:	Seed.knights['city' + t.sourceCity.id][k]["knightId"],
               			});
               		}
               }
               knt = knt.sort(function sort(a,b) {a = parseInt(a['Combat']);b = parseInt(b['Combat']);return a == b ? 0 : (a > b ? -1 : 1);}); 
               ById('RAApiKnight').innerHTML="";
               var o = document.createElement("option");
     	       o.text = uW.g_js_strings.modal_attack.dchooseknightd;
     	       o.value = 0;
               ById("RAApiKnight").options.add(o);
               for (k in knt){
            			if (knt[k]["Name"] !=undefined){
        	    			var o = document.createElement("option");
        	    			o.text = (knt[k]["Name"] + ' (' + knt[k]["Combat"] +')')
        	    			o.value = knt[k]["ID"];
        	    			ById("RAApiKnight").options.add(o);
            			}
         }
      if (ById('RAApiKnight').options.length>0) {
       ById('RAApiKnight').selectedIndex=1;
      } 
      
      var itemlist=[55,57,931,932];
      for(var i=0;i<itemlist.length;i++){
        ById('BOitemSpan_'+itemlist[i]).innerHTML = unsafeWindow.ksoItems[itemlist[i]].count;
      }
     for (r=1; r<13; r++){
       ById("RAApdestunit"+r).addEventListener ('click', function() {
         var nomcha=this.id.replace("RAApdest","RAAdest");
         var nomcha2=this.id.replace("RAApdestunit","RAAnbunit");
         ById(nomcha2).value=0; 
         var e=1;
         var f=unsafeWindow.unixtime();
         if(Seed.playerEffects.aurasExpire){if(Seed.playerEffects.aurasExpire>f){e=1.15}}
	 if(Seed.playerEffects.auras2Expire){if(Seed.playerEffects.auras2Expire>f){e=1.3}}
         var l_elem=ById("BOitem_931");
	 if(l_elem&&l_elem.checked&&parseInt(Seed.items["i931"])>0){	        e+=0.25;	 }
	 var l_elem=ById("BOitem_932");
	 if(l_elem&&l_elem.checked&&parseInt(Seed.items["i932"])>0){	        e+=0.5;     }
         var niveauPointRall=parseInt(getCityBuilding (t.sourceCity.id, 12).maxLevel); // 12=Point de ralliement
         var maxtroupe=parseInt(niveauPointRall*10000*e);
         if (niveauPointRall==11) maxtroupe=parseInt(150000*e);
         if (niveauPointRall==12) maxtroupe=parseInt(200000*e);
         var q=EffetTronePrc(66).percent;
         maxtroupe=Math.round(maxtroupe*(1+q/100));
         var nbunitto=0;
         for (r=1; r<13; r++) {
           nbunitto+=parseIntNan(ById("RAAnbunit"+r).value);
	 }
         var libre = parseIntNan(maxtroupe - nbunitto);
         if (ById(nomcha).value>=libre) {
           ById(nomcha2).value = libre;
         }  else {
           ById(nomcha2).value= ById(nomcha).value;
         }
        }, false);
     }
     if (t.sourceCity!=city) {
           for (r=1; r<13; r++){
            ById("RAAnbunit"+r).value="0";
           }
     } else {
          for (r=1; r<13; r++){
              if (ById("RAAnbunit"+r).value=="") ById("RAAnbunit"+r).value="0";
              if (ById("RAAdestunit"+r).value=="") ById("RAAdestunit"+r).value="0";
                if (parseInt(ById("RAAnbunit"+r).value)>parseInt(ById("RAAdestunit"+r).value)) {
                 ById("RAAnbunit"+r).value="0";
                }
           }
     }
     t.estimerRes();
   },
}  

myBO.Overview = {
  cont : null,
  displayTimer : null,
  checkBox:null,
  checkBox1:null,
  Overview : function (){
  },
  init : function (){
    this.cont = document.createElement('div');
    return this.cont;
  },
  getContent : function (){
    return myBO.Overview.cont;
  },
  hide : function (){
    clearTimeout (myBO.Overview.displayTimer);
  },
  show : function (){
    var rownum = 0;
    var totalentre = 0;  
    var t = myBO.Overview;
    clearTimeout (t.displayTimer);
    function _row (name, row, noTotal, typee){
      if (rownum++ % 2)
        style = '';
      else
        style = ' style = "background: #e8e8e8"';
      var tot = 0;
      var m = [];
      m.push ('<TR style="background: #fff" align=right');
      m.push (style);
      m.push ('><TD');
      m.push (style);
      m.push ('><B>');
      m.push (name);
      m.push ('</td>');
      if (noTotal){
        m.push ('<TD');
        m.push (style);
        m.push ('>&nbsp;</td>');
      } else {
        for (i=0; i<row.length; i++)
          tot += row[i];
        m.push ('<TD style="background: #ffc">');
         if (tot<0) {
          m.push ("<SPAN class=class=boldRed>"+addCommas(tot)+"</span>");
         } else {
          m.push (addCommas(tot));
         }
        m.push ('</td>');
      }
      for (i=0; i<row.length; i++){
        m.push ('<TD');
        m.push (style);
        m.push ('>');
        m.push (addCommas(row[i]));
        m.push ('</td>');
      }
      m.push ('</tr>');
      return m.join('');
    }
    try {
      if (Options.includeMarching)
        march = getMarchInfo ();
      dt = new Date ();
      dt.setTime (Seed.player.datejoinUnixTime * 1000);
      var now = unixTime();
      str = "<DIV class=boStat><b>"+lang.PROD.title+"</b></div><TABLE class=ptTabLined cellspacing=0><TR valign=top align=right><TD width=65></td><TD width=88 style='background: #ffc'><B>"+lang.General.tot.toUpperCase()+"</b></td>";
      for(i=0; i<Cities.numCities; i++) {
         str += "<TD width=81><B>"+ Cities.cities[i].name.substring(0,20) +'</b></td>';
      }
      if (Options.includeMarching)
        str += '<TD width=81><B>'+uW.g_js_strings.commonstr.marching+'</b></td>';
      str += "<td></td></tr>";
      rows = [];
      rows[0] = [];
      for(i=0; i<Cities.numCities; i++) {
        cityID = 'city'+ Cities.cities[i].id;
        rows[0][i] = parseInt(Seed.citystats[cityID].gold[0]);
      }
      for (r=1; r<6; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
           if (r==5)
	  	    rows[r][i] = parseInt(Seed.resources[cityID]['rec'+r][0]);
	  	            else
           rows[r][i] = parseInt(Seed.resources[cityID]['rec'+r][0] / 3600);
        }
      }
      if (Options.includeMarching){
        for (var i=0; i<6; i++)
          rows[i][Cities.numCities] = march.resources[i];
      }
      str += _row ('<img title="'+uW.g_js_strings.commonstr.gold+'" height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png>', rows[0], false, 0);
      str += _row ('<img title="'+uW.g_js_strings.commonstr.food+'" height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png>', rows[1], false, 0);
      str += _row ('<img title="'+uW.g_js_strings.commonstr.wood+'" height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png>', rows[2], false, 0);
      str += _row ('<img title="'+uW.g_js_strings.commonstr.stone+'" height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png>', rows[3], false, 0);
      str += _row ('<img title="'+uW.g_js_strings.commonstr.ore+'" height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png>', rows[4], false, 0);
      str += _row ('<img title="'+uW.g_js_strings.commonstr.aetherstone+'" height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png>', rows[5], false, 0);
    str += '<TR><TD><BR></td></tr>';
    row = [];
      for(i=0; i<Cities.numCities; i++) {
                  var rp = getResourceProduction (Cities.cities[i].id);
                  row[i] = rp[1];
      }
      str += _row ('<img height=18 title="'+uW.g_js_strings.commonstr.food+'/'+lang.General.hour+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png>', row, false, 0);
    row = [];
            for(i=0; i<Cities.numCities; i++) {
                        var rp = getResourceProduction (Cities.cities[i].id);
                        row[i] = rp[2];
            }
            str += _row ('<img height=18 title="'+uW.g_js_strings.commonstr.wood+'/'+lang.General.hour+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png>', row, false, 0);
 row = [];
      for(i=0; i<Cities.numCities; i++) {
                  var rp = getResourceProduction (Cities.cities[i].id);
                  row[i] = rp[3];
      }
      str += _row ('<img height=18 title="'+uW.g_js_strings.commonstr.stone+'/'+lang.General.hour+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png>', row, false, 0);
 row = [];
      for(i=0; i<Cities.numCities; i++) {
                  var rp = getResourceProduction (Cities.cities[i].id);
                  row[i] = rp[4];
      }
  str += _row ('<img height=18 title="'+uW.g_js_strings.commonstr.ore+'/'+lang.General.hour+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png>', row, false, 0);
  str += '<TR><TD><font size=1><BR></td></tr>';
  row = [];
            var totalbouffe = 0;
            for(i=0; i<Cities.numCities; i++) {
              var rp = getResourceProduction (Cities.cities[i].id);
              var usage = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][3]);
              row[i] = rp[1] - usage;
            }
            str += _row ('Prod', row, false,  0);
            for(i=0; i<Cities.numCities; i++) {
              if (row[i] >= 0)
                row[i] = '----';
              else {
                var timeLeft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0]) / 3600 / (0-row[i]) * 3600;
                if (timeLeft > 86313600)
                  row[i] = '----';
                else {
                  if (Options.enableFoodWarn && timeLeft<(Options.foodWarnHours*3600))
                    row[i] = '<SPAN class=whiteOnRed>'+ timestrShort(timeLeft) +'</span>';
                  else
                    row[i] = timestrShort(timeLeft);
                }
              }
            }    
      str += _row ('Aut.', row, true, 0);
      str += '<TR><TD><font size=1><BR></td></tr>';
      for (r=1; r<13; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
          rows[r][i] = parseInt(Seed.units[cityID]['unt'+r]);
        }
      }
      if (Options.includeMarching){
        for (var i=0; i<13; i++)
          rows[i][Cities.numCities] = march.marchUnits[i];
      } 
      str += "</table>";
      myBO.Overview.cont.innerHTML = str;
    } catch (e){
      myBO.Overview.cont.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';
    }   
    t.displayTimer = setTimeout (t.show, 5000);
  },
};


myBO.Stock= {
 cont : null,
 init : function (){
   var t = myBO.Stock;
   unsafeWindow.BOutiliser = t.useItem;
   t.cont = document.createElement('div');
   return t.cont;
 },
   getContent : function (){
       var t = myBO.Stock;
       return t.cont;
     },
     hide : function (){
       var t = myBO.Stock;
       t.state = null;
       clearTimeout (t.displayTimer);
     },
     
     show : function (){  
      var t = myBO.Stock;
      m = "<DIV class=boStat>"+lang.stock.title+"</div>";
      m += "<div style='max-height:480px; height:480px; overflow-y:auto' id='BOStockContenu'></div>";
      t.cont.innerHTML = m; 
      t.voir();
   },
   voir:function() {
    var t = myBO.Stock;
    var  category = ['',lang.stock.cat1,lang.stock.cat2,lang.stock.cat3,lang.stock.cat4,lang.stock.cat5,lang.stock.cat6];
    var puipui={1330:400,1350:600,1411:2000,1455:1350,1474:1000,1465:1350,1351:3000,1445:400,1452:175,1461:90,1371:3500,1391:4500,1427:150,1443:200,1311:1000,1401:1800,1341:2250};
    var puitotal=0;
   var m = "<TABLE border=0 align=center><tr><td colspan=2><b>"+lang.stock.col1+"</td><td><b>"+lang.stock.col1+"</td><td><b>"+lang.stock.col1+"</td><td></td></tr>";
      var test = Seed.items;
      var e=unsafeWindow.Object.keys(Seed.items);
      var lestock = [];   
      for(var d=0;d<e.length;d++) {
       var h=e[d].split("i")[1];
       var pui=0;
       if(unsafeWindow.itemlist["i"+h] && parseInt(Seed.items[e[d]])>0){
        if ((parseInt(h)<1100 || parseInt(h)>1199) && parseInt(unsafeWindow.itemlist["i"+h].category)>0) {
         if (puipui[h])
          pui=puipui[h] * parseInt(Seed.items[e[d]]);
         m += "<tr><td><img title='"+h+"' id='BOitem"+h+"' onclick='BOutiliser("+h+", this);' src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+ h + ".jpg' width=25></td><td>"+unsafeWindow.itemlist["i"+h].name+"</td><td><center><b>"+Seed.items[e[d]]+"</td><td>"+ category[unsafeWindow.itemlist["i"+h].category] + "</td>";
         m+="<td>"+addCommas(pui)+"</td></tr>"; 
         puitotal=puitotal+pui;
        }
       }
      }
      if (puitotal>0) {
      
      m+="<tr><td colspan=4>"+lang.stock.puitotal+"</td><td><b>"+addCommas(puitotal)+"</tr></table>";
      
      }
    ById('BOStockContenu').innerHTML = m;  
   },
   count:0,
   useItem : function(num, id) {
    var t = myBO.Stock;
    id.src='http://www.ronlohse.com/wait2.gif';
    id.onclick="";
    t.count++;
    unsafeWindow.cm.ItemController.use(num);
   
      t.count=0;
      t.voir();
    
  },
}
myBO.Info = {
  cont : null,
  state : null,
  ModelCity : {},
  init : function (){
    var t = myBO.Info;
    t.cont = document.createElement('div');
    return t.cont;
  },

  getContent : function (){
    var t = myBO.Info;
    return t.cont;
  },

  hide : function (){
    var t = myBO.Info;
  },

  show : function (){
    fortmight = {
      u53: "4",
      u55: "7",
      u60: "1",
      u61: "2",
      u62: "3",
    };
    var t = myBO.Info;
    rownum = 0;
    if (t.state == null){      
      m = '<STYLE>.xtabH {background:#ffffe8; border:none; padding-right: 5px; padding-left: 5px; margin-left:10px; }\
              .xtabHL { background:#ffffe8; border-width: 1px; border-style: none none none solid; padding-right:5px; padding-left:5px; margin-left:10px; }\
              .xtabL { background:none; border-width: 1px; border-style: none none none solid; padding-right:5px; padding-left: 5px; margin-left:10px; }\
              .xtabLine { padding:0px; spacing:0px; height:1px; border-color:black; border-width: 1px; border-style: none none solid none }</style>\
          <DIV style="height:650px; max-height:650px; overflow-y:auto; overflow-x:auto"><DIV class=boStat><b>'+lang.info.title1+'</div>\
          <table border=0 width=100%><tr><td colspan=2><center><b><a href=http://kocbottolsoriginal.host22.com target=_toweralert><font size=3>SUPPORTO DEL POWER</font></a></td>\
          </tr><tr><td width=50%>Mappa koc.dunno.com : <a target=_dunno HREF="http://koc.dunno.com/index.sjs?f=KocMapViewer&server_id=' + getServerId() +'">Dominio ' + getServerId() +'</A>\
          </td><td><a target=_sito HREF="http://kocbottolsoriginal.host22.com">'+ScriptName+'</a></td></tr>\
          <tr><td><a target=_devil HREF="http://www.devilalliance.org">Guida non ufficiale a Kingdoms of Camelot</a></td><td>KOCMON : <a target=_blank href="http://kocmon.com/">www.kocmon.com</a></td></table><br>\
          <DIV class=boStat>'+lang.info.title2+'</div><TABLE align=center cellpadding=1 cellspacing=0 width=98%>\
          <TR align=center><TD class=xtab></td><TD class=xtabHL><B>Consumo</b></td><TD class=xtabHL colspan=5><B>COSTI DI COSTRUZIONE</b></td><TD class=xtabHL colspan=7><B>STATO</b></td></tr>\
          <TR valign=bottom align=right><TD class=xtab></td><TD class=xtabHL>Cibo</td><TD class=xtabHL>Cibo</td><TD class=xtabH>Legno</td><TD class=xtabH>Pietra</td>\
          <TD class=xtabH>Minerali</td><TD class=xtabH>Pop</td><TD class=xtabHL>Potere</td><TD class=xtabH>Vita</td><TD class=xtabH>Attacco</td><TD class=xtabH>Difesa</td><TD class=xtabH>Velocitta</td><TD class=xtabH>Raggio</td><TD class=xtabH>Carico</td>\
          </tr>\
          <TR style="height:1px;"><TD style="padding:0px; spacing:0px; height:1px; border-color:black; border-width: 1px; border-style: none none solid none" colspan=14></td></tr>';
      for (ui=1; ui<13; ui++){
        if (++rownum % 2)
          rsty = '';
        else
          rsty = ' style="background: #e8e8e8" ';
        cost = unsafeWindow.unitcost['unt'+ui];
        stats = unsafeWindow.unitstats['unt'+ui];
        food = unsafeWindow.unitupkeeps[ui];
        might = unsafeWindow.unitmight['unt'+ui];
        
        var sped=0,range=0,life=0,atk=0,def=0,loadEffectBoost=0;
        var techLoadBoost=parseInt(Seed.tech.tch10)*0.1;
        if(Seed.playerEffects.loadExpire>uW.unixtime()){loadEffectBoost=0.25}
	var loadBoostBase=(EffetTronePrc(6).percent*0.01)+loadEffectBoost+techLoadBoost;
        var loadBoost=loadBoostBase;
        
        range+=EffetTronePrc(5).percent;   // range
        life += EffetTronePrc(3).percent;   //life
        atk +=EffetTronePrc(1).percent;    //attack

        if(uW.cm.unitFrontendType[ui]=="infantry"){
          life +=EffetTronePrc(26).percent; //infrantry life
          atk +=EffetTronePrc(24).percent;    //infrantry attack
        }
        if(uW.cm.unitFrontendType[ui]=="ranged"){
	   life +=EffetTronePrc(36).percent;  //ranged life
	   range +=EffetTronePrc(37).percent; //ranged range
           atk +=EffetTronePrc(34).percent;    //ranged attack
        }
        if(uW.cm.unitFrontendType[ui]=="siege"){
          range +=EffetTronePrc(58).percent; //siege range
          atk +=EffetTronePrc(56).percent;   //siege attack
          loadBoost+=EffetTronePrc(59).percent*0.01; //siege load - valable pour le siege sauf wagon ^^^^
         
        }
        if(uW.cm.unitFrontendType[ui]=="horsed"){
          life +=EffetTronePrc(46).percent; //horse life
          atk +=EffetTronePrc(44).percent;   //horse attack
          loadBoost+=EffetTronePrc(48).percent*0.01; // horse load
        }
        // estimation life
  	lifestat=stats[0]*(1+(Seed.tech.tch15*5)/100);
        lifestat=lifestat + (stats[0]*((life/100)));
        // estimation range
	rangestat=stats[4]*(1+(Seed.tech.tch13*5)/100);
        rangestat=rangestat + (stats[4]*((range/100)));
        // estimation attack
	atkstat=(stats[1]*(0+(Seed.tech.tch8*5)/100))  + (stats[1]*(0+(Seed.tech.tch15*5)/100));
        atkstat=stats[1] +   atkstat + (stats[1]*((atk/100))) + (stats[1]* ( parseFloat(255*0.005))) + (stats[1]*0.20)  + (stats[1]*0.20);  
        // estimation def
	defstat=(stats[2]*(1+(Seed.tech.tch9*5)/100));
        defstat=defstat + (stats[2]*((def/100))) + (stats[2]* ( parseFloat(255*0.005))) + (stats[2]*0.20);
        // estimation speed
	//sped=stats[3]*(1+(Seed.tech.tch9*5)/100);
        //sped=atkstat + (stats[3]*((atk/100)));
        // estmation load
        loadstat=stats[5] * (1+loadBoost);

      m += '<TR '+ rsty +'align=right><TD class=xtab align=left><B>'+ cost[0].substr(0,16) +'</b></td><TD class=xtabL>'+ food +'</td><TD class=xtabL>'+ cost[1] +'</td><TD class=xtab>'+ cost[2] +'</td>\
            <TD class=xtab>'+ cost[3] +'</td><TD class=xtab>'+ cost[4] +'</td><TD class=xtab>'+ cost[6] +'</td><TD class=xtabL>'+ might +'</td>\
            <TD class=xtab>'+ stats[0] +'</td><TD class=xtab>'+ stats[1] +'</td><TD class=xtab>'+ stats[2] +'</td><TD class=xtab>'+ stats[3] +'</td>\
            <TD class=xtab>'+ stats[4] +'</td><TD class=xtab>'+ stats[5] +'</td></tr>';
            
	m += '<TR '+ rsty +' align=right ><TD class=xtab align=left>&nbsp;</td><TD class=xtabL>&nbsp;</td><TD class=xtabL>&nbsp;</td><TD class=xtab>&nbsp;</td>\
            <TD class=xtab>&nbsp;</td><TD class=xtab>&nbsp;</td><TD class=xtab>&nbsp;</td><TD class=xtabL>&nbsp;</td>\
            <TD class=xtab style="color:red">'+ Math.ceil(lifestat) +'</td><TD class=xtab style="color:red">-</td><TD class=xtab style="color:red">-</td><TD class=xtab style="color:red">-</td>\
            <TD class=xtab style="color:red">'+ Math.ceil(rangestat) +'</td><TD class=xtab style="color:red">'+ Math.ceil(loadstat) +'</td></tr>';
      }
      m += '<TR class=xtabLine><TD colspan=14 class=xtabLine></td></tr>';
      for (k in unsafeWindow.fortcost){
        if (++rownum % 2)
          rsty = '';
        else
          rsty = ' style="background: #e8e8e8" ';
        cost = unsafeWindow.fortcost[k];
        fi = k.substring(3);
        stats = unsafeWindow.fortstats['unt'+fi];
        food = 0;
        might = fortmight['u'+fi];
        name = cost[0].replace ('Defensive','');
        name = name.replace ('Wall-Mounted','');
        m += '<TR '+ rsty +'align=right><TD align=left class=xtab><B>'+ name.substr(0,20) +'</b></td><TD class=xtabL>'+ food +'</td><TD class=xtabL>'+ cost[1] +'</td><TD class=xtab>'+ cost[2] +'</td>\
            <TD class=xtab>'+ cost[3] +'</td><TD class=xtab>'+ cost[4] +'</td><TD class=xtab>'+ cost[6] +'</td><TD class=xtabL>'+ might +'</td>\
            <TD class=xtab>'+ stats[0] +'</td><TD class=xtab>'+ stats[1] +'</td><TD class=xtab>'+ stats[2] +'</td><TD class=xtab>'+ stats[3] +'</td>\
            <TD class=xtab>'+ stats[4] +'</td><TD class=xtab>'+ stats[5] +'</td></tr>';
      }
      m += '<TR class=xtabLine><TD colspan=14 class=xtabLine></td></tr>';
      m += '</table>';
      function _displayrow (name, row){
                    var tot=0;
      			style = ((rownum++ % 2)?'':' style = "background: #e8e8e8"');
      			m += '<TR' + style + '><TD align=right><B>' + name + '</B></td>';
      			for (i=0; i<row.length; i++) {
      				m += ((row[i]==0)?'<td align=right><SPAN class=boldRed>0</SPAN></td>':'<td align=right>'+addCommas(parseInt(row[i]))+'</td>');
      				tot+=parseInt(row[i]);
      				}
      			m += '<td align=right>'+addCommas(tot)+'</td></tr>';
      		}
      		m += '<BR /><DIV class=boStat>'+lang.info.title3+'</div><BR /><SPAN id="Research">&nbsp;</SPAN><BR><DIV class=boStat>'+lang.info.title4+'</div>' +
      			'<BR /><TABLE align=center cellpadding=1 cellspacing=0><TABLE align=center cellpadding=1 cellspacing=0><TR align=right><TD></td>';
      		infoRows = [];
      		for (r=0; r<26; r++)
      			infoRows[r] = [];
      		for(i=0; i<Cities.numCities; i++) {
      			cityID = 'city'+ Cities.cities[i].id;
      			m += "<TD align=center valign=bottom width=60px><B>" + Cities.cities[i].name.replace(/ /g, "<BR>").substr(0,10)  + "</B></TD>";
      			getTroopDefTrainEstimates(cityID,Cities.cities[i].id);
      			infoRows[0][i] = Cities.cities[i].numBarracks;
      			infoRows[1][i] = Cities.cities[i].totLevelsBarracks;
      			infoRows[2][i] = Cities.cities[i].foremanBasePoliticsScore;
      			infoRows[3][i] = Cities.cities[i].marshallCombatScore;
      			infoRows[5][i] = Cities.cities[i].stableLevel;
      			infoRows[6][i] = Cities.cities[i].workshopLevel;
      			infoRows[24][i] = Cities.cities[i].blacksmithLevel;
      			infoRows[25][i] = Cities.cities[i].numHouse;
      			for (var j=1; j<13; j++)
      				infoRows[j+6][i] = ((Cities.cities[i]['Troop'+j+'Time'] > 0)?(3600 / Cities.cities[i]['Troop'+j+'Time']):0);
      			infoRows[19][i] = Cities.cities[i]['Def53Time'];
      			if (infoRows[19][i] > 0)
      				infoRows[19][i] = 3600 / infoRows[19][i];
      			infoRows[20][i] = Cities.cities[i]['Def55Time'];
      			if (infoRows[20][i] > 0)
      				infoRows[20][i] = 3600 / infoRows[20][i];
      			infoRows[21][i] = Cities.cities[i]['Def60Time'];
      			if (infoRows[21][i] > 0)
      				infoRows[21][i] = 3600 / infoRows[21][i];
      			infoRows[22][i] = Cities.cities[i]['Def61Time'];
      			if (infoRows[22][i] > 0)
      				infoRows[22][i] = 3600 / infoRows[22][i];
      			infoRows[23][i] = Cities.cities[i]['Def62Time'];
      			if (infoRows[23][i] > 0)
      				infoRows[23][i] = 3600 / infoRows[23][i];
      		}
      		m += "<td align=center valign=bottom width=60px><b>"+lang.info.tot+"</td></tr>";
      		rownum=0;
      		_displayrow (lang.info.row25, infoRows[25]);
      		_displayrow (lang.info.row0, infoRows[0]);
      		_displayrow (lang.info.row1, infoRows[1]);
      		_displayrow (lang.info.row2, infoRows[2]);
      		_displayrow (lang.info.row3, infoRows[3]);
      		_displayrow (lang.info.row5, infoRows[5]);
      		_displayrow (lang.info.row24, infoRows[24]);
      		_displayrow (lang.info.row6, infoRows[6]);      		
      		m += "<TR><TD></TD><TD nowrap align=center colspan="+(Cities.numCities)+"><B>"+lang.info.trainhour+"</B></TD></TR>";
      		_displayrow (uW.unitcost['unt1'][0], infoRows[7]);
      		_displayrow (uW.unitcost['unt2'][0], infoRows[8]);
      		_displayrow (uW.unitcost['unt3'][0], infoRows[9]);
      		_displayrow (uW.unitcost['unt4'][0], infoRows[10]);
      		_displayrow (uW.unitcost['unt5'][0], infoRows[11]);
      		_displayrow (uW.unitcost['unt6'][0], infoRows[12]);
      		_displayrow (uW.unitcost['unt7'][0], infoRows[13]);
      		_displayrow (uW.unitcost['unt8'][0], infoRows[14]);
      		_displayrow (uW.unitcost['unt9'][0], infoRows[15]);
      		_displayrow (uW.unitcost['unt10'][0], infoRows[16]);
      		_displayrow (uW.unitcost['unt11'][0], infoRows[17]);
      		_displayrow (uW.unitcost['unt12'][0], infoRows[18]);
      		m += "<TR><TD></TD><TD nowrap align=center colspan="+(Cities.numCities)+"><B>"+lang.info.buildhour+"</B></TD></TR>";
      		_displayrow (uW.fortcost['frt53'][0], infoRows[19]);
      		_displayrow (uW.fortcost['frt55'][0], infoRows[20]);
      		_displayrow (uW.fortcost['frt60'][0], infoRows[21]);
      		_displayrow (uW.fortcost['frt61'][0], infoRows[22]);
      		_displayrow (uW.fortcost['frt62'][0], infoRows[23]);
		m += "</TABLE><BR />";
      m += '<BR><DIV class=boStat>'+lang.info.title5+'</div><DIV class=ptentry><TABLE align=center cellpadding=1 cellspacing=0>\
      <TR><TD class=xtab align=right><B>'+lang.General.source+' : </b></td><TD  class=xtab> X: <INPUT id=calcX type=text\> Y: <INPUT id=calcY type=text\> '+lang.General.or+' '+unsafeWindow.g_js_strings.commonstr.city+' : <SPAN id=ptloc1></span></td></tr>\
      <TR><TD class=xtab><B>'+lang.General.dest+' : </b></td><TD class=xtab> X: <INPUT id=calcX2 type=text\> Y: <INPUT id=calcY2 type=text\> '+lang.General.or+' '+unsafeWindow.g_js_strings.commonstr.city+' <SPAN id=ptloc2></span></td></tr></table>\
      <CENTER><DIV style="width:60%; font-size:14px; border: 1px solid; background-color:white; margin:20px 3px 3px 0px; padding:4px" id=ptdistout></div>\
<div><b>'+lang.General.EstimateT+' </b><select id="idETASelect">\
        <option value="0" > ---- </option>';
        var z=0;
        for (y in unsafeWindow.unitcost) {
          z++;
          m+='<option value="'+z+'">'+unsafeWindow.unitcost[y][0]+'</option>';
	}
m +='</select></div><DIV style="width:60%; font-size:14px; border: 1px solid; background-color:white; margin:20px 3px 3px 0px; padding:4px" id=ptETAout></div></center>';
m += '<BR><DIV class=boStat>'+lang.info.title6+'</div><DIV id=ptProvMap style="height:'+ provMapCoords.imgHeight +'px; width:'+ provMapCoords.imgWidth +'px; background-repeat:no-repeat; background-image:url(\''+ URL_PROVINCE_MAP +'\')"></div></div>';
var bor,ector,kay,bedivere,gawain,percival,galahad,lancelot,arthur,morgana,mordred;
if (Seed.items.i1101){bor=Seed.items.i1101}else{bor=0};
if (Seed.items.i1102){ector=Seed.items.i1102}else{ector=0};
if (Seed.items.i1103){kay=Seed.items.i1103}else{kay=0};
if (Seed.items.i1104){bedivere=Seed.items.i1104}else{bedivere=0};
if (Seed.items.i1105){gawain=Seed.items.i1105}else{gawain=0};
if (Seed.items.i1106){percival=Seed.items.i1106}else{percival=0};
if (Seed.items.i1107){galahad=Seed.items.i1107}else{galahad=0};
if (Seed.items.i1108){lancelot=Seed.items.i1108}else{lancelot=0};
if (Seed.items.i1109){arthur=Seed.items.i1109}else{arthur=0};
if (Seed.items.i1110){morgana=Seed.items.i1110}else{morgana=0};
if (Seed.items.i1111){mordred=Seed.items.i1111}else{mordred=0};
if (Seed.items.i1112){Stag=Seed.items.i1112}else{Stag=0};
if (Seed.items.i1113){Pendragon=Seed.items.i1113}else{Pendragon=0};
if (Seed.items.i1114){Lady=Seed.items.i1114}else{Lady=0};
if (Seed.items.i1115){Merlin=Seed.items.i1115}else{Merlin=0};	
if (Seed.items.i1120){aetherseal=Seed.items.i1120}else{aetherseal=0};	
if (Seed.items.i1121){ysbadden=Seed.items.i1121}else{ysbadden=0};	
if (Cities.cities[1]){ville2="#99EE99";}else{ville2="#EE9999";}
if (Cities.cities[2]){ville3="#99EE99";}else{ville3="#EE9999";}
if (Cities.cities[3]){ville4="#99EE99";}else{ville4="#EE9999";}  
if (Cities.cities[4]){ville5="#99EE99";}else{ville5="#EE9999";}
if (Cities.cities[5]){ville6="#99EE99";}else{ville6="#EE9999";}
if (Cities.cities[6]){ville7="#99EE99";}else{ville7="#EE9999";}
if (Cities.cities[7]){ville8="#99EE99";}else{ville8="#EE9999";}
m += '<style>CAPTION.MYTABLE  {background-color:eeffff;color:black;border-style:solid;border-width:1px;border-color:black;}\
  TABLE.MYTABLE  { \
     font-family:arial;\
     border-collapse:collapse;\
     font-size:10pt;\
     background-color:F5F5F5;\
     width:100%;\
     border-style:solid;\
     border-color:black;\
     border-width:1px;\
  } TH.MYTABLE  {\
     font-size:10pt;\
     color:black;\
     text-align:center;\
     border-style:solid;\
     border-color:black;\
     border-width:1px;\
  } TR.MYTABLE { }\
  TD.MYTABLE {  \
     font-size:10pt;\
     background-color:FFFFE5;\
     color:black;\
     border-style:solid;\
     border-width:1px;\
     text-align:left;\
  }</style>\
<TABLE CLASS="MYTABLE" CELLPADDING=0 CELLSPACING=0>\
    <CAPTION CLASS="MYTABLE">'+lang.info.title7+'</CAPTION><THEAD >\
      <TR CLASS="MYTABLE">\
        <TH CLASS="MYTABLE">'+uW.g_js_strings.commonstr.cities+'</TH>\
        <TH CLASS="MYTABLE">Besoins 1</TH>\
        <TH CLASS="MYTABLE">Besoins 2</TH>\
        <TH CLASS="MYTABLE">Besoins 3</TH>\
      </TR>\
    </THEAD><TBODY>\
      <TR CLASS="MYTABLE">  \
        <TD CLASS="MYTABLE" style="background-color:'+ville2+';">'+uW.g_js_strings.commonstr.city+' 2</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+ville2+';">Niveau 7 ('+Seed.player.title+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+ville2+';">10 Amis</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+ville2+';">&nbsp;</TD>\
      </TR><TR CLASS="MYTABLE">  \
        <TD CLASS="MYTABLE" style="background-color:'+ville3+';">'+uW.g_js_strings.commonstr.city+' 3</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+ ( (bor>=4)?"#99EE99":ville3 ) +';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1101.jpg>&nbsp;4 Bor ('+bor+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+ ( (ector>=2)?"#99EE99":ville3 ) +';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1102.jpg>&nbsp;2 Ector ('+ector+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+ ( (kay>=1)?"#99EE99":ville3 ) +';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1103.jpg>&nbsp;1 Kay ('+kay+')</TD>\
      </TR><TR CLASS="MYTABLE">  \
        <TD CLASS="MYTABLE" style="background-color:'+ville4+';">'+uW.g_js_strings.commonstr.city+' 4</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (kay>=4)?"#99EE99":ville4 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1103.jpg>&nbsp;4 Kay ('+kay+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (bedivere>=3)?"#99EE99":ville4 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1104.jpg>&nbsp;3 Bedivere ('+bedivere+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (gawain>=1)?"#99EE99":ville4 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1105.jpg>&nbsp;1 Gawain ('+gawain+')</TD>\
      </TR>\
      <TR CLASS="MYTABLE">  \
        <TD CLASS="MYTABLE" style="background-color:'+ville5+';">'+uW.g_js_strings.commonstr.city+' 5</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (percival>=4)?"#99EE99":ville5 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1106.jpg>&nbsp;4 Perceval ('+percival+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (galahad>=3)?"#99EE99":ville5 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1107.jpg>&nbsp;3 Galaad ('+galahad+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (lancelot>=2)?"#99EE99":ville5 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1108.jpg>&nbsp;2 Lancelot ('+lancelot+')</TD>\
      </TR>\
      <TR CLASS="MYTABLE">  \
        <TD CLASS="MYTABLE" style="background-color:'+ville6+';">'+uW.g_js_strings.commonstr.city+' 6</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (arthur>=4)?"#99EE99":ville6 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1109.jpg>&nbsp;4 Roi Arthur ('+arthur+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (morgana>=3)?"#99EE99":ville6 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1110.jpg>&nbsp;3 Morgane ('+morgana+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (mordred>=2)?"#99EE99":ville6 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1111.jpg>&nbsp;2 Mordred ('+mordred+')</TD>\
      </TR>\
       <TR CLASS="MYTABLE">  \
        <TD CLASS="MYTABLE" style="background-color:'+ville7+';">'+uW.g_js_strings.commonstr.city+' 7</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (Stag>=4)?"#99EE99":ville7 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1112.jpg>&nbsp;4 Roi Stag ('+Stag+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (Pendragon>=3)?"#99EE99":ville7 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1113.jpg>&nbsp;3 Terrestre ('+Pendragon+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (Lady>=2)?"#99EE99":ville7 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1114.jpg>&nbsp;2 Aquatique ('+Lady+')</TD>\
      </TR>\
      <TR CLASS="MYTABLE">  \
        <TD CLASS="MYTABLE" style="background-color:'+ville8+';">'+uW.g_js_strings.commonstr.city+' 8</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (Merlin>=4)?"#99EE99":ville8 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1115.jpg>&nbsp;4 Merlin ('+Merlin+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (aetherseal>=3)?"#99EE99":ville8 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1120.jpg>&nbsp;3 Aetherseal ('+aetherseal+')</TD>\
        <TD CLASS="MYTABLE" style="background-color:'+( (ysbadden>=2)?"#99EE99":ville8 )+';"><img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1121.jpg>&nbsp;2 Ysbadden  ('+ysbadden +')</TD>\
      </TR>\
    </TBODY></TABLE><TABLE CLASS="MYTABLE" CELLPADDING=0 CELLSPACING=0><CAPTION CLASS="MYTABLE">'+lang.info.title8+'</CAPTION><THEAD >\
        <TR CLASS="MYTABLE">\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1101.jpg title="Bor"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1102.jpg title="Ector"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1103.jpg title="Kay"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1104.jpg title="Bedivere"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1105.jpg title="Gawain"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1106.jpg title="Perceval"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1107.jpg title="Galaad"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1108.jpg title="Lancelot"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1109.jpg title="Arthur"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1110.jpg title="Morgane"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1111.jpg title="Mordred"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1112.jpg title="Stag"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1113.jpg title="Terrestre"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1114.jpg title="Aquatique"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1115.jpg title="Merlin"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1120.jpg title="Aetherseal"></TH>\
          <TH CLASS="MYTABLE"><img width=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1121.jpg title="Ysbadden"></TH>\
         </TR>\
 </THEAD><TR CLASS="MYTABLE">\
  <TD CLASS="MYTABLE"><center><b>'+bor+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+ector+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+kay+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+bedivere+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+gawain+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+percival+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+galahad+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+lancelot+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+arthur+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+morgana+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+mordred+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+Stag+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+Pendragon+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+Lady+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+Merlin+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+aetherseal+'</TD>\
  <TD CLASS="MYTABLE"><center><b>'+ysbadden+'</TD>\
  </TR><TR CLASS="MYTABLE"></tr>\
  </table>';
  
 t.cont.innerHTML = m;
        new CdispCityPicker ('ptloc1', ById('ptloc1'), true, t.eventFromLocChanged, 0).bindToXYboxes(ById('calcX'), ById('calcY'));
    new CdispCityPicker ('ptloc2', ById('ptloc2'), true, t.eventLocChanged, 0).bindToXYboxes(ById('calcX2'), ById('calcY2'));
     t.eventFromLocChanged(Cities.cities[0], Cities.cities[0].x, Cities.cities[0].y); 
    ById('idETASelect').addEventListener ( 'change', t.eventLocChanged, false); 
    function rlShow(rl) {
    			var retval = '<TD nowrap><B>'+rl.Name+'</B></TD><TD align=right><B>&nbsp;&nbsp;';
    			nlETA = ((rl.NextLevelETA > 0)?('(' + (rl.Level + 1) + ': ' + timestr(rl.NextLevelETA) + ')'):'');
    			retval += ((rl.Level < 9)?('<SPAN class=boldRed>' + rl.Level + '</SPAN></B></TD><TD nowrap>&nbsp;&nbsp;' + nlETA + '</TD>'):(rl.Level + '</B></TD><TD nowrap>&nbsp;&nbsp;' + nlETA + '</TD>'));
    			return retval;
    };
    var m = '';
    getResearchLevels();
    m += '<TABLE align=center cellpadding=1 cellspacing=0>' +
    			'<TR>' + rlShow(researchLevels[1]) + '<TD width=10></TD>' + rlShow(researchLevels[6]) + '<TD width=10></TD>' + rlShow(researchLevels[12]) + '</TR>' +
    			'<TR>' + rlShow(researchLevels[2]) + '<TD></TD>' + rlShow(researchLevels[8]) + '<TD></TD>' + rlShow(researchLevels[13]) + '</TR>' +
    			'<TR>' + rlShow(researchLevels[3]) + '<TD></TD>' + rlShow(researchLevels[9]) + '<TD></TD>' + rlShow(researchLevels[14]) + '</TR>' +
    			'<TR>' + rlShow(researchLevels[4]) + '<TD></TD>' + rlShow(researchLevels[15]) + '<TD></TD>' + rlShow(researchLevels[10]) + '</TR>' +
    			'<TR>' + rlShow(researchLevels[5]) + '<TD></TD>' + rlShow(researchLevels[11]) + '<TD></TD>' + rlShow(researchLevels[16]) + '</TR></TABLE>';
    ById('Research').innerHTML = m;
     for (var c=0; c<Cities.numCities; c++)      
        t.makeCityImg (c, ById('ptProvMap'));
      t.state = 1;
    }
  },
  makeCityImg : function (cityNum, eMap){
    var t = my.Info;
    var city = Cities.cities[cityNum];
    var x = parseInt((provMapCoords.mapWidth * city.x) / 750);
    var y = parseInt((provMapCoords.mapHeight * city.y) / 750);
    var ce = document.createElement ('div');
    ce.style.background = 'black';
    ce.style.opacity = '1.0';
    ce.style.position='relative';
    ce.style.display='block';
    ce.style.width='14px';
    ce.style.height='16px';
    ce.style.border='1px solid #fff';
    ce.style.color = 'white';
    ce.style.textAlign = 'center';
    ce.style.top = (y+provMapCoords.topMargin-(cityNum*16)-8) +'px';      
    ce.style.left = (x+provMapCoords.leftMargin-7) +'px';
    eMap.appendChild(ce);
    ce.innerHTML = (cityNum+1) +'';
  },
  
  eventLocChanged : function (city, x, y){
    var t = myBO.Info;
    var x1 = parseInt(ById('calcX').value);
    var x2 = parseInt(ById('calcX2').value);
    if (isNaN(x2))
      return;
    var y1 = parseInt(ById('calcY').value);
    var y2 = parseInt(ById('calcY2').value);
    var m = lang.info.ptdistout1+' '+ x1 +','+ y1 +' '+lang.info.ptdistout2+' '+ x2 +','+ y2 +' '+lang.info.ptdistout3+' <B>'+ distance (x1, y1, x2, y2).toFixed(2) +'</b>';
    ById('ptdistout').innerHTML = m;
    var dist = distance (x1, y1, x2, y2);
    if (t.ModelCity) m = estETA(dist, ById('idETASelect').value, t.ModelCity.id,4)
     else 
      m = estETA(dist, ById('idETASelect').value, 0, 4)
    if (m != null)
           ById('ptETAout').innerHTML = "Atk : "+m.etaStr+" - Renf : "+m.friendEtaStr;
  },
  eventFromLocChanged : function (city, x, y){
    var t = myBO.Info;
    t.ModelCity = city;
    var x1 = parseInt(ById('calcX').value);
    var x2 = parseInt(ById('calcX2').value);
    if (isNaN(x2))
      return;
    var y1 = parseInt(ById('calcY').value);
    var y2 = parseInt(ById('calcY2').value);
    var m = lang.info.ptdistout1+' '+ x1 +','+ y1 +' '+lang.info.ptdistout2+' '+ x2 +','+ y2 +' '+lang.info.ptdistout3+' <B>'+ distance (x1, y1, x2, y2).toFixed(2) +'</b>';
    ById('ptdistout').innerHTML = m;
    var dist = distance (x1, y1, x2, y2);
       if (t.ModelCity) m = estETA(dist, ById('idETASelect').value, t.ModelCity.id,4)
        else 
      m = estETA(dist, ById('idETASelect').value, 0, 4)
    if (m != null)
       ById('ptETAout').innerHTML = "Atk : "+m.etaStr+" - Renf : "+m.friendEtaStr;
  },
}

myBO.Alliance = {
  tabOrder : 120,
  cont : null,
  alliancemembers:[],
  number:0,
  totalmembers:0,
  error:false,
  
  getContent : function (){
      var t = myBO.Alliance;
      return t.cont;
  },
  init : function (){
      var t = myBO.Alliance;
      t.cont = document.createElement('div');
      return t.cont;
  },  
  show : function (){    
     var t = myBO.Alliance;   
     t.cont.style.overflowY = 'scroll';
     t.cont.style.maxHeight = '500px';
     t.totalmembers=0;
     t.alliancemembers=[];	
     unsafeWindow.getdetails = t.getMemberDetails;
    var m =  '<DIV class=boStat><b>'+lang.ALLIANCE.title+'</b></div><TABLE align=center cellpadding=1 cellspacing=0></table>';
    m += '<TABLE class=ptTab><TD width=200px>'+lang.ALLIANCE.list+'</td><TD>'+lang.ALLIANCE.sort+': <select id="searchAlli">';
	m += '<option value="name">'+uW.g_js_strings.commonstr.nametx+'</options>';
    m += '<option value="might">'+uW.g_js_strings.commonstr.might+'</option>';
    m += '<option value="login">'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+'</option>';
    m += '<option value="cities">'+uW.g_js_strings.commonstr.cities+'</option>';
    m += '<option value="position">'+lang.ALLIANCE.position+'</option>';
    m += '<option value="glory">'+uW.g_js_strings.commonstr.glory+'</option>';
	m += '<option value="dip">'+lang.ALLIANCE.daypos+' (DIP)</option></select></td>';
    m += '<TD><INPUT id=alList type=submit value="'+lang.ALLIANCE.list+'"></td>';
    m += '<TD id=progress></td>';
    m += '<TR><TD width=200px>'+lang.ALLIANCE.listdiplo+'</td><TD><INPUT id=aldiplo type=submit value="'+lang.ALLIANCE.listdiplot+'"></td></tr></table>';
    m+='<DIV class=boStat><b>'+lang.ALLIANCE.resume+'</div><TABLE align=center cellpadding=1 cellspacing=0 class=ptTab></table>';
    m += '<TABLE id=alOverviewTab class=alTab><TR align="center"></tr></table>';
   t.cont.innerHTML = m;
   ById('alList').addEventListener('click', function(){
    	if (!t.searching){
	    	t.totalmembers=0;
	    	t.alliancemembers=[];	
		    ById('alOverviewTab').innerHTML ="";
		    ById('progress').innerHTML ="";
		    ById('progress').innerHTML = uW.g_js_strings.commonstr.research +"...";
		    ById('alList').disabled = true;
		    t.error=false;
		    t.fetchAllianceMemberPage();
		} 
    }, false);
    
    ById('searchAlli').addEventListener('click', function(){
        if (t.alliancemembers!="") {
        	ById('alOverviewTab').innerHTML ="";
        	t.paintMembers(); 
        }
    }, false);
    ById('aldiplo').addEventListener('click', function(){t.paintDiplomacy();}, false);  
    
  window.addEventListener('unload', t.onUnload, false);
  },
  paintMembers: function(){
  var t = myBO.Alliance; 
	  		  if (ById('searchAlli').value == "name") {
				  var sortmembers = t.alliancemembers.sort(function(a, b){
				         var sortA=a.Name.toLowerCase(), sortB=b.Name.toLowerCase()
				         if (sortA < sortB) 
				          return -1
				         if (sortA > sortB)
				          return 1
				         return 0 
				        });
			  }     
			  if (ById('searchAlli').value == "might") {
			  	  var sortmembers = t.alliancemembers.sort(function(a, b){
			  	         var sortA=parseInt(a.Might),sortB=parseInt(b.Might)
			  	         if (sortA > sortB) 
			  	          return -1
			  	         if (sortA < sortB)
			  	          return 1
			  	         return 0 
			  	        });
			  }     
			  if (ById('searchAlli').value == "login") {
			  	  var sortmembers = t.alliancemembers.sort(function(a, b){
			  	         var sortA=a.LastLogin,sortB=b.LastLogin
			  	         if (sortA < sortB) 
			  	          return -1
			  	         if (sortA > sortB)
			  	          return 1
			  	         return 0 
			  	        });
			  }     
			  if (ById('searchAlli').value == "cities") {
			  	  var sortmembers = t.alliancemembers.sort(function(a, b){
			  	         var sortA=a.Cities,sortB=b.Cities
			  	         if (sortA < sortB) 
			  	          return -1
			  	         if (sortA > sortB)
			  	          return 1
			  	         return 0 
			  	        });
			  }     
			  if (ById('searchAlli').value == "dip") {
			  	  var sortmembers = t.alliancemembers.sort(function(a, b){
			  	         var sortA=a.dip,sortB=b.dip
			  	         if (sortA < sortB) 
			  	          return -1
			  	         if (sortA > sortB)
			  	          return 1
			  	         return 0 
			  	        });
			  }     
			  if (ById('searchAlli').value == "position") {
			  	  var sortmembers = t.alliancemembers.sort(function(a, b){
			  	         var sortA=a.Position,sortB=b.Position
			  	         if (sortA < sortB) 
			  	          return -1
			  	         if (sortA > sortB)
			  	          return 1
			  	         return 0 
			  	        });
			  } 
			  if (ById('searchAlli').value == "glory") {
			  	  var sortmembers = t.alliancemembers.sort(function(a, b){
			  	         var sortA=parseInt(a.glory),sortB=parseInt(b.glory);
			  	         if (sortA > sortB) 
			  	          return -1
			  	         if (sortA < sortB)
			  	          return 1
			  	         return 0 
			  	        });
			  }      
			  for (var y = (sortmembers.length-1); y >=0; y--) {
			                      t._addTab(sortmembers[y].Name,sortmembers[y].Might,sortmembers[y].LastLogin,sortmembers[y].Position,sortmembers[y].dip,sortmembers[y].uid,sortmembers[y].fbuid,sortmembers[y].Cities,sortmembers[y].avatarurl,sortmembers[y].glory,sortmembers[y].dateJoined);
			                      t.cont.style.overflowY = 'scroll';
			  }
			 t._addTabHeader();
   },
  
    _addTab: function(Name,Might,LastLogin,Position,dip,uid,fbuid,Cities,avatar,gloire,arrive){
             var t = myBO.Alliance;
             var row = ById('alOverviewTab').insertRow(0);
             row.vAlign = 'top';
             row.insertCell(0).innerHTML ='<img width=25 src="'+ avatar +'">';
             row.insertCell(1).innerHTML ='<A target="_tab" href="http://www.facebook.com/profile.php?id='+ fbuid +'">'+uW.g_js_strings.commonstr.profile+'</a>';
             row.insertCell(2).innerHTML = Name;
             var cell2 = row.insertCell(3);
       		 cell2.width = "60" ;
       		 cell2.align = "right" ;
       		 cell2.vAlign = "top";
       		 cell2.innerHTML = addCommas(Might);
       		var cell2 = row.insertCell(4);
       		 cell2.width = "60" ;
       		 cell2.align = "right" ;
       		 cell2.vAlign = "top"; 
       		 cell2.innerHTML = addCommas(gloire);
       		row.insertCell(5).innerHTML = Cities;
       		 row.insertCell(6).innerHTML = officerId2String (Position);
       		 row.insertCell(7).innerHTML = dip;
       		 row.insertCell(8).innerHTML = LastLogin;
       		 row.insertCell(9).innerHTML = arrive;
          }, 
          
    _addTabHeader: function() {
    var t = myBO.Alliance;
        var row = ById('alOverviewTab').insertRow(0);
        row.vAlign = 'top';
        row.insertCell(0).innerHTML = "<b>Avatar";
        row.insertCell(1).innerHTML = "<b>Facebook";
        row.insertCell(2).innerHTML = "<b>"+uW.g_js_strings.commonstr.nametx;
        row.insertCell(3).innerHTML = "<b>"+uW.g_js_strings.commonstr.might;
        row.insertCell(4).innerHTML = "<b>"+uW.g_js_strings.commonstr.glory;
        row.insertCell(5).innerHTML = "<b>"+uW.g_js_strings.commonstr.city;
        row.insertCell(6).innerHTML = "<b>"+lang.ALLIANCE.position;
        row.insertCell(7).innerHTML = "<b><span title='"+lang.ALLIANCE.daypos+"'>DIP</span>";
        row.insertCell(8).innerHTML = "<b>"+uW.g_js_strings.modal_messages_viewreports_view.lastlogin;
        row.insertCell(9).innerHTML = "<b>"+lang.ALLIANCE.joined;
    },   
    paintDiplomacy : function () {
    	ById('alOverviewTab').innerHTML ="";
    	ById('progress').innerHTML ="";
    	var m= '<TR><TD colspan=4 style=\'background: #33CC66;\' align=center><B>'+uW.g_js_strings.commonstr.friendly+': </b></td></tr>';
    	if (Seed.allianceDiplomacies['friendly'] == null) m+='<TR><TD>'+uW.g_js_strings.getDiplomacy.sorrynoalli+'</td>';
    	else m += '<TABLE class=xtab><TR><TD>'+uW.g_js_strings.commonstr.alliance+'</td><TD>'+uW.g_js_strings.commonstr.members+'</td></tr>';
    	for (k in Seed.allianceDiplomacies['friendly']){
				m+='<TR><TD>'+Seed.allianceDiplomacies['friendly'][k]['allianceName']+'</td>';
				m+='<TD align=center>'+Seed.allianceDiplomacies['friendly'][k]['membersCount']+'</td>';
    	}
    	m+='<TR></tr></table>';
    	m+= '<TR><TD colspan=4 style=\'background: #CC0033;\' align=center><B>'+uW.g_js_strings.commonstr.hostile+': </b></td></tr>';
    	if (Seed.allianceDiplomacies['hostile'] == null) m+='<TR><TD>'+uW.g_js_strings.getDiplomacy.sorrynoalli+'</td>';
    	else m += '<TABLE class=xtab><TR><TD>'+uW.g_js_strings.commonstr.alliance+'</td><TD>'+uW.g_js_strings.commonstr.members+'</td></tr>';
    	for (k in Seed.allianceDiplomacies["hostile"]){
    		m+='<TR><TD>'+Seed.allianceDiplomacies["hostile"][k]['allianceName']+'</td>';
    		m+='<TD align=center>'+Seed.allianceDiplomacies["hostile"][k]['membersCount']+'</td>';
    	}
    	m+='<TR></tr></table>';
    	m+= '<TR><TD colspan=4 style=\'background: #FF6633;\' align=center><B>'+uW.g_js_strings.getDiplomacy.friendlytoyou+'</b></td></tr>';
    	if (Seed.allianceDiplomacies['friendlyToYou'] == null) m+='<TR><TD>'+uW.g_js_strings.getDiplomacy.sorrynoalli+'</td>';
    	else m += '<TABLE class=xtab><TR><TD>'+uW.g_js_strings.getDiplomacy.alliname+'</td><TD>'+lang.Alliance.member+'</td></tr>';
    	for (k in Seed.allianceDiplomacies["friendlyToYou"]){
    		m+='<TR><TD>'+Seed.allianceDiplomacies["friendlyToYou"][k]['allianceName']+'</td>';
    		m+='<TD align=center>'+Seed.allianceDiplomacies["friendlyToYou"][k]['membersCount']+'</td>';
    	}
    	m+='<TR></tr></table>';
    	ById('alOverviewTab').innerHTML = m;
    },
    
        
    fetchAllianceMemberPage : function () {
    var t = myBO.Alliance;
    ById('alList').disabled = true;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.pf = 0;
    
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (transport) {
      	  var rslt = eval("(" + transport.responseText + ")");
          t.totalmembers = (rslt["allianceInfo"]["members"]);
          for (var i=1;i<=10;i++) {
                 params.pageNo = i;
                 params.pf = 0;
                 new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetMembersInfo.php" + unsafeWindow.g_ajaxsuffix, {
                   method: "post",
                   parameters: params,
                   onSuccess: function (transport) {
                    var info = eval("(" + transport.responseText + ")");
                    if (info.ok) {  
                       for (var k in info["memberInfo"]){
                         if ( info["memberInfo"][k]["might"] != undefined && !t.error){  
                           t.alliancemembers.push ({
                               Name: info["memberInfo"][k]["name"],
                               Might: info["memberInfo"][k]["might"],
                               Cities: info["memberInfo"][k]["cities"],
                               Position : info["memberInfo"][k]["positionType"],
                               dip : info["memberInfo"][k]["daysInPosition"],
                               LastLogin : info["memberInfo"][k]["lastLogin"],
                               uid : info["memberInfo"][k]["userId"],
                               fbuid : info["memberInfo"][k]["fbuid"],	
                               avatarurl : info["memberInfo"][k]["avatarurl"],	
                               glory : info["memberInfo"][k]["glory"],	
                               dateJoined : info["memberInfo"][k]["dateJoined"],	
                           });
                          }
                           ById('alOverviewTab').innerHTML ="";
                           t.paintMembers();
                   		}
                       if (!t.error) ById('progress').innerHTML	 = '(' + (t.alliancemembers.length) +'/'+ t.totalmembers +')';
                       if ( t.alliancemembers.length >= t.totalmembers) ById('alList').disabled = false;
                    } else  if (info.error) {
                    	ById('alList').disabled = false;
                    	ById('progress').innerHTML = "ERROR";
                    	t.error=true;
                   	}
                   },
                   onFailure: function (rslt) {;
                     notify ({errorMsg:'AJAX error'});
                   },
           });
          }
      },
      onFailure: function (rslt) {;
        notify ({errorMsg:'AJAX error'});
      },
    });
  },
  hide : function (){         
  },
};


/************************ Tournoi *************************/
myBO.Tournoi = {
 cont:null,
 state:0,
 
 displayTimer : null,
 init : function (){
    this.cont = document.createElement('div');
    return this.cont;
 },
 hide : function (){
  var t = myBO.Tournoi;
  clearTimeout (t.displayTimer);
 },
 getContent : function (){
	    var t = myBO.Tournoi;
	    return t.cont;
 },
 show : function () {
  var t = myBO.Tournoi;
  
  clearTimeout (t.displayTimer);
  
  t.cont.innerHTML = "<div class='tourny_modal_upsell'></div><DIV class=boStat><b>"+lang.tournoi.title+" - <input type=button value='?' id='boaidetournoi' class=boAide onclick=window.open('"+sitesupport+"?page=aide_tournoi');></b></div>";
  
 
  var mhtl = "<table width=100% class=ptTab><tr><td></td>";
  for(var i=0; i<Cities.numCities; i++) {
   mhtl += "<TD align=center valign=bottom width=50px><B>" + Cities.cities[i].name.replace(/ /g, "<BR>").substr(0,20) + "</B></TD>";
  }
  mhtl += "<td align=center width=60px><b>"+lang.General.tot+"</td></tr>";
    mhtl += "<tr><td>"+uW.g_js_strings.commonstr.population+"/h</td>";
    var pop=[],tot1=0;
    for(var i=0; i<Cities.numCities; i++) {
     cityID = 'city'+ Cities.cities[i].id;
     pop[i] =  parseInt(Seed.citystats[cityID]["pop"][1]) / 2;
     mhtl += "<td  align=right>" + addCommas(parseInt(pop[i])) +"</td>";
     tot1+=parseInt(pop[i]);
    }
  mhtl += "<td align=right><b>"+addCommas(tot1)+"</td></tr>";
  mhtl +=" <tr><td>"+uW.unitcost['unt2'][0]+"/h</td>";
  var temps=[],tot=0;
  for(var i=0; i<Cities.numCities; i++) {
   temps[i]=((Cities.cities[i]['Troop2Time'] > 0)?(3600 / Cities.cities[i]['Troop2Time']):0);
   mhtl += "<td align=right>" + addCommas(parseInt(temps[i])) +"</td>";
   tot+=parseInt(temps[i]);
  }
  mhtl += "<td align=right><b>"+addCommas(tot)+"</td></tr>";

  mhtl +=" <tr><td>&nbsp;</td>";
  var diff=0;
  for(var i=0; i<Cities.numCities; i++) {
   diff = parseInt(pop[i] - temps[i]);
   var couleur=" style='color:green' ";
   if (diff<0) couleur=" style='color:red' ";
   mhtl += "<td "+couleur+"  align=right><b>" + addCommas(parseInt(diff)) +"</b></td>";
  }
  diff = parseInt(tot1 - tot);
  var couleur=" style='color:green' ";
  if (diff<0) couleur=" style='color:red' ";
  mhtl += "<td "+couleur+" align=right><b>" + addCommas(parseInt(diff)) +"</b></td></tr>";
  
  
    mhtl +=" <tr><td>"+uW.unitcost['unt3'][0]+"/h</td>";
    var temps=[],tot=0;
    for(var i=0; i<Cities.numCities; i++) {
     temps[i]=((Cities.cities[i]['Troop3Time'] > 0)?(3600 / Cities.cities[i]['Troop3Time']):0);
     mhtl += "<td align=right>" + addCommas(parseInt(temps[i])) +"</td>";
     tot+=parseInt(temps[i]);
    }
  mhtl += "<td align=right><b>"+addCommas(tot)+"</td></tr>";
    mhtl +=" <tr><td>&nbsp;</td>";
    var diff=0;
    for(var i=0; i<Cities.numCities; i++) {
     diff = parseInt(pop[i] - temps[i]);
     var couleur=" style='color:green' ";
     if (diff<0) couleur=" style='color:red' ";
     mhtl += "<td "+couleur+"  align=right><b>" + addCommas(parseInt(diff)) +"</b></td>";
    }
    diff = parseInt(tot1 - tot);
    var couleur=" style='color:green' ";
    if (diff<0) couleur=" style='color:red' ";
    mhtl += "<td "+couleur+" align=right><b>" + addCommas(parseInt(diff)) +"</b></td></tr>";
    
  
  
  
  mhtl +="<tr><td></td></tr><tr><td>"+uW.g_js_strings.commonstr.happiness+"</td>";
  for(var i=0; i<Cities.numCities; i++) {
   cityID = 'city'+ Cities.cities[i].id;
   var bon = parseInt(Seed.citystats[cityID]["pop"][2]); 
   var bonc = "red";
   if (bon>99) bonc="green";
   mhtl += "<td style='color:"+bonc+"'><center><b>"+bon+"</td>";
  }
  var now = unixTime();
  var totalpop=0;
  mhtl += "</tr><tr><td>"+lang.tournoi.training+"</td>";
  var phtl = "</tr><tr><td>"+lang.tournoi.popdispo+"</td>";
    for(var i=0; i<Cities.numCities; i++) {
     cityID = 'city'+ Cities.cities[i].id;
     var totTime = 0;
     var q = Seed.queue_unt[cityID]; 
     if (q!=null && q.length>0) {
         totTime = q[q.length-1][3] - now;
         totalpop=0;
         for (var zz=0; zz<q.length; zz++){
         totalpop += parseInt((parseInt(q[zz][1]) * unsafeWindow.unitcost['unt'+q[zz][0]][6]) / 2);
         }
     }
     if (totTime < 0) totTime = 0;
     if (totTime < 3600)
      var bonc="style='color:red'";
     else
      var bonc="";
     mhtl += "<td "+bonc+"><center><b>"+timestr(totTime)+"</td>";
     phtl += "<td "+bonc+"><center><b>"+addCommas(totalpop)+"</td>";
    }
  mhtl += '<tr><td></td></tr>'+phtl+'<tr><td><img height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png></td>'
  for(var i=0; i<Cities.numCities; i++) {
   cityID = 'city'+ Cities.cities[i].id;
   var mine=Seed.resources[cityID]['rec4'][0] / 3600
   var bonc="";
   if (mine<=15000000) 
    var bonc="style='color:red'";
   
    mhtl += '<td "+bonc+" align=right><b>'+UniteKMG(parseInt(mine)) +'</td>';
  }
  mhtl += "</tr></table><br><DIV class=boStat><b>"+lang.tournoi.title2+"</b></div>";
  t.cont.innerHTML += mhtl;
  
  

  
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.format=2;
  params.tournyPos=0;
  
    	
  new AjaxRequest(unsafeWindow.g_ajaxpath+"ajax/getLeaderboard.php"+unsafeWindow.g_ajaxsuffix, {  method:"post",  parameters:params,
  
  onSuccess:function(transport){
   var rslt=eval("("+transport.responseText+")");
   if(rslt.ok){
   
    if(!rslt.data){
	   
	t.cont.innerHTML +="<div class='tourny_modal_upsell'><br><center><b>"+unsafeWindow.g_js_strings.modal_tourny_changetab.notourny+"</b></center></div><br>";
	  
	  
    }else{ // fin rslt.data
     var tournyhtml=new Array();
     
     if(rslt.name){
	    tournyhtml.push("<div><center><b><u>"+rslt.name+"</u></b></center></div>")
     }  else{
	    tournyhtml.push("<div class='tournymodaltitle'><center>"+unsafeWindow.g_js_strings.commonstr.tournament+"</div>")
     }
	   tournyhtml.push("<div>");
	   
	   
	   
	   if(rslt.startdate&&rslt.enddate){
	   	   	    var startTime=rslt.startdate;
	   	   	    var endTime=rslt.enddate;
	   	   	    var now=parseInt(new Date().getTime()/1000);
	   	   	    tournyhtml.push("<table width=100% align=center class=ptTab><tr bgcolor=#FE8888><td width=40%><b>"+lang.tournoi.start+"</td><td width=40%><b>"+lang.tournoi.end+"</td><td width=20%><b>"+lang.tournoi.timeRem+"</td></tr>");
	   	   	    dt = new Date ();
	   	            dt.setTime (startTime * 1000);
	   	            dtf = new Date ();
	   	            dtf.setTime (endTime * 1000);
	   	           
	   	            var restant = endTime - now; 
	   	            
	   	   	   
	   	   	   tournyhtml.push("<tr><td>");
	   	   	     tournyhtml.push("" + dt.toLocaleDateString() + " - "+ dt.toLocaleTimeString());
	   	   	    tournyhtml.push("</td><td>");
	   	   	    tournyhtml.push("" + dtf.toLocaleDateString()+ " - "+ dtf.toLocaleTimeString());
	   	   	    tournyhtml.push("</td><td>"+timestr(restant,1)+"</td></tr></table>");
	   	     tournyhtml.push("<br>");
	   
	   }
	   
	   
	   tournyhtml.push("<center><DIV style='max-height:400px; overflow-y:auto;'><table class='tourny_list_table' cellpadding='0' cellspacing='0' border='0' width=90% style='margin:3px'>");
	   tournyhtml.push("<thead>");
	   tournyhtml.push("<tr>");
     if(rslt.type==24){
	    tournyhtml.push("<td class='rankcol' style='background-color:red'>");
	    tournyhtml.push("<div><select id='BOTournoiPM'><option value=5>5</option><option value=10>10</option><option value=25>25</option><option value=50>50</option><option value=100>100</option></select></div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td  style='background-color:red'>");
	    tournyhtml.push("<div>"+unsafeWindow.g_js_strings.modal_tourny_changetab.chancellorname+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td  style='background-color:red'>");
	    tournyhtml.push("<div>"+unsafeWindow.g_js_strings.commonstr.alliance+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td  style='background-color:red'>");
	    tournyhtml.push("<div>"+unsafeWindow.g_js_strings.modal_tourny_changetab.mightgained+"</div>");
	    tournyhtml.push("</td  style='background-color:red'>");
	    tournyhtml.push("<td  style='background-color:red'> ");
	    tournyhtml.push("<div>"+unsafeWindow.g_js_strings.modal_tourny_changetab.rewardperplayer+"</div>");
	    tournyhtml.push("</td>")
      }else{
            tournyhtml.push("<td	class='rankcol' style='background-color:green'>");
	    tournyhtml.push("<div><select id='BOTournoiPM'><option value=5>5</option><option value=10>10</option><option value=25>25</option><option value=50>50</option><option value=100>100</option></select></div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td  style='background-color:green'>");
	    tournyhtml.push("<div>"+uW.g_js_strings.commonstr.nametx+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td  style='background-color:green'>");
	    tournyhtml.push("<div>"+unsafeWindow.g_js_strings.commonstr.alliance+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td  style='background-color:green'>");
	    tournyhtml.push("<div>"+rslt.contestcategory+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td  style='background-color:green'>");
	    tournyhtml.push("<div>"+unsafeWindow.g_js_strings.commonstr.reward+"</div>");
	    tournyhtml.push("</td>")
     }
	   tournyhtml.push("</tr>");
	   tournyhtml.push("</thead>");
	   tournyhtml.push("</tbody>");
	   var nb=rslt.data.length;
	   var votrepuissance = 0;
	   for(var i=0;i<rslt.data.length;i++){
	    var row=rslt.data[i];
	    if(rslt.type==24){
	     // pour le tournoi alliance
	     if (getMyAlliance()[1] == row.alliance) {
	      votrepuissance=row.contestValue;
	      break;
	     }
	    } else {
	     if (Seed.player.prefix + ' '+ Seed.player.name == row.name ) {
	      votrepuissance=row.contestValue;
	      break;
	     }	
	    }
	   }
	   for(var i=0;i< Options.TournoiLigne;i++){
	    var row=rslt.data[i];
	    var rewardString=row.itemCount+" ";
	    if(row.itemType==0){
	     rewardString+=unsafeWindow.g_js_strings.commonstr.gems;
	    }else{
	     rewardString+=unsafeWindow.itemlist["i"+row.itemType].name;
	    }
	    var couleur="";
	    if(rslt.type==24){
	     // pour le tournoi alliance
	     if (getMyAlliance()[1] == row.alliance) {
	      couleur=" style='background-color:#77FF77' ";
	     }
	    }else{
	     if (getMyAlliance()[1] == row.alliance) {
	       if(i%2==1){
	     	      couleur=" style='background-color:#FF9977' ";
	     	    }else{
	     	      couleur=" style='background-color:#FFAA88' ";
	       }
	     
	     }
	     if (Seed.player.prefix + ' '+ Seed.player.name == row.name ) {
	      couleur=" style='background-color:#77FF77' ";
	     }
	    }
	    if(i%2==1){
	     tournyhtml.push("<tr>")
	    }else{
	     tournyhtml.push("<tr class='stripe'>")
	    }
	    tournyhtml.push("<td class='rankcol' "+couleur+">");
	    tournyhtml.push("<div><b>"+row.ranking+"</b></div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td "+couleur+">");
	    tournyhtml.push("<div>"+row.name+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td "+couleur+">");
	    tournyhtml.push("<div>"+(row.alliance||"----")+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td "+couleur+">");
	    tournyhtml.push("<div>"+addCommas(row.contestValue));
	    if (votrepuissance>0) {
	      var ecartavecvous = parseInt(row.contestValue - votrepuissance);
	      if (ecartavecvous>0) {
	       tournyhtml.push("&nbsp;(+ " + addCommas(ecartavecvous) +")");
	      } 
	      if (ecartavecvous<0) {
	       tournyhtml.push("&nbsp;(" + addCommas(ecartavecvous) +")");
	      }
	    }
	    tournyhtml.push("</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("<td "+couleur+">");
	    tournyhtml.push("<div>"+rewardString+"</div>");
	    tournyhtml.push("</td>");
	    tournyhtml.push("</tr>")
	   } // fin du for
	
	      if(rslt.type!=24){

	    for(var i= Options.TournoiLigne;i<rslt.data.length;i++){
	   	    var row=rslt.data[i];
	   	 
	   	    if (Seed.player.prefix + ' '+ Seed.player.name == row.name ) {
	   	      var rewardString=row.itemCount+" ";
	   	     	    if(row.itemType==0){
	   	     	     rewardString+=unsafeWindow.g_js_strings.commonstr.gems;
	   	     	    }else{
	   	     	     rewardString+=unsafeWindow.itemlist["i"+row.itemType].name;
	   	     	    }
	   	     	    tournyhtml.push("<tr class='stripe' >")
	   	     	    tournyhtml.push("<td class='rankcol' style='background-color:#77FF77'>");
	   	     	    tournyhtml.push("<div><b>"+row.ranking+"</b></div>");
	   	     	    tournyhtml.push("</td>");
	   	     	    tournyhtml.push("<td style='background-color:#77FF77'>");
	   	     	    tournyhtml.push("<div>"+row.name+"</div>");
	   	     	    tournyhtml.push("</td>");
	   	     	    tournyhtml.push("<td style='background-color:#77FF77'>");
	   	     	    tournyhtml.push("<div>"+(row.alliance||"----")+"</div>");
	   	     	    tournyhtml.push("</td>");
	   	     	    tournyhtml.push("<td style='background-color:#77FF77'>");
	   	     	    tournyhtml.push("<div>"+addCommas(row.contestValue)+"</div>");
	   	     	    tournyhtml.push("</td>");
	   	     	    tournyhtml.push("<td style='background-color:#77FF77'>");
	   	     	    tournyhtml	.push("<div>"+rewardString+"</div>");
	   	     	    tournyhtml.push("</td>");
	   	            tournyhtml.push("</tr>")
	   	   }    
	   }
	   }
	   tournyhtml.push("</tbody>");
	   tournyhtml.push("</table>");
      tournyhtml.push("</div></div>");
      t.cont.innerHTML += tournyhtml.join("");  
      
           ById('BOTournoiPM').addEventListener ('change', 
           function() { 
            Options.TournoiLigne=ById('BOTournoiPM').value;
            saveOptions();
            t.show();
           }, false);      
           
	   ById('BOTournoiPM').value=Options.TournoiLigne;
	  
       
          } // fin rslt.data 
         } else {
            t.cont.innerHTML = "<div class='tourny_modal_upsell'><center>"+lang.tournoi.error+"</div>";
         }
       }, onFailure:function()  {
         t.cont.innerHTML = "<div class='tourny_modal_upsell'><center>"+lang.tournoi.error+"</div>";
       }
   });
   t.displayTimer = setTimeout (t.show, 240000);       
  },
 
},


/************************ Ressources **********************/
myBO.Resources = {
   cont:null,
  resource : {1:uW.g_js_strings.commonstr.food, 2:uW.g_js_strings.commonstr.wood, 3:uW.g_js_strings.commonstr.stone, 4:uW.g_js_strings.commonstr.ore},
  users : [],
  doList : [], // list of gifts to accept
  accepting : false,
  city : null,
  total : {gold:0, 1:0, 2:0, 3:0, 4:0},
  
  init : function (){
    this.cont = document.createElement('div');
    return this.cont;
  }, 
  show : function (){
    var t = myBO.Resources;
    this.cont.style.overflowY = 'scroll';
     this.cont.innerHTML = '<DIV class=boStat><b>'+lang.Resources.title+'</b></div><TABLE cellpadding=0 cellspacing=0 class=pbTab width=100%><TR><TD align=center><INPUT id="pballlist" type=submit value="'+lang.Resources.pballlist+'" \><INPUT id="pballlist2" type=submit value="'+lang.Resources.pballlist2+'" \></td></tr></table><HR>\
        <DIV id=resDiv style="width:100%; min-height:300px; height:100%">';
    ById('pballlist').addEventListener ('click', function() { t.e_clickfetchlist(1); }, false);
    ById('pballlist2').addEventListener ('click', function() { t.e_clickfetchlist(2); }, false);
  },
  
  hide : function (){
  },
  
  progress : function (msg, span, add){
	if(add)
		ById(span).innerHTML+=msg;
	else
		ById(span).innerHTML=msg;
  },

  e_clickfetchlist : function  (tt){     // (also cancel accepting)
    var t = myBO.Resources;
	t.users = [];
    if (t.accepting){
      ById('pballlist').value = lang.Resources.pballlist;
      ById('resDiv').innerHTML+= '<BR><SPAN class=boldRed>'+lang.Resources.cancel+'</span>';
      t.accepting = false;
      return;
    }
    if (tt==1) ById('resDiv').innerHTML = lang.Resources.load1+' <span id=pbResUserListCount></span>';
    if (tt==2) ById('resDiv').innerHTML = lang.Resources.load2+' <span id=pbResUserListCount></span>';
    
    t.fetchUserList (tt, gotUserList);
    function gotUserList(userList){
		if(userList.length < 1){
			listGifts();
			return;
		}
		ById('resDiv').innerHTML += '<BR>'+lang.Resources.check+' <span id=pbResUserAvailCount></span>';
		t.checkDailyAction(userList, listGifts);
	}
    
    function listGifts (){
	  t.city = Cities.cities[0];
	  var m = '<DIV class=boStat><CENTER>'+lang.Resources.title2+'&nbsp;('+ t.users.length +' '+lang.Resources.find+')</center></div>';
      if (t.users.length<1){
        ById('resDiv').innerHTML = m + '<BR><BR><CENTER>'+lang.Resources.nothing+'</center>';
        return;
      }
      m += '<TABLE class=pbTab align=center><TR><TD align=right>'+unsafeWindow.g_js_strings.commonstr.city+' : </td><TD id=pbrescityselspan></td></tr>\
          <TR><TD align=right>'+lang.Resources.collect+'</td><TD>'
        + htmlSelector (t.resource, Options.getResType, 'id=pbResColType')
        + '</td></tr><TR><TD>'+lang.Resources.select+'</td><TD width=250><INPUT type=submit id=pbResDo value="'+lang.Resources.accept+'">\
        &nbsp; <SPAN id=pbResNone class=boldRed></span></td></tr></table><HR><TABLE class=pbTab><TR valign=top><TD>\
        <INPUT id=pbResButAll type=submit value="'+lang.General.all+'" style="width:100%; margin-bottom:5px"><BR><INPUT id=pbResButNone type=submit value="'+lang.General.none+'"></td>\
        <TD width=10></td><TD><TABLE align=center cellpadding=0 cellspacing=0 class=pbTabLined>\
        <TBODY id=pbResTbody style="height:250px; overflow:auto; display:block;">\
        <TR style="font-weight:bold; background:white"><TD>'+lang.General.name+'</td><TD>'+uW.g_js_strings.commonstr.might+'</td><TD width=20></td></tr>';
      for (var i=0; i<t.users.length; i++){
        m += '<TR><TD><INPUT type=checkbox id=pbrchk_'+ i +'> &nbsp;'+ t.users[i].name +'</td><TD>'+ t.users[i].might +'</td></tr>';
      }
      ById('resDiv').innerHTML = m + '</tbody></table></td></tr></table>';
	  new CdispCityPicker ('pbrescitysel', ById('pbrescityselspan'), true, t.e_CityButton, t.city.idx);
      ById('pbResDo').addEventListener ('click', t.getErDone, false);
      ById('pbResButAll').addEventListener ('click', t.e_butAll, false);
      ById('pbResButNone').addEventListener ('click', t.e_butNone, false);
      // var tbody = ById('pbResTbody');
      // tbodyScroller (tbody, getRemainingHeight (tbody, mainPop.div));
    }
  },

  e_CityButton : function (city, x, y){
    var t = myBO.Resources;
	t.city = city;
  },
  
  e_butAll : function (){
    var t = myBO.Resources;
    for (var i=0; i<t.users.length; i++)
      ById('pbrchk_'+i).checked = true;
  },
  
  e_butNone : function (){
    var t = myBO.Resources;
    for (var i=0; i<t.users.length; i++)
      ById('pbrchk_'+i).checked = false;
  },
  
  getErDone : function (){
    var t = myBO.Resources;
    t.doList = [];
    ById('pbResNone').innerHTML = '';
	Options.getResType = ById('pbResColType').value;
	t.total = {gold:0, 1:0, 2:0, 3:0, 4:0};
    for (var i=0; i<t.users.length; i++){
      if (ById('pbrchk_'+i).checked)
        t.doList.push (t.users[i]);
    }
    if (t.doList.length==0){
      ById('pbResNone').innerHTML = lang.Resources.error1;
      return;
    }
    t.accepting = true;
    ById('pballlist').value = lang.Resources.stop;
    ById('resDiv').innerHTML = '<DIV id=rsltDiv style="height:400px; max-height:400px; overflow-y:auto"><B>'+lang.Resources.collecting+' '+ t.doList.length +' '+lang.Resources.members+'</b><BR></div>';    
    t.acceptNext ();
  },

    
  allDone : function (msg){
    var t = myBO.Resources;
	msg += '<BR><BR>'+lang.Resources.total+'<BR>\
		   Or : '+addCommas(t.total.gold)+'<BR>';
	for(var i=1; i<=4; i++){
		msg += t.resource[i]+': '+addCommas(t.total[i])+'<BR>';
	}
    ById('rsltDiv').innerHTML += '<BR><BR>' + msg;
    ById('pballlist').value = lang.Resources.pballlist;
    t.accepting = false;
  },
  
    
  acceptNext : function (){
    var t = myBO.Resources;
    var gift = t.doList.shift();
    if (gift == null){
      t.allDone (lang.Resources.alldone);
      return;
    }
    var acpDiv = ById('rsltDiv');
    var curDiv = document.createElement ('div');
    acpDiv.appendChild (curDiv);
    curDiv.innerHTML = '<B>>> '+ gift.name +': ';    
    var statSpan = document.createElement ('span');
    curDiv.appendChild (statSpan);
    statSpan.innerHTML = lang.Resources.collecting2;
    t.getCourtAction (gift, gotGiftData);
        
    function gotGiftData (rslt){
      if (!t.accepting)
        return;
      if (rslt.ok){
        var msg = rslt.gold +' '+uW.g_js_strings.commonstr.gold+' - '+rslt.resource +' '+ t.resource[rslt.resourcetype]+'&nbsp; &nbsp; <font color=green><b>OK</b></font>.';
        statSpan.innerHTML += msg;
		t.total.gold += rslt.gold;
		t.total[rslt.resourcetype] += rslt.resource;
		t.acceptNext ();  
        return;
      }
        
      if (rslt.msg)
        msg = '<B>'+ rslt.msg + '</b>';
      else
        msg = '<SPAN class=boldRed>ERROR : '+ rslt.ajaxErr +'</span>';

      curDiv.removeChild (statSpan);
      curDiv = document.createElement ('div');
      curDiv.className = 'indent25';
      acpDiv.appendChild (curDiv);
      curDiv.innerHTML = msg;
      t.acceptNext ();  
    }
    
  },

  getMembersInfo : function (pageNo, notify) {
    var t = myBO.Resources;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.pageNo = pageNo;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetMembersInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errMsg:'Ajax Comm Error'});
      },
    });
  },
    getFriendsInfo : function (notify) {
      var t = myBO.Resources;
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getAppFriends.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          notify (rslt);
        },
        onFailure: function (rslt) {
          notify ({errMsg:'Ajax Comm Error'});
        },
      });
  },
  getDailyAction : function (uid, notify){
	var t = myBO.Resources;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.pid = uid;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errMsg:'Ajax Comm Error'});
      },
    });
  },
  
  getCourtAction : function (gift, notify){
	var t = myBO.Resources;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    params.atype = Options.getResType;
	params.toid = gift.userId;
	params.givercityid = t.city.id;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/courtDoAction.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errMsg:'Ajax Comm Error'});
      },
    });
  },
  
  checkDailyAction : function (userList, notify){
	var t = myBO.Resources;
	var count = 0;
    t.getDailyAction(userList[count].userId, parseViewCourt);
	
	function parseViewCourt (rslt){
		if (!rslt.ok || rslt.errMsg)
			notify ({errMsg:'Ajax Comm Error'});
		if(rslt.dailyActionFlag == 0)
			t.users.push(userList[count]);
		t.progress(count, 'pbResUserAvailCount');
		count++;
		if(count < userList.length){
			t.getDailyAction(userList[count].userId, parseViewCourt);
		} else {
			notify();
		}
	}
  },
  fetchUserList : function (tt, notify){
    var t = myBO.Resources;
    var userList = [];
    if (tt==1)
      t.getMembersInfo(1, parseAlliancePage);
    
    if (tt==2)
      t.getFriendsInfo(parseAlliancePage2);
    function parseAlliancePage (rslt){
      if (!rslt.ok || rslt.errMsg)
        notify ({errMsg:'Ajax Comm Error'});
	  var users = rslt.memberInfo;
      for(var k in users){
		userList.push({userId:users[k].userId, name:users[k].name, might:users[k].prestige, type:'alliance'});
	  }
	  t.progress(userList.length, 'pbResUserListCount');
	  if(rslt.currentPage < rslt.noOfPages){
		t.getMembersInfo((rslt.currentPage+1), parseAlliancePage);
	  } else {
		notify(userList);
		//t.getFriendsInfo(parseAlliancePage2);
	  }
    }
    
    
    function parseAlliancePage2 (rslt){
	      if (!rslt.ok || rslt.errMsg)
	        notify ({errMsg:'Ajax Comm Error'});
		  var users = rslt.data;
	          for(var k in users){
	             if (users[k].userId!=undefined)
			userList.push({userId:users[k].userId, name:users[k].displayName, might:users[k].might, type:'friends'});
		  }
		  t.progress(userList.length, 'pbResUserListCount');
		  notify(userList);
    }
	
  },
   getContent : function (){
  	    var t = myBO.Resources;
  	    return t.cont;
 },
},
/***
DEFCON5 - tempo di pace (che viene messo per qualche giorno all'uscitsa della guerra, poi va sottinteso, 
DEFCON4 - guerra imminente o prime rappresaglie e esporazioni; 
DEFCON3 - guerra a tutti gli effetti, con attacchi e murate da ambedue i lati; 
DEFCON2 - guerra pesante e situazione sfavorevole, che determina certi tipi di comportamenti, tipo quiescenza, truppe in santuario ed estrema difesa; 
DEFCON1 - la guerra è persa, il comando non riesce piu a controllare l'alleanza, quindi si puo' abbandonare l'alleanza per evitare ulteriori rappresaglie... 
			il defcon 1 è la situazione che generalmente precede lo scioglimento dell'alleanza....
**/


myBO.Spam = {
  cont : null,
  timer : null,
  
  init : function (){ 
    var t = myBO.Spam;
    t.cont = document.createElement('div');
     return t.cont;
 },
    getContent : function (){
   	    var t = myBO.Spam;
   	    return t.cont;
 },
  show : function (){ 
    var t = myBO.Spam;

        var m = '<DIV class=boStat>'+lang.Spam.title+'</div><TABLE class=pbTab width=100% height=0% ><TR align="center">';
    
           if (Options.spamconfig.aspam == true) {
            m += '<TD><INPUT id=pbSpamEnable type=submit value="Spam = ON"></td>';
           }
           else {
            m += '<TD><INPUT id=pbSpamEnable type=submit value="Spam = OFF"></td>';
           }
    	   m += '<td><input type=button value="Spam '+uW.g_js_strings.modal_auto_attack.now+'" id=bospamnow></td>';    	   
           if (Options.spamconfig.spamstate == 'a') {
            m += '<TD><INPUT id=pbSpamState type=submit value="'+lang.Spam.pbSpamState1+'"></td>';
           }
           else {
            m += '<TD><INPUT id=pbSpamState type=submit value="'+lang.Spam.pbSpamState2+'"></td>';
           }
            m += '</tr></table></div>';
           m += '<DIV class=boStat>OPTIONS</div><TABLE class=pbTab>';
            m += '<tr><td>'+lang.Spam.pbSpamMin+' <INPUT id=pbSpamMin type=text size=2 maxlength=3 value="'+ Options.spamconfig.spammins +'"  \> '+lang.General.mins+'</td></tr><BR>\
                  <tr><TD><TABLE cellpadding=0 cellspacing=0>';
                
     //           type="radio" name="sex"
         	m += '<TD align=left><INPUT type="radio" name="st" id=idSpamAd'+ (Options.SpamMode.Spam?' CHECKED ':'') +'>'+lang.Spam.pbSpamAd+' </td><TD><INPUT id=pbSpamAd type=text size=60 maxlength=250 value="'+ Options.spamconfig.spamvert +'" \></td></tr>';
		 	m += '<TD align=left><INPUT type="radio" name="st" id=idAvviso'+ (Options.SpamMode.Avv?' CHECKED ':'') +'>'+uW.g_js_strings.commonstr.status+' &nbsp;</td><TD> &nbsp; &nbsp; &nbsp; '+ htmlSelector({def5:'DEFCON 5', def4:'DEFCON 4', def3:'DEFCON 3',def2:'DEFCON 2',def1:'DEFCON 1'},Options.spamconfig.def,'id=BOselectDefMode') +'</td></tr>';
            m += '</table><BR>';
            m += '<div style="width:500px; max-width:500px; height:auto;"; id=IdScoutAllianceProgress>'
            		+'<font color=red><b>DEFCON 5</b>: </font><b>'+lang.Spam.Defcon.Def5
            		+'<br><font color=red><b>DEFCON 4</b>: </font>'+lang.Spam.Defcon.Def4
            		+'<br><font color=red><b>DEFCON 3</b>: </font>'+lang.Spam.Defcon.Def3
            		+'<br><font color=red><b>DEFCON 2</b>: </font>'+lang.Spam.Defcon.Def2
            		+'<br><font color=red><b>DEFCON 1</b>: </font>'+lang.Spam.Defcon.Def1
            		+'</div></b>';
                          
        t.cont.innerHTML = m;
            ById('bospamnow').addEventListener('click', function() {
			t.spamnow();
		}, false);
        ById('pbSpamEnable').addEventListener ('click', function(){t.toggleon(this);}, false);
        ById('pbSpamAd').addEventListener ('change', t.e_spamOptChanged, false);
        ById('pbSpamMin').addEventListener ('change', t.e_spamOptChanged, false);
    	ById('pbSpamState').addEventListener ('click', function(){t.togglespam(this);}, false);
    	ById('idSpamAd').addEventListener ('click', function(){ 
    	Options.SpamMode.Spam = true;	Options.SpamMode.Avv = false;
    	document.getElementById("idSpamAd").checked=true;
    	document.getElementById("idAvviso").checked=false;
    	saveOptions();
    	}, false);
    	ById('idAvviso').addEventListener ('click', function(){ 
    	Options.SpamMode.Spam = false;	Options.SpamMode.Avv = true; 
    	document.getElementById("idSpamAd").checked=false;
    	document.getElementById("idAvviso").checked=true;   	
    	saveOptions();
    	}, false);
        ById('BOselectDefMode').addEventListener ('change', t.e_spamOptChanged, false);	
        saveOptions ();
  },
  hide : function (){  
    var t = myBO.Spam;
  },
  	  
 e_spamOptChanged : function (){
  var t = myBO.Spam;
  Options.spamconfig.def = ById('BOselectDefMode').value;
  Options.spamconfig.spamvert = ById('pbSpamAd').value;
  Options.spamconfig.spammins = ById('pbSpamMin').value;
  if(parseInt(Options.spamconfig.spammins) < 30){
   Options.spamconfig.spammins = 30;
   ById('pbSpamMin').value = 30;
  }
  saveOptions ();
 },

spamnow: function(){
if("def1"==Options.spamconfig.def)var StatDefcon="DEFCON 1";else"def2"==Options.spamconfig.def?StatDefcon="DEFCON 2":"def3"==Options.spamconfig.def?StatDefcon="DEFCON 3":"def4"==Options.spamconfig.def?StatDefcon="DEFCON 4":"def5"==Options.spamconfig.def&&(StatDefcon="DEFCON 5");	
  	if (Options.SpamMode.Spam & !Options.SpamMode.Avv) {
    sendChat ("/" + Options.spamconfig.spamstate + " " +  Options.spamconfig.spamvert);
    } else {
    	if (Options.SpamMode.Avv & !Options.SpamMode.Spam) {
    		sendChat ('/a '+uW.g_js_strings.commonstr.status+' '+uW.g_js_strings.commonstr.alliance+': '+StatDefcon);
    	}
    }
},

 togglespam: function(obj){
  var t = myBO.Spam;
  if (Options.spamconfig.spamstate == 'a') {
   Options.spamconfig.spamstate = 'g';
   obj.value = lang.Spam.pbSpamState2;
  }
  else {
   Options.spamconfig.spamstate = 'a';
   obj.value = lang.Spam.pbSpamState1;
  }
  saveOptions ();

 },

 toggleon: function(obj){
  var t = myBO.Spam;
  if (Options.spamconfig.aspam == true) {
   Options.spamconfig.aspam = false;
   obj.value = "Spam = OFF";
  }
  else {
   Options.spamconfig.aspam = true;
   obj.value = "Spam = ON";
   SpamEvery.init();
  }
  saveOptions ();

 },
}; 

var SpamEvery  = {
  timer : null,
  spamtimer : 0,
  init : function (){
    if (!Options.spamconfig.aspam) return;
    if (Options.spamconfig.spammins < 30)
      Options.spamconfig.spammins = 30;
    SpamEvery.setEnable (Options.spamconfig.aspam);
  },
  setEnable : function (tf){
    var t = SpamEvery;
    clearTimeout (t.timer);
    if (tf)
      t.timer = setTimeout (t.count, 60*1000);
  },
  count : function (){
   var t = SpamEvery;
   t.spamtimer = Options.spamconfig.spammins;
   if(parseInt(t.spamtimer) < 30) t.spamtimer = 30;
   if (Options.spamconfig.atime > t.spamtimer) {
    Options.spamconfig.atime = 2;
    t.doit ();
   } else {
    Options.spamconfig.atime = (Options.spamconfig.atime + 1);
    SpamEvery.init ();
   }
   saveOptions ();
  },
  doit : function (){
if("def1"==Options.spamconfig.def)var StatDefcon="DEFCON 1";else"def2"==Options.spamconfig.def?StatDefcon="DEFCON 2":"def3"==Options.spamconfig.def?StatDefcon="DEFCON 3":"def4"==Options.spamconfig.def?StatDefcon="DEFCON 4":"def5"==Options.spamconfig.def&&(StatDefcon="DEFCON 5");
  	if (Options.SpamMode.Spam & !Options.SpamMode.Avv) {
    sendChat ("/" + Options.spamconfig.spamstate + " " +  Options.spamconfig.spamvert);
    } else {
    	if (Options.SpamMode.Avv & !Options.SpamMode.Spam) {
    		sendChat ('/a '+uW.g_js_strings.commonstr.status+' '+uW.g_js_strings.commonstr.alliance+': '+StatDefcon);
    	}
    }
    SpamEvery.init ();
  }
}

/*********************************** Log Tab ***********************************/
myBO.ActionLog = {
  myDiv : null,
  logTab : null,
  maxEntries: 300,
  last50 : [],
  state : null,
   init : function (){    // called once, upon script startup
 
        this.myDiv = document.createElement('div');
 
     window.addEventListener('unload', t.onUnload, false);
    return this.myDiv;
  },
  show : function (div){
    var t = myBO.ActionLog;
    
        t.myDiv = this.myDiv;
        t.myDiv.innerHTML = '<DIV  class=boStat>'+lang.StatLabelLogs.toUpperCase()+' '+ScriptName+'</div><DIV style="height:535px; max-height:535px; overflow-y:auto">\
       <select id=BOSuiviFiltre><option value="">'+lang.General.all+'</option><option value="Error">'+lang.General.error+'</option><option value="Rapport">'+uW.g_js_strings.commonstr.deletetx+' '+uW.g_js_strings.commonstr.reports+'</option><option value="Transport">Auto '+uW.g_js_strings.commonstr.transport+'</option><option value="'+lang.TRANSP.Appros+'">'+lang.TRANSP.Appros+'</option><option value="AutoForm">Auto '+uW.g_js_strings.commonstr.train+'</option><option value="Reassign">Auto '+uW.g_js_strings.commonstr.reassign+'</option><option value="AutoFO">'+uW.g_js_strings.commonstr.darkForest+'</option><option value="RAID">Raid</option><option value="AutoCrest">AutoCrest</option><option value="AutoTrone">AutoTrone</option><option value="AutoScout">AutoScout</option></select>\
       &nbsp;<input type=button value="'+uW.g_js_strings.modaltitles.deleteall+'" id=BOLogClean><br><TABLE cellpadding=0 cellspacing=0 id=BOactionlog class=pbTabLined></table></div>';
     t.logTab = ById('BOactionlog');  
     t.filtre = ById('BOSuiviFiltre'); 
     t.state = 1;
     t.filtre.addEventListener ('change', t.pouette, false);
     ById('BOLogClean').addEventListener ('click', t.deleteall, false);
   
    t.pouette();
  },
  deleteall: function() {
    var t = myBO.ActionLog;
    saveValue ('BOlog_'+getServerId(), '[]');
     t.pouette();
  },
  pouette: function() {
    var t = myBO.ActionLog;
    t.logTab.innerHTML="<TR><TD></td><td></td><TD width=95%></td></tr>";
      var a = JSON2.parse(loadValue ('BOlog_'+getServerId(), '[]'));
      if (matTypeof(a) == 'array'){
        t.last50 = a;
        for (var i=0; i<t.last50.length; i++) {
           if (t.filtre.value=="" || t.filtre.value==t.last50[i].ou) {
           t._addTab (t.last50[i].msg, t.last50[i].ou, t.last50[i].ts);      
          }
  
        }
    }
  
  },
  hide : function (){
  },
  getContent : function (){
      return myBO.ActionLog.myDiv;
  },  
  _addTab : function (msg, ou, ts){
    var t = myBO.ActionLog;
    if (t.state != 1)
      return;
    if (t.logTab.rows.length >= t.maxEntries)
      t.logTab.deleteRow(t.maxEntries-1);
    var row = t.logTab.insertRow(0);
    row.vAlign = 'top';
    row.insertCell(0).innerHTML = ts;
    row.insertCell(1).innerHTML = ou;
    row.insertCell(2).innerHTML = msg;
  },
  
  log : function (msg,ou){
    var t = myBO.ActionLog;
    var ts = new Date().toTimeString().substring (0,8);
    if (t.filtre) {
     if (t.filtre.value=="" || t.filtre.value==ou) {
      t._addTab (msg, ou, ts);
     }  
    }else {
    t._addTab (msg, ou, ts);
    }
    while (t.last50.length >= 50)
      t.last50.shift();
    t.last50.push ({msg:msg, ts:ts, ou:ou});
    saveValue ('BOlog_'+getServerId(), JSON2.stringify(t.last50));
  },
    onUnload : function (){
      var t = myBO.ActionLog;
      if (!ResetAll) saveValue ('BOlog_'+getServerId(), JSON2.stringify(t.last50));
  },
}

function actionLog (ou,msg){
    myBO.ActionLog.log (msg,ou);  
}
   

/*********************************** Throme TAB ***********************************/
myBO.Trone = {
  myDiv : null,
  cont : null,
  passage:null,
  timer : null, 
  filtre:"",
  tableau:[],
  filtre2:"",
  filtre3:"",
  filtre6:0,
  filtre7:false,
  filtre8:"",
  filtre4:Options.AllEffet,
  filtre5:Options.EffetRouge,
  init : function (){ 
    this.myDiv = document.createElement('div');
    return this.myDiv;
  },

  hide : function (){
    var t = myBO.Trone;
    
  },
  getContent : function (){
      return myBO.Trone.myDiv;
  },

  show : function (){
     var t = myBO.Trone;
     if (Options.salvageconfig.CityCity==undefined) Options.salvageconfig.CityCity=0;
     uW.BOsalvage=t.salvage;
     uW.BOequipItem=t.equipItem;
     uW.BOUnequipItem=t.UnequipItem;
     uW.BORepair = t.Repair;
     uW.BOupgradeQualite = t.upgradeQualite;
     uW.BOupgradeLevel = t.upgradeLevel;
     t.cont = this.myDiv;
     var m="",nb=0,nbbroken=0,k=Seed.throne.slotEquip[Seed.throne.activeSlot],i=Seed.throne.inventory,e,faction,i = uW.kocThroneItems,sl=0;
     if (t.passage==null) {
      t.passage=1;
     var taille = 500; //uW.screen.height - mainPop2.getLocation().y - 450;
      m += '<DIV class=boStat><b>'+lang.Trone.title+' - <input type=button value="?" id=boaidetrone class=boAide></b></div><table style="background-color:transparent;max-width:100%;width:755px;" cellspacing=0 cellpadding=2><tr>\
         <td><input type=checkbox id=BOFiltre4ST> '+lang.Trone.BOFiltre4ST+' &nbsp;<input type=checkbox id=BOFiltre7ST> '+lang.Trone.BOFiltre7ST+'<br>'+lang.Trone.BOlisteeffets+' <select id=BOlisteeffets></select>\
         <br>'+lang.Trone.BOTroneCityCity+' <span id=BOTroneCityCity></span>&nbsp;<span id=BOTroneCityCityS>\
         <td style="text-align:right"><font size=1>'+lang.pubbao+'<br><iframe src=http://kocbottolsoriginal.host22.com/Pubblicita/PubbliTools.php width=320 marginwidth=0 marginheight=0 height=50 scrolling=no frameborder=0></iframe></td>\
         </tr></table>';    
      m +='<DIV class=boStat><b>'+lang.Trone.title2+'</b></div><DIV id=BOTroneAether style="width:100%;height:45px;max-height:45px;"></DIV><DIV class=boStat><b>'+lang.Trone.title3+'</b></div><DIV id=BOTroneE style="width:100%;height:33px;max-height:33px;"></DIV>\
      <DIV class=boStat><b>'+lang.Trone.title4+' - <span id=BONbArticle></span></b></div><center><table style="background-color:transparent;max-width:95%;width:755px;" cellspacing=0 cellpadding=2>\
      <tr><td colspan=1 width=35>&nbsp;</td>\
      <td width=35><select id=BOFiltre8ST><option value="">Niveau...</option><option value=1>+1</option><option value=2>+2</option><option value=3>+3</option><option value=4>+4</option><option value=5>+5</option><option value=6>+6</option><option value=7>+7</option><option value=8>+8</option><option value=9>+9</option><option value=10>+10</option></select></td>\
      <td width=120><select id=BOFiltre2ST><option value="">Qualite...</option><option value="0">'+uW.g_js_strings.throneRoom.simple+'</option><option value="1">'+unsafeWindow.g_js_strings.throneRoom.common+'</option><option value="2">'+unsafeWindow.g_js_strings.throneRoom.uncommon+'</option><option value="3">'+unsafeWindow.g_js_strings.throneRoom.rare+'</option><option value="4">'+unsafeWindow.g_js_strings.throneRoom.epic+'</option><option value="5">'+unsafeWindow.g_js_strings.throneRoom.wondrous+'</option><option value="6">'+uW.g_js_strings.throneRoom.unique+'</option></select></td>\
      <td width=80><select id=BOFiltreST><option value="">Famille...</option><option value="briton">briton</option><option value="druid">druid</option><option value="fey">fey</option></select></td>\
      <td width=80><select id=BOFiltre3ST><option value="">Type...</option><option value="advisor">advisor</option><option value="banner">banner</option><option value="chair">chair</option><option value="table">table</option><option value="window">window</option></select></td>\
      <td width=250><select id=BOFiltre5ST></select></td>\
      <td width=80><input type=checkbox id=BOTroneInverse>'+lang.Trone.BOTroneInverse+'</td></tr></table><DIV id=BOTroneC style="width:100%;height:'+taille+'px; max-height:'+taille+'px; overflow-y:auto"></div><br>';
       t.cont.innerHTML = m; 
        ById('boaidetrone').addEventListener('click', function(){
                  	       	 window.open(sitesupport+"?page=aide_trone");
        } , false);
       var dcp0 = new CdispCityPicker ('BORCityC', ById('BOTroneCityCity'), false, function(c) { ById('BOTroneCityCityS').innerHTML=c.name;var t = myBO.Trone;Options.salvageconfig.CityCity=c.idx;saveOptions();t.show();}, Options.salvageconfig.CityCity); 
 	
    	
    	 var liste = uW.cm.thronestats.effects;
	     ById("BOlisteeffets").innerHTML="";
	     var o = document.createElement("option");
	     o.text = "----";
	     o.value = 0;
	     ById("BOlisteeffets").options.add(o);
	     for (k in liste){
	         if (liste[k] !=undefined){
	             	var o = document.createElement("option");
	             	o.text = liste[k][1];
	             	o.value = k;
	             	ById("BOlisteeffets").options.add(o);
	         }
	     }
	     ById("BOFiltre5ST").innerHTML="";
	     var o = document.createElement("option");
	     o.text = "----";
	     o.value = 0;
	     ById("BOFiltre5ST").options.add(o);
	     for (k in liste){
	         if (liste[k] !=undefined){
	             	var o = document.createElement("option");
	             	o.text = liste[k][1];
	             	o.value = k;
	             	ById("BOFiltre5ST").options.add(o);
	         }
	     }
	     ById('BOlisteeffets').value=t.filtre5;
	     ById("BOlisteeffets").addEventListener ('change', t.filtreaction, false);
	     
	     ById('BOFiltreST').value=t.filtre;
	     ById('BOFiltreST').addEventListener ('change', t.filtreaction, false);
	     ById('BOFiltre2ST').value=t.filtre2;
	     ById('BOFiltre2ST').addEventListener ('change', t.filtreaction, false);
	     ById('BOFiltre3ST').value=t.filtre3;
	     ById('BOFiltre3ST').addEventListener ('change', t.filtreaction, false);
	     ById('BOFiltre4ST').checked=t.filtre4;
	     ById('BOFiltre4ST').addEventListener ('click', t.filtreaction, false); 
	     ById('BOFiltre5ST').value=t.filtre6;
     		ById('BOFiltre5ST').addEventListener ('change', t.filtreaction, false); 
    	
    	     ById('BOFiltre7ST').checked=t.filtre7;
	     ById('BOFiltre7ST').addEventListener ('click', t.filtreaction, false); 
	     ById('BOFiltre8ST').value=t.filtre8;
	     ById('BOFiltre8ST').addEventListener ('click', t.filtreaction, false); 
	     
	     ById('BOTroneInverse').checked=Options.TroneInverse;
	     ById('BOTroneInverse').addEventListener ('click', function() {
	      Options.TroneInverse = ById('BOTroneInverse').checked;

	      saveOptions ();
   		 t.show();
	     }, false); 
    	
     }
     m='<table style="background-color:transparent;width:755px;max-width:95%;" cellspacing=0 cellpadding=2>';
     t.tableau=[];
     for (var z in i) {
           if (i[z].id) {
            e=uW.kocThroneItems[i[z].id];
            if (e) {
              
              t.tableau[sl]=i[z].id;
              sl++
            }
           }
     }
     var lignauto = Seed.throne.rowNum * 5;
     if (Options.TroneInverse) t.tableau.reverse();
     var pastoucher = [];
  
       for (var nbslot=1;nbslot<=Seed.throne.slotNum;nbslot++) {
        B = Seed.throne.slotEquip[nbslot];
        for (var zzz in B) {
         if (uW.kocThroneItems[B[zzz]]) {
          pastoucher.push(B[zzz]);
         }
        }
       } 

     var nbl=t.tableau.length+1;
     
     var BOtimeLeft=-1;
     if (Seed.queue_throne) {
      if (Seed.queue_throne.end)
          BOtimeLeft = Seed.queue_throne.end - uW.unixtime();
     }
     
     for (var z=0;z<t.tableau.length;z++) {
       e=uW.kocThroneItems[t.tableau[z]];
       nb++
       faction=e.faction;
       x=0;
       nbl--;
       if ( (t.filtre=="" || t.filtre==faction) && (t.filtre2=="" || t.filtre2==e.quality) && (t.filtre3=="" || t.filtre3==e.type) && (t.filtre7==false || (t.filtre7==e.isBroken || (t.filtre=true && Seed.queue_throne.itemId==e.id)))  && (t.filtre8=="" || t.filtre8==e.level)   )  {
       
       var ok=0;
       for (var u in e.effects) {
            if (t.filtre6==e.effects[u].id) {
                 ok=1;
            }
        }
       
       if (t.filtre6=="0" || ok==1) {
       var styleez="";
       
      
  
       
       if (e.isEquipped) {
        equip="equip";
        styleez="background-color:#DC9999";
       }else{
        equip="normal";
        }
        
       if (pastoucher.toString().indexOf(t.tableau[z])>-1 && equip=="normal") 
          styleez="background-color:#99DC99";
        
       var styleauto="";
       m+="<tr><td style='"+styleez+";width:35px'>"
       if (Seed.queue_throne) {
        if (Seed.queue_throne.itemId==e.id) {
           nbbroken++
            m+="<img title='"+ThroneItemName(e) +"' width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/modal/sm_hammer.png>";
        } else {
         if (e.isBroken) {
            nbbroken++
	          m+="<img title='"+ThroneItemName(e) +"' width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/modal/sm_fail_overlay.png>";
         } else {
          m+="<img title='"+ThroneItemName(e) +"' width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/"+ faction.replace('briton','britton') +"/"+ faction.replace('briton','britton') +"_"+e.type+"_"+equip+"_1.png>";
         }
        }
       } else {
         if (e.isBroken) {
	          m+="<img title='"+ThroneItemName(e) +"' width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/modal/sm_fail_overlay.png>";
        } else {
          m+="<img title='"+ThroneItemName(e) +"' width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/"+ faction.replace('briton','britton') +"/"+ faction.replace('briton','britton') +"_"+e.type+"_"+equip+"_1.png>";
        }									                
       }
        m+="</td><td colspan=4 style='"+styleez+";width:250px'>"+ ThroneItemName(e) +"</td>";
        m+="<td style='"+styleez+";width:300px'>";
        for (var u in e.effects) {
           x++;
           L = e.effects[u];
           if ((e.quality >= x && !t.filtre4) || t.filtre4) {
           var coleur="";
           var stylee="";
           if (e.quality < x) 
            stylee="text-decoration:line-through";
           if (t.filtre5==e.effects[u].id) stylee+=";color:#AA1111;font-weigth:bold";
 	    effect = uW.cm.thronestats.effects[L.id];
            tier = uW.cm.thronestats.tiers[L.id][L.tier];           
            var percent = + tier.base + (e.level * e.level + e.level) * + tier.growth * 0.5;
            //percent = percent > 0 ? "+" + percent : + percent;
            percent = Math.round(percent*100)/100;
            typpee="";
            for (l=0;l<effect["2"].length;l++){
             typpee+=effect["2"][l];
            }
           m+="<span style='"+stylee+"'><font color="+coleur+">" + percent + "% " + effect[1] + " ("+typpee+")</font></span><bR>";
         }
        }
        
        if ((Options.TroneInverse && nbl<=lignauto) || (!Options.TroneInverse && nb<=lignauto)) {
        m+="</td><td style='"+styleez+"'><center>";
        
         if (Seed.queue_throne && Seed.queue_throne.itemId==e.id) {
	              var timeLeft = Seed.queue_throne.end - uW.unixtime();
	              if (timeLeft<0) timeLeft=0;
	 	      m+=lang.Trone.repairing+"<br>"+timestr(timeLeft)+"";
	}else{
	  if (e.isBroken) {
	    if (BOtimeLeft<0) {
	              m+="<a onclick='BORepair("+t.tableau[z]+")' class='buttonv2 h20 blue'>"+lang.Trone.repair+"</a>";
	    }
           
         } else {
         if (e.quality<5) {
           stoneenhance=uW.cm.thronestats["enhance"][e.quality+1].Stones;
           cityId='city'+Seed.cities[Options.salvageconfig.CityCity][0];
	   if (parseIntNan(stoneenhance)<parseIntNan(Seed.resources[cityId]['rec5'][0])) {
             m+="<a onclick='BOupgradeQualite("+t.tableau[z]+",0)' class='buttonv2 h20 brown' title='Besoin de "+stoneenhance+" pierres ether'>"+lang.Trone.enhance+"</a>";
            }
         }
         if (e.level<9) {
           stoneupgrade=uW.cm.thronestats["upgrade"][e.level+1].Stones;
           cityId='city'+Seed.cities[Options.salvageconfig.CityCity][0];
	   if (parseIntNan(stoneupgrade)<parseIntNan(Seed.resources[cityId]['rec5'][0])) {
            m+="<a onclick='BOupgradeLevel("+t.tableau[z]+",0)' class='buttonv2 h20 brown' title='"+stoneupgrade+"'>"+lang.Trone.upgrade+"</a>";
            
           }
          }
          
          if (uW.ksoItems[20005].count > 0) {
          m+="<bR>";
          if (e.quality<5) {
	             stoneenhance=uW.cm.thronestats["enhance"][e.quality+1].Stones;
	             cityId='city'+Seed.cities[Options.salvageconfig.CityCity][0];
	  	   if (parseIntNan(stoneenhance)<parseIntNan(Seed.resources[cityId]['rec5'][0])) {
	               m+="<a onclick='BOupgradeQualite("+t.tableau[z]+",20005)' class='buttonv2 h20 brown' title='Besoin de "+stoneenhance+" pierres ether'><img align=absmiddle width=13 src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/20005.jpg'> "+lang.Trone.enhance+"</a>";
	              }
	           }
	           if (e.level<9) {
	             stoneupgrade=uW.cm.thronestats["upgrade"][e.level+1].Stones;
	             cityId='city'+Seed.cities[Options.salvageconfig.CityCity][0];
	  	   if (parseIntNan(stoneupgrade)<parseIntNan(Seed.resources[cityId]['rec5'][0])) {
	              m+="<a onclick='BOupgradeLevel("+t.tableau[z]+",20005)' class='buttonv2 h20 brown' title='"+stoneupgrade+"'><img align=absmiddle width=13 src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/20005.jpg'> "+lang.Trone.upgrade+"</a>";
	              
	             }
          }
          
          }
          m+="<br><a onclick='BOsalvage("+t.tableau[z]+")' class='buttonv2 h20 red'>"+lang.Trone.salvage+"</a>";
          if (equip=="normal") 
           m+="<a onclick='BOequipItem("+t.tableau[z]+")' class='buttonv2 h20 blue'>"+lang.Trone.equip+"</a>";
          else
           m+="<a onclick='BOUnequipItem("+t.tableau[z]+")' class='buttonv2 h20 blue'>"+lang.Trone.unequip+"</a>";
         } 
         }
        } else {
           m+="</td><td style="+styleez+"><center><i><b>"+lang.Trone.norow+"</b>";
        }
        m+"</td></tr>";
       }
      }
       
     }
     ById("BOTroneC").innerHTML=m;
     // Equipement
     var effft="",faction={0:'advisor',1:'banner',2:'chair',3:'table',4:'window'};
     var zz="<center><table width=100%><tr>";
     for (var fp in faction) {
      equip="normal";
      effft="";
      var k=Seed.throne.slotEquip[Seed.throne.activeSlot];
      for (var tt in k) {
      if (uW.kocThroneItems[k[tt]])
       if (uW.kocThroneItems[k[tt]].type==faction[fp]) {
        equip="equip";
        x=0;
        for (var u in uW.kocThroneItems[k[tt]].effects) {
          x++;
          if (uW.kocThroneItems[k[tt]].quality >= x) {
            var ww=uW.cm.thronestats.tiers[uW.kocThroneItems[k[tt]].effects[u].id][uW.kocThroneItems[k[tt]].effects[u].tier];
            var pourc = + ww.base + (uW.kocThroneItems[k[tt]].level * uW.kocThroneItems[k[tt]].level + uW.kocThroneItems[k[tt]].level) * + ww.growth * 0.5;
            pourc = Math.ceil(pourc);
            effft+= pourc + "% " + uW.cm.thronestats.effects[uW.kocThroneItems[k[tt]].effects[u].id][1]+ "&#013;";
            
            }
        }
       }
      }
      zz+="<td><img title='"+effft+"' align=absmiddle width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/britton/britton_"+faction[fp]+"_"+equip+"_1.png><td>"+faction[fp]+"</td>";
     }
     zz+="</tr></table>";
     ById("BOTroneE").innerHTML=zz;
     ById("BONbArticle").innerHTML= nb + " article(s) dont "+ nbbroken +" cass&eacute;(s)";
     clearTimeout(t.citystattimer);
     t.citystat();
  },
  citystattimer:null,
  citystat:function() {
   var t = myBO.Trone;
   var zz="<TABLE class=ptTabLined cellspacing=0 style='margin-bottom:5px;'><tr>";
   var zx="";
   clearTimeout(t.citystattimer);
     
   for(var i=0; i<Cities.numCities; i++) {
      var cityID = 'city'+ Cities.cities[i].id;
            zz += "<TD width=81 align=center><B>"+ Cities.cities[i].name.substring(0,10) +'</b></td>';
            zx += "<TD width=81 align=center><B>"+ addCommas(parseIntNan(Seed.resources[cityID]['rec5'][0])) + "</b></td>";
      }
    
       
   zz+="<td><img align=absmiddle width=13 src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/20001.jpg'></td>\
   <td><img align=absmiddle width=13 src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/20002.jpg'></td>\
   <td><img align=absmiddle width=13 src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/20005.jpg'></td>\
   <td><img align=absmiddle width=13 src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/20006.jpg'></td></tr><tr>"+zx+"<td>"+uW.ksoItems[20001].count+"</tD><td>"+uW.ksoItems[20002].count+"</tD><td>"+uW.ksoItems[20005].count+"</tD><td>"+uW.ksoItems[20006].count+"</tD>";
   zz+="</table>";
   
   ById("BOTroneAether").innerHTML=zz;
   t.citystattimer=setTimeout(t.citystat,5000);
   
  },
  filtreaction: function() {
    var t = myBO.Trone;
    t.filtre = ById('BOFiltreST').value;
    t.filtre2 = ById('BOFiltre2ST').value;
    t.filtre3 = ById('BOFiltre3ST').value;
    t.filtre4 = ById('BOFiltre4ST').checked;
    t.filtre5 = ById('BOlisteeffets').value;
    t.filtre6 = ById('BOFiltre5ST').value;
    t.filtre7 = ById('BOFiltre7ST').checked;
    t.filtre8 = ById('BOFiltre8ST').value;
    Options.EffetRouge = t.filtre5;
    Options.AllEffet = t.filtre4;
    saveOptions ();
    t.show();
  
  },
  upgradeQualite:function(id,objet) {
    var t = myBO.Trone;
    
    var currentcityid = Seed.cities[Options.salvageconfig.CityCity][0];
    
    var params = uW.Object.clone(uW.g_ajaxparams);
       params.action="upgradeQuality";
       params.ctrl="throneRoom\\ThroneRoomServiceAjax";
       params.throneRoomItemId=id; 
       params.buffItemId=objet;
       params.payment="aetherstone";
       params.cityId=currentcityid;
       uW.ajax.Request(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{method:"post",parameters:params,loading:true,
        onSuccess:function(transport) {
         var m = eval("(" + transport.responseText + ")");
         if (m.ok === true){
          Seed.resources["city" + currentcityid].rec5[0] = Seed.resources["city" + currentcityid].rec5[0] - m.aetherstones;
          if (objet>0) {
           uW.ksoItems[objet].subtract();
          }
          var s = uW.kocThroneItems[id];
          if (m.success) {
           s.quality = m.item.quality;s.level = m.item.level;s.name = s.createName();
          } else {
           s.quality = m.item.quality;s.level = m.item.level;s.name = s.createName();
           if (m.break) { 
            s.brokenType = "quality"; 
            s.isBroken = true;
            s.name = s.createName();
           }
          }
          uW.cm.ThroneView.renderInventory(uW.kocThroneItems);
          t.show();
          
         }
        }
   });
    
  },
  upgradeLevel:function(id,objet) {
    var t = myBO.Trone;
        var currentcityid = Seed.cities[Options.salvageconfig.CityCity][0];
        
        var params = uW.Object.clone(uW.g_ajaxparams);
           params.action="upgradeLevel";
           params.ctrl="throneRoom\\ThroneRoomServiceAjax";
           params.throneRoomItemId=id; 
           params.buffItemId=objet;
           params.payment="aetherstone";
           params.cityId=currentcityid;
           uW.ajax.Request(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{method:"post",parameters:params,loading:true,
            onSuccess:function(transport) {
             var m = eval("(" + transport.responseText + ")");
             if (m.ok === true){
              Seed.resources["city" + currentcityid].rec5[0] = Seed.resources["city" + currentcityid].rec5[0] - m.aetherstones;
              if (objet>0) {
	                 uW.ksoItems[objet].subtract();
          }
                        var s = uW.kocThroneItems[id];
	                if (m.success) {
	                 s.quality = m.item.quality;s.level = m.item.level;s.name = s.createName();
	                } else {
	                 s.quality = m.item.quality;s.level = m.item.level;s.name = s.createName();
	                 if (m.break) { 
	                  s.brokenType = "level"; 
	                  s.isBroken = true;
	                  s.name = s.createName();
	                 }
	                }
	                uW.cm.ThroneView.renderInventory(uW.kocThroneItems);
          		t.show();
             }
            }
   });
    
  },
  Repair:function(id) {
   var t = myBO.Trone;
   var params = uW.Object.clone(uW.g_ajaxparams);
   params.action="timeRepair";
   params.ctrl="throneRoom\\ThroneRoomServiceAjax";
   params.throneRoomItemId=id; 
   uW.ajax.Request(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{method:"post",parameters:params,loading:true,
    onSuccess:function(transport) {
     var m = eval("(" + transport.responseText + ")");
     if (m.ok === true){
      Seed.queue_throne.start = uW.unixtime();
      Seed.queue_throne.end = m.eta;
      Seed.queue_throne.itemId = id;
      uW.kocThroneItems[id].isBroken = false;
      unsafeWindow.cm.ThroneView.renderInventory(unsafeWindow.kocThroneItems);
      t.show();
     }
    }
   });

  },
  equipItem: function(id) {
   var t = myBO.Trone;
    var params = uW.Object.clone(uW.g_ajaxparams);
   params.action="equipItem";
   params.ctrl="throneRoom\\ThroneRoomServiceAjax";
   params.itemId=id; 
   params.presetId=Seed.throne.activeSlot;
   uW.ajax.Request(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{method:"post",parameters:params,loading:true,
    onSuccess:function(transport) {
     var m = eval("(" + transport.responseText + ")");
     if (m.ok === true){
      uW.cm.ThroneView.clickItemEquip(uW.kocThroneItems[id]);
      t.show();
     }
    }
   });
  },
  UnequipItem: function(id) {
     var t = myBO.Trone;
      var params = uW.Object.clone(uW.g_ajaxparams);
     params.action="unequipItem";
     params.ctrl="throneRoom\\ThroneRoomServiceAjax";
     params.itemId=id; 
     params.presetId=Seed.throne.activeSlot;
     uW.ajax.Request(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{method:"post",parameters:params,loading:true,
      onSuccess:function(transport) {
       var m = eval("(" + transport.responseText + ")");
       if (m.ok === true){
        uW.cm.ThroneView.clickItemUnequip(uW.kocThroneItems[id]);
        t.show();
       }
      }
     });
  },
  salvage: function(id) {
   var t = myBO.Trone;
   
   if (uW.kocThroneItems[id].level>0) {
    var a=confirm("Etes-vous sur ?");
    if (!a) return;
   }
   
    var params = uW.Object.clone(uW.g_ajaxparams);
   params.action="salvage";
   params.ctrl="throneRoom\\ThroneRoomServiceAjax";
   params.itemId=id; 
   params.cityId=Seed.cities[Options.salvageconfig.CityCity][0];  
   uW.ajax.Request(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{method:"post",parameters:params,loading:true,
    onSuccess:function(transport) {
     var m = eval("(" + transport.responseText + ")");
     if (m.ok){ 
      
      uW.kocThroneItems[id].salvage();
      t.show();
     }else{
      
     }
    }
   });
  }
}

/*********************************** Test TAB ***********************************/
myBO.Test = {
  tabOrder: 25,
  tabDisabled : false,        
  tabLabel : 'Test',
  myDiv : null,
  cont : null,
 
  init : function (){    // called once, upon script startup
    this.myDiv = document.createElement('div');
    return this.myDiv;
  },

  hide : function (){
    var t = myBO.Test;
  },
  getContent : function (){
      return myBO.Test.myDiv;
  },
  show : function (){
     var t = myBO.Test;
     t.cont = this.myDiv;
     var citySelect = '   <SELECT id=fakeCity>';
     	    for (var c=0; c<Cities.numCities; c++) {
     		 	 aCity = Cities.cities[c].name + ' ('+Cities.cities[c].x + ','+ Cities.cities[c].y+')';
     	         citySelect += '<option value=\''+c+'\'>'+aCity+'</option>';
     	    }
	    citySelect += '</select>';
     
     
  var m = '<DIV class=boStat><b>TEST DES ALERTES - DETECTION DES ATTAQUES</b></div><TABLE><TR><TD align=right>'+uW.g_js_strings.commonstr.scouting+'</td><TD><INPUT type=checkbox id=fakeIsScout></td><TD align=right>'+uW.g_js_strings.commonstr.wilderness+'</td><TD><INPUT type=checkbox id=fakeIsWild></td></tr>\
        <TR><TD colspan=2 align=right>Time ('+lang.General.secs+') : </td><TD><INPUT type=text size=4 value=300 id=fakeSeconds></td></tr>\
        <TR><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt1'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_1_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop0></td><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt2'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_2_30_s34.jpg></td><TD><INPUT type=text size=6 value=1 id=faketroop1></td></tr>\
	<TR><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt3'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_3_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop2></td><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt4'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_4_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop3></td></tr>\
	<TR><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt5'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_5_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop4></td><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt6'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_6_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop5></td></tr>\
	<TR><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt7'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_7_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop6></td><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt8'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_8_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop7></td></tr>\
	<TR><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt9'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_9_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop8></td><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt10'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_10_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop9></td></tr>\
	<TR><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt11'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_11_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop10></td><TD align=right><img height=18 title="'+unsafeWindow.unitcost['unt12'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_12_30_s34.jpg></td><TD><INPUT type=text size=6 value=0 id=faketroop11></td></tr>\
	<TR><TD align=right>'+uW.g_js_strings.commonstr.attacker+'</td><TD><INPUT type=text size=13 value="Kabam!" id=fakeName></td><td align=right>'+uW.g_js_strings.commonstr.might+'</td><td><INPUT type=text size=13 value="5441192" id=fakeMight></td></tr>\
	<TR><TD align=right>'+uW.g_js_strings.commonstr.target+'</td><TD>'+citySelect+'</td><td><INPUT id=testSendMarch type=submit value="Fake '+uW.g_js_strings.modal_barracks_train.attack+'" \></td></tr>';
   m+='</td></tr></table><br><center><INPUT id=ptReloadKOC type=submit value="Reload KOC" \>\
        <BR><DIV id=testDiv style="background-color:#fffff0; maxwidth:675; max-height:30px; height:0px; overflow-y:auto;"></div>';
    t.cont.innerHTML = m;
    
     ById('testSendMarch').addEventListener ('click', t.clickFakeAttack, false);
    ById('ptReloadKOC').addEventListener ('click', t.reloadKOC, false);
 
    function xyNotify(city, x, y){
      var m = '[ Notified: '+ (city?city.name:'null') +', x='+ x +', y='+ y +' ]';
      ById('testNotify').innerHTML = m;
    }
   
  },
  writeDiv : function (msg){
    var t = myBO.Test;
    if (t.state != null)
    ById('testDiv').innerHTML = msg;
  },

  addDiv : function (msg){
    var t = myBO.Test;
    if (t.state != null)
    ById('testDiv').innerHTML += msg;
  },
  
  reloadKOC : function (){
   
      reloadKOC();
  },
  
  createFakeAttack : function (cityNum, isScout, isWild, isFalse, secs, troops, name, might){
     var marchId = 'm'+ (88888 + Math.floor(Math.random()*11111));
     var march = {};
     if (matTypeof(Seed.queue_atkinc)=='array')
       Seed.queue_atkinc = {};
     if (isFalse)
       march.marchType = 0;
     else if (isScout)
       march.marchType = 3;
     else
       march.marchType = 4;
 
     march.toCityId = Cities.cities[cityNum].id;
     if (isWild) {
       keys = unsafeWindow.Object.keys(Seed.wilderness['city'+Cities.cities[cityNum].id]);
       march.toTileId = Seed.wilderness['city'+Cities.cities[cityNum].id][keys[0]].tileId;
     } else {
       march.toTileId = Cities.cities[cityNum].tileId;
     }
     secs = parseInt(secs);
     march.arrivalTime = unixTime() + secs;
     march.departureTime = unixTime() - 10;
      march.unts = {}
 	for(i=0; i<12; i++){
 	  if(troops[i] > 0)
 		march.unts["u"+(i+1)] = addCommas(troops[i]);
 	}
     march.pid = 1234567;
     march.score = 9;
     march.mid = marchId.substr(1);
     march.players = {}
     march.players.u1234567 = {}
     march.players.u1234567.n = name;
     march.players.u1234567.t = 60;
     march.players.u1234567.m = might;
     march.players.u1234567.s = 'M';
     march.players.u1234567.w = 1;
     march.players.u1234567.a = 1;
     march.players.u1234567.i = 5;
     Seed.queue_atkinc[marchId] = march;
     Seed.players.u1234567 = march.players.u1234567;
   },
 
   clickFakeAttack : function (){
     var t = myBO.Test;
     var isScout = ById('fakeIsScout').checked;
     var isWild = ById('fakeIsWild').checked;
     var isFalse = false;
 	var troops = [];
 	for(i=0; i<12; i++)
 		troops[i] = parseInt(ById('faketroop'+i).value);
     var secs = parseInt(ById('fakeSeconds').value);
 	var name = ById('fakeName').value;
 	var city = ById('fakeCity').value;
 	var might = ById('fakeMight').value;
     t.createFakeAttack (city, isScout, isWild, isFalse, secs, troops ,name,might);
   },
}

/********************************* RESUME ***********************************/

Tabs.Overview = {
  tabOrder: 1,
  tabLabel:  lang.BoiteLabelResumer,
  myDiv: null,

  displayTimer : null,
  checkBox:null,
  defMode : {},  
  checkBox1:null,
  Overview : function (){
  },

  init : function (div){
     
    var t = Tabs.Overview;
    unsafeWindow.BOCrafting = t.Crafting;
    unsafeWindow.BOCraftingItem = t.CraftingItem;
    t.myDiv = div;  
    var str= '<div id="BOResumeDIV" style="height:' + (Options.HauteurBoite-30) +'px;max-height:' + (Options.HauteurBoite-30) +'px;overflow-y:auto"></div>';
    t.myDiv.innerHTML = str;
    t.BOResumeDIV = ById("BOResumeDIV");
    
  },

  getContent : function (){

  },

  hide : function (){
   var t = Tabs.Overview;
    clearTimeout (t.displayTimer);
  },
 show : function (){
   var t = Tabs.Overview;
   clearTimeout (t.displayTimer);
   t.setContent();
 },
 CraftingItem: function (obj, currentcity, itemId, recipeId, categoryId) {
  var t = Tabs.Overview;
  if (obj) obj.value="Crafting...";
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.action="craft";
        params.ctrl="Crafting";
        params.cityId=currentcity;
        params.insurance=false;
 	params.itemId=itemId;
 	params.recipeId=recipeId;
 	params.categoryId=categoryId;
 
        new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch.php" + unsafeWindow.g_ajaxsuffix, {
                      method: "post",
       		    parameters: params,
      	onSuccess: function (transport) {
          var o=eval("("+transport.responseText+")");
          if(o.ok===true){
           if (o.status=="error") {
            //alert("Erreur crafting : " + o.errorMessage);
            if (obj) obj.value="Craft";
           } else if(o.status=="failure"){
	     //alert("Echec crafting !");
	     if (obj) obj.value="Craft - try again";
	   } else if (o.status=="success"){
	     if (obj) obj.value="Craft OK";
		if(!Seed.queue_craft["city"+currentcity]) {
		 Seed.queue_craft["city"+currentcity]=[];
		}
     		var n={};
     		n.recipeId=recipeId;
     		n.craftingUnixTime=o.time.startTime;
     		n.craftingEtaUnixTime=o.time.endTime;
     		n.craftingId=o.craftingId;
     		n.categoryId=null;
     		n.recipeIndex=null;
     		unsafeWindow.seed.queue_craft["city"+currentcity].push(n);
     		setTimeout(function() { t.Crafting(currentcity); },1000);
     	  }
        } 
        
        },
         onFailure: function () {          t.Crafting(currentcity);         }
        });
 },
 Crafting: function(currentcity) {
  var t = Tabs.Overview;
   var messagebody ="", ReciId=0, catId=0;
   var ret=getCityBuilding(currentcity,20).count;
   if (ret>0) {
     var texte="";
     var i=Seed.queue_craft["city"+currentcity];
     if(i.length>0) {
      var q=i[0];
      var totTime = 0;
      var now = unixTime();
      totTime = q.craftingEtaUnixTime - now;
      if (totTime > 0) {
         texte= "Reste " + timestr(totTime);
         ReciId=q.recipeId;
         catId=q.categoryId;
      }
     }
     messagebody += "<TABLE width=95% border=0 align=center class=ptTab>";
     messagebody += "<tr style='background-Color:#AAA;'><td colspan=2><b>"+uW.g_js_strings.commonstr.items+"</td><td><b>"+lang.Overview.col1+"</td><td><b>"+lang.Overview.col2+"</td><td><b>"+uW.g_js_strings.commonstr.requirements+"</td></tr>"; 
     for (ZZ in uW.recipelist) {
     for(var i=0; i < uW.recipelist[ZZ].length; i++){
       var h = parseInt(uW.recipelist[ZZ][i].output_item_id);
       var recipe_id = uW.recipelist[ZZ][i].recipe_id;
       var category = uW.recipelist[ZZ][i].category;
       var qte=0;
       if (parseInt(Seed.items["i"+h])>0) qte=parseIntNan(Seed.items["i"+h]);
            messagebody += "<tr><td colspan=2><img src='http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/"+ h + ".jpg' width=25>&nbsp;"+unsafeWindow.itemlist["i"+h].name+"</td><td><center><b>"+qte+"</td>";
 	if (texte!="") {
 	   if (ReciId==recipe_id && catId==category) {
 	     messagebody += "<td><b><i>"+texte+"</td>";
 	   }else {
	           messagebody += "<td>&nbsp;</td>";
	           }
	 }     else
         messagebody += "<td><input type=button value='Craft' onclick='BOCraftingItem(this,"+currentcity+","+h+","+recipe_id+","+category+")'></td>";
         messagebody += "<td>"+ uW.recipelist[ZZ][i].input.resources[1] + " Ether<bR>";
        for (k in uW.recipelist[ZZ][i].input.items) {
         if (uW.itemlist["i"+k])       
          messagebody += uW.recipelist[ZZ][i].input.items[k] + "/"+parseIntNan(Seed.items["i"+k])+" " + uW.itemlist["i"+k].name+"<br>";
       }
    messagebody += "</td></tr>"
      }
     }
       messagebody+="</table>";  
  } else {
   messagebody += "<center>"+lang.Overview.nofey+"</center>";
  }
  if (t.BOPopCrafting == null) {
     	t.BOPopCrafting = new CPopup('BOPopCrafting', 0, 0, 560, 700, true, function() {clearTimeout (1000);});
     	t.BOPopCrafting.centerMe (mainPop.getMainDiv());
     	}
     	var m = '<DIV style="max-height:665px; height:665px; overflow-y:scroll">';
     	m+= messagebody + '</div>';
     	t.BOPopCrafting.getMainDiv().innerHTML = m;
     	t.BOPopCrafting.getTopDiv().innerHTML = '<DIV align=center><B>'+lang.Overview.titlefey+'</B></DIV>';
	t.BOPopCrafting.show(true);  

 },

 setContent : function (){

    var t = Tabs.Overview;
    var rownum = 0;
    var totalentre = 0;  
    function UniteFormation(id) {
     var nbunit=0; // 
     for(i=0; i<Cities.numCities; i++) {
      var cityIdd = Cities.cities[i].id;
      var q = Seed.queue_unt['city'+cityIdd];
      var qs = q.toString();
       if (q!=null && q.length>0 ){
        for (var ii=0; ii<q.length; ii++){
         if (q[ii][0]==id) nbunit+=parseIntNan(q[ii][1]);
         
        }
      }
      }
      totalentre += parseIntNan(nbunit*UniteCout(id));
      return nbunit;
    }
    function UniteCout(id) {
      var Unitcout=parseIntNan(uW.unitupkeeps[id]); 
      return Unitcout;
    }
 
    function _row (name, row, noTotal, typee){
      if (rownum++ % 2)
        style = '';
      else
        style = ' style = "background: #e8e8e8"';
      var tot = 0;
      var m = [];
      m.push ('<TR style="background: #fff" align=right');
      m.push (style);
      m.push ('><TD');
      m.push (style);
      m.push ('><B>');
      m.push (name);
      m.push ('</td>');
      if (noTotal){
        m.push ('<TD');
        m.push (style);
        m.push ('>&nbsp;</td>');
      } else {
        for (i=0; i<row.length; i++)
          tot += row[i];
        m.push ('<TD style="background: #ffc">');
         if (tot<0) {
              m.push ("<SPAN class=boldRed>"+UniteKMG(tot)+"</span>");
         } else {
	   if (typee>0 || !Options.EnableReduireUnit)
	    m.push (addCommas(tot));
           else 
            m.push (UniteKMG(tot));
         }
        m.push ('</td>');
      }
      for (i=0; i<row.length; i++){
        m.push ('<TD');
        m.push (style);
        m.push ('>');
        if (typee>0 || !Options.EnableReduireUnit) 
         m.push (addCommas(row[i]));
        else 
         m.push (UniteKMG(row[i]));
        m.push ('</td>');
      }
      if (Options.EnableFormation && typee>0) {
       m.push ('<td>'+addCommas(UniteFormation(typee))+'</td>');    
      }
      if (Options.EnableFormation && name=='Form') {
         if (!Options.EnableReduireUnit)
          m.push("<td>&nbsp;</td><td>" + addCommas(totalentre) + "</td>");
         else
          m.push("<td>&nbsp;</td><td>" + UniteKMG(totalentre) + "</td>");
      }
      m.push ('</tr>');
      return m.join('');
    }

 
    try {
      if (Options.includeMarching)
        march = getMarchInfo ();
  
      dt = new Date ();
      dt.setTime (Seed.player.datejoinUnixTime * 1000);
      
      str = '<DIV class=boStat style="margin-top:4px; margin-bottom:5px; "><TABLE cellspacing=0 class=ptTab cellpadding=0 width=98% align=center>\
        <TR align=left><TD><SPAN class=boStatLight>Domain: </span>' + unsafeWindow.domainName +'</td><TD><SPAN class=boStatLight>Joined on :</span> '+ dt.toLocaleDateString() +'</td>\
        <TD><SPAN class=boStatLight>'+uW.g_js_strings.commonstr.alliance+': </span> ' + getMyAlliance()[1] +'</td>\
        <TD><SPAN class=boStatLight>'+uW.g_js_strings.commonstr.might+': </span> ' + addCommas(Seed.player.might) +'</td>\
        <TD><SPAN class=boStatLight>'+unsafeWindow.g_js_strings.commonstr.glory+' : </span> <span title="Max : ' + addCommas(Seed.player.maxGlory) +'">' + addCommas(Seed.player.glory) +'</span></td>\
        <TD><SPAN class=boStatLight>Trone : '+addCommas(uW.cm.ThroneController.calcMight())+'</span></td>\
        </tr></table></div><span id="debugtest"></span>';
     
      str += "<DIV id=overMainDiv style='font-size:10px;padding:5px'><TABLE class=ptTabOverview cellpadding=0 cellspacing=0><TR  align=center><TD width=45 align=center></td><TD width=88 style='background: #ffc; font-size:150%' align=center><SPAN class=oohfancy>"+lang.Overview.sum+"</SPAN></td>";
      for(i=0; i<Cities.numCities; i++) {
         cityID = 'city'+ Cities.cities[i].id;
         Gate = parseInt(Seed.citystats[cityID].gate);
	 if(Gate == 0) var couleurr="#77EE77";
         if(Gate != 0) var couleurr="#EE7777";
         
         str += "<TD width=80 style='background-color:"+couleurr+"'><SPAN class=oohfancy>"+ Cities.cities[i].name.substring(0,20) +"</SPAN><BR><a href='javascript:void(0)' onclick='cm.utils.CoordinateLinkController.onClick(event)' class='coordinateLink'>("+Cities.cities[i].x +","+ Cities.cities[i].y+")</a><BR>"+ unsafeWindow.provincenames['p'+ Cities.cities[i].provId] +"</td>";
       
      }

      if (Options.includeMarching)
        str += '<TD width=81><B>'+lang.Overview.includeMarching+'</b></td>';
      if (Options.EnableFormation)  
       str += '<TD width=81><B>'+lang.Overview.EnableFormation+'</b></td>'; 
       
      str += "<td></td></tr>";
      str += "<tr><td><DIV id=pbSwfPlayer></div></td><td></td>";
      
      for (var cityId in Cities.byID)
      		str += '<TD align=center><INPUT type=submit id=BOtabut_'+ cityId +' value=""></td>';
      str += '</tr>';
      
      rows = [];
      rowsnm = [];  
      rows[0] = [];
     // Ressources
     if (Options.showRes) {
      for(i=0; i<Cities.numCities; i++) {
        cityID = 'city'+ Cities.cities[i].id;
        rows[0][i] = parseInt(Seed.citystats[cityID].gold[0]);
      }
      for (r=1; r<6; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
          if (r==5)
           rows[r][i] = parseInt(Seed.resources[cityID]['rec'+r][0]);
          else
           rows[r][i] = parseInt(Seed.resources[cityID]['rec'+r][0] / 3600);
          
        }
       
      }
  
      if (Options.includeMarching){
        for (var i=0; i<6; i++)
          rows[i][Cities.numCities] = parseIntNan(march.resources[i]);
      }
      str += _row ('<img height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png>', rows[0], false, 0);
      str += _row ('<img height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png>', rows[1], false, 0);
      str += _row ('<img height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png>', rows[2], false, 0);
      str += _row ('<img height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png>', rows[3], false, 0);
      str += _row ('<img height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png>', rows[4], false, 0);
      str += _row ('<img height=18 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png>', rows[5], false, 0);
      
      if (Options.showProduction) {
       
          str += '<TR><TD><BR></td></tr>';
         
          row = [];
            for(i=0; i<Cities.numCities; i++) {
                        var rp = getResourceProduction (Cities.cities[i].id);
                        row[i] = rp[1];
            }
            str += _row ('<img height=18 title="'+lang.Overview.prodfood+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png>', row, false, 0);
          row = [];
                  for(i=0; i<Cities.numCities; i++) {
                              var rp = getResourceProduction (Cities.cities[i].id);
                              row[i] = rp[2];
                  }
                  str += _row ('<img height=18 title="'+lang.Overview.prodwood+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png>', row, false, 0);
                  
       row = [];
            for(i=0; i<Cities.numCities; i++) {
                        var rp = getResourceProduction (Cities.cities[i].id);
                        row[i] = rp[3];
            }
            str += _row ('<img height=18 title="'+lang.Overview.prodstone+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png>', row, false, 0);
            
       row = [];
            for(i=0; i<Cities.numCities; i++) {
                        var rp = getResourceProduction (Cities.cities[i].id);
                        row[i] = rp[4];
            }
        str += _row ('<img height=18 title="'+lang.Overview.prodore+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png>', row, false, 0);
            
      }
      
      
     }
      
         str += '<TR><TD style="font-size:6px"><BR></td></tr>';
	            row = [];
	            var totalbouffe = 0;
	            for(i=0; i<Cities.numCities; i++) {
	              var rp = getResourceProduction (Cities.cities[i].id);
	              //var usage = parseIntNan(Seed.resources["city" + Cities.cities[i].id]['rec1'][3]);
	              row[i] = rp[1];
	            }
	            //str += _row ('Prod', row, false,  0);
	            
	            for(i=0; i<Cities.numCities; i++) {
	              if (row[i] >= 0)
	                row[i] = '----';
	              else {
	                var timeLeft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0]) / 3600 / (0-row[i]) * 3600;
	                if (timeLeft > 86313600)
	                  row[i] = '----';
	                else {
	                  if (Options.enableFoodWarn && timeLeft<(Options.foodWarnHours*3600))
	                    row[i] = '<SPAN class=whiteOnRed><blink>'+ timestrShort(timeLeft) +'</blink></span>';
	                  else
	                    row[i] = timestrShort(timeLeft);
	                }
	              }
	            }    
      str += _row (lang.Overview.auton, row, true, 0);
      
        
            var now = unixTime();
            str += '<TR><TD style="font-size:6px"><BR></font></td></tr>';
            str +='<tr style="background: #fff" align=right><td><img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/131.jpg title="'+uW.g_js_strings.commonstr.build+'"></td><td>&nbsp;</td>';
            for(i=0; i<Cities.numCities; i++) {
             var totTime = 0;
             if (Seed.queue_con["city" + Cities.cities[i].id].length > 0) {
              var q=Seed.queue_con["city" + Cities.cities[i].id][0];
              var totTime = 0;
              totTime = q[4] - now;
              if (totTime < 0)
                totTime = 0;
              if (totTime < 3600)
                affuichage = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
              else
                affuichage = timestr(totTime);
              str +="<td>"+ affuichage + "</td>";  
             } else {
             str +="<td>0s</td>";
             }
            }    
            str +="</tr>"; 
            //
            str +='<tr style="background: #e8e8e8" align=right><td><img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/1.jpg title="'+uW.g_js_strings.commonstr.technology+'"></b></td><td>&nbsp;</td>';
            for(i=0; i<Cities.numCities; i++) {
             var totTime = 0;
             if (Seed.queue_tch["city" + Cities.cities[i].id].length > 0) {
              var q=Seed.queue_tch["city" + Cities.cities[i].id][0];
              var totTime = 0;
              totTime = q[3] - now;
              if (totTime < 0)
                totTime = 0;
              if (totTime < 3600)
                affuichage = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
              else
                affuichage = timestr(totTime);
              
              str +="<td>"+ affuichage + "</td>";  
       
             } else {
             str +="<td>0s</td>";
             }
            }    
             str +="</tr>"; 
      // crafting
          str +='<tr style="background: #e8e8e8" align=right><td><img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/items/70/3.jpg title="Crafting"></b></td><td>&nbsp;</td>';
            for(i=0; i<Cities.numCities; i++) {
             var totTime = 0;
             if (Seed.queue_craft["city" + Cities.cities[i].id].length > 0) {
              var q=Seed.queue_craft["city" + Cities.cities[i].id][0];
              var totTime = 0;
              totTime = q.craftingEtaUnixTime - now;
              if (totTime < 0)
                totTime = 0;
              if (getCityBuilding(Cities.cities[i].id,20).count>0 && totTime == 0)
                affuichage = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
              else
                affuichage = timestr(totTime);
              
              str +="<td><span onclick='BOCrafting("+Cities.cities[i].id+");'>"+ affuichage + "</span></td>";  
       
             } else {
             affuichage = timestr(totTime);
             if (getCityBuilding(Cities.cities[i].id,20).count>0)
                affuichage = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
                
             str +="<td><span onclick='BOCrafting("+Cities.cities[i].id+");'>"+affuichage+"</span></td>";
             }
            }    
             str +="</tr>"; 
             // Reviving
            str +='<tr style="background: #e8e8e8" align=right><td><img height=20 src="'+URL_HOSPITAL+'" title="'+uW.g_js_strings.revive.trainttl+'"></b></td><td>&nbsp;</td>';
            for(i=0; i<Cities.numCities; i++) {
             var totTime = 0;
             var ah=Seed.queue_revive["city" + Cities.cities[i].id];
             var l=0;
             if (ah) {
              for(var an=0;an<Math.min(ah.length,1);an++){
                 var P=uW.unixtime();
                 l=parseInt(ah[an][3])-P;
              }
              var totTime = 0;
              totTime = parseIntNan(l);
              if (totTime < 0)
                totTime = 0;
                affuichage = timestr(totTime);
              
              str +="<td><span>"+ affuichage + "</span></td>";  
       
             } else {
             affuichage = timestr(totTime);
                
             str +="<td><span>"+affuichage+"</span></td>";
             }
            }    
             str +="</tr>";  
             
             
             
      // Population
      
      if (Options.showPop) {
       str += '<TR><TD style="font-size:6px"><BR></td></tr>';
       
              for (r=0; r<7; r++){
                rowsnm[r] = [];
              }
              for(i=0; i<Cities.numCities; i++) {
                cityID = 'city'+ Cities.cities[i].id;
                rowsnm[0][i] = parseIntNan(Seed.citystats[cityID]["pop"][1]); 
                rowsnm[1][i] = parseIntNan(Seed.citystats[cityID]["pop"][0]); 
                rowsnm[2][i] = parseIntNan(Seed.citystats[cityID]["pop"][3]);  
                rowsnm[5][i] = parseIntNan(Seed.citystats[cityID]["pop"][2]); 
                if (rowsnm[5][i] < 100)
		                  rowsnm[5][i] = '<SPAN class=boldRed>' + rowsnm[5][i] + '</SPAN>';
                rowsnm[3][i] = rowsnm[0][i] * rowsnm[5][i] / 100 - rowsnm[2][i];
                rowsnm[4][i] = rowsnm[1][i] - rowsnm[2][i];                     
                rowsnm[6][i] = parseIntNan(Seed.citystats[cityID]["gold"][1]);    
                if (rowsnm[6][i] > 0)
                  rowsnm[6][i] = '<SPAN class=boldRed>' + rowsnm[6][i] + '</SPAN>';
              }
      
              rownum = 0;
              str += _row ('<span class=pdxCapShadowSG>'+lang.Overview.pop1+'</span>',  rowsnm[0]);
              str += _row ('<span class=pdxCapShadowSG>'+lang.Overview.pop2+'</span>',  rowsnm[1]);
              str += _row ('<span class=pdxCapShadowSG>'+lang.Overview.pop3+'</span>',  rowsnm[2]);
              str += _row ('<span class=pdxCapShadowSG>'+lang.Overview.pop4+'</span>', rowsnm[3]);
              str += _row ('<span class=pdxCapShadowSG>'+lang.Overview.pop5+'</span>', rowsnm[4]);
              str += _row ('<span class=pdxCapShadowSG><img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/happiness.png title="'+uW.g_js_strings.commonstr.happiness+'"></span>',  rowsnm[5], true);
        str += _row ('<span class=pdxCapShadowSG><img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/taxes.png title="'+uW.g_js_strings.changeTax.taxrate+'"></span>', rowsnm[6], true);
      }
      
      
      // Troupes
      if (Options.showTroops) {
      
      str += '<TR><TD style="font-size:6px"><BR></td></tr>';
      for (r=1; r<13; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
          rows[r][i] = parseInt(Seed.units[cityID]['unt'+r]);
        }
      }
      if (Options.includeMarching){
        for (var i=0; i<13; i++)
          rows[i][Cities.numCities] = parseIntNan(march.marchUnits[i]);
      }
      rownum = 0;
      this.totalentre = 0;
      for (r=1; r<13; r++){
       str += _row ('<img height=18 title="'+unsafeWindow.unitcost['unt'+r][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg>', rows[r],false, r);
      }
      
      }
      
      var row = [];
            for(i=0; i<Cities.numCities; i++) {
              var totTime = 0;
              var q = Seed.queue_unt['city'+Cities.cities[i].id]; 
              if (q!=null && q.length>0)
                totTime = q[q.length-1][3] - now;
              if (totTime < 0)
                totTime = 0;
              if (totTime < 86400)
                row[i] = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
              else
                row[i] = timestr(totTime);
            }
      str += _row (lang.Overview.EnableFormation, row, true, 0);
      
           // Defenses du remparts
            if (Options.showDefense) {
             str += '<TR><TD style="font-size:6px"><BR></td></tr>';
             owsnm = [];
                     for (r=0; r<5; r++){
                       rowsnm[r] = [];
                     }
                     for(i=0; i<Cities.numCities; i++) {
                       var wall = {};
                       getWallInfo (Cities.cities[i].id, wall);
                       rowsnm[0][i] = parseIntNan(wall.Crossbows);
                       rowsnm[1][i] = parseIntNan(wall.Trebuchet);
                       rowsnm[2][i] = parseIntNan(wall.Caltrops);
                       if (isNaN(parseInt(wall.SpikedBarrier))) // KoC bug if wall lvl 0
                         rowsnm[3][i] = 0;
                       else
                       rowsnm[3][i] = parseIntNan(wall.SpikedBarrier);
                       rowsnm[4][i] = parseIntNan(wall.Trap);
                     }
                     if (Options.defBau){
                       var q = Seed.queue_unt;
                       for(i=0; i<Cities.numCities; i++) {
                         var q = Seed.queue_fort['city'+Cities.cities[i].id];
                         if (q && q.length>0){
                           for (qi=0; qi<q.length; qi++) {
                             if (q[qi][0]==53)
                               rowsnm[0][i] += parseIntNan(q[qi][1]);
                             if (q[qi][0]==55)
                               rowsnm[1][i] += parseIntNan(q[qi][1]);
                             if (q[qi][0]==60)
                               rowsnm[4][i] += parseIntNan(q[qi][1]);
                             if (q[qi][0]==61)
                               rowsnm[2][i] += parseIntNan(q[qi][1]);
                             if (q[qi][0]==62)
                               rowsnm[3][i] += parseIntNan(q[qi][1]);
                           }
                         }
                       }
                     }
             
                     rownum = 0;
                     str += _row ('<span class=pdxCapShadowSG><img height=18 title="'+unsafeWindow.fortcost.frt53[0]+'" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_53_30.jpg"></span>',  rowsnm[0]);
                     str += _row ('<span class=pdxCapShadowSG><img height=18 title="'+unsafeWindow.fortcost.frt55[0]+'" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_55_30.jpg"></span>',  rowsnm[1]);
                     str += _row ('<span class=pdxCapShadowSG><img height=18 title="'+unsafeWindow.fortcost.frt60[0]+'" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_60_30.jpg"></span>',  rowsnm[4]);
                     str += _row ('<span class=pdxCapShadowSG><img height=18 title="'+unsafeWindow.fortcost.frt61[0]+'" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_61_30.jpg"></span>', rowsnm[2]);
                     str += _row ('<span class=pdxCapShadowSG><img height=18 title="'+unsafeWindow.fortcost.frt62[0]+'" src="http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_62_30.jpg"></span>',  rowsnm[3]);
      }
      
     
      var row = [];
      for(i=0; i<Cities.numCities; i++) {
        var wall = {};
        getWallInfo (Cities.cities[i].id, wall);
        var totTime = 0;
        var q = Seed.queue_fort['city'+Cities.cities[i].id]; 
        if (q!=null && q.length>0)
          totTime = q[q.length-1][3] - now;
        if (totTime < 0)
          totTime = 0;
        if (totTime<1 && (wall.wallSpaceUsed < wall.wallSpace-4 || wall.fieldSpaceUsed < wall.fieldSpace-4))
          row[i] = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
        else
          row[i] = timestr(totTime);
      } 
      
      
      str += _row (lang.Overview.def, row, true, 0);
      
      str += '<TR><TD style="font-size:6px"><BR></td></tr>';
      
      // Nombre de marches
      row = [];
      for(i=0; i<Cities.numCities; i++) {
        var cityId = 'city'+ Cities.cities[i].id;
        var slots = 0;
        for (var k in Seed.queue_atkp[cityId]){   
         march = Seed.queue_atkp[cityId][k];
         if (typeof (march) == 'object'){
           slots++;
         }
        }
        var niveauPointRall=parseInt(getCityBuilding (Cities.cities[i].id, 12).maxLevel); 
        if (niveauPointRall==12) niveauPointRall=11;  
        row[i] = '<SPAN><B>'+ slots +'/'+ niveauPointRall +'</b></span>';
      }
      str += _row (lang.Overview.march, row, true, 0);     
      // Terres sauvages
      row = [];
      for(i=0; i<Cities.numCities; i++) {
        var totWilds = 0;
        dat = Seed.wilderness['city'+ Cities.cities[i].id];
        if (dat!=null && matTypeof(dat)=='object')
          for (k in dat)
            ++totWilds;
        var nivcastle = parseInt(Seed.buildings['city'+ Cities.cities[i].id].pos0[1]);
        var castle = nivcastle;
        if (nivcastle==11) castle=12; 
        if (nivcastle==12) castle=14; 
        if (totWilds < castle)
        {
         row[i] = '<SPAN class=boldRed><B>'+ totWilds +'/'+ castle +'</b></span>';
        }else{
          
          row[i] = totWilds +'/'+ castle;
        }
      }
      str += _row (lang.Overview.ts, row, true, 0);
      row = [];
      var did = {}; 
      for(i=0; i<Cities.numCities; i++) {
        totKnights = 0;
        dat = Seed.knights['city'+ Cities.cities[i].id];
        for (k in dat)
          ++totKnights;
         
        var Knidispo = 0;
        var niveauPointRall=parseInt(getCityBuilding (Cities.cities[i].id, 12).maxLevel);
        if (niveauPointRall==12) niveauPointRall=11;  // fix : Send eleven armies at a time for level 12
        for (var z=0; z<knightRoles.length; z++){
	        var leader = Seed.leaders['city'+Cities.cities[i].id][knightRoles[z][1]+'KnightId'];
	        if (leader == 0) {
	                
	        }else{
	         did['knt'+leader] = true;
	        }
         }
         for (k in Seed.knights['city'+Cities.cities[i].id]){
	         if (!did[k])
	           Knidispo++;    
         }
         if (Knidispo<niveauPointRall) {
          row[i] = '<b>' + totKnights + '</b> - <span title="'+lang.Overview.knight1+'"><SPAN class=boldRed><B>'+Knidispo+'/' + niveauPointRall +'</span></span>';
         }else {
          row[i] = '<b>' + totKnights + '</b> - <span title="'+lang.Overview.knight1+'">'+Knidispo+'/' + niveauPointRall +'</span>';
	 }        
         
      }
      str += _row (lang.Overview.knight, row, true, 0);          
      str += "</table>";
      t.BOResumeDIV.innerHTML = str +'</div>';
      
      function addListener (but, i){
                  but.addEventListener ('click', function (){t.butToggleDefMode(i)}, false);
      }
      for (var cityId in Cities.byID){
        	  var but = document.getElementById ('BOtabut_'+ cityId);
        	  addListener (but, cityId);
        	  t.defMode[cityId] =  parseInt(Seed.citystats["city" + cityId].gate);
        	  t.displayDefMode (cityId);
      }
   
    } catch (e){
      t.BOResumeDIV.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';
    }   
    t.displayTimer = setTimeout (t.setContent, 3000);
  },
  butToggleDefMode : function (cityId){
      var t = Tabs.Overview;
      var mode = 1;
      if (Seed.citystats["city" + cityId].gate != 0)
        mode = 0;
      t.ajaxSetDefMode (cityId, mode, function (newMode){
          t.defMode[cityId] = newMode;
          t.displayDefMode (cityId);
        });
    },
        
    displayDefMode : function (cityId){
      var t = Tabs.Overview;
      var but = ById('BOtabut_'+ cityId);
      if (t.defMode[cityId]){
        but.className = 'BODefButOn';
        but.value = lang.Overview.def+' = ON';  
      } else {
        but.className = 'BODefButOff';
        but.value = lang.Overview.def+' = OFF'; 
      }  
  },
  ajaxSetDefMode : function (cityId, state, notify){
  		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  		params.cid = cityId;
  		params.state = state;
  		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/gate.php" + unsafeWindow.g_ajaxsuffix, {
  			method: "post",
  			parameters: params,
  			onSuccess: function (rslt) {
  				if (rslt.ok) {
  					Seed.citystats["city" + cityId].gate = state;
  					notify (state);
  				}
  			},
  			onFailure: function () {
  			}
  		})
  },
};

/************** Rapports *******************/
Tabs.Rpt = {
	tabOrder:		2,
	tabLabel:		uW.g_js_strings.commonstr.reports,
	cont:			null,
	state:			null,
	minPages:		parseInt(Options.arPageFrom),
	maxPages:		parseInt(Options.arPageTo),
	data:			[],
	dataDF:	[],dataAT:	[],
	report:			[],
	reportDF:		[],
	reportAT:		[],
	totalPages:	parseInt(Options.arPageTo),
	what:			'',
	whatNot:		'',
	content:		'',

  show : function () {

    var t = Tabs.Rpt;
    if (Options.RptAuto) t.handleRptSearch();
  },
	hide : function (){
  	},

	init : function (div) {
		var t = Tabs.Rpt;
		t.cont = div;
		unsafeWindow.getmsg = t.getMailBody;
		unsafeWindow.DelMail = t.DeleteMail;
		unsafeWindow.getReport = t.getReportBody;
		unsafeWindow.DelReport = t.DeleteReport;
	        var tc = '<DIV class=boStat>'+uW.g_js_strings.commonstr.reports.toUpperCase() +' '+uW.g_js_strings.commonstr.alliance.toUpperCase() +'-'+uW.g_js_strings.commonstr.player.toUpperCase() +' - '+uW.g_js_strings.commonstr.message.toUpperCase() +' - <input type=button value="?" id=boaiderapport class=boAide></DIV><DIV class=ptentry><TABLE><TR align=center valign=center>';
		tc += '<TD class=xtab align=right>'+lang.Rpt.type+'&nbsp;<SELECT id="idRptType">';
		tc += '<OPTION value="alliance" ' + (Options.rptType=='alliance'?'SELECTED':'') + '>'+uW.g_js_strings.commonstr.reports+' '+uW.g_js_strings.commonstr.alliance+'</OPTION>';
		tc += '<OPTION value="player" ' + (Options.rptType=='player'?'SELECTED':'') + '>'+uW.g_js_strings.commonstr.reports+' '+uW.g_js_strings.commonstr.player+'</OPTION>';
		tc += '<OPTION value="inbox" ' + (Options.rptType=='inbox'?'SELECTED':'') + '>'+uW.g_js_strings.commonstr.inbox+'</OPTION>';
		tc += '<OPTION value="outbox" ' + (Options.rptType=='outbox'?'SELECTED':'') + '>'+uW.g_js_strings.commonstr.outbox+'</OPTION></SELECT>';
		tc += '<BR /><INPUT id=idRptSearch type=submit value="Ok" />&nbsp;Auto : <input type=checkbox id="idRptAuto" ' +(Options.RptAuto?'CHECKED':'')+'> '+lang.Rpt.pages+'&nbsp;<INPUT id="idRptPageFrom" size=1 value="' + Options.arPageFrom + '">'+lang.Rpt.to+'<INPUT id="idRptPageTo" size=1 value="' + Options.arPageTo + '"></TD>';
		tc += '<TD class=xtab align=right>'+uW.g_js_strings.commonstr.attacker+' :&nbsp;<SELECT id="idRptAttacker">'; // Options.arPageFrom - Options.arPageTo
		tc += '<OPTION value="Them" ' + (Options.arAttacker=='Them'?'SELECTED':'') + '>'+lang.Rpt.them+'</OPTION>';
		tc += '<OPTION value="Us" ' + (Options.arAttacker=='Us'?'SELECTED':'') + '>'+lang.Rpt.us+'</OPTION>';
		tc += '<OPTION value="Both" ' + (Options.arAttacker=='Both'?'SELECTED':'') + '>'+lang.Rpt.both+'</OPTION></SELECT>';
		tc += '<BR />'+uW.g_js_strings.commonstr.target+' :&nbsp;<SELECT id="idRptTarget">';
		tc += '<OPTION value="Them" ' + (Options.arTarget=='Them'?'SELECTED':'') + '>'+lang.Rpt.them+'</OPTION>';
		tc += '<OPTION value="Us" ' + (Options.arTarget=='Us'?'SELECTED':'') + '>'+lang.Rpt.us+'</OPTION>';
		tc += '<OPTION value="Both" ' + (Options.arTarget=='Both'?'SELECTED':'') + '>'+lang.Rpt.both+'</OPTION></SELECT></TD>';
		tc += '<TD class=xtab align=right>'+lang.Rpt.idRptWhat+'&nbsp;<INPUT id=idRptWhat type=text size=11 maxlength=50 value=""><BR />';
		tc += ''+lang.Rpt.idRptWhatNot+'&nbsp;<INPUT id=idRptWhatNot type=text size=11 maxlength=50 value=""></TD>';
		tc += '<TD class=xtab align=left><INPUT id=idRptAttack type=checkbox '+(Options.arAttack?'CHECKED':'')+' />&nbsp;'+uW.g_js_strings.commonstr.atk+'<BR />';
		tc += '<INPUT id=idRptScout type=checkbox '+(Options.arScout?'CHECKED':'')+' />&nbsp;'+uW.g_js_strings.commonstr.scouting+'</TD>';
		tc += '<TD class=xtab align=left><INPUT id=idRptReinforce type=checkbox '+(Options.arReinforce?'CHECKED':'')+' />&nbsp;'+uW.g_js_strings.commonstr.reinforce+'<BR />';
		tc += '<INPUT id=idRptTransport type=checkbox '+(Options.arTransport?'CHECKED':'')+' />&nbsp;'+uW.g_js_strings.commonstr.transporting+'</TD>';
		tc += '<TD class=xtab align=left><select id=idRptFiltre1><option value="">--</option><option value="0">'+lang.Rpt.idRptFiltre1_1+'</option><option value=54>'+lang.Rpt.idRptFiltre1_2+'</option></select><br>'+lang.Rpt.BOSyntheseAttack+' <input type=checkbox id=BOSyntheseAttack></TD></TR></TABLE></DIV>';
		tc += '<DIV class=boStat><TABLE width=100% cellspacing=0><TR><TD class=xtab align=left width=125><DIV id=idRptSearched></DIV></TD></TD>';
		tc += '<TD class=xtab><TD class=xtab align=center><SPAN style="white-space:normal" id=idRptStatus>&nbsp;</span></TD></TD>';
		tc += '<TD class=xtab><TD class=xtab align=right width=125><DIV id=idRptFound></DIV></TD></TR></TABLE></DIV>';
		tc += '<DIV id="idBoRptResultsDiv" style="height:' + (Options.HauteurBoite-140) +'px; max-height:' + (Options.HauteurBoite-140) +'px; overflow-x:auto; overflow-y:auto; white-space:nowrap;"></DIV>';
		
		t.cont.innerHTML = tc;
		
		 ById('boaiderapport').addEventListener('click', function(){
		             	 window.open(sitesupport+"?page=aide_rapport");
		      	} , false);
    	
		ById('idRptType').addEventListener ('change', t.handleRptType, false);
		ById('idRptPageFrom').addEventListener ('change', t.handleRptPages, false);
		ById('idRptPageTo').addEventListener ('change', t.handleRptPages, false);
		ById('idRptAttacker').addEventListener ('change', t.handleRptAttacker, false);
		ById('idRptTarget').addEventListener ('change', t.handleRptTarget, false);
		ById('idRptWhat').addEventListener ('keyup', t.handleRptWhat, false);
		ById('idRptWhatNot').addEventListener ('keyup', t.handleRptWhatNot, false);
		ById('idRptSearch').addEventListener ('click', t.handleRptSearch, false);
		ById('idRptFiltre1').addEventListener ('change', t.handleRptWhat, false);
	
		t.togOpt ('idRptAttack', 'arAttack');
		t.togOpt ('idRptScout', 'arScout');
		t.togOpt ('idRptReinforce', 'arReinforce');
		t.togOpt ('idRptTransport', 'arTransport');
		t.togOpt ('idRptAuto','RptAuto');
		
	},
	DeleteMail: function(rptid, type) {
   var t = Tabs.Rpt;
   var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
   params.requestType="ACTION_ON_MESSAGES";
   params.selectedAction="delete";
   params.boxType=ById('idRptType').value;
   params.selectedMessageIds=rptid;

   new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
         method: "post",
         parameters: params,
         onSuccess: function (rslt) {
           if (rslt.ok) {
           
           t.handleRptSearch();
           
           }
           if (notify)
             notify (rslt.errorMsg);
         },
         onFailure: function () {
           if (notify)
             notify ('AJAX ERROR');
         },
       });
  },
  
  DeleteReport: function(rptid, isUnread) {
   var t = Tabs.Rpt;
     
   var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
   params.s0rids = rptid;
   params.s1rids = '';
   params.cityrids = '';
   
   new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/deleteCheckedReports.php" + unsafeWindow.g_ajaxsuffix, {
         method: "post",
         parameters: params,
         onSuccess: function (rslt) {
           if (rslt.ok) {
           
           if (isUnread){
             unsafeWindow.seed.newReportCount = parseInt(unsafeWindow.seed.newReportCount) - 1;
             unsafeWindow.messages_notify_bug()
           } 
           //t.handleRptSearch();
           //t.DisplayRpt();
           }
    
         },
         onFailure: function () {
             t.handleRptSearch();
         },
       });
  },
	togOpt: function (checkboxId, optionName){
		var t = Tabs.Rpt;
		var checkbox = ById(checkboxId);
		checkbox.addEventListener ('change', eventHandler, false);
		function eventHandler (){
			Options[optionName] = this.checked;
			saveOptions();
			if (t.data.length > 0)
				if (Options.rptType == 'alliance' || Options.rptType == 'player')
					t.DisplayRpt();
				else
					t.DisplayMail();
		}
	},

	handleRptType: function(){
		var t = Tabs.Rpt;
		Options.rptType = ById("idRptType").value;
		saveOptions();
		ById("idRptSearched").innerHTML = '';
		ById("idRptStatus").innerHTML = '&nbsp;';
		ById("idRptFound").innerHTML = '';
		ById("idBoRptResultsDiv").innerHTML = '';
	},

	handleRptPages: function(){
		var t = Tabs.Rpt;
		t.minPages=parseInt(ById("idRptPageFrom").value);
		t.maxPages=parseInt(ById("idRptPageTo").value);
		if (t.maxPages < t.minPages) {
			t.maxPages = t.minPages;
			ById("idRptPageTo").value = t.maxPages;
		}
		Options.arPageFrom = t.minPages;
		Options.arPageTo = t.maxPages;
		saveOptions();
		t.totalPages=t.maxPages;
	},

	handleRptAttacker: function(){
		var t = Tabs.Rpt;
		Options.arAttacker = ById("idRptAttacker").value;
		saveOptions();
		if ((Options.rptType == 'alliance' || Options.rptType == 'player') && t.data.length > 0)
			t.DisplayRpt();
	},

	handleRptTarget: function(){
		var t = Tabs.Rpt;
		Options.arTarget = ById("idRptTarget").value;
		saveOptions();
		if ((Options.rptType == 'alliance' || Options.rptType == 'player') && t.data.length > 0)
			t.DisplayRpt();
	},

	handleRptWhat: function(){
		var t = Tabs.Rpt;
		t.what = ById("idRptWhat").value;
		if (t.data.length > 0)
			if (Options.rptType == 'alliance' || Options.rptType == 'player')
				t.DisplayRpt();
			else
				t.DisplayMail();
	},

	handleRptWhatNot: function(){
		var t = Tabs.Rpt;
		t.whatNot = ById("idRptWhatNot").value;
		if (t.data.length > 0)
			if (Options.rptType == 'alliance' || Options.rptType == 'player')
				t.DisplayRpt();
			else
				t.DisplayMail();
	},

	handleRptSearch: function(){
		var t = Tabs.Rpt;
		if (t.searchRunning){
			t.searchRunning = false;
			t.stopSearch (uW.g_js_strings.commonstr.cancelled.toUpperCase());
			return;
		}
		t.handleRptPages();
		document.getElementById ('idRptSearch').value = 'Stop';
		ById('idRptStatus').innerHTML = uW.g_js_strings.commonstr.research+' page ' + t.minPages + ' / ' + t.maxPages;
		t.searchRunning = true;
		t.data=[];
		t.report = [];
		t.dataDF=[];
		t.dataAT=[];
		t.reportAT=[];
		t.reportDF = [];
		if (Options.rptType == 'alliance' || Options.rptType == 'player')
			t.getRpt(t.minPages);
		else
			t.getMail(t.minPages);
	},

	stopSearch: function (msg){
		var t = Tabs.Rpt;
		if (t.searchRunning || msg == uW.g_js_strings.commonstr.cancelled.toUpperCase())
			document.getElementById ('idRptStatus').innerHTML = '<FONT color=#ffaaaa>' + msg + '</FONT>';
		document.getElementById ('idRptSearch').value = 'Ok';
		t.searchRunning = false;
		if (Options.rptType == 'alliance' || Options.rptType == 'player')
			t.DisplayRpt();
		else
			t.DisplayMail();
	},

	getMail: function (pageNum){
		var t = Tabs.Rpt;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.pf=0;
		params.requestType="GET_MESSAGE_HEADERS_FOR_USER_INBOX";
		params.boxType = ById('idRptType').value;
		params.pageNo = pageNum;
		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (rslt) {
				t.getMailCallback(rslt, pageNum);
			},
			onFailure: function () {
			},
		}, false);
	},

	getMailCallback: function(rslt, page) {
		var t = Tabs.Rpt;
		if (rslt) {
			if (!rslt.ok) {
				ById("idRptStatus").innerHTML = '<FONT color=#ffaaaa>' + rslt.errorMsg + '</FONT>';
				return;
			}
			t.totalPages=parseInt(rslt.noOfPages);
			if (t.totalPages < t.maxPages)
				t.maxPages = t.totalPages;
			if (rslt.message && page) {
				var ml = rslt.message;
				if (rslt.messageCount > 0) {
					var rptkeys = unsafeWindow.Object.keys(ml);
					for (var i = 0; i < rptkeys.length; i++) {
						var rpt = ml[rptkeys[i]];
						rpt.page = page;
						t.data.push(rpt);
					}
				}
			}
			if (parseInt(page)+1 <= t.maxPages && t.searchRunning) {
				ById("idRptStatus").innerHTML = uW.g_js_strings.commonstr.research +' page ' + (parseInt(page)+1) + ' / ' + t.maxPages;
				t.getMail(parseInt(page)+1);
				if (t.data.length > 0)
					t.DisplayMail();
			} else if (page)
				t.stopSearch ('Fini !');
		}
	},

	getRpt: function (pageNum){
		var t = Tabs.Rpt;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.pageNo = pageNum;
		if (Options.rptType == 'alliance')
			params.group = "a";
		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/listReports.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (rslt){
				t.getRptCallback (rslt, pageNum);
			},
			onFailure: function (rslt){
				t.getRptCallback (rslt, pageNum);
			},
		}, false);
	},
	getRptCallback: function(rslt, page){
		var t = Tabs.Rpt;
		if (rslt) {
			if (!rslt.ok) {
				ById("idRptStatus").innerHTML = '<FONT color=#ffaaaa>' + rslt.errorMsg + '</FONT>';
				return;
			}
			t.totalPages=parseInt(rslt.totalPages);
			if (t.totalPages < t.maxPages)
				t.maxPages = t.totalPages;
			if (rslt.arReports && page) {
				var ar = rslt.arReports;
				//if (ar.length == 0)
					//t.stopSearch('Page vide trouve depuis la page ' + page + ' - Kabam glitch');
				var rptkeys = unsafeWindow.Object.keys(ar);
				for (var i = 0; i < rptkeys.length; i++) {
					var rpt = ar[rptkeys[i]];
					var reportId = parseInt(rpt.reportId);
					t.report[reportId] = [];
					t.report[reportId].side1Name = rslt.arPlayerNames['p'+rpt.side1PlayerId];
					t.report[reportId].side1AllianceId = parseInt(rpt.side1AllianceId);
					if (rpt.side1AllianceId > 0)
						t.report[reportId].side1AllianceName = rslt.arAllianceNames['a'+rpt.side1AllianceId];
					else
						t.report[reportId].side1AllianceName = '-';
					if (rpt.side1CityId > 0)
						t.report[reportId].side1CityName = rslt.arCityNames['c'+rpt.side1CityId];
					else
						t.report[reportId].side1CityName = '-';
					t.report[reportId].side1XCoord = rpt.side1XCoord;
					t.report[reportId].side1YCoord = rpt.side1YCoord;
					if (parseInt(rpt.side0PlayerId) == 0) { // Kabam
						t.report[reportId].side0Name = 'Ennemi';
						t.report[reportId].side0AllianceName = '';
						t.report[reportId].side0CityName = '';
					} else {
						t.report[reportId].side0Name = rslt.arPlayerNames['p'+rpt.side0PlayerId];
						if (rpt.side0AllianceId > 0)
							t.report[reportId].side0AllianceName = rslt.arAllianceNames['a'+rpt.side0AllianceId];
						else
							t.report[reportId].side0AllianceName = '-';
						if (rpt.side0CityId > 0)
							t.report[reportId].side0CityName = rslt.arCityNames['c'+rpt.side0CityId];
						else
							t.report[reportId].side0CityName = '-';
					}
					t.report[reportId].side0AllianceId = parseInt(rpt.side0AllianceId);
					t.report[reportId].side0XCoord = rpt.side0XCoord;
					t.report[reportId].side0YCoord = rpt.side0YCoord;
					if (parseInt(rpt.side0TileType) == 10)
						t.report[reportId].side0TileTypeText='Prair';
					else if (parseInt(rpt.side0TileType) == 11)
						t.report[reportId].side0TileTypeText='Lac';
					else if (parseInt(rpt.side0TileType) == 20)
						t.report[reportId].side0TileTypeText='Fore';
					else if (parseInt(rpt.side0TileType) == 30)
						t.report[reportId].side0TileTypeText='Coll';
					else if (parseInt(rpt.side0TileType) == 40)
						t.report[reportId].side0TileTypeText='Mont';
					else if (parseInt(rpt.side0TileType) == 50)
						t.report[reportId].side0TileTypeText='Plai';
					else if (parseInt(rpt.side0TileType) == 51 && parseInt(rpt.side0CityId) == 0)
						t.report[reportId].side0TileTypeText='Barb';
					else if (parseInt(rpt.side0TileType) == 54)
						t.report[reportId].side0TileTypeText='F.S.';
					else if (parseInt(rpt.side0CityId) == 0)
						t.report[reportId].side0TileTypeText='Barb';
					else
						t.report[reportId].side0TileTypeText='Vil';
						
						
						
					
					t.report[reportId].side0TileTypeLevel = t.report[reportId].side0TileTypeText + ' ' + rpt.side0TileLevel;
					t.report[reportId].side0TileType = rpt.side0TileType;
					t.report[reportId].side0TileLevel = rpt.side0TileLevel;
					t.report[reportId].page = page;
					t.report[reportId].reportUnixTime = rpt.reportUnixTime;
					if (rpt.side0AllianceId == parseInt(getMyAlliance()[0]))
						t.report[reportId].sideId = 0;
					else if (rpt.side1AllianceId == parseInt(getMyAlliance()[0])) {
						t.report[reportId].sideId = 1;
					} else { 
						if (rpt.side0PlayerId == getMyUserId())
							t.report[reportId].sideId = 0;
						else if (rpt.side1PlayerId == getMyUserId())
							t.report[reportId].sideId = 1;
						else 
							t.report[reportId].sideId = -1;
					}					
					if (!ById("BOSyntheseAttack").checked && parseInt(rpt.side0TileType) == 54 && Options.rptType=='player') {
					    t.FindItemRpt(reportId, t.report[reportId].sideId, t.report[reportId].side0TileLevel);  
				        }
					if (ById("BOSyntheseAttack").checked && (rpt.marchType == 4 || rpt.marchType == 3))
					{
					    t.BOSyntheseAttack(reportId, t.report[reportId].sideId, 0);
					}
					
					if (rpt.marchType == 0)
						t.report[reportId].marchName = 'Desertion';
					else if (rpt.marchType == 1)
						t.report[reportId].marchName = 'Transport';
					else if (rpt.marchType == 2)
						t.report[reportId].marchName = 'Renfort';
					else if (rpt.marchType == 3 || rpt.marchType == 11) {
						if (t.report[reportId].sideId == 0)
							t.report[reportId].marchName = 'Contre-Ecl';
						else
							t.report[reportId].marchName = 'Eclaireur';
					} else if (rpt.marchType == 4) {
						if (t.report[reportId].sideId == 0)
							t.report[reportId].marchName = 'Defense';
						else
							t.report[reportId].marchName = 'Attaque';
					} else if (rpt.marchType == 10 || rpt.marchType == 9) {
					 t.report[reportId].marchName = 'Attaque';
					} else
						t.report[reportId].marchName = '?';
					t.data.push ({
						reportId: reportId,
					});
				}
			}
			if (parseInt(page)+1 <= t.maxPages && t.searchRunning) {
				ById("idRptStatus").innerHTML = uW.g_js_strings.commonstr.research + ' page ' + (parseInt(page)+1) + ' / ' + t.maxPages;
				t.getRpt(parseInt(page)+1);
				if (t.data.length > 0)
					t.DisplayRpt();
			} else if (page) {
				
				if (ById("BOSyntheseAttack").checked) {
				 t.stopSearch ('<a id=BOresumeAT style="color:#ffaaaa" onclick="javascript:void(0);"><u>'+lang.Rpt.BOresumeAT+'</u></a>');
				 setTimeout(function() { ById("BOresumeAT").addEventListener ('click', t.AfficheResumeAtk, false);  }, 1000);
				} else {
				
				if (Options.rptType=='player') {
				 t.stopSearch ('<a id=BOresumeDF style="color:#ffaaaa" onclick="javascript:void(0);"><u>'+lang.Rpt.BOresumeDF+' '+uW.g_js_strings.commonstr.darkForest+'</u></a>');
				 setTimeout(function() {
				   ById("BOresumeDF").addEventListener ('click', t.AfficheResume, false);
				  }, 1000);
				 } else {
				  t.stopSearch (lang.Rpt.end);
				 }
				}
			}
		}
	},
	AfficheResumeAtk:function() {
	 var t = Tabs.Rpt;
	 var puipui=new Array();
	 var fortmight = {u53: "4",u55: "7",u60: "1",u61: "2",u62: "3",    };
	 for (var ui = 1 ; ui<13; ui++)
		 puipui.push(unsafeWindow.unitmight['unt'+ui]);
	 puipui[52] = fortmight['u53'];
	 puipui[54] = fortmight['u55'];
	 puipui[59] = fortmight['u60'];
	 puipui[60] = fortmight['u61'];
	 puipui[61] = fortmight['u62'];
	 var messageBody="";
	 reportsSearched = t.dataAT.length;
	 reportsFound = 0;
         var tr0=0,tr1=0,tr2=0,tr3=0,tr4=0,tr5=0;
	 if (reportsSearched>0) {
	  messageBody +='<br><table width=98%><thead><th>'+uW.g_js_strings.commonstr.player+'<br>'+uW.g_js_strings.commonstr.alliance+'</th><th><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png></th>\
	  <th><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png></th><th><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png></th>\
	  <th><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png></th><th><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png></th>\
	  <th><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png></th></thead><tbody>';
	  t.dataAT.sort(function(a, b){
		var sortA=a.nom,sortB=b.nom;
		if (sortA < sortB) return -1
		if (sortA > sortB) return 1
		return 0 
	  });
	 var datartp = [];
	 var nbrp=0;
	 for (var i=0; i<reportsSearched;i++) {
	  var idrapport=t.dataAT[i].reportId;
	  if ((t.what == '' || (t.dataAT[i].nom.search(t.what, "i") != -1)  || (t.dataAT[i].alliance.search(t.what, "i") != -1))
	      && (t.whatNot == '' || (t.dataAT[i].nom.search(t.whatNot, "i") != -1 && t.dataAT[i].alliance.search(t.whatNot, "i") != -1)))
	  {
	   
	   if (datartp[nbrp]==undefined) { 
	     datartp[nbrp]=[];
	     datartp[nbrp].nom = t.dataAT[i].nom;
	     datartp[nbrp].alliance = t.dataAT[i].alliance;
	     datartp[nbrp].res0=0;
	     datartp[nbrp].res1=0;
	     datartp[nbrp].res2=0;
	     datartp[nbrp].res3=0;
	     datartp[nbrp].res4=0;
	     datartp[nbrp].res5=0;
	     for (var z=1;z<64;z++) {
	      datartp[nbrp]['s1unit'+z] =0;
	      datartp[nbrp]['s0unit'+z] =0;
	     }
	   }  
	   if(datartp[nbrp].nom==t.dataAT[i].nom && datartp[nbrp].alliance==t.dataAT[i].alliance) {
	     datartp[nbrp].res0 += parseIntNan(t.reportAT[idrapport].res0);
	     datartp[nbrp].res1 += parseIntNan(t.reportAT[idrapport].res1);
	     datartp[nbrp].res2 += parseIntNan(t.reportAT[idrapport].res2);
	     datartp[nbrp].res3 += parseIntNan(t.reportAT[idrapport].res3);
	     datartp[nbrp].res4 += parseIntNan(t.reportAT[idrapport].res4);
	     datartp[nbrp].res5 += parseIntNan(t.reportAT[idrapport].res5);
	       for (var z=1;z<64;z++) {
	        datartp[nbrp]['s1unit'+z] += parseIntNan(t.reportAT[idrapport]['s1unit'+z]);
	        datartp[nbrp]['s0unit'+z] += parseIntNan(t.reportAT[idrapport]['s0unit'+z]);
	      }
	   } else {
	     nbrp++;
	     datartp[nbrp]=[];
	     datartp[nbrp].nom = t.dataAT[i].nom;
	     datartp[nbrp].alliance = t.dataAT[i].alliance;
	     datartp[nbrp].res0=0;
	     datartp[nbrp].res1=0;
	     datartp[nbrp].res2=0;
	     datartp[nbrp].res3=0;
	     datartp[nbrp].res4=0;
	     datartp[nbrp].res5=0;
	     datartp[nbrp].res0 += parseIntNan(t.reportAT[idrapport].res0);
	     datartp[nbrp].res1 += parseIntNan(t.reportAT[idrapport].res1);
	     datartp[nbrp].res2 += parseIntNan(t.reportAT[idrapport].res2);
	     datartp[nbrp].res3 += parseIntNan(t.reportAT[idrapport].res3);
	     datartp[nbrp].res4 += parseIntNan(t.reportAT[idrapport].res4);
	     datartp[nbrp].res5 += parseIntNan(t.reportAT[idrapport].res5);
	     for (var z=1;z<64;z++) {
	     	      datartp[nbrp]['s1unit'+z] =0;
	     	      datartp[nbrp]['s0unit'+z] =0;
	     	      datartp[nbrp]['s1unit'+z] += parseIntNan(t.reportAT[idrapport]['s1unit'+z]);
	     	      datartp[nbrp]['s0unit'+z] += parseIntNan(t.reportAT[idrapport]['s0unit'+z]);	     
	     }
	   }
	   }// fin du regrouppement
	  }
	  reportsSearched = datartp.length;
	  var tres=[0,0,0,0,0,0];
	  var perts1=[];var perts0=[];
	  for (var z=1;z<64;z++) { perts1[z]=0;perts0[z]=0; }
	  
	  for (var i=0; i<reportsSearched;i++) {
	   messageBody += '<tr><td>'+datartp[i].nom+'<br>'+datartp[i].alliance+'</td>';
	    for (var res=0;res<6;res++) {
	     messageBody += '</td><td align=right>';
	     var cb=0;
	     if (datartp[i]["res"+res] != undefined) {
	       cb=parseIntNan(datartp[i]["res"+res]);
	       tres[res]+=cb;
	     }
	     messageBody += addCommas(cb);
	    }
	    for (var z=1;z<64;z++) {
	     perts1[z]+=parseIntNan(datartp[i]['s1unit'+z]);
	     perts0[z]+=parseIntNan(datartp[i]['s0unit'+z]);
	    } 
	  }
	  messageBody += '</td></tr><tr><td><b>'+lang.Rpt.sum+'</td>';
	  for (var res=0;res<6;res++) messageBody +='<td align=right><b>'+addCommas(tres[res])+'</b></td>';
	  messageBody += "</tr></table>";
	  messageBody += "<br><table><thead><th width=120><b>"+lang.Rpt.pertes+"</b></th>";
	  for (var z=1;z<64;z++) {
	    if (perts1[z]>0) {
	      messageBody +='<th width=6%><img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+z+'_30.jpg ';
	      if(z<14)
	        messageBody +='title="'+unsafeWindow.unitcost['unt'+z][0]+'"';
	      messageBody +='></th>';
	    }
	  }
	  messageBody +='<th></th></thead><tr><td>'+lang.Rpt.number+'</td>';
	  for (var z=1;z<64;z++) if (perts1[z]>0) messageBody +='<td align=right>'+ addCommas(perts1[z])+'</td>';
	  messageBody +='<td></td></tr><tr><td>'+uW.g_js_strings.commonstr.might+'</td>';
	  for (var z=1;z<64;z++) if (perts1[z]>0) messageBody +='<td align=right>'+ addCommas(parseIntNan(perts1[z])*parseIntNan(puipui[z-1]))+'</td>';
	  var to1=0;
	  messageBody +='<td></td></tr><tr><td>'+uW.g_js_strings.commonstr.might+' total</td>';
	  for (var z=1;z<64;z++) to1+=(parseIntNan(perts1[z])*parseIntNan(puipui[z-1]));
	  messageBody += "<td align=right><b>"+addCommas(to1)+"</b></td></tr><thead><th><b>"+lang.Rpt.pertes2+"</b></th>";
	  for (var z=1;z<64;z++) {
	   if (perts0[z]>0) {
	      messageBody +='<th width=6%><img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+z+'_30.jpg ';
	      if(z<14)
	        messageBody +='title="'+unsafeWindow.unitcost['unt'+z][0]+'"';
	      messageBody +='></th>';
	   }
	  }
	  messageBody +='<th></th></thead><tr><td>'+lang.Rpt.number+'</td>';
	  for (var z=1;z<64;z++) if (perts0[z]>0)messageBody +='<td align=right>'+ addCommas(parseIntNan(perts0[z]))+'</td>';
	  messageBody +='<td></td></tr><tr><td>'+uW.g_js_strings.commonstr.might+'</td>';
	  
	  for (var z=1;z<64;z++) if (perts0[z]>0)messageBody +='<td align=right>'+ addCommas(parseIntNan(perts0[z])*parseIntNan(puipui[z-1]))+'</td>';
	  var to2=0;
	  messageBody +='</tr><tr><td>'+uW.g_js_strings.commonstr.might+' total</td>';
	  for (var z=1;z<64;z++) to2+= (parseIntNan(perts0[z])*parseIntNan(puipui[z-1]));
	  messageBody +="<td align=right><b>"+addCommas(to2)+"</b></td></tr></table><br>";

	  if (to1<to2)
	    messageBody += "<br><b>"+lang.Rpt.mes1+" <font color=#449944>"+addCommas((to2-to1))+"</font><br>";
	  if (to1==to2)
	    messageBody += "<br><b>"+lang.Rpt.mes2+"<br>";  
	   if (to1>to2)
	    messageBody += "<br><b>"+lang.Rpt.mes1+" <font color=#994444>"+addCommas((to1-to2))+"</font><br>";  
	    
	 } else {
	  messageBody +="<br><center>"+lang.Rpt.err1+"<br>";
	 }
	 t.popRapportAT = new CPopup('pbRapportATBody', 0, 0, 770, 500, true, function() {clearTimeout (1000);});
	 t.popRapportAT.centerMe (mainPop.getMainDiv());
	 var m = '<DIV style="max-height:465px; height:465px; overflow-y:scroll">';
	 m+= messageBody + '</div>';
	 t.popRapportAT.getMainDiv().innerHTML = m;
	 t.popRapportAT.getTopDiv().innerHTML = '<DIV align=center><B>'+lang.Rpt.title1+'</B></DIV>';
	 t.popRapportAT.show(true);
	},
	AfficheResume:function() {
	 var t = Tabs.Rpt;
	 var messageBody="";
	 reportsSearched = t.dataDF.length;
	 reportsFound = 0;
	 if (t.dataDF.length>0) {
	messageBody +='<br><center><table width=60%><thead><th>'+lang.Rpt.report+'</th><th>'+uW.g_js_strings.commonstr.level+'</th><th colspan=2>'+lang.Rpt.itemfind+'</th></thead><tbody>';
	for (var i=0; i<reportsSearched;i++) {
	var idrapport=t.dataDF[i].reportId;
	var rpt =  t.reportDF[idrapport];
	messageBody += '<tr><td align=right><a onclick="getReport('+ idrapport+')">'+idrapport+'</A></td><td>'+rpt.lvl+'</td><td><img width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/' + rpt.item + '.jpg></td><td>'+unsafeWindow.ksoItems[rpt.item].name+'</td></tr>';
	}
	messageBody += "</tbody></table>";
	} else {
	messageBody +="<br><center>"+lang.Rpt.noitem+"<br>";
	}
	
	messageBody +='<br><input type=button value="'+lang.Rpt.BODelAllDF+'" id=BODelAllDF></center>';
	
	
	t.popRapportDF = new CPopup('pbRapportDFBody', 0, 0, 500, 405, true, function() {clearTimeout (1000);});
	t.popRapportDF.centerMe (mainPop.getMainDiv());

	var m = '<DIV style="max-height:365px; height:4365px; overflow-y:scroll">';
	m+= messageBody + '</div>';
	t.popRapportDF.getMainDiv().innerHTML = m;
	t.popRapportDF.getTopDiv().innerHTML = '<DIV align=center><B>'+lang.Rpt.title_popRapportDF+' '+unsafeWindow.g_js_strings.commonstr.darkForest+'</B></DIV>';
	t.popRapportDF.show(true);
	ById('BODelAllDF').addEventListener ('click', t.DeleteRptDF, false);
					
	},
	pagesasup:0,
	DeleteRptDF:function() {
	 var t = Tabs.Rpt;
	 t.pagesasup = 0;
	 t.fetchreport(0, t.checkreports);
	 t.popRapportDF.show(false);
	 t.popRapportDF.destroy();
	 t.popRapportDF = null;
	},
	 fetchreport : function(pageNo, callback){
		var t =  Tabs.Rpt;
		 if (t.pagesasup>=t.maxPages) return;
			var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
			if(pageNo > 1)
				params.pageNo = pageNo;
			new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/listReports.php" + unsafeWindow.g_ajaxsuffix, {
				method: "post",
				parameters: params,
				onSuccess: function (rslt) {
				        t.pagesasup++;
					callback(rslt);
				},
					onFailure: function () {
					t.pagesasup++;
					callback();
				},
			});
	    },
		
	    checkreports : function(rslt){
			var t = Tabs.Rpt;
			if(!rslt.ok){
				return;
			}
			if(rslt.arReports.length < 1){
				return;
			}
			var reports = rslt.arReports;
			var totalPages = rslt.totalPages;
			var deletes1 = new Array();
			for(k in reports){
					if(reports[k].side0TileType==54)
						deletes1.push(k.substr(2));
				
			}
			if(deletes1.length > 0 ){
				t.deleteCheckedReports(deletes1);
			} else {
				
				return;
			}
	    },
    	deleteCheckedReports : function(deletes1){
    		var t =  Tabs.Rpt;
    		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    		params.s1rids = deletes1.join(",");
    		params.cityrids = '';
    		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/deleteCheckedReports.php" + unsafeWindow.g_ajaxsuffix, {
    			method: "post",
    			parameters: params,
    			onSuccess: function (rslt) {
    				if(rslt.ok){
    					Seed.newReportCount = parseInt(Seed.newReportCount) - parseInt(deletes1.length);
    				}
    				t.fetchreport(0, t.checkreports);
    				t.DisplayRpt();
    			},
    			onFailure: function () {
    			},
    		});
    },
    BOSyntheseAttack:function(reportId, sideId, lvl) {

     var t = Tabs.Rpt;
     var rpt = t.report[reportId];
     var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
     	  params.rid=reportId;
	  params.side=sideId;
     if (params.side > -1) {
     	   new AjaxRequest(unsafeWindow.g_ajaxpath+"ajax/fetchReport.php"+unsafeWindow.g_ajaxsuffix, {  method:"post",  parameters:params,
       
     	   onSuccess:function(msg){
     		var rslt = eval("(" + msg.responseText + ")");
     		t.dataAT.push ({reportId: reportId, nom:rpt.side0Name, alliance:rpt.side0AllianceName});
     		t.reportAT[reportId] = [];
     		t.reportAT[reportId].nom = rpt.side0Name;
     		t.reportAT[reportId].alliance = rpt.side0AllianceName;
     		t.reportAT[reportId].res0=0;
     		t.reportAT[reportId].res1=0;
     		t.reportAT[reportId].res2=0;
     		t.reportAT[reportId].res3=0;
     		t.reportAT[reportId].res4=0;
     		t.reportAT[reportId].res5=0;
     		if (rslt.loot) {
     		 if (rslt['loot'][0] !== undefined) t.reportAT[reportId].res0=rslt['loot'][0];
     		 if (rslt['loot'][1] !== undefined) t.reportAT[reportId].res1=rslt['loot'][1];
     		 if (rslt['loot'][2] !== undefined) t.reportAT[reportId].res2=rslt['loot'][2];
     		 if (rslt['loot'][3] !== undefined) t.reportAT[reportId].res3=rslt['loot'][3];
     		 if (rslt['loot'][4] !== undefined) t.reportAT[reportId].res4=rslt['loot'][4];
     		 if (rslt['loot'][6] !== undefined) t.reportAT[reportId].res5=rslt['loot'][6];
     	        }
     	        if (sideId==0) { // les pertes !!!!
     	         for (var zz=0;zz<6;zz++)
     	            t.reportAT[reportId]["res"+zz] = t.reportAT[reportId]["res"+zz] *-1;
     	        }
     	        if (rslt['fght'] != undefined){
     	        	if (rslt['fght']["s1"] != undefined) {
     	        		for (var i=1;i<13;i++) {
					if (rslt['fght']["s1"]['u'+i] != undefined) {
						if (sideId==1) t.reportAT[reportId]['s1unit'+i]=rslt['fght']["s1"]['u'+i][0] - rslt['fght']["s1"]['u'+i][1]; // perte 
						else t.reportAT[reportId]['s0unit'+i]=rslt['fght']["s1"]['u'+i][0] - rslt['fght']["s1"]['u'+i][1]; // perte 

					}else{
					 	if (sideId==1) t.reportAT[reportId]['s1unit'+i]=0;
						else t.reportAT[reportId]['s0unit'+i]=0;
					}
				}
				for (var i=53;i<=55;i++) {
					if (rslt['fght']["s1"]['f'+i] != undefined) {
						if (sideId==1) t.reportAT[reportId]['s1unit'+i] = rslt['fght']["s1"]['f'+i][0] - rslt['fght']["s1"]['f'+i][1];
						else t.reportAT[reportId]['s0unit'+i] = rslt['fght']["s1"]['f'+i][0] - rslt['fght']["s1"]['f'+i][1];
				
			 		}else{
			 			if (sideId==1) t.reportAT[reportId]['s1unit'+i]=0;
			 			else t.reportAT[reportId]['s0unit'+i]=0;
					}
			 	}
		 		for (var i=60;i<=63;i++) {
					if (rslt['fght']["s1"]['f'+i] != undefined) {
						if (sideId==1) t.reportAT[reportId]['s1unit'+i] = rslt['fght']["s1"]['f'+i][0] - rslt['fght']["s1"]['f'+i][1];
						else t.reportAT[reportId]['s0unit'+i] = rslt['fght']["s1"]['f'+i][0] - rslt['fght']["s1"]['f'+i][1];
				
					}else{
			 			if (sideId==1) t.reportAT[reportId]['s1unit'+i]=0;
			 			else t.reportAT[reportId]['s0unit'+i]=0;
					}
			 	}	
		 	}
     	         	if (rslt['fght']["s0"] != undefined) {
     	         		for (var i=1;i<13;i++) {
					if (rslt['fght']["s0"]['u'+i] != undefined) {
					  if (sideId==1) {
					   t.reportAT[reportId]['s0unit'+i]=rslt['fght']["s0"]['u'+i][0] - rslt['fght']["s0"]['u'+i][1]; // perte
					  }else{
					    t.reportAT[reportId]['s1unit'+i]=rslt['fght']["s0"]['u'+i][0] - rslt['fght']["s0"]['u'+i][1]; // perte
					  }
					} else {
					 if (sideId==1) {
					  t.reportAT[reportId]['s0unit'+i]=0;
					 } else {
					   t.reportAT[reportId]['s1unit'+i]=0;
					 }
					}
				}
     	         		for (var i=53;i<=55;i++) {
		 			if (rslt['fght']["s0"]['f'+i] != undefined) {
		 				if (sideId==1) {
		 					t.reportAT[reportId]['s0unit'+i] = rslt['fght']["s0"]['f'+i][0] - rslt['fght']["s0"]['f'+i][1];
		 				} else {
		 					t.reportAT[reportId]['s1unit'+i] = rslt['fght']["s0"]['f'+i][0] - rslt['fght']["s0"]['f'+i][1];
		 				}
		 			}else{
						if (sideId==1) t.reportAT[reportId]['s0unit'+i]=0;
						else t.reportAT[reportId]['s1unit'+i]=0;
					}
			 	}
		 		for (var i=60;i<=63;i++) {
		 			if (rslt['fght']["s0"]['f'+i] != undefined) {
		 				if (sideId==1) {
		 					t.reportAT[reportId]['s0unit'+i] = rslt['fght']["s0"]['f'+i][0] - rslt['fght']["s0"]['f'+i][1];
		 				} else {
		 					t.reportAT[reportId]['s1unit'+i] = rslt['fght']["s0"]['f'+i][0] - rslt['fght']["s0"]['f'+i][1];
		 				}
		 			}else{
			 			if (sideId==1) {
			 					t.reportAT[reportId]['s0unit'+i]=0;
			 				} else {
			 					t.reportAT[reportId]['s1unit'+i]=0;
						}
			 		}	
		 		}
			}
     	        }
     	        
        } });
      }  
    },
    FindItemRpt:function(reportId, sideId, lvl) {
	  var t = Tabs.Rpt;
	  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	  params.rid=reportId;
	  params.side=sideId;
	  if (params.side > -1) {
	   new AjaxRequest(unsafeWindow.g_ajaxpath+"ajax/fetchReport.php"+unsafeWindow.g_ajaxsuffix, {  method:"post",  parameters:params,
  
	   onSuccess:function(msg){
		var rslt = eval("(" + msg.responseText + ")");
		if (rslt.loot) {
			if (rslt['loot'][5] !== undefined) {
				var q=unsafeWindow.Object.keys(rslt['loot'][5]);
				if (q.length>0) {
			 			  for(var u=0,y=q.length;u<y;++u){
			 				C=q[u];
			 				if (unsafeWindow.ksoItems[C]!==undefined) {
			 				 t.dataDF.push ({reportId: reportId,});
			 				 t.reportDF[reportId] = [];
			 				 t.reportDF[reportId].lvl = lvl;
			 				 t.reportDF[reportId].item = C;
			 				}
			 			  }
			 	}
			
	          
	                    }
	          
	               }
	        }
            });
          }  
	
	},
	DisplayMail: function (){
		var t = Tabs.Rpt;
		var results = ById("idBoRptResultsDiv");
		if(!t.data.length) {
			results.innerHTML = '<center>'+lang.Rpt.noresult+'</center>';
			return;
		}
		reportsSearched = t.data.length;
		reportsFound = 0;
		t.content = '';
		for (var i=0; i<reportsSearched;i++) {
			var rpt = t.data[i];
			if ((t.what == '' || (rpt.subject.search(t.what, "i") != -1) || (rpt.displayName.search(t.what, "i") != -1))
				&& (t.whatNot == '' || ((rpt.subject.search(t.whatNot, "i") == -1) && (rpt.displayName.search(t.whatNot, "i") == -1)))) {
				if (rpt.subject == '')
					rpt.subject = lang.Rpt.nosubject;
				reportsFound++;
				if (reportsFound == 1)
					t.content += '<center><table width=97%><thead><th>P</th><th>Date</th><th>De</th><th>Sujet</th><th>X</th></thead><tbody>';
				var stylee="";
				if (rpt.messageRead==0) stylee=' style="background-color:#CCCCCC;"';
				t.content += '<tr><td align=right '+stylee+'>'+rpt.page+'</td><td '+stylee+'>'+rpt.dateSent+'</td><td '+stylee+'>'+rpt.displayName+'</td>';
				t.content += '<td '+stylee+'><A><SPAN onclick="getmsg('+ rpt.messageId +')">' + rpt.subject + '</SPAN></a></td><td><a onclick="DelMail('+ rpt.messageId +');"><img src="http://cdn1.iconfinder.com/data/icons/musthave/16/Remove.png" border=0 title="Supprimer ce message"></a></td></tr>';
			}
		}
		if (reportsFound > 1)
			t.content += '</tbody></table></center>';
		if (reportsFound == 0 && reportsSearched > 0)
			t.content = '<center>'+lang.Rpt.noresult+'</center>';
		results.innerHTML = t.content;
		ById("idRptSearched").innerHTML = '&nbsp'+lang.Rpt.result+' ' + reportsSearched;
		ById("idRptFound").innerHTML = lang.Rpt.found+' ' + reportsFound;
	},

	getMailBody: function(ID,dataI){
		var t = Tabs.Rpt;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.messageId=ID;
		params.requestType="GET_MESSAGE_FOR_ID";

		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (rslt) {
				if (rslt.ok)
					t.displayMailBody(rslt.messageBody, ID);
			},
			onFailure: function () {},
		}, false);
	},

	displayMailBody: function (messageBody, ID) {
		var t = Tabs.Rpt;
		if (t.popMsg == null) {
		  t.popMsg = new CPopup('pbMailBody', 0, 0, 670, 500, true, function() {clearTimeout (1000);});
		  t.popMsg.centerMe (mainPop.getMainDiv());
		}
		messageBody=messageBody.replace(/custom-line-break/g,"<br>");
		var m = '<DIV style="max-height:465px; height:465px; overflow-y:scroll"><br><hr>';
		m+= messageBody + '<hr><a onclick="DelMail('+ ID +');"><img src="http://cdn1.iconfinder.com/data/icons/musthave/16/Remove.png" border=0 title="Supprimer ce message">'+lang.General.delete+'</a><br></div>';
		t.popMsg.getMainDiv().innerHTML = m;
		t.popMsg.getTopDiv().innerHTML = '<DIV align=center><B>Messagerie</B></DIV>';
		t.popMsg.show(true);
	},

	DisplayRpt: function (){
		var t = Tabs.Rpt;
		var results = ById("idBoRptResultsDiv");
		if(!t.data.length) {
			results.innerHTML = '<center>'+lang.Rpt.noresult+'</center>';
			return;
		}
		var myAllianceId = parseInt(getMyAlliance()[0]);
		reportsSearched = t.data.length;
		reportsFound = 0;
		t.content = '';
		for (var i=0; i<reportsSearched;i++) {
			var reportId = t.data[i].reportId;
			var rpt = t.report[reportId];
			if ((rpt.side0Name=='undefined') && (rpt.marchName != 'Desertion'))
				continue;
			if ((((myAllianceId == parseInt(rpt.side1AllianceId) && Options.arAttacker != 'Them')
				|| (myAllianceId != parseInt(rpt.side1AllianceId) && Options.arAttacker != 'Us')
				|| Options.arAttacker == 'Both')
				&& ((myAllianceId == parseInt(rpt.side0AllianceId) && Options.arTarget != 'Them')
				|| (myAllianceId != parseInt(rpt.side0AllianceId) && Options.arTarget != 'Us')
				|| Options.arTarget == 'Both')
				&& ((Options.arAttack && (rpt.marchName == 'Attaque' || rpt.marchName == 'Defense'))
				|| (Options.arScout && (rpt.marchName == 'Contre-Ecl' || rpt.marchName == 'Eclaireur'))
				|| (Options.arReinforce && rpt.marchName == 'Renfort')
				|| (Options.arTransport && rpt.marchName == 'Transport')))
				|| (rpt.marchName == 'Desertion')) {
				if (((t.what == ''
					|| (rpt.side1Name.search(t.what, "i") != -1)
					|| (rpt.side1AllianceName.search(t.what, "i") != -1)
					|| (rpt.side0Name.search(t.what, "i") != -1)
					|| (rpt.side0AllianceName.search(t.what, "i") != -1)
					|| (rpt.side0TileTypeText.search(t.what, "i") != -1))
					&& (t.whatNot == ''
					|| ((rpt.side1Name.search(t.whatNot, "i") == -1)
					&& (rpt.side1AllianceName.search(t.whatNot, "i") == -1)
					&& (rpt.side0Name.search(t.whatNot, "i") == -1)
					&& (rpt.side0AllianceName.search(t.whatNot, "i") == -1)
					&& (rpt.side0TileTypeText.search(t.whatNot, "i") == -1))))
					|| (rpt.marchName == 'Desertion')) {
					
					if ((ById("idRptFiltre1").value=="") ||   (rpt.side0TileType==54 && ById("idRptFiltre1").value==54)  ||
					    (rpt.side0TileType>0 && rpt.side0TileType<51 && ById("idRptFiltre1").value==0)) {
					
					
					reportsFound++;
					if (reportsFound == 1) {
						t.content += '<center><table class=ptTabOverview width=100% cellspacing=0 cellpadding=3><thead><th>P</th><th>R.</th><th>Date</th><th>'+uW.g_js_strings.commonstr.attacker+'</th><th>De</th>';
						if (Options.arAttacker != 'Us')
							t.content += '<th>Alliance</th>';
						t.content += '<th>Action</th><th>'+uW.g_js_strings.commonstr.target+'</th><th>A</th>';
						if (Options.arTarget != 'Us')
							t.content += '<th>Alliance</th>';
						t.content += '<th>Type</th><th><span title="Ville la plus proche">VP</span></th><th><span title="Distance de la ville la plus proche">D</span></th></thead><tbody>';
					}
					
					
					var closestDist=999999;
					var closestLoc=null;
					var closestNum=1;
					for (var c=0; c<Cities.numCities; c++){
						var city = Cities.cities[c];
						var dist=distance(city.x,city.y,rpt.side0XCoord,rpt.side0YCoord);
						if(dist<closestDist) {
							closestDist=dist;
							closestLoc=city.x +','+ city.y;
							closestNum=c+1;
						}
					}
					if (rpt.marchName == 'Contre-Ecl' || rpt.marchName == 'Defense')
					 style=' style="background-color:#EF9999;"';
					else if (rpt.marchName == 'Renfort')
					 style=' style="background-color:#99EF99;"';
					else
					 style="";
					t.content += '<tr id="BOrpt'+ reportId +'"><td align=right '+style+'>'+rpt.page+'</td><td  align=right '+style+'><a onclick="getReport('+ reportId+')"><img  border=0 src="http://cdn1.iconfinder.com/data/icons/woothemesiconset/16/search_button.png"></a>';
					 if (rpt.side0Name==Seed.player.name || rpt.side1Name==Seed.player.name) {
					         t.content +='&nbsp;<a onclick="DelReport('+ reportId +', false);document.getElementById(\'BOrpt'+ reportId +'\').style.display=\'none\';"><img src="http://cdn1.iconfinder.com/data/icons/musthave/16/Remove.png" border=0 title="Supprimer mon rapport"></a>';
        					}
					t.content += '</td><td '+style+'>'+formatUnixTime(rpt.reportUnixTime,'24hour')+'</td>';
					if (rpt.marchName == 'Desertion') {
						t.content += '<td '+style+'></td><td '+style+'></td>';
						if (Options.arAttacker != 'Us')
							t.content += '<td '+style+'></td>';
						t.content += '<td '+style+'>'+rpt.marchName+'</td><td '+style+'></td><td '+style+'></td><td '+style+'></td>';
						if (Options.arAttacker != 'Us')
							t.content += '<td '+style+'></td>';
						t.content += '<td '+style+'></td><td '+style+'></td>';
						} else {
						t.content += '<td '+style+'><span title="'+rpt.side1Name+'">'+rpt.side1Name.substring(0,12)+'</span></td><td align=center '+style+'><a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ rpt.side1XCoord +','+ rpt.side1YCoord +')</a></td>';
						if (Options.arAttacker != 'Us')
						t.content += '<td '+style+'><span title="'+rpt.side1AllianceName+'">'+rpt.side1AllianceName.substring(0,17)+'</span></td>';
						            if (rpt.marchName == 'Contre-Ecl' || rpt.marchName == 'Eclaireur')
						             t.content += '<TD '+style+'><FONT color="FF8822">'+rpt.marchName+'</font></td>';
							    else if (rpt.marchName == 'Attaque' || rpt.marchName == 'Defense')
							     t.content += '<TD '+style+'><FONT color="FF1122">'+rpt.marchName+'</font></td>';
							    else if (rpt.marchName == 'Renfort')
	      					 	     t.content += '<TD '+style+'><FONT color="339933">'+rpt.marchName+'</font></td>';
	      					 	    else
	      					 	     t.content += '<TD '+style+'>'+rpt.marchName+'</td>';
						//t.content += '<td>'+rpt.marchName+'</td>';
						t.content += '<td '+style+'><span title="'+rpt.side0Name+'">'+rpt.side0Name.substring(0,12)+'</span></td>';
						t.content += '<td align=center '+style+'><a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ rpt.side0XCoord +','+ rpt.side0YCoord +')</a></td>';
						if (Options.arTarget != 'Us')
							t.content += '<td '+style+'><span title="'+rpt.side0AllianceName+'">'+rpt.side0AllianceName.substring(0,17)+'</span></td>';
						t.content += '<td '+style+'>'+rpt.side0TileTypeLevel+'</td><td align=center '+style+'><A onclick=\"citysel_click(document.getElementById(\'citysel_'+ (closestNum)+'\'));\">' + closestLoc + '</a></td><td align=right '+style+'>'+Math.floor(closestDist)+'</td></tr>';
					}
				}	
				}
			}
		}
		if (reportsFound > 1)
			t.content += '</tbody></table></center>';
		if (reportsFound == 0 && reportsSearched > 0)
			t.content = '<center>'+lang.Rpt.noresult+'</center>';
		results.innerHTML = t.content;
		ById("idRptSearched").innerHTML = lang.Rpt.result+' ' + reportsSearched;
		ById("idRptFound").innerHTML = lang.Rpt.found+' ' + reportsFound;
	},

	getReportBody: function(reportId){
		var t = Tabs.Rpt;
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.rid=reportId;
		params.side=t.report[reportId].sideId;
		if (params.side > -1) {
			new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchReport.php" + unsafeWindow.g_ajaxsuffix, {
				method: "post",
				parameters: params,
				onSuccess: function (rslt) {
					t.displayReportBody(rslt,reportId);
				},
				onFailure: function (rslt) {},
			}, false);
		} else {
			
		}
	},

	displayReportBody: function (rslt, reportId) {
		var t = Tabs.Rpt;
		var popReport = null;
		var rpt = t.report[reportId];
		var m = '';
		var fortmight = {u53: "4",u55: "7",u60: "1",u61: "2",u62: "3",    };
		var unitImg = [];
		var puipui=new Array();
		for (var ui = 1 ; ui<13; ui++)
		 puipui.push(uW.unitmight['unt'+ui]);
		puipui[53] = fortmight['u53'];
		puipui[55] = fortmight['u55'];
		puipui[60] = fortmight['u60'];
		puipui[61] = fortmight['u61'];
		puipui[62] = fortmight['u62'];
		ordre_grandeur=0;
		delta_perte=0;
		var perte_atk = 0;
		var perte_def = 0;
		for (var i=1;i<13;i++)
			unitImg[i] = '<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+i+'_30_s34.jpg title="'+uW.unitcost['unt'+i][0]+'"></TD><TD>' + uW.unitcost['unt'+i][0].substr(0,10);
		for (var i=101;i<111;i++)
			unitImg[i] = '<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+i+'_30.jpg title="'+uW.g_js_strings.monsterUnitsNames['m'+i]+'"></TD><TD>' + uW.g_js_strings.monsterUnitsNames['m'+i].substr(0,10);
	        unitImg[53] = '<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_53_30.png></TD><TD>'+ uW.fortcost.frt53[0];
		unitImg[55] = '<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_55_30.png></TD><TD>'+ uW.fortcost.frt55[0];
		unitImg[60] = '<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_60_30.png></TD><TD>'+ uW.fortcost.frt60[0];
		unitImg[61] = '<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_61_30.png></TD><TD>'+ uW.fortcost.frt61[0];
		unitImg[62] = '<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_62_30.png></TD><TD>' + uW.fortcost.frt62[0];
		goldImg = '<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png></TD><TD>' + uW.g_js_strings.commonstr.gold;;
		foodImg = '<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png></TD><TD>' + uW.g_js_strings.commonstr.food;
		woodImg = '<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png></TD><TD>' + uW.g_js_strings.commonstr.wood;;
		stoneImg = '<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png></TD><TD>' + uW.g_js_strings.commonstr.stone;;
		oreImg = '<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png></TD><TD>' + uW.g_js_strings.commonstr.ore;;
		aetherstoneImg = '<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png></TD><TD>'+ uW.g_js_strings.commonstr.aetherstone;
		
		function buildHeader () {
			var h='<TABLE class=ptTab width=100%>';
			h+='<TR valign=top><TD align=left width=10%><B>';
			if (rpt.marchName == 'Contre-Ecl')
			 h+=uW.g_js_strings.commonstr.location+" " + uW.g_js_strings.modal_messages_viewreports_view.antiscoutingat+' ';
			else if (rpt.marchName == 'Eclaireur')
				h+=uW.g_js_strings.modal_messages_viewreports_view.scoutrpt+' ';
			else if (rpt.marchName == 'Attaque' || rpt.marchName == 'Defense')
				h+=uW.g_js_strings.modal_messages_viewreports_view.battleat+' ';
				
			else if (rpt.marchName == 'Renfort' || rpt.marchName == 'Transport')
				h+=rpt.marchName+' depuis<BR />'+rpt.marchName+' vers</B>';
			else if (rpt.marchName == 'Transport')
			  h+=rpt.marchName+' depuis<BR />'+uW.g_js_strings.modal_messages_viewreports_view.transpto+'</B>';
			if (rpt.side0TileTypeText == 'Barb')
				h+=' Camp Barbare '+uW.g_js_strings.commonstr.level+' ' + rpt.side0TileLevel;
			else if (rpt.side0TileTypeText != 'Ville')
				h+=' '+rpt.side0TileTypeText+' '+uW.g_js_strings.commonstr.level+' '+ rpt.side0TileLevel+' ';
			h+='</B>';
			if (rpt.marchName == 'Attaque' || rpt.marchName == 'Defense' || rpt.marchName == 'Contre-Ecl' || rpt.marchName == 'Eclaireur')
			 if (rslt['displayGlory']!==undefined)
			   h+='<br><B>'+uW.g_js_strings.commonstr.glory+' : <font color=red>'+rslt['glory']+'</font></B>';
				
			h+='</td>';
			if (rpt.marchName == 'Renfort' || rpt.marchName == 'Transport') {
				h+='<TD align=left width=1%>';
				if (Seed.player.name != rpt.side1Name)
					h+=rpt.side1Name;
				if (Seed.player.name != rpt.side0Name)
					h+='<BR />'+rpt.side0Name;
				h+='</TD>';
			}
			h+='<TD align=left width=5%>';

			if (rpt.marchName == 'Renfort' || rpt.marchName == 'Transport')
				h+='<a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ rpt.side1XCoord +','+ rpt.side1YCoord +')</a><BR />';
			h+='<a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ rpt.side0XCoord +','+ rpt.side0YCoord +')</a></TD>';

			if (rpt.side0TileTypeText != 'Ville' && rpt.side0TileTypeText != 'Barb' && (rpt.marchName == 'Attaque' || rpt.marchName == 'Defense')) {
				if (rslt['conquered']==1)
					h+='<TD><FONT color="#CC0000"><B>'+uW.g_js_strings.commonstr.conquered+'</B></font></td>';
				else if (rslt['conquered']==0)
					h+='<TD><FONT color="#66CC33"><B>S&eacute;curis&eacute;</B></font></td>';
			} else if (rpt.marchName == 'Renfort' || rpt.marchName == 'Transport') {
				h+='<TD align=left width=5%>'+rpt.side1CityName+'<BR />';
				if (rpt.side0CityName != '')
					h+=rpt.side0CityName+'</TD>';
				else
					h+=rpt.side0TileTypeText+' Niveau '+ rpt.side0TileLevel+'</TD>';
			}

			h+='<TD align=right>' + formatUnixTime(rpt.reportUnixTime,'24hour') + '<BR />&nbsp;';
			if (rpt.side0Name==Seed.player.name || rpt.side1Name==Seed.player.name)
			  h+='<a onclick="DelReport('+ reportId +', false);ById(\'BOrpt'+ reportId +'\').style.display=\'none\';ById(\'pbShowOther_X\').click();"><img src="http://cdn1.iconfinder.com/data/icons/musthave/16/Remove.png" border=0 title="Supprimer mon rapport"></a>';
			
			h+='&nbsp;'+uW.g_js_strings.modal_messages_viewreports_view.reportno+': ' + reportId + '</TD></TR></TABLE>';
			return h;
		}

		function handleunts () { // Troops sent to Reinforce or troops found on a Scout
			var hunts = '', th = '', tc = '', tf = '';
			if (rslt['unts'] != undefined) {
				if (rpt.marchName == 'Renfort')
					th='<TABLE class=ptTab><TR><TH colspan=3 align=left>Renforts Envoy&eacute;s</TH></TR>';
				else if (rslt['unts']['u1'] != undefined || rslt['unts']['u2'] != undefined || rslt['unts']['u3'] != undefined || rslt['unts']['u4'] != undefined || rslt['unts']['u5'] != undefined || rslt['unts']['u6'] != undefined || rslt['unts']['u7'] != undefined || rslt['unts']['u8'] != undefined || rslt['unts']['u9'] != undefined || rslt['unts']['u10'] != undefined || rslt['unts']['u11'] != undefined || rslt['unts']['u12'] != undefined)
					th='<TABLE class=ptTab><TR><TH colspan=3 align=left>'+uW.g_js_strings.commonstr.troops+'</TH></TR>';
				for (var i=1;i<13;i++)
					if (rslt['unts']['u'+i] != undefined)
						tc+='<TR><TD>' + unitImg[i] + '</TD><TD align=right>'+addCommas(rslt['unts']['u'+i])+'</TD></TR>';
				
				tf='</TABLE>';
			}
			if (tc != '')
				hunts = th + tc + tf;
			return hunts;
		}

		function handlersc () { // Resources brought with reinforcements or found on a Scout
			var hrsc = '', th = '', tc = '', tf = '';
			if (rslt['rsc'] != undefined) {
				if (rslt['rsc']['r1'] > 0 || rslt['rsc']['r2'] > 0 || rslt['rsc']['r3'] > 0 || rslt['rsc']['r4'] > 0) {
					if (rpt.marchName == 'Renfort')
						th='<TABLE class=ptTab><TR><TH colspan=3 align=left>'+uW.g_js_strings.commonstr.resources+'</TH></TR>';
					else {
						th='<TABLE class=ptTab><TR><TH colspan=3 align=left>'+uW.g_js_strings.commonstr.resources+'</TH></TR>';
						if (rslt['gld'] > 0)
							tc+='<TR><TD>'+goldImg+'</TD><TD align=right>'+addCommasInt(rslt['gld'])+'</TD></TR>';
					}
					if (rslt['rsc']['r1'] > 0)
						tc+='<TR><TD>'+foodImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r1'])+'</TD></TR>';
					if (rslt['rsc']['r2'] > 0)
						tc+='<TR><TD>'+woodImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r2'])+'</TD></TR>';
					if (rslt['rsc']['r3'] > 0)
						tc+='<TR><TD>'+stoneImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r3'])+'</TD></TR>';
					if (rslt['rsc']['r4'] > 0)
						tc+='<TR><TD>'+oreImg+'</TD><TD align=right>'+addCommasInt(rslt['rsc']['r4'])+'</TD></TR>';
					tf='</TABLE>';
				}
			}
			if (tc != '')
				hrsc = th + tc + tf;
			return hrsc;
		}

		function handlefrt () { // Fortifications found on a Scout
			var hfrt = '', th = '', tc = '', tf = '';
			if (rslt['frt'] != undefined) {
				if (rslt['frt']['f53'] != undefined || rslt['frt']['f55'] != undefined || rslt['frt']['f60'] != undefined || rslt['frt']['f61'] != undefined || rslt['frt']['f62'] != undefined) {
					th='<TABLE class=ptTab><TR><TH colspan=3 align=left>'+uW.g_js_strings.modal_openWalls.walldef+'</TH></TR>';
					if (rslt['frt']['f53'] != undefined)
						tc+='<TR><TD>' + unitImg[53] + '</TD><TD align=right>'+addCommas(rslt['frt']['f53'])+'</TD></TR>';
					if (rslt['frt']['f55'] != undefined)
						tc+='<TR><TD>' + unitImg[55] + '</TD><TD align=right>'+addCommas(rslt['frt']['f55'])+'</TD></TR>';
					if (rslt['frt']['f60'] != undefined)
						tc+='<TR><TD>' + unitImg[60] + '</TD><TD align=right>'+addCommas(rslt['frt']['f60'])+'</TD></TR>';
					if (rslt['frt']['f61'] != undefined)
						tc+='<TR><TD>' + unitImg[61] + '</TD><TD align=right>'+addCommas(rslt['frt']['f61'])+'</TD></TR>';
					if (rslt['frt']['f62'] != undefined)
						tc+='<TR><TD>' + unitImg[62] + '</TD><TD align=right>'+addCommas(rslt['frt']['f62'])+'</TD></TR>';
					tf='</TABLE>';
				}
			}
			if (tc != '')
				hfrt = th + tc + tf;
			return hfrt;
		}

		function handleblds (bType) {
		     if (rslt['blds'] != undefined) {
		
			var blds = rslt['blds']['b'+bType]; 
			var couleur='';
			if (bType==8) couleur=' style="background-color:red"';
			b = '<TR><TD '+couleur+'>'; arField = [], firstbld = true;
			b+=unsafeWindow.buildingcost["bdg"+bType][0]+'</TD><TD '+couleur+'>';
			for (var i=1; i<12; i++)
				arField[i]=0;
			for (var i=0; i < blds.length; i++)
				arField[blds[i]]++
			for (var i=11; i>0; i--) {
				if (arField[i] > 0) {
					if (firstbld)
						firstbld = false;
					else
						b+=', ';
					if (arField[i] > 1)
						b+=arField[i] + ' x ';
					b+=' ' + i;
				}
			}
			b+='</TD></TR>';
		       } else {
		        b='';
		       }
		       return b;
		}

    	if (t.popReport == null) {
 		if (rpt.marchName == 'Renfort') {
			t.popReport = new CPopup('pbShowRein', 0, 0, 425, 340, true, function() {clearTimeout (1000);});
			m+= '<DIV style="height:285px">';
		} else if (rpt.marchName == 'Transport') {
			t.popReport = new CPopup('pbShowTrans', 0, 0, 525, 240, true, function() {clearTimeout (1000);});
			m+= '<DIV style="height:185px">';
		} else if (rpt.marchName == 'Eclaireur' && rslt['winner']>=1 && rpt.sideId==1){
			t.popReport = new CPopup('pbShowOther', 0, 0, 550, 500, true, function() {clearTimeout (1000);});
			m+= '<DIV style="max-height:485px; height:485px; overflow-y:scroll">';
		} else {
			t.popReport = new CPopup('pbShowOther', 0, 0, 630, 440, true, function() {clearTimeout (1000);});
			m+= '<DIV style="max-height:423px; height:423px; overflow-y:scroll">';
		}
		t.popReport.centerMe (mainPop.getMainDiv());
	        t.popReport.autoHeight (true); 
	      }
		m+=buildHeader();

		if (rpt.marchName == 'Transport') { // Transport
			m+='<TABLE class=ptTab>'; // Only transports have these in rslt, so handle them here
			if (parseInt(rslt['gold']) > 0)
				m+='<TR><TD>'+goldImg+'</TD><TD align=right>'+addCommas(rslt['gold'])+'</TD></TR>';
			if (parseInt(rslt['resource1']) > 0)
				m+='<TR><TD>'+foodImg+'</TD><TD align=right>'+addCommas(rslt['resource1'])+'</TD></TR>';
			if (parseInt(rslt['resource2']) > 0)
				m+='<TR><TD>'+woodImg+'</TD><TD align=right>'+addCommas(rslt['resource2'])+'</TD></TR>';
			if (parseInt(rslt['resource3']) > 0)
				m+='<TR><TD>'+stoneImg+'</TD><TD align=right>'+addCommas(rslt['resource3'])+'</TD></TR>';
			if (parseInt(rslt['resource4']) > 0)
				m+='<TR><TD>'+oreImg+'</TD><TD align=right>'+addCommas(rslt['resource4'])+'</TD></TR>';
			if (parseInt(rslt['resource5'])> 0)
				m+='<TR><TD>'+aetherstoneImg+'</TD><TD align=right>'+addCommas(rslt['resource5'])+'</TD></TR>';
			m+='</TABLE>';
		}

		m+='<TABLE class=ptTab>';
		if ((rslt['winner']>=1 && rpt.sideId==0) || (rslt['winner']==0 && rpt.sideId==1)) {
			if (rpt.marchName == 'Eclaireur')
				m+='<TR><TD><FONT color="#CC0000"><B>'+uW.g_js_strings.modal_messages_viewreports_view.scoutfail+'</B></font></TD></TR>';
			else
				m+='<TR><TD><FONT color="#CC0000"><B>'+uW.g_js_strings.commonstr.defeat+'</B></font></TD></TR>';
		}
		if (rslt['winner']==0 && rpt.sideId==0)
			m+='<TR><TD><FONT color="#66CC33"><B>'+uW.g_js_strings.commonstr.victory+' !</B></font></TD></TR>';
		if (rslt['winner']>=1 && rpt.sideId==1)
			m+='<TR><TD><FONT color="#66BB33"><B>'+uW.g_js_strings.commonstr.victory+' !</B></font></TD></TR>';
		
		if (rslt['wall'] != undefined) {
			
				
			if (rslt['wall'] > 0 && rslt['wall'] < 100)
				m+='<TR><TD>'+uW.g_js_strings.modal_messages_viewreports_view.wallbreach+' '+rslt['wall']+' '+uW.g_js_strings.modal_messages_viewreports_view.percdamage+'</TD></TR>';
			else
				m+='<TR><TD>'+ uW.g_js_strings.modal_messages_viewreports_view.wallbreach+'</TD></TR>';
		}
		m+= '</TABLE><BR />';
		if (rslt['wonGloryItem']) {
		  m+="<TABLE class=ptTab><TR><td><img width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/" + rslt['wonGloryItem'] + ".jpg></td><td colspan=2>"+unsafeWindow.ksoItems[rslt['wonGloryItem']].name+"</td></tr></TABLE><BR />";
		}
		
		if (rslt['throneRoomDrop']) {
		  var A=rslt['throneRoomDrop'];
		  faction=A.faction;
		  if (unsafeWindow.kocThroneItems[rslt['throneRoomDrop'].id]) {
       	           var name=ThroneItemName(unsafeWindow.kocThroneItems[rslt['throneRoomDrop'].id]);
       	         
		  m+="<TABLE class=ptTab><TR><td><img width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/throne/icons/30/"+faction+"/"+faction+"_"+A.type+"_normal_1.png></td><td colspan=2>"+name+"</td></tr></TABLE><BR />";
		 }
		}
		if (rslt['loot'] != undefined) {
			m+='<TABLE class=ptTab>';
			if (rslt['loot'][0] > 0)
				m+='<TR><TD>'+goldImg+'</TD><TD align=right>'+addCommas(rslt['loot'][0])+'</TD></TR>';
			if (rslt['loot'][1] > 0)
				m+='<TR><TD>'+foodImg+'</TD><TD align=right>'+addCommas(rslt['loot'][1])+'</TD></TR>';
			if (rslt['loot'][2] > 0)
				m+='<TR><TD>'+woodImg+'</TD><TD align=right>'+addCommas(rslt['loot'][2])+'</TD></TR>';
			if (rslt['loot'][3] > 0)
				m+='<TR><TD>'+stoneImg+'</TD><TD align=right>'+addCommas(rslt['loot'][3])+'</TD></TR>';
			if (rslt['loot'][4] > 0)
				m+='<TR><TD>'+oreImg+'</TD><TD align=right>'+addCommas(rslt['loot'][4])+'</TD></TR>';
			if (rslt['loot'][6] > 0)
				m+='<TR><TD>'+aetherstoneImg+'</TD><TD align=right>'+addCommas(rslt['loot'][6])+'</TD></TR>';
			if (rslt['loot'][5] !== undefined) {
				var q=unsafeWindow.Object.keys(rslt['loot'][5]);
				if (q.length>0) {
				 for(var u=0,y=q.length;u<y;++u){
				 C=q[u];
				 if (unsafeWindow.ksoItems[C]!==undefined) 
				  m+="<TR><td><img width=30 src=https://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/items/70/" + C + ".jpg></td><td colspan=2>"+unsafeWindow.ksoItems[C].name+"</td></tr>";
			        }
			        }
				
			}
			
			m+='</TABLE><BR />';
		}

		if (rpt.marchName == 'Renfort') {
			m+=handleunts();
			m+=handlersc();
		}

		if (rpt.marchName == 'Eclaireur' && rslt['winner']>=1) {
			m+='<TABLE class=ptTab width=100%><TR><TD width=50% align=left valign=top>';
			m+=handleunts();
			if (rpt.side0TileTypeText!='F.S.')  m+=handlefrt();			
			 m+=handlersc();
			m+='</TD><TD width=50% align=left valign=top>';
			if (rpt.side0TileTypeText!='F.S.') {
			m+='<TABLE class=ptTab width=100%>';
			if (rslt['lstlgn'] != undefined) {
				if (!rslt['lstlgn'])
					m+='<TR><TD>'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+' : -</TD></TR>';
				else
					m+='<TR><TD>'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+' : ' + formatUnixTime(rslt['lstlgn']) + '</TD></TR>';
			}
			m+='<TR><TD>'+uW.g_js_strings.modal_messages_viewreports_view.knightskills+' : ';
			if (rslt['knt'] != undefined)
				m+=rslt['knt']['cbt'];
			else
				m+='None';
			m+='</TD></TR>';
			
			if (rslt['pop'] != undefined)
				m+='<TR><TD>'+uW.g_js_strings.commonstr.population+' : ' + addCommas(rslt['pop']) + '</TD></TR>';
			if (rslt['hap'] != undefined)
				m+='<TR><TD>'+uW.g_js_strings.commonstr.happiness+' : ' + addCommas(rslt['hap']) + '</TD></TR></TABLE>';
			
			 if (rslt['blds'] != undefined) {
				m+='<b><a id=BORptBatClick>'+uW.g_js_strings.commonstr.buildings+'</a></b><br><TABLE class=ptTab id=BORptBat style="display:none">';
				for (var i=0; i<53; i++)
					if (rslt['blds']['b'+i] != undefined)
						m+=handleblds(i);
				m+='</TABLE>';
			 }
			 if (rslt['tch'] != undefined) {
				m+='<b><a id=BORptRechercheClick>'+uW.g_js_strings.commonstr.technology+'</a></b><br><TABLE class=ptTab id=BORptRecherche style="display:none">';
				for (var tl=1; tl < 17; tl++)
					if (tl != 7)
						m+='</TD></TR><TR><TD>'+researchLevels[tl].Name+'</TD><TD align=right>' + rslt['tch']['t'+tl] + '</TD></TR>';
				m+='</TABLE>';
			 }
			}
			m+='</TD></TR></TABLE>';
		}

		if (rslt['fght'] != undefined){
			m+='<TABLE class=ptTab width=100%><TR><TD width=50% align=left valign=top>';
			m+='<TABLE class=ptTab width=100%>';
			m+='<TR><TD colspan=4><B>'+uW.g_js_strings.commonstr.attacker+'</B> ('+rpt.side1Name+')';
			if (rslt['winner']>=1)
				m+='<FONT color="#CC0000"><B> '+uW.g_js_strings.commonstr.winner+'</B></FONT>';
			m+='</TD></TR>';
			if (rpt.marchName == 'Attaque' || rpt.marchName == 'Defense')
				m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.knightskills+' : ' + rslt['s1KCombatLv'] + '</TD></TR>';
			if (rslt['s1atkBoost']!== undefined)
			 if (100*rslt['s1atkBoost']>0)
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.attackboosted+' : ' + 100*rslt['s1atkBoost'] + '%</TD></TR>';
			if (rslt['s1defBoost']!== undefined)
			 if (100*rslt['s1defBoost']>0) 
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.defenseboosted+' : ' + 100*rslt['s1defBoost'] + '%</TD></TR>';
			if (rslt['s1lifeBoost']!== undefined)
			 if (100*rslt['s1lifeBoost']>0)
			  m+='<TR><TD colspan=4>Vie : ' + 100*rslt['s1lifeBoost'] + '%</TD></TR>';
			if (rslt['s1guardianDefBoost']!== undefined)
			 if (100*rslt['s1guardianDefBoost']>0)
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.guardian_defenseboosted+' : ' + 100*rslt['s1guardianDefBoost'] + '%</TD></TR>';
			if (rslt['s1guardianAtkBoost']!== undefined)
			 if ( 100*rslt['s1guardianAtkBoost']>0)
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.guardian_attackboosted+' : ' + 100*rslt['s1guardianAtkBoost'] + '%</TD></TR>';
			if (rslt['s1guardianMarchBoost']!== undefined)
			 if (100*rslt['s1guardianMarchBoost']>0)
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.guardian_marchboosted+' : ' + 100*rslt['s1guardianMarchBoost'] + '%</TD></TR>';
			m+='<TR><TD colspan=4><a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ rpt.side1XCoord +','+ rpt.side1YCoord +')</a> ' + rpt.side1CityName + '</TD></TR>';
			if (rslt['fght']["s1"] != undefined) {
				m+='<TR><TH></TH><TH align=left>'+uW.g_js_strings.commonstr.troops+'</TH><TH align=right>'+uW.g_js_strings.report_view.fought+'</TH><TH align=right>'+uW.g_js_strings.report_view.survived+'</TH><TH align=right>'+uW.g_js_strings.report_view.wounded+'</TH></TR>';
				for (var i=1;i<13;i++) {
					if (rslt['fght']["s1"]['u'+i] != undefined) {
						if (rslt['fght']["s1"]['u'+i][0] > rslt['fght']["s1"]['u'+i][1]) {
							perte_atk= perte_atk +(rslt['fght']["s1"]['u'+i][0] - rslt['fght']["s1"]['u'+i][1])*puipui[i-1];
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s1"]['u'+i][0])+'</td>';
							m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s1"]['u'+i][1])+'</FONT></td>';
							m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s1"]['u'+i][2])+'</FONT></td></tr>';
						} else {
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s1"]['u'+i][0])+'</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s1"]['u'+i][1])+'</td></tr>';
						}
					}
				}
			}
			m+='</TABLE><br>';
			// Bonus divers ^^^
			if (rslt['s1ThroneRoomBoosts']) {
			m+='<b><a id=BORptS1ThroneClick>'+uW.g_js_strings.report_view.throne_room+'</a></b><br><TABLE class=ptTab id=BORptS1Throne style="display:none">';
			  for (var i in rslt['s1ThroneRoomBoosts']) {
	
			   m+='<TR><TD><B>'+uW.cm.thronestats.effects[i][1]+'</B></td><td align=right>'+ rslt['s1ThroneRoomBoosts'][i] +' %</td></tr>'; 
			 
			  }
			m+='</TABLE>';
			}else{
				//  m+='<b>Aucun bonus de la salle du tr&ocirc;ne</b>';
			}
			
			m+='</TD><TD width=50% align=left valign=top>';
			m+='<TABLE class=ptTab width=100%>';
			m+='<TR><TD colspan=4><B>'+uW.g_js_strings.commonstr.defenders+'</B> ('+rpt.side0Name+')';
			if (rslt['winner']==0)
				m+='<FONT color="#CC0000"><B> '+uW.g_js_strings.commonstr.winner+'</B></FONT>';
			m+='</TD></TR>';
			if (rpt.marchName == 'Attaque' || rpt.marchName == 'Defense')
				m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.knightskills+' : ' + rslt['s0KCombatLv'] + '</TD></TR>';
			if (rslt['s0atkBoost'] !== undefined)
			 if (100*rslt['s0atkBoost']>0)
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.attackboosted+' : ' + 100*rslt['s0atkBoost'] + '%</TD></TR>';
			if (rslt['s0defBoost'] !== undefined)
			 if (rslt['s0defBoost']>0)
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.defenseboosted+' : ' + 100*rslt['s0defBoost'] + '%</TD></TR>';
			if (rslt['s0lifeBoost']!== undefined)
			 if (100*rslt['s0lifeBoost']>0)
			  m+='<TR><TD colspan=4>Vie : ' + 100*rslt['s0lifeBoost'] + '%</TD></TR>';
			if (rslt['s0guardianDefBoost']!== undefined)
			 if (100*rslt['s0guardianDefBoost']>0)
			 m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.guardian_defenseboosted+' : ' + 100*rslt['s0guardianDefBoost'] + '%</TD></TR>';
			if (rslt['s0guardianAtkBoost']!== undefined)
			 if (100*rslt['s0guardianAtkBoost']>0)
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.guardian_attackboosted+' : ' + 100*rslt['s0guardianAtkBoost'] + '%</TD></TR>';
			if (rslt['s0guardianMarchBoost']!== undefined)
			 if (100*rslt['s0guardianMarchBoost'])
			  m+='<TR><TD colspan=4>'+uW.g_js_strings.modal_messages_viewreports_view.guardian_marchboosted+' : ' + 100*rslt['s0guardianMarchBoost'] + '%</TD></TR>';
			if (rslt['rnds']!==undefined)
			   m+='<TR><TD colspan=4>Tour : ' + rslt['rnds'] + '</TD></TR>';
			if (rslt['fght']["s0"] != undefined) {
				m+='<TR><TH></TH><TH align=left>'+uW.g_js_strings.commonstr.troops+'</TH><TH align=right>'+uW.g_js_strings.report_view.fought+'</TH><TH align=right>'+uW.g_js_strings.report_view.survived+'</TH></TR>';
				for (var i=1;i<13;i++) {
					if (rslt['fght']["s0"]['u'+i] != undefined) {
						if (rslt['fght']["s0"]['u'+i][0] > rslt['fght']["s0"]['u'+i][1]) {
							perte_def= perte_def +(rslt['fght']["s0"]['u'+i][0] - rslt['fght']["s0"]['u'+i][1])*puipui[i-1];
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['u'+i][0])+'</td>';
							m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s0"]['u'+i][1])+'</FONT></td></tr>';
						} else {
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['u'+i][0])+'</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['u'+i][1])+'</td></tr>';
						}
					}
				}
				// Dark Forest
							for (var i=101;i<111;i++) {
									if (rslt['fght']["s0"]['m'+i] != undefined) {
										if (rslt['fght']["s0"]['m'+i][0] > rslt['fght']["s0"]['m'+i][1]) {
											m+='<TR><TD>' + unitImg[i] + '</td>';
											m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['m'+i][0])+'</td>';
											m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s0"]['m'+i][1])+'</FONT></td></tr>';
										} else {
											m+='<TR><TD>' + unitImg[i] + '</td>';
											m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['m'+i][0])+'</td>';
											m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['m'+i][1])+'</td></tr>';
										}
									}
				}
				//
				for (var i=53;i<=55;i++) {
					if (rslt['fght']["s0"]['f'+i] != undefined) {
						if (rslt['fght']["s0"]['f'+i][0] > rslt['fght']["s0"]['f'+i][1]) {
							perte_def= perte_def +(rslt['fght']["s0"]['f'+i][0] - rslt['fght']["s0"]['f'+i][1])*puipui[i];
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
							m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</font></td></tr>';
						} else {
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</td></tr>';
						}
					}
				}
				for (var i=60;i<=63;i++) {
					if (rslt['fght']["s0"]['f'+i] != undefined) {
						if (rslt['fght']["s0"]['f'+i][0] > rslt['fght']["s0"]['f'+i][1]) {
							perte_def= perte_def +(rslt['fght']["s0"]['f'+i][0] - rslt['fght']["s0"]['f'+i][1])*puipui[i];
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
							m+='<TD align=right><FONT color="#CC0000">'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</font></td></tr>';
						} else {
							m+='<TR><TD>' + unitImg[i] + '</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][0])+'</td>';
							m+='<TD align=right>'+addCommas(rslt['fght']["s0"]['f'+i][1])+'</td></tr>';
						}
					}
				}
			} else
				m+='<TR><TD>'+uW.g_js_strings.modal_messages_viewreports_view.notroopsdef+'</TD></TR>';
			m+='</TABLE><br>';
			// Bonus divers ^^^
			if (rslt['s0ThroneRoomBoosts']) {
			m+='<b><a id=BORptS0ThroneClick>'+uW.g_js_strings.report_view.throne_room+'</a></b><br><TABLE class=ptTab id=BORptS0Throne style="display:none">';
			  for (var i in rslt['s0ThroneRoomBoosts']) {
	
			   m+='<TR><TD><B>'+uW.cm.thronestats.effects[i][1]+'</B></td><td align=right>'+ rslt['s0ThroneRoomBoosts'][i] +' %</td></tr>'; 
			 
			  }
			
			m+='</TABLE>';
				
			}else{
			  //m+='<b>Aucun bonus de la salle du tr&ocirc;ne</b>'
			}
			
			m+='</TD></TR>';
			delta_perte = perte_atk - perte_def;
			delta_pos = 1;
			ordre_grandeur = 1; 
			delta_perte = delta_perte/1000;
			if (delta_perte<0){
				delta_pos = -1; 
				delta_perte = Math.abs(delta_perte);
			}
			if (delta_perte>1000) { 
				ordre_grandeur = 2;
				delta_perte = entier_1dec(delta_perte/1000);
			}
			if (delta_perte<1) {
				ordre_grandeur = 0;
				delta_perte = entier_1dec(delta_perte*1000);
			}
			if (ordre_grandeur == 1) { 
				delta_perte = entier_1dec(delta_perte);
			}
			perte_atk = entier_1dec(perte_atk/1000);
			perte_def = entier_1dec(perte_def/1000);
			m+='<TR><TD colspan=4>&nbsp;</TD></TR>';
			if ((delta_pos == 1) && (delta_perte != 0)) {
				m+='<TR><TD><FONT color="#000"><b>'+uW.g_js_strings.commonstr.might+' '+lang.Rpt.lost+'</b> ('+rpt.side1Name+') : </FONT><FONT color="#CC0000"> '+(perte_atk)+'k</FONT></TD><TD><FONT color="#00"><b>'+uW.g_js_strings.commonstr.might+' '+lang.Rpt.lost+'</b> ('+rpt.side0Name+') : '+perte_def+'k </FONT></TD></TR>';
				if (ordre_grandeur==2) {
					m+='<TR><TD style="background-color: #FFFF00;"><FONT color="#ff00ff">'+lang.Rpt.lost1+'</FONT><FONT color="#CC0000"> '+delta_perte+'M</FONT></TD><TD></TD></TR></table>';
				} else if (ordre_grandeur==1){
					m+='<TR><TD style="background-color: #FFFF00;"><FONT color="#ff00ff">'+lang.Rpt.lost1+'</FONT><FONT color="#CC0000"> '+delta_perte+'k </FONT></TD><TD></TD></TR></table>';
				} else if(ordre_grandeur==0){
					m+='<TR><TD style="background-color: #FFFF00;"><FONT color="#ff00ff">'+lang.Rpt.lost1+'</FONT><FONT color="#CC0000"> '+delta_perte+'</FONT></TD><TD></TD></TR></table>';
				}
			}
			if ((delta_pos == -1) && (delta_perte != 0)) {
				m+='<TR><TD><FONT color="#000"><b>'+uW.g_js_strings.commonstr.might+' '+lang.Rpt.lost+'</b> ('+rpt.side1Name+') : '+perte_atk+'k</FONT></TD><TD><FONT color="#000"><b>'+uW.g_js_strings.commonstr.might+' '+lang.Rpt.lost+'</b> ('+rpt.side0Name+') : </FONT><FONT color="#CC0000"> '+perte_def+'k </FONT></TD></TR>';
				if (ordre_grandeur==2) {
					m+='<TR><TD></TD><TD style="background-color: #FFFF00;"><FONT color="#ff00ff">'+lang.Rpt.lost1+'</FONT><FONT color="#CC0000"> '+delta_perte+'M</FONT></TD></TR></table>';
				} else if (ordre_grandeur==1){
					m+='<TR><TD></TD><TD style="background-color: #FFFF00;"><FONT color="#ff00ff">'+lang.Rpt.lost1+'</FONT><FONT color="#CC0000"> '+delta_perte+'k</FONT></TD></TR></table>';
				} else if (ordre_grandeur==0){
					m+='<TR><TD style="background-color: #FFFF00;"><FONT color="#ff00ff">'+lang.Rpt.lost1+'</FONT><FONT color="#CC0000"> '+delta_perte+'</FONT></TD><TD></TD></TR></table>';
				}
			}
			if (delta_perte == 0 && (perte_def>0 || perte_atk>0)) {
				m+='<TR><TD><FONT color="#000"><b>'+uW.g_js_strings.commonstr.might+' '+lang.Rpt.lost+'</b> ('+rpt.side1Name+') : '+perte_atk+'k</FONT></TD><TD><FONT color="#000"><b>'+uW.g_js_strings.commonstr.might+' '+lang.Rpt.lost+'</b> ('+rpt.side0Name+') : '+perte_def+'k </FONT></TD></TR></TABLE>';		
			}
		}

		m+='</DIV>';
		t.popReport.getMainDiv().innerHTML = m;
		t.popReport.getTopDiv().innerHTML = '<DIV align=center><B>'+uW.g_js_strings.commonstr.report+'</B></DIV>';
	        t.popReport.show(true);
    		t.popReport.autoHeight (true); 
    		if (ById('BORptS0ThroneClick')) {
				 ById('BORptS0ThroneClick').addEventListener('click', function () {
				    		  if (ById('BORptS0Throne').style.display=="none") {ById('BORptS0Throne').style.display="block";} else {ById('BORptS0Throne').style.display="none";}
				 },false);
    		}
    		if (ById('BORptS1ThroneClick')) {
		 ById('BORptS1ThroneClick').addEventListener('click', function () {
		    		  if (ById('BORptS1Throne').style.display=="none") {ById('BORptS1Throne').style.display="block";} else {ById('BORptS1Throne').style.display="none";}
		 },false);
    		}
    		if (ById('BORptBatClick')) {
		 ById('BORptBatClick').addEventListener('click', function () {
		    		  if (ById('BORptBat').style.display=="none") {ById('BORptBat').style.display="block";} else {ById('BORptBat').style.display="none";}
		 },false);
    		}
    		if (ById('BORptRechercheClick')) {
    		 ById('BORptRechercheClick').addEventListener('click', function () {
    		  if (ById('BORptRecherche').style.display=="none") {ById('BORptRecherche').style.display="block";} else {ById('BORptRecherche').style.display="none";}
    		 },false);
	      }	
	},

};
Tabs.Marches = {
  tabOrder: 3,
  tabLabel: uW.g_js_strings.commonstr.march,
  cont:null,
  displayTimer:null,
  curTabBut : null,
  curTabName : null,
  state : null,
  
  hide : function (){
      var t = Tabs.Marches;
      clearTimeout (t.displayTimer);
  },
  
  show : function (){
   var t = Tabs.Marches;
       clearTimeout (t.displayTimer);
       if (t.curTabName == 'Z')
         t.showReinforcementsOut();
       else if (t.curTabName == 'R')
         t.showReinforcements();
       else if (t.curTabName == 'M')
         t.showMarches(9);
       else
      t.showAttacks();
  },
  init : function (div){  
    var t = Tabs.Marches; 
    t.cont = div;
    uW.pr58Recall = t.ajaxRecall;
    uW.BOraid_delete = t.ajaxDeleteRaid;
    uW.r8x6Home = t.butSendHome;
    uW.pr57Recall = t.butRecall2;
  
    var atkclass='';
    if(Seed && Seed.queue_atkinc) {
      for(k in Seed.queue_atkinc){
        m = Seed.queue_atkinc[k];
        if (m.marchType == 4){
    	   atkclass = 'style="background-color:#FF9999;"';
    	 }
      }
    }
    
    t.cont.innerHTML = '<TABLE class=ptTab align=center><TR><TD><INPUT class=bopbSubtab ID=BoptmrchSubM type=submit value="'+ uW.g_js_strings.commonstr.marching +'"></td>\
          <TD><INPUT class=bopbSubtab ID=BoptmrchSubA type=submit '+atkclass+' value="' + uW.g_js_strings.modaltitles.impatks + '"></td>\
          <TD><INPUT class=bopbSubtab ID=BoptmrchSubR type=submit value="'+uW.g_js_strings.openEmbassy.encampall+'"></td>\
          <TD><INPUT class=bopbSubtab ID=BoptmrchSubZ type=submit value="'+uW.g_js_strings.commonstr.reinforced+'"></td><td><input type=button value="?" id=boaidemarches class=boAide></td></tr></table>\
      <DIV id="BoptMarchOutput" style="margin-top:5px; height:'+(Options.HauteurBoite-65)+'px;max-height:'+(Options.HauteurBoite-65)+'px;overflow-y:auto"></div>';
     t.marchDiv = ById('BoptMarchOutput'); 
    ById('BoptmrchSubA').addEventListener('click', e_butSubtab, false);
    ById('BoptmrchSubR').addEventListener('click', e_butSubtab, false);
    ById('BoptmrchSubM').addEventListener('click', e_butSubtab, false);
    ById('BoptmrchSubZ').addEventListener('click', e_butSubtab, false);
       ById('boaidemarches').addEventListener('click', function(){
    	       	 window.open(sitesupport+"?page=aide_marches");
    	} , false);
       if (atkclass!='') {
       changeSubtab (ById('BoptmrchSubA'));  
       }else {
       changeSubtab (ById('BoptmrchSubM'));  
       }
       
      function e_butSubtab (evt){
          changeSubtab (evt.target);   
      }
    
      function changeSubtab (but){
          if (but == t.curTabBut)
            return;
          if (t.curTabBut){
            t.curTabBut.className='bopbSubtab'; 
            t.curTabBut.disabled=false;
          }
          t.curTabBut = but;
          but.className='bopbSubtab bopbSubtabSel'; 
          but.disabled=true;
          t.curTabName = but.id.substr(11);
          if (Options.currentTab=="Marches") t.show2();
      }  
    
  },
  show2 : function (){
    var t = Tabs.Marches;
    t.state = null;
    clearTimeout (t.displayTimer);
    if (t.curTabName == 'Z')
      t.showReinforcementsOut();
    else if (t.curTabName == 'R')
      t.showReinforcements();
    else if (t.curTabName == 'M')
      t.showMarches(9);
    else
      t.showAttacks();
  },
 
   /***   ATTACKS SUBTAB  ***/
  showAttacks : function (){
      var t = Tabs.Marches;
      clearTimeout (t.displayTimer);
      var now = unixTime();
      var target, atkType, who, atkclass;
      var ss = '<div class=boStat>'+uW.g_js_strings.modaltitles.impatks.toUpperCase()+' - <input type=button value="?" id=boaidemarches2 class=boAide></div>';
      var s = '';
      s += '<STYLE> .eclkk{background:#ffff55;} .attackkk{background:#ff5555;} .attackkA{background:#ff9955;}</style>';
      s += '<TABLE border=0 cellspacing=0 cellpadding=2 width=100% class=ptTab>';
      s += '<tr><td width=55><b>'+uW.g_js_strings.commonstr.timeremaining+'</td><td width=60><b>'+lang.marchs.attackcol2+'</td><td width=140 colspan=2><b>'+uW.g_js_strings.commonstr.location+'</td><td width=150 colspan=2><b>'+uW.g_js_strings.commonstr.attacker+'</td><td width=35><b>'+uW.g_js_strings.commonstr.distance+'</td><td width=25><b>'+uW.g_js_strings.commonstr.knight+'</td><td><b>'+uW.g_js_strings.commonstr.troops+'</td></tr>';  
      var at=0;
      if(Seed && Seed.queue_atkinc) {
       var sortem = [];    
       for (var k in Seed.queue_atkinc) 
          sortem.push (Seed.queue_atkinc[k]);

        sortem.sort (function (a,b){
          var x; if ((x = a.arrivalTime-b.arrivalTime)!=0) 
            return x; 
          return b.arrivalTime-a.arrivalTime;
        });    

       for (i=0; i<sortem.length; i++){
          var m = sortem[i]; 
      
      	if (m.marchType == 3){
	      atkType = uW.g_js_strings.commonstr.scouting;
	      atkclass = 'eclkk';
	    } else if (m.marchType == 4){
	      atkType = uW.g_js_strings.commonstr.atk;
	      atkclass = 'attackkk';
	       var nbtroupe=0;
	       for (k in m.unts){
	                nbtroupe += parseInt(m.unts[k]);
                }
	        if (nbtroupe==1) {
	         atkclass = 'attackkA';
	        }
	      
	    } else {
	      atkType ="?";
	      atkclass = '';
    	 }
    	 if (atkclass !='') {  
    	 at++;
    	 s += '<tr align=left class="'+atkclass+'">';
    	 var arrivedans = unsafeWindow.timestr(parseInt(m.arrivalTime - unixTime()));
    	 s += '<td class="'+atkclass+'">' + arrivedans +'</td>';
    	 var couelur="";
    	 var city = Cities.byID[m.toCityId];
    	 if (city.tileId == m.toTileId) {
           target = '<a onclick="citysel_click(document.getElementById(\'citysel_'+ (city.idx+1)+'\'));">'+ city.name.substring(0,10) +'</a>';
           cityID = 'city'+ m.toCityId;
	   Gate = parseInt(Seed.citystats[cityID].gate);
	   if(Gate == 0) {
	   	bouttt = '<input type=button value="'+lang.marchs.attackcol2.toUpperCase()+' OFF" id="but_'+m.toCityId+'" style="background-color:#00AA00;padding:2px;border:1px solid yellow;">';
	   	}	   else {
		bouttt = '<input type=button value="'+lang.marchs.attackcol2.toUpperCase()+' ON" id="but_'+m.toCityId+'" style="background-color:red;">';
		}
           coordos = '<a class="coordinateLink" onclick="cm.utils.CoordinateLinkController.onClick(event)" href="javascript:void(0)">('+ city.x + ',' + city.y +')</a>';
         } else {
           target = lang.marchs.targetTS;
           bouttt='';
           for (k in Seed.wilderness['city'+m.toCityId]){
            if (Seed.wilderness['city'+m.toCityId][k].tileId == m.toTileId){
             coordos = '<a class="coordinateLink" onclick="cm.utils.CoordinateLinkController.onClick(event)" href="javascript:void(0)">('+Seed.wilderness['city'+m.toCityId][k].xCoord + ',' + Seed.wilderness['city'+m.toCityId][k].yCoord+')</a>';
             break;           
            }
           }
         }  
         s += '<td class="'+atkclass+'" align=center>'+bouttt+'</td><td class="'+atkclass+'" align=center><b>' + target + '<td class="'+atkclass+'" align=center>'+coordos+'</b></td>';
         
         if (Seed.players['u'+m.pid]) {
	    who = '<span>'+Seed.players['u'+m.pid].n +'<br>'+addCommas(Seed.players['u'+m.pid].m)+'</span>';
	 
	 } else if (m.players && m.players['u'+m.pid]) {
	    who = m.players['u'+m.pid].n;
	 } else{
	    who = lang.marchs.unknow;
	
      	 }
      	 if (m.fromXCoord) { 
      	  who += '</td><td class="'+atkclass+'"><a class="coordinateLink" onclick="cm.utils.CoordinateLinkController.onClick(event)" href="javascript:void(0)">(' + m.fromXCoord +','+ m.fromYCoord+')</a>';
      	 } else {
      	  who += '</td><td class="'+atkclass+'">???</a></td>';
      	 }
      	 s += '<td class="'+atkclass+'">' + who + '</td>';
      	 if (m.fromXCoord) {
      	  s +='<td class="'+atkclass+'">'+ distance(city.x,city.y,m.fromXCoord,m.fromYCoord) +'</td>';
      	 } else {
      	   s +='<td class="'+atkclass+'">&nbsp;</td>';
      	 }
         var troupe = "";
         for (k in m.unts){
          var uid = parseInt(k.substr (1));
          troupe += m.unts[k] +' '+ unsafeWindow.unitcost['unt'+uid][0] +'<br>';
         }
         var knh='&nbsp;';
         if (m.knt) {
	  for (k in m.knt){
	    knh=parseInt(m.knt[k]);
	  }        
         }
	 s += '<td class="'+atkclass+'">'+knh+'</td>';
         s += '<td class="'+atkclass+'">' + troupe +'</td>';
 
         s += '</tr>';
         } 
      	} 
      	s+='</table>';
      	if (at==0) {
      	 s ="<tr><colspan=4><br><center>"+uW.g_js_strings.ImpendingAttacks.noIncomingAttacks+"...</td></tr>";
      	}
      }
      t.marchDiv.innerHTML = ss + "" + s; 
       ById('boaidemarches2').addEventListener('click', function(){
          	       	 window.open(sitesupport+"?page=aide_marches2");
    	} , false);
       for (var cityId in Cities.byID){
      	var but = document.getElementById ('but_'+ cityId);
      	if (but) addListener (but, cityId);
       }
       function addListener (but, i){      	 but.addEventListener ('click', function (){t.butToggleDefMode(i)}, false);       }
      
      t.displayTimer = setTimeout (t.showAttacks, 900);
    },
    defMode:{},
    butToggleDefMode : function (cityId){
        var t = Tabs.Marches;
        var mode = 1;
        if (Seed.citystats["city" + cityId].gate != 0)
          mode = 0;
          t.ajaxSetDefMode (cityId, mode, function (newMode){
    
          });
    },
    ajaxSetDefMode : function (cityId, state, notify){
    		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    		params.cid = cityId;
    		params.state = state;
    		new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/gate.php" + unsafeWindow.g_ajaxsuffix, {
    			method: "post",
    			parameters: params,
    			onSuccess: function (rslt) {
    				if (rslt.ok) {
    					Seed.citystats["city" + cityId].gate = state;
    					notify (state);
    				} 
    			},
    			onFailure: function () {
    			}
    		})
     },
    
    /***   MARCHES SUBTAB  ***/
    showMarches : function (numville){
 
      var t = Tabs.Marches;
      var rownum = 0;
      var now = unixTime();
     	
      clearTimeout (t.displayTimer);
      if (t.state == null){       
       var s = '<div class=boStat>'+uW.g_js_strings.modal_openRallypoint.troopmove+' ('+uW.g_js_strings.commonstr.remove+' Raid :<input id=BOVoirRaid type=checkbox '+ (!Options.voirRaid?'':' CHECKED ') +'>) - <input type=button value="?" id=boaidemarches1 class=boAide></div>';  
       s += '<STYLE> .tot{background:#f0e0f8;} .city{background:#ffffaa;}</style><input style="font-size:12px" type=button id="9_BOVilleBouton" value="0">';
       for (var c=0; c<Cities.numCities; c++){
            s += '<input style="font-size:12px" type=button id="'+ c +'_BOVilleBouton" value="' + (parseInt(c)+1) + ' : '+ Cities.cities[c].name.substring(0,10) +'">';
       }
       s += '<div id="showMarchDiv"></div>';
       t.marchDiv.innerHTML = s;
        ById('boaidemarches1').addEventListener('click', function(){
           	       	 window.open(sitesupport+"?page=aide_marches1");
    	} , false);
       ById('BOVoirRaid').addEventListener('click', function() {
       
         Options.voirRaid = ById('BOVoirRaid').checked;
         saveOptions();
         
       }, false);
       
       ById("9_BOVilleBouton").addEventListener('click', function(){
                           var t = Tabs.Marches;
                           clearTimeout (t.displayTimer);
                           t.showMarches(this.id.substring(0,1));
                           
       }, false);
       
       for (var c=0; c<Cities.numCities; c++){
          ById(c + "_BOVilleBouton").addEventListener('click', function(){
                    var t = Tabs.Marches;
                    clearTimeout (t.displayTimer);
                    t.showMarches(this.id.substring(0,1));
           }, false);
       }
       t.state = 1; 
      }
      s = '<TABLE cellspacing=0 cellpadding=2 width=100% class=ptTab>';
      tot = [];
      for (i=0; i<13; i++)  tot[i] = 0;
      var c = numville;
      if (numville==9) {
        for (var c=0; c<Cities.numCities; c++){
          var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
               
          if (matTypeof(que)=='object') {
            var a=0;
            for (k in que) {
              march = que[k]; 
              if ((march.marchType!=2 && !Options.voirRaid) || (march.marchType!=9 && march.marchType!=2 && Options.voirRaid) ) { 
                 a++;
                 if (a==1) {
      	             var cityID = 'city'+ Cities.cities[c].id;
      	             var slots=0;
		     for(var z in Seed.queue_atkp[cityID])
		     	slots++;      
      	             var niveauPointRall=parseInt(getCityBuilding (Cities.cities[c].id, 12).maxLevel); 
      	             if (niveauPointRall==12) niveauPointRall=11;  
      	  	     s+= '<TR class="city"><TD class="city">'+lang.marchs.PR+' : '+slots+' / '+niveauPointRall+'</td><TD class="city" colspan=19 align=center><font size=3><B><i><u>'+uW.g_js_strings.commonstr.city+' ' + (parseInt(c)+1) + ' : '+ Cities.cities[c].name +'</b></td></tr>';
      	         }
                 var mid = k.substr(1);
                 knight = '';
                 if (Seed.queue_atkp['city'+ Cities.cities[c].id][k]["knightId"] !=0){
		  for (i in Seed.knights['city'+ Cities.cities[c].id]) {
		    if (i == ("knt" + Seed.queue_atkp['city'+ Cities.cities[c].id][k]["knightId"]) ) knight = '' +Seed.knights['city'+ Cities.cities[c].id][i]["combat"] +'';
		  }
  		 } else knight = '';
                var playerId = march.toPlayerId;
                if (playerId==undefined) playerId=0;
                var cityId = march.toCityId;
                var tileType = parseInt(march.toTileType);
                var tileLevel = march.toTileLevel;
                var who = lang.marchs.unknow;
                if (Seed.players['u' + playerId]) {
		 who = Seed.players['u' + playerId].n;
		}
		if (march.marchType==1) { 
		  var player = "<span>"+lang.marchs.citylevel+" "+ tileLevel +"</span>";
		}else {
		  var player = "<span title=''>"+lang.marchs.boglevel+" "+ tileLevel +"</span>";
		}
		if (march.marchType==10 || march.marchType==11) { 
		  var player = "<span>"+lang.marchs.folevel+" "+ tileLevel +"</span>";
		}
		var numtile=parseInt(tileType/10) + 1;
		if (tileType==10) numtile=1;
		if (tileType==11) numtile=2;
                if (tileType <= 50) { 
                  player = tileNames[numtile] +" " + tileLevel;
                }
                if (tileType == 51 && playerId == 0 && march.toTileLevel==7) { 
                  player = uW.g_js_strings.commonstr.city+" " + tileLevel;
                }
                if (tileType == 51 && playerId == 0 && march.toTileLevel==9) {
		  player = lang.marchs.barblevel+" " + tileLevel;
                }
                if (tileType == 54 && playerId == 0) {
		     player = lang.marchs.folevel+" " + tileLevel;
                }
                var nomville="";
                if (playerId > 0 && tileType == 51) { 
                 if (march.marchType==1) {
                  for(i=0; i<Cities.numCities; i++) {
                   if (cityId==Cities.cities[i].id) {
                    nomville=Cities.cities[i].name
                     break;
                   }
                  }
                  player = lang.marchs.mycity+' '+ nomville;
                 } else {
                  player = lang.marchs.citylevel+' '+ tileLevel;
                 }
                }
                var typeattack="?";
                if (march.marchType==3) typeattack=uW.g_js_strings.commonstr.scouting; 
                if (march.marchType==4) typeattack=uW.g_js_strings.modal_barracks_train.attack;
                if (march.marchType==10) typeattack=uW.g_js_strings.modal_barracks_train.attack;
                if (march.marchType==11) typeattack=uW.g_js_strings.commonstr.scouting;
                if (march.marchType==1) typeattack=uW.g_js_strings.commonstr.transporting;
                if (march.marchType==5) typeattack=uW.g_js_strings.commonstr.reassign;
                if (march.marchType==9) typeattack=uW.g_js_strings.modal_barracks_train.attack + ' Raid';
                var now = new Date();
                var statusm = march.marchStatus;
                var Marchstatut="<span title='Type : "+march.marchType+" "+uW.g_js_strings.commonstr.status+" : "+statusm+"'>?</span> ";
                var arrivedans="0s";
                var arrivedanssec=0;
		if (statusm==1) { 
		 Marchstatut="";
		 if (march.marchType==3 || march.marchType==11) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/scouting.jpg" align=absmiddle>';
		 if (march.marchType==4 || march.marchType==10) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/attacking.jpg" align=absmiddle>';
		 if (march.marchType==9) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/attacking.jpg" align=absmiddle>';
		 if (march.marchType==1) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/transporting.jpg" align=absmiddle>';
                 if (march.marchType==5) 
                  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>';
		  Marchstatut+="&nbsp;"+uW.g_js_strings.commonstr.marching; 
		  arrivedans = unsafeWindow.timestr(parseInt(march.destinationUnixTime - unixTime()));
		  arrivedanssec = parseInt(march.destinationUnixTime - unixTime());
		}
                if (statusm==8) { 
                  Marchstatut = '<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/returning.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.commonstr.back;
                  arrivedans = unsafeWindow.timestr(march.returnUnixTime - unixTime());
                  arrivedanssec = parseInt(march.returnUnixTime - unixTime());
                }
                if (statusm==2) { 
                   Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.commonstr.encamped;
                }
                if (statusm==5) { 
                   Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.attack_generatequeue.waitreport;
                }
                if (statusm==4) { 
		   Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/autoAttack/raid_resting.png" align=absmiddle>&nbsp;' + uW.g_js_strings.attack_generatequeue.unloadingloot;
                }
                if (statusm==3 || statusm==10 ) { 
		  Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/autoAttack/raid_stopped_desat.png" align=absmiddle>&nbsp;' + uW.g_js_strings.attack_generatequeue.raidstopped;
		}
 
                s += '<TR align=left><td align=left width=10%>';
                if (march.marchType!=9 && statusm==1 && arrivedanssec>60) s +='<A class=button20 onclick="pr58Recall('+ mid+','+Cities.cities[c].id+')"><SPAN>'+uW.g_js_strings.commonstr.recall+'</span></a>';
                if (march.marchType!=9 && statusm==2) s +='<A class=button20 onclick="attack_recall('+ mid+', 1, '+Cities.cities[c].id+');"><span>'+uW.g_js_strings.commonstr.recall+'</span></a>';
                if (march.marchType==9 && statusm==10 && arrivedanssec<=0) s +='<A class=button20 onclick="BOraid_delete('+ mid+','+Cities.cities[c].id+');return false;"><span>'+uW.g_js_strings.commonstr.remove+'</span></a>';
             
             s +='</td><td align=left width=10%>'+typeattack+'</td><td>'+arrivedans+'</td><td align=left width=15%>' + Marchstatut +'</td>\
                <TD align=left width=15%>' + player + '</td><td><a class="coordinateLink" onclick="cm.utils.CoordinateLinkController.onClick(event)" href="javascript:void(0)">(' + march.toXCoord +','+ march.toYCoord +')</a></td><td>' + knight +' </td><td colspan=12>'
	       for (i=1; i<13; i++) {
	                  if (statusm==8) { 
	                    if (parseInt (march['unit'+ i +'Return']) > 0) {
	      	           s += unsafeWindow.unitcost['unt'+i][0].substr(0,6)+" :" + parseInt (march['unit'+ i +'Return']) + "<br>";
	      	          tot[i] += parseInt (march['unit'+ i +'Return']);
	                  }
	                  
	                  } else {
	                   if (parseInt (march['unit'+ i +'Count']) > 0) {
	                       s += unsafeWindow.unitcost['unt'+ i][0].substr(0,6) +" :" + parseInt (march['unit'+ i +'Count']) + "<br>";
	                       tot[i] += parseInt (march['unit'+ i +'Count']);
	                   }
	                  }
                }
	      
                s += '</td><td style="font-size:11px">';
      		if (march.marchType!=9) {
      		  s += '<a  class=button20 onclick="view_march('+ mid+');return false;";><span>'+uW.g_js_strings.commonstr.view+'</psan></a></td>';
      		  }else {
      		  s+='</td>';
      		  }
                s += '</tr>';
              }
            }
        }
      }
      s += '<TR><TD colspan=20><BR><BR></td></tr></table><TABLE cellspacing=0 cellpadding=2 width=100%><tr><td colspan=1></td>';
     	 for (var k=1;k<13;k++)
     	 	s += '<TD width=7% align=center><B>' + unsafeWindow.unitcost['unt'+k][0].substr(0,6) + '</b></td>';
     	 s += '</tr>';
     	 s += '<TR align=center><TD class="tot" align=left width=10%><B>'+lang.marchs.tot+'</b></td>';
     	 for (i=1; i<13; i++)
     		s+= '<TD class="tot">'+ tot[i] +'</td>';
     	 s += '<td></td></tr></table>';
	 s += '<BR><BR><DIV style="font-size: 10px"></div>';
            
  } else { 
      
      
   var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
   if (matTypeof(que)=='object') {      
			var a=0;
			for (k in que){
	                   march = que[k]; 
	                   
	              if ((march.marchType!=2 && !Options.voirRaid) || (march.marchType!=9 && march.marchType!=2 && Options.voirRaid) ) { 
                  a++;
	                   if (a==1) {
	         	             var cityID = 'city'+ Cities.cities[c].id;
	         	             var slots=0;
	   		     for(var z in Seed.queue_atkp[cityID])
	   		     	slots++;
	   	      	             
	         	             var niveauPointRall=parseInt(getCityBuilding (Cities.cities[c].id, 12).maxLevel); 
	        if (niveauPointRall==12) niveauPointRall=11;  
	         	  	     s+= '<TR class="city"><TD class="city">'+lang.marchs.PR+' : '+slots+' / '+niveauPointRall+'</td><TD class="city" colspan=18 align=center><font size=3><B><i><u>'+unsafeWindow.g_js_strings.commonstr.city+' ' + (parseInt(c)+1) + ' : '+ Cities.cities[c].name +'</b></td></tr>';
	         	        }
	                   var mid = k.substr(1);
	                   knight = '';
	                    if (Seed.queue_atkp['city'+ Cities.cities[c].id][k]["knightId"] !=0){
	   		  				    	for (i in Seed.knights['city'+ Cities.cities[c].id]) {
	   		  				    			if (i == ("knt" + Seed.queue_atkp['city'+ Cities.cities[c].id][k]["knightId"]) ) knight = '&nbsp;('+lang.marchs.knight+' : ' +Seed.knights['city'+ Cities.cities[c].id][i]["combat"] +')';
	   		  				    	}
	     				    } else knight = '';
	                  var playerId = march.toPlayerId;
			                 if (playerId==undefined) playerId=0;
			                 var cityId = march.toCityId;
			                 var tileType = parseInt(march.toTileType);
			                 var tileLevel = march.toTileLevel;
			                 var who = lang.marchs.unknow;
			                 if (Seed.players['u' + playerId]) {
			 		 who = Seed.players['u' + playerId].n;
			 		}
			 		if (march.marchType==1) { 
			 		  var player = "<span>" + lang.marchs.citylevel + ' ' + tileLevel +"</span>";
			 		}else {
			 		  var player = "<span title=''>"+lang.marchs.boglevel+" "+ tileLevel +"</span>";
			 		}
			 		if (march.marchType==10 || march.marchType==11) { 
			 		  var player = "<span>"+lang.marchs.folevel+" "+ tileLevel +"</span>";
			 		}
			 		var numtile=parseInt(tileType/10) + 1;
			 		if (tileType==10) numtile=1;
			 		if (tileType==11) numtile=2;
			                 if (tileType <= 50) { 
			                   player = tileNames[numtile] +" "+lang.marchs.level+" " + tileLevel;
			                 }
			                 if (tileType == 51 && playerId == 0 && march.toTileLevel==7) { 
			                   player = lang.marchs.citylevel + ' ' + tileLevel;
			                 }
			                 if (tileType == 51 && playerId == 0 && march.toTileLevel==9) { 
			 		  player = lang.marchs.barblevel + ' ' + tileLevel;
			                 }
			                 if (tileType == 54 && playerId == 0) { 
			 		     player = lang.marchs.folevel + ' ' + tileLevel;
			                 }
			                 var nomville="";
			                 if (playerId > 0 && tileType == 51) { 
			                  if (march.marchType==1) {
			                   for(i=0; i<Cities.numCities; i++) {
			                    if (cityId==Cities.cities[i].id) {
			                     nomville=Cities.cities[i].name
			                      break;
			                    }
			                   }
			                   player = lang.marchs.mycity + ' '+ nomville;
			                  } else {
			                   player = lang.marchs.citylevel + ' ' +tileLevel;
			                  }
			                 }
                var typeattack="?";
	       if (march.marchType==3) typeattack=uW.g_js_strings.commonstr.scouting; 
	                       if (march.marchType==4) typeattack=uW.g_js_strings.modal_barracks_train.attack;
	                       if (march.marchType==10) typeattack=uW.g_js_strings.modal_barracks_train.attack;
	                       if (march.marchType==11) typeattack=uW.g_js_strings.commonstr.scouting;
	                       if (march.marchType==1) typeattack=uW.g_js_strings.commonstr.transporting;
	                       if (march.marchType==5) typeattack=uW.g_js_strings.commonstr.reassign;
                if (march.marchType==9) typeattack=uW.g_js_strings.modal_barracks_train.attack + ' Raid';
	                 var now = new Date();
                var statusm = march.marchStatus;
                var Marchstatut="<span title='Type : "+march.marchType+" "+uW.g_js_strings.commonstr.status+" : "+statusm+"'>?</span> ";
                var arrivedans="0s";
                var arrivedanssec=0;
		if (statusm==1) { 
		 Marchstatut="";
		 if (march.marchType==3 || march.marchType==11) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/scouting.jpg" align=absmiddle>';
		 if (march.marchType==4 || march.marchType==10) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/attacking.jpg" align=absmiddle>';
		 if (march.marchType==9) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/attacking.jpg" align=absmiddle>';
		 if (march.marchType==1) 
		  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/transporting.jpg" align=absmiddle>';
                 if (march.marchType==5) 
                  Marchstatut+='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>';
		  Marchstatut+="&nbsp;"+uW.g_js_strings.commonstr.marching; 
		  arrivedans = unsafeWindow.timestr(parseInt(march.destinationUnixTime - unixTime()));
		  arrivedanssec = parseInt(march.destinationUnixTime - unixTime());
		}
                if (statusm==8) { 
                  Marchstatut = '<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/returning.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.commonstr.back;
                  arrivedans = unsafeWindow.timestr(march.returnUnixTime - unixTime());
                  arrivedanssec = parseInt(march.returnUnixTime - unixTime());
                }
                if (statusm==2) { 
                   Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.commonstr.encamped;
                }
                if (statusm==5) { 
                   Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.attack_generatequeue.waitreport;
                }
                if (statusm==4) { 
		   Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/autoAttack/raid_resting.png" align=absmiddle>&nbsp;' + uW.g_js_strings.attack_generatequeue.unloadingloot;
                }
                if (statusm==3 || statusm==10) { 
		  Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/autoAttack/raid_stopped_desat.png" align=absmiddle>&nbsp;' + uW.g_js_strings.attack_generatequeue.raidstopped;
		}
 
                s += '<TR align=left><td align=left width=10%>';
                if (march.marchType!=9 && statusm==1 && arrivedanssec>60) s +='<A class=button20 onclick="pr58Recall('+ mid+','+Cities.cities[c].id+')"><SPAN>'+uW.g_js_strings.commonstr.recall+'</span></a>';
                if (march.marchType!=9 && statusm==2) s +='<A class=button20 onclick="attack_recall('+ mid+', 1, '+Cities.cities[c].id+');"><span>'+uW.g_js_strings.commonstr.recall+'</span></a>';
                if (march.marchType==9 && statusm==10 && arrivedanssec<=0) s +='<A class=button20 onclick="BOraid_delete('+ mid+','+Cities.cities[c].id+');return false;"><span>'+uW.g_js_strings.commonstr.remove+'</span></a>';
             
               s +='</td><td align=left width=10%>'+typeattack+'</td><td>'+arrivedans+'</td><td align=left width=15%>' + Marchstatut +'</td>\
	                      <TD align=left width=15%>' + player + '</td><td><a class="coordinateLink" onclick="cm.utils.CoordinateLinkController.onClick(event)" href="javascript:void(0)">(' + march.toXCoord +','+ march.toYCoord +')</a></td><td>' + knight +' </td><td colspan=12>'
	      	       for (i=1; i<13; i++) {
	      	                  if (statusm==8) { 
	      	                    if (parseInt (march['unit'+ i +'Return']) > 0) {
	      	      	           s += uW.unitcost['unt'+i][0].substring(0,5)+" :" + parseInt (march['unit'+ i +'Return']) + "<br>";
	      	      	          tot[i] += parseInt (march['unit'+ i +'Return']);
	      	                  }
	      	                  
	      	                  } else {
	      	                   if (parseInt (march['unit'+ i +'Count']) > 0) {
	      	                       s += uW.unitcost['unt'+i][0].substring(0,5)+" :" + parseInt (march['unit'+ i +'Count']) + "<br>";
	      	                       tot[i] += parseInt (march['unit'+ i +'Count']);
	      	                   }
	      	                  }
	                      }
	      	      
	                      s += '</td><td style="font-size:11px">';
	            		if (march.marchType!=9) {
	            		  s += '<a  class=button20 onclick="view_march('+ mid+');return false;";><span>'+uW.g_js_strings.commonstr.view+'</psan></a></td>';
	            		  }else {
	            		  s+='</td>';
	            		  }
                s += '</tr>';
	        }
     } 
     s += '<TR><TD colspan=18><BR><BR></td></tr></table><TABLE cellspacing=0 cellpadding=2 width=100% class=ptTab ><tr><td colspan=1></td>';
     for (r=1; r<13; r++)  s += '<TD width=7% align=center><B>' + uW.unitcost['unt'+r][0].substring(0,5)+ '</b></td>';
     s += '</tr>';
     s += '<TR align=center><TD class="tot" align=left width=10%><B>'+lang.marchs.tot+'</b></td>';
     for (i=1; i<13; i++) s+= '<TD class="tot">'+ tot[i] +'</td>';
     s += '<td></td></tr></table>';
    } else {
     s= '<br><br>'+lang.marchs.nomarch;
    } 
   }
   ById('showMarchDiv').innerHTML = s;
   t.displayTimer = setTimeout (function() { t.showMarches(numville);   }, 1000);
  },
  ajaxDeleteRaid: function(marchId, cityId) {
      var villeencours=cityId;
               var march = Seed.queue_atkp["city" + villeencours]["m" + marchId];
               if (march == null){
                            return;
               }    
               var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
               params.action="deleteMarch";
               params.marchId = marchId;
           params.ctrl="BotManager";
           params.settings={cityId:villeencours}; 
      	   unsafeWindow.ajax.Request(unsafeWindow.g_ajaxpath+"ajax/_dispatch.php"+unsafeWindow.g_ajaxsuffix,{method:"post",parameters:params,loading:true,
onSuccess:function(transport) {
  var m = eval("(" + transport.responseText + ")");
   if (m.ok){        
            var j=marchId;
            var t=cityId;
            var n=Seed.units["city"+t];
            for(var o=0;o<13;++o){
             if (m["unit"+o+"Return"]) {
              var p=parseInt(m["unit"+o+"Return"]);
              if(!isNaN(p)&&(p>0)){
               n["unt"+o]=parseInt(n["unt"+o])+p;
               }
             }
            }
            unsafeWindow.cityinfo_army();
            var s="city"+t;
            // recherche de mon chevalier
            var mymarch = unsafeWindow.seed.queue_atkp["city" + t]["m" + j];
            var kngId= mymarch.knightId;
            delete Seed.queue_atkp[s]["m"+j];
            if(unsafeWindow.Object.keys(Seed.queue_atkp[s]).length==0){
              Seed.queue_atkp[s]=[];
            }
            Seed.knights["city"+t]["knt"+kngId].knightStatus=1;          
     } else {

       
     }
    }, onFailure: function () {
       
    },
   });

  },
  /***  REINFORCEMENTS SUBTAB  ***/
  showReinforcementsOut : function (){
      var rownum = 0;
       var t = Tabs.Marches;
      clearTimeout (t.displayTimer);
      var s = '<div class=boStat>'+lang.marchs.title1+' - <input type=button value="?" id=boaidemarches4 class=boAide></div>';
      s += '<STYLE> .tot{background:#f0e0f8;} .city{background:#ffffaa;}</style>';
      s += '<TABLE cellspacing=0 cellpadding=2 width=100% class=ptTab >';
      tot = [];
      for (i=0; i<13; i++)
        tot[i] = 0;
        
      for (var c=0; c<Cities.numCities; c++){
        var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
        if (matTypeof(que)=='array')
          continue;

        var a=0;
        for (k in que){
          march = que[k]; 
          if (march.marchType==2) { 
          a++;
          if (a==1) {
	   s+= '<TR class="city"><TD class="city" colspan=16 align=left><B>'+unsafeWindow.g_js_strings.commonstr.city+' ' + (parseInt(c)+1) + ' : '+ Cities.cities[c].name +'</b></td></tr>';
          }
          var mid = k.substr(1);
          knight = '';
	  if (Seed.queue_atkp['city'+ Cities.cities[c].id][k]["knightId"] !=0){
	  		  for (i in Seed.knights['city'+ Cities.cities[c].id]) {
	  		    if (i == ("knt" + Seed.queue_atkp['city'+ Cities.cities[c].id][k]["knightId"]) ) knight = '' +Seed.knights['city'+ Cities.cities[c].id][i]["combat"] +'';
	  		  }
  	  } else knight = '';
          if (parseInt(march.knightCombat)>0) knight=' ('+ march.knightCombat +')';
	  try {
	     player = Seed.players['u'+march.toPlayerId].n; //Seed.players['u'+k].n;
	   } catch (err){
	     player = lang.marchs.unknow;
          }
        
          s += '<TR align=left><td align=left width=12%>';
          var statusm = march.marchStatus;
          var Marchstatut='';
          var arrivedans="0s";
          var arrivedanssec=0;
          if (statusm==1) { 
            Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.commonstr.marching;
            arrivedans = unsafeWindow.timestr(parseInt(march.destinationUnixTime - unixTime()));
            arrivedanssec = parseInt(march.destinationUnixTime - unixTime());
          }
          if (statusm==2) { 
            Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.commonstr.encamped;
          }
          if (statusm==8) { 
            Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/returning.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.commonstr.back;
            arrivedans = unsafeWindow.timestr(parseInt(march.returnUnixTime - unixTime())); 
            arrivedanssec = parseInt(march.returnUnixTime - unixTime());
          }
          if (statusm==5) { 
           Marchstatut='<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg" align=absmiddle>&nbsp;'+uW.g_js_strings.attack_generatequeue.waitreport;
          }
          if (statusm==1 && arrivedanssec>60){
            s +='<A class=button20 onclick="pr58Recall('+ mid+','+Cities.cities[c].id+')"><SPAN>'+uW.g_js_strings.commonstr.recall+'</span></a>';
          }
          if (statusm==2) { 
             s +='<A class=button20 onclick="pr57Recall('+ mid+')"><SPAN>'+uW.g_js_strings.commonstr.recall+'</span></a>';
          } else {
            s += '&nbsp;';
          }
             
          s+='</td><td align=left width=15%>'+Marchstatut+'</td><td>'+arrivedans+'</td><TD align=left width=30%>' + player + ' <a class="coordinateLink" onclick="cm.utils.CoordinateLinkController.onClick(event)" href="javascript:void(0)">(' + march.toXCoord +','+ march.toYCoord +')</a>&nbsp;' + knight +' </td><td colspan=12>'
          for (i=1; i<13; i++) {
            if (statusm==8) { 
              if (parseInt (march['unit'+ i +'Return']) > 0) {
	          s += " " + parseInt (march['unit'+ i +'Return']) + " "+uW.unitcost['unt'+i][0].substring(0,8)+"<br>";
	          tot[i] += parseInt (march['unit'+ i +'Return']);
            }
            
            } else {
             if (parseInt (march['unit'+ i +'Count']) > 0) {
                s += " " + parseInt (march['unit'+ i +'Count']) + " "+uW.unitcost['unt'+i][0].substring(0,6)+"<br>";
                tot[i] += parseInt (march['unit'+ i +'Count']);
             }
            }
          }
          s += '</td></tr>';
          }// fin de MarchType
        }      
      } 
      
       s += '<TR><TD colspan=16><BR><BR></td></tr></table><TABLE cellspacing=0 cellpadding=2 class=ptTab width=100%><tr><td colspan=1></td>';
            for (r=1; r<13; r++)
              s += '<TD width=7% align=center><B>' + uW.unitcost['unt'+r][0].substring(0,5)+ '</b></td>';
            s += '</tr>';
            s += '<TR align=center><TD class="tot" align=left width=10%><B>'+lang.marchs.tot+'</b></td>';
            for (i=1; i<13; i++)
              s+= '<TD class="tot">'+ tot[i] +'</td>';
      s += '</tr></table>';
      t.marchDiv.innerHTML = s;
        ById('boaidemarches4').addEventListener('click', function(){
          	       	 window.open(sitesupport+"?page=aide_marches4");
    	} , false);
      t.displayTimer = setTimeout (t.showReinforcementsOut, 5000);
      return;
  },
     
  showReinforcements : function (){
   var rownum = 0;
    
    var t = Tabs.Marches;
    clearTimeout (t.displayTimer);
      
    function clickShowRemaining (){
      checkBox = ById('idCheck2');
      if (checkBox.checked)
        Options.encRemaining = false;
      else
        Options.encRemaining = true;
      t.show2 ();
    }
  
    enc = {};
    numSlots = 0;
    
    if (matTypeof(Seed.queue_atkinc) != 'array'){
      for (k in Seed.queue_atkinc){
        march = Seed.queue_atkinc[k];
        if (march.marchType == 2){
          ++numSlots;
          city = march.toCityId;
          from = march.fromPlayerId;
          if (!enc[city])
            enc[city] = {};
          if (!enc[city][from])
            enc[city][from] = [];
          s = {};
          s.knight = parseInt (march.knightCombat);
          s.marchId = k.substr(1);
          s.fromXCoord = march.fromXCoord;
          s.fromYCoord = march.fromYCoord;
          s.troops = [];
          for (i=1; i<13; i++){
            if (Options.encRemaining)
              s.troops[i] = parseInt (march['unit'+ i +'Return']);
            else
              s.troops[i] = parseInt (march['unit'+ i +'Count']);
          }
          enc[city][from].push (s);
        }
      }
    }
    s = '<div class=boStat>'+lang.marchs.title2+' - <input type=button value="?" id=boaidemarches3 class=boAide></div>';
    if (numSlots == 0){
      s += '<BR><CENTER><B>'+lang.marchs.notroops+'</b></center>';
    } else {
      s += '<STYLE> .tot{background:#f0e0f8;} .city{background:#ffffaa;} .entete{background:#efa9a9;}</style>';
      s += '<TABLE cellspacing=0 cellpadding=2 width=100%>\
      <tr><td class="entete">'+lang.marchs.refcol1+'</td><td class="entete">'+lang.marchs.refcol2+'</td><td class="entete">'+lang.marchs.refcol3+'</td><td class="entete">'+uW.g_js_strings.commonstr.knight+'</td><td colspan=12 class="entete">'+uW.g_js_strings.commonstr.troops+'</td><td class="entete">'+lang.marchs.refcol5+'</td></tr>';

      tot = [];
      totent= 0;
      for (i=0; i<13; i++) {
        tot[i] = 0;
        
      }
      for (c in Cities.cities){
        dest = Cities.cities[c].id;
        if (enc[dest]){
          s+= '<TR><TD class="city" colspan=17 align=left><B>'+uW.g_js_strings.commonstr.city+' ' + (parseInt(c)+1) + ' : '+ Cities.cities[c].name +'</b></td></tr>';
          for (p in enc[dest]){
            try {
              player = Seed.players['u'+p].n;
            } catch (err){
              player = '???';
            }
            for (m=0; m<enc[dest][p].length; m++){
              var march = enc[dest][p][m];
              knight = '';
              if (march.knight > 0)
                knight = ' '+ march.knight +'';       
              s += '<TR align=left><td align=left width=12%><A class=button20 onclick="r8x6Home('+ march.marchId +')"><SPAN>'+uW.g_js_strings.commonstr.dismiss+'</span></a></td>\
              <TD align=left><a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+march.fromXCoord+','+march.fromYCoord+')'+'</a></td>\
              <TD align=left width=25%>'+ player +' </td><td align=left>'+ knight+'</td><td colspan=12>'
              var g=0;
              for (i=1; i<13; i++){
               if (march.troops[i] > 0) {
                s += ''+ march.troops[i]  +' '+ uW.unitcost['unt'+i][0].substring(0,5) +'<br>';
               }
               tot[i] += march.troops[i];
               g+=parseInt(march.troops[i])*parseInt(uW.unitupkeeps[i]);
               
              }
              totent += g;
              s += '</td><td>';
              s += addCommas(g) + '</td></tr>';
            }
          }
        }
      }
      s += '<TR><TD colspan=17><BR><BR></td></tr></table><TABLE cellspacing=0 cellpadding=2 width=100%><tr><td colspan=1></td>';
      for (r=1; r<13; r++)
              s += '<TD width=7% align=center><B>' + uW.unitcost['unt'+r][0].substring(0,5)+ '</b></td>';
        
      s += '</tr>';
      s += '<TR align=center><TD class="tot" align=left width=10% rowspan=2><B>'+lang.marchs.tot+'</b></td>';
      for (i=1; i<13; i++)
        s+= '<TD class="tot">'+ tot[i] +'</td>';
      s += '</tr><td colspan=12>'+lang.marchs.refcol5+' : '+addCommas(totent)+' '+lang.marchs.foodh+'</td></table>';
    }

    s += '<BR><BR><INPUT type=CHECKBOX id=idCheck2 '+ (Options.encRemaining?'':' CHECKED ') +'> '+lang.marchs.encRemaining;
    s += '<BR><BR><DIV style="font-size: 10px">'+lang.marchs.comment+'</div>';
    t.marchDiv.innerHTML = s;
    checkBox = ById('idCheck2');
    ById('boaidemarches3').addEventListener('click', function(){  window.open(sitesupport+"?page=aide_marches3");    } , false);
    checkBox.addEventListener('click', clickShowRemaining, false);
    t.displayTimer = setTimeout (t.show2, 10000);
  },
  butSendHome : function (marchId){
        var t = Tabs.Marches;
        t.ajaxSendHome (marchId); 
   },
   ajaxSendHome : function (marchId, notify){ 
     var march = Seed.queue_atkinc['m'+ marchId];
     if (march == null)
         return; 
     var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
     params.mid = marchId;
     params.cid = march.toCityId;
     params.fromUid = march.fromPlayerId;
     params.fromCid = march.fromCityId;
     new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/kickoutReinforcements.php" + unsafeWindow.g_ajaxsuffix, {
         method: "post",
         parameters: params,
         onSuccess: function (rslt) {
           if (rslt.ok){
             var upkeep = 0;
             for (var i=1; i<13; i++)
               upkeep += parseInt(march["unit" + i + "Return"]) * parseInt(unsafeWindow.unitupkeeps[i]);
             unsafeWindow.seed.resources["city"+ march.toCityId].rec1[3] -= upkeep;
             if (parseInt(march.fromPlayerId) == parseInt(unsafeWindow.tvuid)) {
               var mymarch = unsafeWindow.seed.queue_atkp["city" + march.fromCityId]["m" + marchId];
               var marchtime = Math.abs(parseInt(mymarch.destinationUnixTime) - parseInt(mymarch.eventUnixTime));
               mymarch.returnUnixTime = unixTime() + marchtime;
               mymarch.marchStatus = 8;
             }
             delete unsafeWindow.seed.queue_atkinc["m" + marchId];
             if (notify != null)
               notify(null);
           } else {
             if (notify != null)
               notify(rslt.errorMsg);
           }
         },
         onFailure: function () {
           if (notify != null)
             notify(rslt.errorMsg);
         },
     });
  },
  butRecall2 : function (marchId){
     var t = Tabs.Marches;
     t.ajaxRecall2 (marchId); 
  },
  ajaxRecall2 : function (marchId, notify){
    var villeencours;
          for (var c=0; c<Cities.numCities; c++){
            var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
            if (matTypeof(que)=='array')
              continue;
            for (k in que){
              if (k == 'm'+marchId){
                villeencours = Cities.cities[c].id;
                break;
              }
            }    
        }  
     var march = Seed.queue_atkp["city" + villeencours]["m" + marchId];
           if (march == null){
             return;
           }    
           var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
           params.mid = marchId;
           params.cid = villeencours; 
           new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/undefend.php" + unsafeWindow.g_ajaxsuffix, {
               method: "post",
               parameters: params,
               onSuccess: function (rslt) {
                 if (rslt.ok){
                   if(rslt.updateSeed){
		   unsafeWindow.seed.queue_atkp["city"+params.cid]["m"+params.mid].marchStatus=8;
		   var marchtime=parseInt(unsafeWindow.seed.queue_atkp["city"+params.cid]["m"+params.mid].returnUnixTime)-parseInt(unsafeWindow.seed.queue_atkp["city"+params.cid]["m"+params.mid].destinationUnixTime);
		   var ut=unsafeWindow.unixtime();
		   if(unsafeWindow.seed.playerEffects.returnExpire>ut){marchtime*=0.5}
		   unsafeWindow.seed.queue_atkp["city"+villeencours]["m"+marchId].destinationUnixTime=rslt.destinationUnixTime||ut;
		   unsafeWindow.seed.queue_atkp["city"+villeencours]["m"+marchId].returnUnixTime=rslt.returnUnixTime||ut+marchtime*rslt.returnMultiplier;
		   unsafeWindow.seed.queue_atkp["city"+villeencours]["m"+marchId].marchStatus=8;
		   //unsafeWindow.update_seed(rslt.updateSeed)
 		  }
 		 }
               },
               onFailure: function () {
               
               
               },
     });
          
  },   
  ajaxRecall : function (marchId, cid, notify){
       var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
              params.mid = marchId;
              params.cid = cid;
              
              new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/cancelMarch.php" + unsafeWindow.g_ajaxsuffix, {
                  method: "post",
                  parameters: params,
                  onSuccess: function (rslt) {
                    if (rslt.ok){
                    
                     if(rslt.updateSeed){
 		       unsafeWindow.seed.queue_atkp["city"+params.cid]["m"+params.mid].marchStatus=8;   
 		       var marchtime=parseInt(unsafeWindow.seed.queue_atkp["city"+params.cid]["m"+params.mid].returnUnixTime)-parseInt(unsafeWindow.seed.queue_atkp["city"+params.cid]["m"+params.mid].destinationUnixTime);
 		       var ut=unsafeWindow.unixtime();
 		       if(unsafeWindow.seed.playerEffects.returnExpire>unsafeWindow.unixtime()){marchtime*=0.5}
		       unsafeWindow.seed.queue_atkp["city"+cid]["m"+marchId].destinationUnixTime=rslt.destinationUnixTime||ut;
		       unsafeWindow.seed.queue_atkp["city"+cid]["m"+marchId].returnUnixTime=rslt.returnUnixTime||ut+marchtime*rslt.returnMultiplier;
		       unsafeWindow.seed.queue_atkp["city"+cid]["m"+marchId].marchStatus=8;
 		       //unsafeWindow.update_seed(rslt.updateSeed);
                     }
                     for(var j=1;j<13;j++){
		       unsafeWindow.seed.queue_atkp["city"+cid]["m"+marchId]["unit"+j+"Return"]=parseInt(unsafeWindow.seed.queue_atkp["city"+cid]["m"+marchId]["unit"+j+"Count"])
 		     }
 		    }
                  },
                  onFailure: function () {
                  
                  
                  },
     });

  },
};
Tabs.Search = {
  tabOrder: 4,
  tabLabel: uW.g_js_strings.commonstr.research,
  cont:null,
  state : null,
  show : function (div){
    var t = Tabs.Search;  
  },
  hide : function (){
  },
  clickedPlayerDetail : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = lang.Search.PDetail;
    t.fetchPlayerInfo (uid, function (r) {t.gotPlayerDetail(r, span)});
  },
  clickedPlayerLeaderboard : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = lang.Search.PLeaderboard;
    t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard(r, span)});
  }, 
  gotPlayerLeaderboard : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    if (rslt.totalResults == 0){
      span.innerHTML = lang.Search.PLb2;
      return;
    }
    var p = rslt.results[0];
    var an = p.allianceName;
    if (!an || an=='' || p.officerType==4)
      an = lang.Search.ANothing;
    else
      an += ' ('+ officerId2String(p.officerType) +')';
    m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>'+uW.g_js_strings.commonstr.leaderboard+' : </b></td><TD colspan=2> '+uW.g_js_strings.commonstr.might+' : '+ p.might  +' &nbsp; '+uW.g_js_strings.commonstr.alliance+' : '+ an +'</td></tr>'; 
    for (var i=0; i<p.cities.length; i++){
      var c = p.cities[i];
      m += '<TR><TD align=right><B>'+uW.g_js_strings.commonstr.city+' #'+ (i+1) +':</b></td><TD> &nbsp; '+ c.cityName 
      +' <a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ c.xCoord +',' +c.yCoord+ ')</a></td><TD width=75%> &nbsp; Niveau : '
      + c.tileLevel +' &nbsp; &nbsp; status: '+ cityStatusString (c.cityStatus) +' &nbsp; &nbsp; cr&eacute;de : ' + c.dateCreated.substr(0,10) +'</td></tr>';
    }  
    span.innerHTML = m + '</table>';
  },
  gotPlayerDetail : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    var u = rslt.userInfo[0];
    var a = lang.Search.ANothing;
    if (u.allianceName)
      a = u.allianceName +' ('+ getDiplomacy(u.allianceId) + ')';
    var m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>'+lang.Search.detail+'</b> &nbsp; </td><TD>'+uW.g_js_strings.commonstr.alliance+' : '+ a +' &nbsp; '+uW.g_js_strings.commonstr.cities+' : '
          + u.cities +' &nbsp; '+uW.g_js_strings.commonstr.population+' : '+ u.population +'</td></tr><TR><TD></td><TD>'+uW.g_js_strings.commonstr.province+' : ';
    var pids = u.provinceIds.split (',');
    var p = [];
    for (var i=0; i<pids.length; i++)
      p.push(unsafeWindow.provincenames['p'+pids[i]]);
    span.innerHTML = m + p.join (', ') +'</td></tr></table>';
  },

  aName : '',
  eventSubmit : function (){
    var t = Tabs.AllianceList;
    ById('ptallErr').innerHTML='';
    t.aName = ById('allAllName').value;
    if (t.aName.length < 3){
      ById('ptallErr').innerHTML = uW.g_js_strings.getAllianceSearchResults.entryatleast3;
      return;
    }
    var myA = getMyAlliance ();
    ById('altInput').innerHTML = '';
    ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'...</center>';
    if (myA[0]!=0 && myA[1].toLowerCase().indexOf(t.aName.toLowerCase())>=0 )
      t.fetchAllianceList (t.aName, myA[0], t.eventGotAllianceList);
    else
      t.fetchAllianceList (t.aName, null, t.eventGotAllianceList);
  },
  init : function (div){
    var t = Tabs.Search;
    this.cont = div;
    uW.BoPTpd = t.clickedPlayerDetail;
    uW.BoPTpd2 = t.clickedPlayerLeaderboard;
    uW.BoPCpo2 = t.clickedPlayerCheckOnline;
    uW.BoPCplo2 = t.clickedPlayerGetLastLogin;
    uW.BOGetThrone = t.clickedPlayerGetThrone;
    var Provinces={1:{name:uW.provincenames["p1"],x:75,y:75},2:{name:uW.provincenames["p2"],x:225,y:75},3:{name:uW.provincenames["p3"],x:375,y:75},4:{name:uW.provincenames["p4"],x:525,y:75},5:{name:uW.provincenames["p5"],x:625,y:75},6:{name:"Paimpont",x:75,y:225},7:{name:"Caméliard",x:225,y:225},8:{name:"Sarras",x:375,y:225},9:{name:"Canoel",x:525,y:225},10:{name:"Avalon",x:625,y:225},11:{name:"Carmathen",x:75,y:375},12:{name:"Shallot",x:225,y:375},13:{name:"-------",x:375,y:375},14:{name:uW.provincenames["p13"],x:525,y:375},15:{name:uW.provincenames["p14"],x:625,y:375},16:{name:uW.provincenames["p15"],x:75,y:525},17:{name:uW.provincenames["p16"],x:225,y:525},18:{name:uW.provincenames["p17"],x:375,y:525},19:{name:uW.provincenames["p18"],x:525,y:525},20:{name:uW.provincenames["p19"],x:625,y:525},21:{name:uW.provincenames["p20"],x:75,y:675},22:{name:uW.provincenames["p21"],x:225,y:675},23:{name:uW.provincenames["p22"],x:375,y:675},24:{name:uW.provincenames["p23"],x:525,y:675},25:{name:uW.provincenames["p24"],x:625,y:675}}
    if (t.state == null){
      this.cont.innerHTML = '\
        <DIV class=ptentry><table><tr valign=bottom><TD class=xtab width=100 align=right>Type : </td><TD>\
        <SELECT id="srcType">\
          <OPTION value=0>'+uW.g_js_strings.commonstr.barbariancamp+'</option>\
          <OPTION value=1>'+uW.g_js_strings.commonstr.wilderness+'</option>\
	  <OPTION value=2>'+uW.g_js_strings.commonstr.city+'</option>\
	  <OPTION value=3>'+uW.g_js_strings.commonstr.darkForest+'</option>\
        </select></td></tr>\
        </table>\
        <DIV id="srcOpts" style="height:80px"></div></div>\
        <DIV id="srcResults" style="height:400px; max-height:400px;"></div>';
      var psearch = document.getElementById ("pasrcType");
      m = '<TABLE><TR valign=middle><TD class=xtab width=100 align=right>&nbsp; X: </td><TD class=xtab>\
        <INPUT id="srchX" type=text size=3\> &nbsp; Y: <INPUT id="srchY" type=text size=3\>';
      m += '&nbsp;<span><select id="BOprovinceXY"><option>--'+uW.g_js_strings.commonstr.province+'--</option>';
      for (var i in Provinces) {
	    m += '<option value="'+i+'">'+Provinces[i].name+'</option>';
      }
      m += '</select></span> &nbsp; <SPAN id=spInXY></span>';
	  m += '</td></tr><TR><TD class=xtab align=right>'+uW.g_js_strings.commonstr.distance+' : </td><TD class=xtab>'+lang.Search.between+' <INPUT id=srcaDist size=4 value=0 /> '+lang.Search.and+' <INPUT id=srcDist size=4 value=10 /></td></tr>';
      m += '<TR><TD class=xtab></td><TD class=xtab><INPUT id=srcStart type=submit value="'+uW.g_js_strings.commonstr.research+'"/></td></tr>';
      m += '</table>';
      document.getElementById ('srcOpts').innerHTML = m;
      var citysrc0=new CdispCityPicker ('srchdcp', document.getElementById ('spInXY'), false, t.clickCitySourceSelect, Cities.byID[unsafeWindow.currentcityid].idx);
      if (Options.srcTypeSelect) 
       document.getElementById ('srcType').value=Options.srcTypeSelect;
      if (Options.srcaDist) 
       document.getElementById ('srcaDist').value=Options.srcaDist;
      if (Options.srcDist) 
       document.getElementById ('srcDist').value=Options.srcDist;    
      document.getElementById ('srcType').addEventListener ('change', function() {
        Options.srcTypeSelect = document.getElementById ('srcType').value;
        saveOptions();
      }, false); 
      document.getElementById ('srcaDist').addEventListener ('change', function() {
              Options.srcaDist = document.getElementById ('srcaDist').value;
              saveOptions();
      }, false); 
      document.getElementById ('srcDist').addEventListener ('change', function() {
              Options.srcDist = document.getElementById ('srcDist').value;
              saveOptions();
      }, false); 
      document.getElementById ('BOprovinceXY').addEventListener ('change', function() {
	  if (this.value >= 1) {
	      document.getElementById ('srchX').value = Provinces[this.value].x;
		document.getElementById ('srchY').value = Provinces[this.value].y;
		  document.getElementById ('srcDist').value = "75";
	  }
	  }, false); 
      document.getElementById ('srcStart').addEventListener ('click', t.clickedSearch, false);
      t.state = 1;
    }
  },
  clickCitySourceSelect : function (city){
    var t = Tabs.Search;
    t.sourceCity = city;
    document.getElementById ('srchX').value=t.sourceCity.x;
    document.getElementById ('srchY').value=t.sourceCity.y;
  },
  opt : {},
  searchRunning : false,
  tilesSearched : 0,
  tilesFound : 0,
  curX : 0,
  curY : 0,
  lastX : 0,
  firstX : 0,
  firstY : 0,
  lastY : 0,
  normalizeCoord : function (x){
    if ( x >= 750)
      x -= 750;
    else if (x < 0)
      x += 750;
    return parseInt (x/5) * 5;
  },
  clickedSearch : function (){
    var t = Tabs.Search;
    if (t.searchRunning){
      t.stopSearch (lang.Search.cancel);
      return;
    }
    t.opt.searchType = ById('srcType').value;
    t.opt.startX = parseInt(ById('srchX').value);
    t.opt.startY = parseInt(ById('srchY').value);
    t.opt.maxDistance = parseInt(ById('srcDist').value);
    t.opt.maxDistanceA = parseInt(ById('srcaDist').value);
    errMsg = '';
    if (isNaN (t.opt.startX) ||t.opt.startX<0 || t.opt.startX>749)
      errMsg = lang.Search.err1+"<BR>";
    if (isNaN (t.opt.startY) ||t.opt.startY<0 || t.opt.startY>749)
      errMsg += lang.Search.err2+"<BR>";
    if (isNaN (t.opt.maxDistanceA) ||t.opt.maxDistanceA<0)
     errMsg += lang.Search.err3+"<BR>";
    if (isNaN (t.opt.maxDistance) ||t.opt.maxDistance<1)
      errMsg += lang.Search.err4+"<BR>";
    if (t.opt.maxDistance<=t.opt.maxDistanceA)
      errMsg += lang.Search.err5+"<BR>";
    if(t.opt.maxDistanceA > 375)
       errMsg += lang.Search.err1+"<BR>";
    if (errMsg != ''){
      ById('srcResults').innerHTML = '<FONT COLOR=#660000>'+lang.Search.error+' :</font><BR><BR>'+ errMsg;
      return;
    }

    t.searchRunning = true;
    ById('srcStart').value = lang.Search.stop;
    m = '<DIV class=boStat><TABLE width=100% cellspacing=0><TR><TD class=xtab width=125><DIV id=statSearched></div></td>\
        <TD class=xtab align=center><SPAN id=statStatus></span></td>\
        <TD class=xtab align=right width=125><DIV id=statFound></div></td></tr></table></div>\
      <TABLE width=100%><TR valign=top><TD><DIV id=divOutTab style="height:'+(Options.HauteurBoite-230)+'px; max-height:'+(Options.HauteurBoite-230)+'px; overflow-y:auto; width:420px;"></div></td>\
      <TD id="tddivOutOpts" width=100% height=100% style="background:#e0e0f0; height:100%; padding:5px"><DIV id=divOutOpts></div></td></tr><tr><td colspan=2><div id=BOdivKOCAttackExport style="position:absolute;background-color:white;height:470px; max-height:470px; overflow-y:auto; width:600px;display:none"></div></td><input type=checkbox id=ShowHideOpts>'+lang.Search.ShowHideOpts+'</tr></table>';
    ById('srcResults').innerHTML = m;
    ById('ShowHideOpts').addEventListener ('click', function (){
		  if (ById("ShowHideOpts").checked) {
		  ById("tddivOutOpts").style.display="none";
		  ById("divOutTab").style.width="100%";
		  } else {
		  ById("tddivOutOpts").style.display="block";
		  ById("divOutTab").style.width="420px";
		  }
	  }, false);
     
    if (t.opt.searchType == 0)
      typeName = uW.g_js_strings.commonstr.barbarians;
    else if (t.opt.searchType == 1)
      typeName = uW.g_js_strings.commonstr.wilderness;
    else if (t.opt.searchType == 3)
      typeName = uW.g_js_strings.commonstr.darkForest;
	else 
	  typeName = uW.g_js_strings.commonstr.cities;

    m = '<CENTER><B>'+uW.g_js_strings.commonstr.research+' : '+ typeName +'<BR>\
        '+lang.Search.center+' : '+ t.opt.startX +','+ t.opt.startY +'  &nbsp; '+uW.g_js_strings.commonstr.distance+' : '+ t.opt.maxDistanceA +' -> '+ t.opt.maxDistance +'<BR></center>\
        <DIV class=ptentry><TABLE cellspacing=0 width=100%><TR align=center><TD class=xtab colspan=10><B>OPTIONS :</b><BR></td></tr>';
    if (t.opt.searchType == 1 || t.opt.searchType == 0 || t.opt.searchType == 3) {
     m += '<TR><TD class=xtab align=right>'+lang.Search.minlevel+'</td><TD class=xtab> <INPUT id=filMinLvl size=2 value='+ Options.srcMinLevel +' /></td></tr>\
        <TR><TD class=xtab align=right>'+lang.Search.maxlevel+'</td><TD class=xtab> <INPUT id=filMaxLvl size=2 value='+ Options.srcMaxLevel +' /></td></tr>';
	}
    if (t.opt.searchType == 1){
      m += '<TR><TD class=xtab align=right>'+lang.Search.typewilderness+':</td><TD class=xtab align=right>'+uW.g_js_strings.commonstr.woods+'<INPUT id=woodWild type=CHECKBOX'+ (Options.woodWild?' CHECKED':'') +'></td></tr>';
      m += '<TR><TD class=xtab align=right>'+uW.g_js_strings.commonstr.grassland+'/'+uW.g_js_strings.commonstr.lake+'<INPUT  id=foodWild type=CHECKBOX '+ (Options.foodWild?' CHECKED':'') +'></td>\
	       <TD class=xtab align=right>'+uW.g_js_strings.commonstr.mountain+'<INPUT id=mtnWild type=CHECKBOX '+ (Options.mtnWild?' CHECKED':'') +'></td></tr>';
      m += '<TR><TD class=xtab align=right>'+uW.g_js_strings.commonstr.plain+'<INPUT id=plnWild type=CHECKBOX '+ (Options.plnWild?' CHECKED':'') +'></td>\
           <TD class=xtab align=right>'+uW.g_js_strings.commonstr.hills+'<INPUT id=hillWild type=CHECKBOX'+ (Options.hillWild?' CHECKED':'') +'></td></tr>';
      m += '<TR><TD class=xtab align=right>'+lang.Search.filter+':</td><TD class=xtab><SELECT style="width: 135px" id=idTSSrchFilter>\
             <OPTION value=0>'+lang.Search.TS0+'</option><OPTION value=1>'+lang.Search.TS1+'</option><OPTION value=2>'+lang.Search.TS2+'</option><OPTION value=3>'+lang.Search.TS3+'</option><OPTION value=4>'+lang.Search.TS4+'</option></select></td></tr>';
    } 
    if (t.opt.searchType == 1 || t.opt.searchType == 0 || t.opt.searchType == 3 ) {
        m+= '<TR><TD class=xtab align=right>'+lang.Search.orderby+':</td><TD class=xtab><SELECT id=filSortBy>\
          <OPTION value="level" '+ (Options.srcSortBy=='level'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.level+'</option>\
          <OPTION value="dist" '+ (Options.srcSortBy=='dist'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.distance+'</option>';
          if (t.opt.searchType == 1) {
                m+= '<OPTION value="play" '+ (Options.srcSortBy=='play'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.player+'</option>';
                m+= '<OPTION value="alli" '+ (Options.srcSortBy=='alli'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.alliance+'</option>';
            }    
		  m+= '</select></td></tr>\
			<TR><TD class=xtab align=right>'+lang.Search.coords+':</td><TD class=xtab><INPUT type=checkbox id=coordsOnly \></td></tr>\
			</table></div><BR><SPAN id=srchSizeWarn></span><DIV id=BOpbSrcExp></div>';
    } else {
			
		m+= '<TR><TD class=xtab align=right >Voir :</td><TD class=xtab align=left ><SELECT style="width: 135px" id=idSrchFilter>\
             <OPTION value=0>'+lang.Search.Cit0+'</option>\
             <OPTION value=1>'+lang.Search.Cit1+'</option>\
	     <OPTION value=2>'+lang.Search.Cit2+'</option>\
	     <OPTION value=3>'+lang.Search.Cit3+'</option>\
	     <OPTION value=4>'+lang.Search.Cit4+'</option>\
	     <OPTION value=5>'+lang.Search.Cit5+'</option>\
	     <OPTION value=6>'+lang.Search.Cit6+'</option>\
             </select></td></tr>';
	
		m+= '<TR><TD class=xtab align=right>'+lang.Search.orderby+':</td><TD class=xtab><SELECT id=filSortBy>\
          <OPTION value="might" '+ (Options.srcSortBy=='might'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.might+'</option>\
          <OPTION value="dist" '+ (Options.srcSortBy=='dist'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.distance+'</option>\
                  <OPTION value="play" '+ (Options.srcSortBy=='play'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.player+'</option>\
        <OPTION value="alli" '+ (Options.srcSortBy=='alli'?'SELECTED':'')  +'>'+uW.g_js_strings.commonstr.alliance+'</option>\
        </select></td></tr>\
        <tr><TD class=xtab align=right>'+uW.g_js_strings.commonstr.might+' min :</td><TD class=xtab><input size=8 id=filPuissance value="'+Options.filPuissance+'"></td></tr>\
         <tr><TD class=xtab align=right>'+uW.g_js_strings.commonstr.might+' max :</td><TD class=xtab><select id=filPuissanceMax>\
         <option value="500" '+ (Options.filPuissanceMax=='500'?'SELECTED':'')  +'>500</option>\
         <option value="2500" '+ (Options.filPuissanceMax=='2500'?'SELECTED':'')  +'>2 500</option>\
         <option value="10000" '+ (Options.filPuissanceMax=='10000'?'SELECTED':'')  +'>10 000</option>\
         <option value="50000" '+ (Options.filPuissanceMax=='50000'?'SELECTED':'')  +'>50 000</option>\
         <option value="100000" '+ (Options.filPuissanceMax=='100000'?'SELECTED':'')  +'>100 000</option>\
         <option value="500000" '+ (Options.filPuissanceMax=='100000'?'SELECTED':'')  +'>500 000</option>\
         <option value="1000000" '+ (Options.filPuissanceMax=='1000000'?'SELECTED':'')  +'>1 000 000</option>\
         <option value="100000000" '+ (Options.filPuissanceMax=='100000000'?'SELECTED':'')  +'>100m</option>\
         <option value="900000000" '+ (Options.filPuissanceMax=='900000000'?'SELECTED':'')  +'>900m</option>\</select></td></tr>\
        <TR><TD class=xtab align=right>'+lang.Search.coords+':</td><TD class=xtab><INPUT type=checkbox id=coordsOnly \></td></tr>\
         </table></div><BR><SPAN id=srchSizeWarn></span><BR><SPAN id=srchSizeWarn></span><DIV id=BOpbSrcExp></div>';	
	}
    ById('divOutOpts').innerHTML = m;
    if (t.opt.searchType == 1 || t.opt.searchType == 0 || t.opt.searchType == 3) {
		ById('filMinLvl').addEventListener ('change', function (){
		  Options.srcMinLevel = ById('filMinLvl').value;
		  saveOptions();
		  t.dispMapTable ();
		  }, false);
		ById('filMaxLvl').addEventListener ('change', function (){
		  Options.srcMaxLevel = ById('filMaxLvl').value;
		  saveOptions();
		  t.dispMapTable ();
		  }, false);
	 }
    ById('filSortBy').addEventListener ('change', function (){
      Options.srcSortBy = ById('filSortBy').value;
      saveOptions();
      t.dispMapTable ();
      }, false);
    ById('coordsOnly').addEventListener ('change', function (){ t.dispMapTable (); }, false);
    if (t.opt.searchType == 1){
    ById('foodWild').addEventListener ('change', function(){
        Options.foodWild = ById('foodWild').checked;
        saveOptions();
        t.dispMapTable ();
        }, false);
    ById('hillWild').addEventListener ('change', function(){
        Options.hillWild = ById('hillWild').checked;
        saveOptions();
        t.dispMapTable();
        }, false);
    ById('mtnWild').addEventListener ('change', function(){
        Options.mtnWild = ById('mtnWild').checked;
        saveOptions();
        t.dispMapTable();
        }, false);
    ById('plnWild').addEventListener ('change', function(){
        Options.plnWild = ById('plnWild').checked;
        saveOptions();
        t.dispMapTable();
        }, false);
    ById('woodWild').addEventListener ('change', function(){
        Options.woodWild = ById('woodWild').checked;
        saveOptions();
        t.dispMapTable ();
        }, false);
   
      ById('idTSSrchFilter').addEventListener ('change', function (){
             Options.TSSrchFilter = (ById('idTSSrchFilter').value);
              saveOptions();
              t.dispMapTable ();
        }, false);
        ById('idTSSrchFilter').value = Options.TSSrchFilter;
    }
    if (t.opt.searchType == 2){

	ById('idSrchFilter').addEventListener ('change', function (){
        Options.citySrchFilter = (ById('idSrchFilter').value);
        saveOptions();
        t.dispMapTable ();
        }, false);

	ById('idSrchFilter').value = Options.citySrchFilter;
	
       
        ById('filPuissance').addEventListener ('change', function (){
        Options.filPuissance = parseInt(ById('filPuissance').value);
        saveOptions();
        t.dispMapTable ();
        }, false);
        ById('filPuissanceMax').addEventListener ('change', function (){
        Options.filPuissanceMax = parseInt(ById('filPuissanceMax').value);
        saveOptions();
        t.dispMapTable ();
        }, false);
	
	}

    t.mapDat = [];
    t.firstX =  t.opt.startX - t.opt.maxDistance;
    t.lastX = t.opt.startX + t.opt.maxDistance;
    t.firstY =  t.opt.startY - t.opt.maxDistance;
    t.lastY = t.opt.startY + t.opt.maxDistance;
    t.tilesSearched = 0;
    t.tilesFound = 0;
    t.curX = t.firstX;
    t.curY = t.firstY;
    var xxx = t.normalizeCoord(t.curX);
    var yyy = t.normalizeCoord(t.curY);
    document.getElementById ('statStatus').innerHTML = uW.g_js_strings.commonstr.research+' : '+ xxx +','+ yyy;
    setTimeout (function(){Map.request (xxx, yyy, 40, t.mapCallback)}, MAP_DELAY);
  },

  dispMapTable : function (){
    var t = Tabs.Search;
    function mySort(a, b){
      if (Options.srcSortBy == 'level'){
        if ((x = a[4] - b[4]) != 0)
          return x;
      }
	  if (Options.srcSortBy == 'might'){
        if ((x = b[10] - a[10]) != 0)
          return x;
      }
      if (Options.srcSortBy == 'alli'){
          
          if (a[11] < b[11]) return -1;
	      else if (a[11] == b[11]) return 0;
	       else return 1;
          
      }
        if (Options.srcSortBy == 'play'){
         
          if (a[9] < b[9]) return -1;
	      else if (a[9] == b[9]) return 0;
	       else return 1;
          
      }
      return a[2] - b[2];
    }

    dat = [];
    for (i=0; i<t.mapDat.length; i++){
      lvl = parseInt (t.mapDat[i][4]);
      type = t.mapDat[i][3];
      puissance = t.mapDat[i][10];
      if (t.opt.searchType == 2 && type == 7 ) {
	  
	  switch(parseInt (Options.citySrchFilter)) {
                case 0:
                 if (Options.filPuissance<=puissance && puissance<=Options.filPuissanceMax) {
                  dat.push(t.mapDat[i]);
                 }
                 break;
                case 1:
                   if ((t.mapDat[i][12] == 'hostile') && (Options.filPuissance<=puissance && puissance<=Options.filPuissanceMax)) {
                    dat.push(t.mapDat[i]);
                   }
                   break;
                case 2:
                   if ((t.mapDat[i][5]===true) && (Options.filPuissance<=puissance && puissance<=Options.filPuissanceMax)) {
                    dat.push(t.mapDat[i]);
                   }
                   break;
                case 3:
                   if ((t.mapDat[i][12] == 'allie') && (Options.filPuissance<=puissance && puissance<=Options.filPuissanceMax)) {
                    dat.push(t.mapDat[i]);
                   }
                   break;
                case 4:
                   if ((t.mapDat[i][12] == 'amicale') && (Options.filPuissance<=puissance && puissance<=Options.filPuissanceMax)) {
                    dat.push(t.mapDat[i]);
                   }
                   break;
                case 5:
                   if ((t.mapDat[i][12] == 'neutre') && (Options.filPuissance<=puissance && puissance<=Options.filPuissanceMax)) {
                    dat.push(t.mapDat[i]);
                   }
                   break;
                 case 6:
                   if ((t.mapDat[i][12] == 'unaligned') && (Options.filPuissance<=puissance && puissance<=Options.filPuissanceMax)) {
                    dat.push(t.mapDat[i]);
                   }
                   break;
             }

		
	  } else {
       if (lvl>=Options.srcMinLevel && lvl<=Options.srcMaxLevel){
        
        if ((t.opt.searchType==3 && (type == 8 || type == 9 || type == 10 || type == 11 || type == 12 || type == 13 || type == 14 || type == 15)) || t.opt.searchType==0
            || (Options.woodWild==1 && type == 3)
            || (Options.hillWild==1 && type ==4)
            || (Options.mtnWild==1 && type==5)
            || (Options.plnWild==1 && type == 6)
            || (Options.foodWild==1 && (type==1 || type==2)))
          if (Options.TSSrchFilter==0)
            dat.push (t.mapDat[i]);
          else if (Options.TSSrchFilter==1 && t.mapDat[i][5]===false)
            dat.push (t.mapDat[i]);
          else if (Options.TSSrchFilter==2 && t.mapDat[i][12] =='hostile')
            dat.push (t.mapDat[i]);  
          else if (Options.TSSrchFilter==3 && t.mapDat[i][12] =='neutre')
            dat.push (t.mapDat[i]);
          else if (Options.TSSrchFilter==4 && t.mapDat[i][12] =='unaligned')
            dat.push (t.mapDat[i]);
        }
       }
    }
    
    ById('statFound').innerHTML = lang.Search.find+' '+ dat.length;
    if (dat.length == 0){
      m = '<BR><CENTER>'+lang.Search.nofind+'</center>';
    } else {
      dat.sort(mySort);
      if (ById("coordsOnly").checked)
        m = '<TABLE align=center id=srcOutTab cellpadding=0 cellspacing=0><TR style="font-weight: bold"><TD>'+uW.g_js_strings.commonstr.location+'</td></tr>';
      else {
        if (t.opt.searchType == 0 || t.opt.searchType == 3) {
			m = '<TABLE id=srcOutTab cellpadding=0 cellspacing=0><TR style="font-weight: bold"><TD>'+uW.g_js_strings.commonstr.location+'</td><TD style="padding-left: 10px">'+lang.Search.distance+'</td><TD style="padding-left: 10px;">'+lang.Search.level+'</td><TD style="padding-left: 10px;">Type</td></tr>';
		}
		if (t.opt.searchType == 1 ) {
			m = '<TABLE id=srcOutTab cellpadding=2 cellspacing=2><TR style="font-weight: bold"><TD>'+uW.g_js_strings.commonstr.location+'</td><TD style="padding-left: 10px">'+lang.Search.distance+'</td><TD style="padding-left: 10px;">'+lang.Search.level+'</td><TD style="padding-left: 10px;">Type</td><TD style="padding-left: 10px;">'+uW.g_js_strings.commonstr.player+'</td><td style="padding-left: 10px;">'+uW.g_js_strings.commonstr.might+'</td><td style="padding-left: 10px;">'+uW.g_js_strings.commonstr.alliance+'</td><td>'+lang.Search.status+'</td><td>'+lang.Search.connexion+'</td></tr>';
		}
		if (t.opt.searchType == 2) {
			 m = '<TABLE id=srcOutTab cellpadding=2 cellspacing=2><TR style="font-weight: bold"><TD>'+uW.g_js_strings.commonstr.location+'</td><TD >'+lang.Search.distance+'</td><TD>'+uW.g_js_strings.commonstr.city+'</td><TD>Proprio</td><TD>'+uW.g_js_strings.commonstr.level+'</td><TD>Puis.</td><td>'+uW.g_js_strings.commonstr.alliance+'</td><TD width=50% style="font-size:9px;">'+lang.Search.more+'</td><td width=30%>&nbsp;</td></tr>';
		}
	
	  }
	  var numRows = dat.length;
      if (numRows > 500 && t.searchRunning){
        numRows = 500;
        ById('srchSizeWarn').innerHTML = lang.Search.notetable+' '+ dat.length +' ' + lang.Search.notetable1;
      }
      for (i=0; i<numRows; i++){
        m += '<TR valign="top"';
		if (dat[i][12]) m += 'class="'+dat[i][12]+'"';
		
		if (ById("coordsOnly").checked){
		   m += ' ><TD valign="top"><DIV>'+ dat[i][0] +','+ dat[i][1] +'</div></td></tr>';
        } else {
           m += ' ><TD valign="top"><DIV>\
	             <a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ dat[i][0] +','+ dat[i][1] +')</a></div></td>';
   		  if (t.opt.searchType == 2) { 
			m += '<TD align="left"  valign="top"><DIV  onclick="PTscout('+ dat[i][0] +','+ dat[i][1] +');return false;"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/scouting.jpg" title="Scout">&nbsp;'+ dat[i][2].toFixed(2) +'</a></td><TD align=left>'+ dat[i][8] +'</td><TD valign="top">'+dat[i][9]+'</td><td>'+dat[i][4]+'</td><TD valign="top">'+addCommasInt(dat[i][10])+'</td><td>'+dat[i][11]+'</td><td>';
			if (dat[i][5]) {
			 m += '<DIV onclick="BoPTscout('+ dat[i][0] +','+ dat[i][1] +');return false;"><A style="font-size:9px;" >'+uW.g_js_strings.commonstr.scouting+'</a></div>';
			} else {
			 m += '<DIV onclick="BoPTpd(this, '+ dat[i][7] +')"><A style="font-size:9px;" >Details</a></div> <DIV style="" onclick="BoPTpd2(this, '+ dat[i][7] +')"><A style="font-size:9px;">'+uW.g_js_strings.commonstr.leaderboard+'</a></div>\
			 		<DIV style="" onclick="BoPCpo2(this, '+ dat[i][7] +')"><A style="font-size:9px;">'+uW.g_js_strings.commonstr.status+'</a></div>\
					<DIV style="" onclick="BoPCplo2(this, '+ dat[i][7] +')"><A style="font-size:9px;">'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+'</a></div>';
             m+= '</td><td><DIV style="" onclick="BOGetThrone(this, '+ dat[i][7] +')"><A style="font-size:9px;">'+uW.g_js_strings.commonstr.throneroom+'</a></div>';
             
             
             m+= '</tr>';
            }
            
            m+='';
		  } else {
           m += '<TD align=right  valign="top">'+ dat[i][2].toFixed(2) +' &nbsp; </td><TD align=right>'+ dat[i][4] +'</td><TD> &nbsp; '+ tileNames[dat[i][3]];
             +'</td>';
           if (t.opt.searchType == 1) {
            if (dat[i][5]) {
             m += '<td>'+dat[i][9]+'<td>'+addCommasInt(dat[i][10])+'</td><td>'+dat[i][11]+'</td>';
             
             if (dat[i][7] && dat[i][7]!=0) {
             m+='<td><DIV style="" onclick="BoPCpo2(this, '+ dat[i][7] +')"><A style="font-size:9px;">'+uW.g_js_strings.commonstr.status+'</a></div></td><td><DIV style="" onclick="BoPCplo2(this, '+ dat[i][7] +')"><A style="font-size:9px;">'+uW.g_js_strings.modal_messages_viewreports.lastlogin+'</a></div></td>';
             } else {
             m+='<td>&nbsp;</td><td>&nbsp;</td>';
             }
             
            
            } else  {
             m +='<td colspan=5 style="text-align=center"><i><b>'+lang.Search.free+'</b></i>';
            }
		   }else{
            m+="<td></td>";
           }
            m +='</tr>';
		  }
		}
       }
      m += '</table>';
    }
    ById('divOutTab').innerHTML = m;
    dat = null;
  },

  mapDat : [],

  stopSearch : function (msg){
    var t = Tabs.Search;
    document.getElementById ('statStatus').innerHTML = '<FONT color=#ffaaaa>'+ msg +'</font>';
    document.getElementById ('srcStart').value = uW.g_js_strings.commonstr.research;
    ById('srchSizeWarn').innerHTML = '';
    if (t.opt.searchType==0){    
      ById('BOpbSrcExp').innerHTML = '<CENTER>'+ strButton20(lang.Search.exportKOCattack, 'id=BOpbSrcDoExp') +'</center>'; 
      document.getElementById ('BOpbSrcDoExp').addEventListener ('click', t.exportKOCattack, false);
    }
    if (t.opt.searchType==3){
    	  document.getElementById ('BOpbSrcExp').innerHTML = '<CENTER>'+ strButton20(lang.Search.generateFSList, 'id=BOSrcDoFS') +'</center>';
          document.getElementById ('BOSrcDoFS').addEventListener ('click', t.generateFSList, false);
    }
    if (t.opt.searchType==2){
    	  document.getElementById ('BOpbSrcExp').innerHTML = '<CENTER>'+ strButton20(lang.Search.generateScoutList, 'id=pbSrcDoScout') +'</center>';
          document.getElementById ('pbSrcDoScout').addEventListener ('click', t.generateScoutList, false);
	}
    t.searchRunning = false;
  },
  generateFSList :function ()
  {
      var t = Tabs.Search;
      var bulkFS = [];
      for (i=0; i<t.mapDat.length; i++){
         bulkFS.push({x:t.mapDat[i][0], y:t.mapDat[i][1], dist:t.mapDat[i][2], lvl:parseInt(t.mapDat[i][4])});
      }
      bulkFS = bulkFS.sort(function sort(a,b) {a = parseInt(a['dist']);b = parseInt(b['dist']);return a == b ? 0 : (a < b ? -1 : 1);}); 
      if(t.selectedCity == null)
  		t.selectedCity = Cities.cities[0];
      t.ShowFSList (bulkFS, t.selectedCity);
   
  },
 ShowFSList:function (coordlist, city) {
   var t = Tabs.Search;
   t.FScity = city;
   if(t.popFS==null){
	  t.popFS = new CPopup ('BOsrcFS', 0,0, 380,600, true, function (){t.popFS.destroy(); t.popFS=null;});
          t.popFS.centerMe (mainPop.getMainDiv());  
    }
    	var m = '<DIV class=boStat>'+uW.g_js_strings.commonstr.darkForest+'</div><div>'+uW.g_js_strings.commonstr.level+': <select id=BOsrcFSLevel><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option></select>&nbsp<input type=button id=BOsrcFSSave value="'+uW.g_js_strings.commonstr.save+'"><br>';
    	for (r=1; r<13; r++){
	    m += '<DIV style="float:left;"><img height=20 title="'+uW.unitcost['unt'+r][0]+'" src=http://kabam1-a.akamaihd.net/kingdomsofcamelot/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg>&nbsp;<input style="border:1px solid black;height:16px;font-size:11px;" id="BOFsUnits'+r+'" type=text size=7 value="0"></DIV>';
      	}
    	m += '</div><br><br><br><br><br><br><DIV>'+uW.g_js_strings.commonstr.city+' : <span id=BOsrcFScitypick> </span></div><BR>';
    	m += '<DIV class=boStat>'+uW.g_js_strings.commonstr.from+' <span id=BOsrcFScity>'+city.name+'</span> <BR> '+lang.Search.numberCible+': '+coordlist.length+'</div>';
    	m += '<DIV style="max-height:220px; overflow-y:auto;"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class=pbTabPadNW><TR style="font-weight:bold; background-color:white"><TD width=15><input type=checkbox id=pbsrcScout_All /></td><TD>Coords</td><td><select id=pbsrcScout_lvl><option value="">Niveau</option><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option></select></td><td>'+uW.g_js_strings.commonstr.distance+'</td></tr>';
    	  for(i=0; i<coordlist.length; i++){
    			m += '<TR style="background-color:white"><TD><input type=checkbox name="pbsrcFSCheck" id="pbsrcScoutCheck_'+coordlist[i].x+'_'+coordlist[i].y+'_'+coordlist[i].lvl+'" value="'+coordlist[i].x+'_'+coordlist[i].y+'_'+coordlist[i].lvl+'" /></td><TD>'+coordlist[i].x+ ','+coordlist[i].y+'</td><td>'+coordlist[i].lvl+'</td><td>'+coordlist[i].dist+'</td></tr>';
    	  }
    	m += '</table></div>';
    	m += '<BR><CENTER>'+ strButton20(lang.Search.startattack, 'id=pbSrcStartScout') +'</center>';
    	m += '<CENTER><DIV style="width:100%; height:100px;max-height:100px; overflow-y:auto;" id=pbSrcScoutResult></DIV></center>';
	

	t.popFS.getMainDiv().innerHTML = m;
	new CdispCityPicker ('BOFSPick', ById('BOsrcFScitypick'), false, function(c,x,y){ById('BOsrcFScity').innerHTML = c.name; t.attackcity = c; }, city.idx);
	
	t.popFS.show(true);
	
	ById('BOsrcFSSave').addEventListener('click', t.enregistrerscrLevel, false);
	ById('BOsrcFSLevel').addEventListener('click', t.changescrLevel, false);
	ById('pbsrcScout_All').addEventListener('change', function(){
			for(k in document.getElementsByName('pbsrcFSCheck'))
				document.getElementsByName('pbsrcFSCheck')[k].checked = ById('pbsrcScout_All').checked;
	}, false);
	ById('pbsrcScout_lvl').addEventListener('change', function(){
			if (ById('pbsrcScout_lvl').value!="") {
				for(k in document.getElementsByName('pbsrcFSCheck')) {
				 var lvl = document.getElementsByName('pbsrcFSCheck')[k].value;
				 if (lvl!==undefined) {
				  var lvll = lvl.split("_");
			          if (lvll[2]==ById('pbsrcScout_lvl').value){
					document.getElementsByName('pbsrcFSCheck')[k].checked = true;
				  }
				 }
			        }
			}
	}, false);
	
	
	
	ById('pbSrcStartScout').addEventListener('click', t.clickedStartFSAttack, false);
	
	t.changescrLevel();
 },
 changescrLevel: function() {
  var t = Tabs.Search;
  if (Options.AttackFSUnits[ById('BOsrcFSLevel').value]!==undefined) {
     for (r=1; r<13; r++){
      ById('BOFsUnits'+r).value=Options.AttackFSUnits[ById('BOsrcFSLevel').value][r];
     } 
   }
 },
 enregistrerscrLevel: function() {
   var t = Tabs.Search;
   Options.AttackFSUnits[ById('BOsrcFSLevel').value]=[];
   for (r=1; r<13; r++){
      Options.AttackFSUnits[ById('BOsrcFSLevel').value][r] = ById('BOFsUnits'+r).value;  
   } 
   saveOptions ();
   t.changescrLevel();
 },
 attacking : false,
 attackcity : null,
 doFSAttack: function(list, city){
  var t = Tabs.Search;
 	ById('pbSrcScoutResult').innerHTML = '';
 	if(list.length < 1){
 		ById('pbSrcScoutResult').innerHTML = '<SPAN class=boldRed>'+lang.Search.errFS1+'</span><br>';
 		t.clickedStartFSAttack();
 		return;
 	}
 	for (var lvl=1;lvl<11; lvl++){ 
         var totalunit=0;
         for (r=1; r<13; r++){
          if (Options.AttackFSUnits[lvl]!=undefined) {
           totalunit += parseInt(Options.AttackFSUnits[lvl][r]);
 	   if(parseInt(Seed.units['city'+city.id]['unt'+r]) < Options.AttackFSUnits[lvl][r]){
 		ById('pbSrcScoutResult').innerHTML = '<SPAN class=boldRed>ERROR : '+unsafeWindow.unitcost['unt'+r][0]+' non disponible pour le niveau '+lvl+'</span><br>';
 		t.clickedStartFSAttack();
 	 	return;
 	   }
 	  } 
 	 }
 	}
	t.doFSAttackCount(list, city, list.length, 0);
	
 },
 doFSAttackCount : function(list, city, total, count){
	var t = Tabs.Search;
	
        if(!t.attacking){
 		ById('pbSrcScoutResult').innerHTML += '<SPAN class=boldRed>Stop</span><BR>';
 		ById('pbSrcStartScout').className = 'button20 ptButton20';
 		ById('pbSrcStartScout').innerHTML = '<SPAN>'+lang.Search.startattack+'/span>';
 		return;
 	}
 	if(total <= (count)){
 		ById('pbSrcScoutResult').innerHTML += lang.Search.finishattack+'<BR>';
 		t.clickedStartFSAttack();
 		return;
 	}
 	var rallypointlevel = t.getRallypoint(city.id);
 	var slots = 0;
        for (z in Seed.queue_atkp['city'+city.id]){           
             slots++;
        }
        if (Seed.queue_atkp['city'+city.id].toSource() == "[]") slots=0;
        if (rallypointlevel==12) rallypointlevel=11;
 	if(slots >= rallypointlevel){
 		setTimeout(function(){t.doFSAttackCount(list, city, total, count)}, 10000);
 		ById('pbSrcScoutResult').innerHTML += lang.Search.waitPR+'<br>';
 		return;
 	}
 	var coords = list[count].split("_");
 	if(coords[0] == 'undefined' || coords[1] == 'undefined'){
 		ById('pbSrcScoutResult').innerHTML += '<SPAN class=boldRed>'+lang.Search.errFS2+'</span>';
 		t.clickedStartFSAttack();
 		return;
 	}
 	ById('pbSrcScoutResult').innerHTML += lang.Search.sendto+' '+coords[0]+','+coords[1]+'...';
 	ById('pbsrcScoutCheck_'+coords[0]+'_'+coords[1]+'_'+coords[2]).checked = false;
 	t.sendAttackFS(coords[0], coords[1], coords[2], city, count, function(c){t.doFSAttackCount(list, city, total, c)});
 },
 sendAttackFS : function(x, y, lvl, city, count, notify){
  var t = Tabs.Search;
  count = parseInt(count);
  var totalunit = 0;
  for (r=1; r<13; r++) {
   if (Options.AttackFSUnits[lvl]!=undefined)
       totalunit += parseInt(Options.AttackFSUnits[lvl][r]);
  }        
  if (totalunit>0) {      
  
  
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.cid = city.id;
  params.kid = 0;
  params.type = 4;
  params.xcoord = x;
  params.ycoord = y;
  for (r=1; r<13; r++)
    params['u'+r]=parseInt(Options.AttackFSUnits[lvl][r]);
  var knt = new Array();
  for (k in Seed.knights['city' + city.id]){
   if (Seed.knights['city' + city.id][k]["knightStatus"] == 1 && Seed.leaders['city' + city.id]["resourcefulnessKnightId"] != Seed.knights['city' + city.id][k]["knightId"] && Seed.leaders['city' + city.id]["politicsKnightId"] != Seed.knights['city' + city.id][k]["knightId"] && Seed.leaders['city' + city.id]["combatKnightId"] != Seed.knights['city' + city.id][k]["knightId"] && Seed.leaders['city' + city.id]["intelligenceKnightId"] != Seed.knights['city' + city.id][k]["knightId"]){
       knt.push ({
                 				Name:   Seed.knights['city' + city.id][k]["knightName"],
                 				Combat:	Seed.knights['city' + city.id][k]["combat"],
                 				ID:	Seed.knights['city' + city.id][k]["knightId"],
       });
    }
  }
  knt = knt.sort(function sort(a,b) {a = parseInt(a['Combat']);b = parseInt(b['Combat']);return a == b ? 0 : (a > b ? -1 : 1);}); 
  if (knt[0]) {
    params.kid= knt[0]["ID"];
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
    		 method: "post",
    		 parameters: params,
    		 loading: true,
    		 onSuccess: function (rslt) {
    		 rslt = eval("(" + rslt.responseText + ")");
    		 if (rslt.ok) {
    			 var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
    			 var ut = unixTime();
    			 var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
    			 var resources=[0,0,0,0,0,0,0,0,0,0,0,0,0];
    			 for(i = 0; i <= unitsarr.length; i++){
    				if(params["u"+i]){
    				unitsarr[i] = params["u"+i];
    				}
    			 }
    			 var currentcityid = params.cid;
    			 unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
    			 if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
    			 ById('pbSrcScoutResult').innerHTML += lang.Search.send+'<BR>';
    			 if (notify)
    			  setTimeout(function(){ notify(count+1); }, 1500);
    		 } else {
    			if (rslt.user_action) {
				 ById('pbSrcScoutResult').innerHTML += '<span title="'+rslt.msg+'">'+lang.General.DetectionCaptcha+'</span><BR>';
	
			} else {
    			 if (rslt.error_code==104 && rslt.msg=="Ne peux attaquer le marais") {
    			  ById('pbSrcScoutResult').innerHTML += '<span title="'+rslt.msg+'">Error - '+uW.g_js_strings.commonstr.bog+'</span><BR>';
    			  if (notify) 
    			    setTimeout(function(){ notify(count+1); }, 10000);
    			 } else {
    			   ById('pbSrcScoutResult').innerHTML += '<span title="'+rslt.msg+'">Error !</span><BR>';
    			  if (notify) 
    			   setTimeout(function(){ notify(count); }, 10000);
    			 }
    			 }
    		  }
    		},
    		onFailure: function () {}
  		}); 
    
    
    
  } else {
   ById('pbSrcScoutResult').innerHTML += 'Error : '+uW.g_js_strings.commonstr.knight+'...<BR>';
   if (notify)
    setTimeout(function(){ notify(count); }, 1000);
  }
  
  } else {
  
   ById('pbSrcScoutResult').innerHTML += '<span>Error !</span><BR>';
   setTimeout(function(){ notify(count+1); }, 500);
  
  }
  
  
 },
 generateScoutList : function (){
     var t = Tabs.Search;
     var bulkScout = [];
     for (i=0; i<t.mapDat.length; i++){

       if (t.mapDat[i][3] == 7){
   
 		if(t.mapDat[i][10] >= Options.filPuissance || t.mapDat[i][5]){
 		if((Options.citySrchFilter=='1' && t.mapDat[i][12] == 'Hostile') ||
 		   (Options.citySrchFilter=='2' && t.mapDat[i][5]===true) ||
 		   (Options.citySrchFilter=='3' && t.mapDat[i][12] == 'Allie') ||
 		   (Options.citySrchFilter=='4' && t.mapDat[i][12]  == 'Amicale') ||
 		   (Options.citySrchFilter=='5' && t.mapDat[i][12] == 'Neutre') ||
 		   (Options.citySrchFilter=='6' && t.mapDat[i][12] == 'unaligned') ||
 		   (Options.citySrchFilter=='0'))
 			bulkScout.push({x:t.mapDat[i][0], y:t.mapDat[i][1], dist:t.mapDat[i][2]});
 		}
 	  }
     }
 	if(t.selectedCity == null)
 		t.selectedCity = Cities.cities[0];
     t.ShowScoutList (bulkScout, t.selectedCity);
   },
   ShowScoutList : function (coordlist, city){
 	var t = Tabs.Search;
 	var popScout = null;
 	t.scoutcity = city;
 	
 	if(popScout==null){
 	  popScout = new CPopup ('pbsrcscout', 0,0, 350,500, true, function (){popScout.destroy(); popScout=null;});
       popScout.centerMe (mainPop.getMainDiv());  
     }
 	var m = '<DIV class=boStat>'+lang.Search.scoutTitle+'</div>';
 		m += '<DIV>'+uW.g_js_strings.commonstr.troops+': <input id=pbsrcScoutAmt value="'+Options.srcScoutAmt+'" /></div><BR>';
 		m += '<DIV>'+lang.General.source+' : <span id=pbsrcScoutcitypick> </span></div><BR>';
 		m += '<DIV class=boStat>'+uW.g_js_strings.commonstr.from+' <span id=pbsrcScoutcity>'+city.name+'</span> <BR> '+lang.Search.numberCible+' '+coordlist.length+'</div>';
 		m += '<DIV style="max-height:220px; overflow-y:auto;"><TABLE align=center cellpadding=0 cellspacing=0 class=pbTabPadNW><TR style="font-weight:bold; background-color:white"><TD width=15><input type=checkbox id=pbsrcScout_All /></td><TD>'+uW.g_js_strings.commonstr.target+'</td></tr>';
 	  for(i=0; i<coordlist.length; i++){
 			m += '<TR style="background-color:white"><TD><input type=checkbox name=pbsrcScoutCheck id="pbsrcScoutCheck_'+coordlist[i].x+'_'+coordlist[i].y+'" value="'+coordlist[i].x+'_'+coordlist[i].y+'" /></td><TD>'+coordlist[i].x+','+coordlist[i].y+'</td></tr>';
 	  }
 	    m += '</table></div>';
 		m += '<BR><CENTER>'+ strButton20(lang.General.startattack, 'id=pbSrcStartScout') +'</center>';
 		m += '<CENTER><DIV style="width:70%; max-height:75px; overflow-y:auto;" id=pbSrcScoutResult></DIV></center>';
 	popScout.getMainDiv().innerHTML = m;
 	new CdispCityPicker ('pbScoutPick', ById('pbsrcScoutcitypick'), false, function(c,x,y){ById('pbsrcScoutcity').innerHTML = c.name; t.scoutcity = c; }, city.idx);
 	popScout.getTopDiv().innerHTML = '<CENTER><B>'+lang.General.generateScoutList+'</b></center>';
 	popScout.show(true);
 	
 	ById('pbsrcScoutAmt').addEventListener('change', function(){
 		Options.srcScoutAmt = parseInt(ById('pbsrcScoutAmt').value);
 		saveOptions();
 	}, false);
 	ById('pbsrcScout_All').addEventListener('change', function(){
 		for(k in document.getElementsByName('pbsrcScoutCheck'))
 			document.getElementsByName('pbsrcScoutCheck')[k].checked = ById('pbsrcScout_All').checked;
 	}, false);
 	ById('pbSrcStartScout').addEventListener('click', t.clickedStartScout, false);
   },
   scouting : false,
   scoutcity : null,
   doScout : function(list, city){
 	var t = Tabs.Search;
 	ById('pbSrcScoutResult').innerHTML = '';
 	if(list.length < 1){
 		ById('pbSrcScoutResult').innerHTML = '<SPAN class=boldRed>ERROR : No coords selected</span>';
 		t.clickedStartScout();
 		return;
 	}
 	if(parseInt(Seed.units['city'+city.id]['unt'+3]) < Options.srcScoutAmt){
 		ById('pbSrcScoutResult').innerHTML = '<SPAN class=boldRed>ERROR : No scouts available</span>';
 		t.clickedStartScout();
 		return;
 	}
 	t.doScoutCount(list, city, list.length, 0);
 	
   },
   	clickedStartScout : function(){
   	var t = Tabs.Search;
   		if(t.scouting == false){
   			t.scouting = true;
   			var ScoutList = [];
   			for(k=0; k<document.getElementsByName('pbsrcScoutCheck').length; k++){
   				if(document.getElementsByName('pbsrcScoutCheck')[k].checked){
   					ScoutList.push(document.getElementsByName('pbsrcScoutCheck')[k].value);
   				}
   			}
   			t.doScout(ScoutList, t.scoutcity);
   			ById('pbSrcStartScout').className = 'button20 pbButCancel';
   			ById('pbSrcStartScout').innerHTML = '<SPAN>Stop</span>';
   		} else {
   			t.scouting = false;
   			ById('pbSrcStartScout').className = 'button20 ptButton20';
   			ById('pbSrcStartScout').innerHTML = '<SPAN>'+lang.Search.startattack+'</span>';
   		}
	},
   doScoutCount : function(list, city, total, count){
 	var t = Tabs.Search;
 	if(!t.scouting){
 		ById('pbSrcScoutResult').innerHTML += '<SPAN class=boldRed>Stop</span><BR>';
 		ById('pbSrcStartScout').className = 'button20 ptButton20';
 		ById('pbSrcStartScout').innerHTML = '<SPAN>'+lang.Search.startattack+'</span>';
 		return;
 	}
 	if(total <= (count)){
 		ById('pbSrcScoutResult').innerHTML += lang.Search.finishattack+'<BR>';
 		t.clickedStartScout();
 		return;
 	}
 	var rallypointlevel = t.getRallypoint(city.id);
 	if(rallypointlevel == 12) rallypointlevel = 11;
 	var slots = 0;
        for (z in Seed.queue_atkp['city'+city.id]){
              slots++;
        }
     if  (Seed.queue_atkp['city'+city.id].toSource() == "[]") slots=0;
 
 	if(slots >= rallypointlevel){
 		setTimeout(function(){t.doScoutCount(list, city, total, count)}, 10000);
 		ById('pbSrcScoutResult').innerHTML += lang.Search.waitPR+'<br>';
 		return;
 	}
 	var coords = list[count].split("_");
 	if(coords[0] == 'undefined' || coords[1] == 'undefined'){
 		ById('pbSrcScoutResult').innerHTML += '<SPAN class=boldRed>'+lang.Search.errFS2+'</span>';
 		t.clickedStartScout();
 		return;
 	}
 	ById('pbSrcScoutResult').innerHTML += lang.Search.sendto + ' '+coords[0]+','+coords[1]+'...';
 	ById('pbsrcScoutCheck_'+coords[0]+'_'+coords[1]).checked = false;
 	t.sendScout(coords[0], coords[1], city, count, function(c){t.doScoutCount(list, city, total, c)});
   },
   sendScout : function(x, y, city, count, notify){
 	var t = Tabs.Search;
 	count = parseInt(count);
 	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
     params.cid = city.id;
 	params.kid = 0;
 	params.type = 3;
 	params.xcoord = x;
 	params.ycoord = y;
 	params.u3 = Options.srcScoutAmt;
 	new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
 		 method: "post",
 		 parameters: params,
 		 loading: true,
 		 onSuccess: function (rslt) {
 		 rslt = eval("(" + rslt.responseText + ")");
 		 if (rslt.ok) {
 			 var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
 			 var ut = unixTime();
 			 var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
 			 var resources=[0,0,0,0,0,0,0,0,0,0,0,0,0];
 			 for(i = 0; i <= unitsarr.length; i++){
 				if(params["u"+i]){
 				unitsarr[i] = params["u"+i];
 				}
 			 }
 			 var currentcityid = params.cid;
 			 unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
 			 if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
 			 ById('pbSrcScoutResult').innerHTML += lang.Search.send+'<BR>';
 			 if (notify)
 			  setTimeout(function(){ notify(count+1); }, 1000);
 		 } else {
 			 ById('pbSrcScoutResult').innerHTML += 'Fail! tentative....<BR>';
 			 if (notify)
 			  setTimeout(function(){ notify(count); }, 1000);
 		  }
 		},
 		onFailure: function () {}
   		});
  },
 getRallypoint: function(cityId){
       var t = Tabs.Search;
       cityId = 'city'+cityId;
       for (o in Seed.buildings[cityId]){
 		var buildingType = parseInt(Seed.buildings[cityId][o][0]);
 		var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
 		if (buildingType == 12){
 			return parseInt(buildingLevel);
 			break;
 		}
 	   }
 	  return 0;
    },
 clickedStartFSAttack : function(){
   var t = Tabs.Search;
   	if(t.attacking == false){
   			t.attacking = true;
   			var ScoutList = [];
   			for(k=0; k<document.getElementsByName('pbsrcFSCheck').length; k++){
   				if(document.getElementsByName('pbsrcFSCheck')[k].checked){
   					ScoutList.push(document.getElementsByName('pbsrcFSCheck')[k].value);
   				}
   			}
   			t.doFSAttack(ScoutList, t.attackcity);
   			ById('pbSrcStartScout').className = 'button20 pbButCancel';
   			ById('pbSrcStartScout').innerHTML = '<SPAN>Stop</span>';
   		} else {
   			t.attacking = false;
   			ById('pbSrcStartScout').className = 'button20 ptButton20';
   			ById('pbSrcStartScout').innerHTML = '<SPAN>'+lang.Search.startattack+'</span>';
		}
 },
 clickedPlayerCheckOnline : function (span, uid){
        var t = Tabs.AllianceList;
      	var s = Tabs.Search;
          span.onclick = '';
          span.innerHTML = uW.g_js_strings.commonstr.loadingddd+"...";
          t.fetchPlayerStatusSimple (uid, function (r) {s.gotPlayerStatus(r, span, uid)});
        },
      
 clickedPlayerGetLastLogin : function (span, uid){
   var t = Tabs.AllianceList;
   var s = Tabs.Search;
          span.onclick = '';
          span.innerHTML = uW.g_js_strings.commonstr.loadingddd+"...";
          t.fetchPlayerLastLogin (uid, function (r) {s.gotPlayerLastLogin(r, span)});
  },
  fetchPlayerThrone : function (uid, notify){
  var t = Tabs.AllianceList;
   var s = Tabs.Search;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        	params.ctrl="throneRoom\\ThroneRoomServiceAjax";
	    		params.action ="getEquipped";
    		params.playerId = uid;
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          onSuccess: function (rslt) {
            notify (rslt);
          },
          onSuccess: function (rslt) {
            notify (rslt);
          },
      });
  },
  clickedPlayerGetThrone: function(span, uid) {
    var t = Tabs.AllianceList;
    var s = Tabs.Search;
    span.onclick = '';
    span.innerHTML = uW.g_js_strings.commonstr.loadingddd+"...";
    s.fetchPlayerThrone (uid, function (r) {s.gotThronePlayer(r, span)});
  
  },
  gotThronePlayer : function (rslt, span){
        var t = Tabs.AllianceList;
        var s = Tabs.Search;
        if (!rslt.ok){
          span.innerHTML = "Impossible";
          return;
        }
        var B=0, w={}, x, C;
        var k=rslt.items;
        var m="";
        for (var K in k) {
           x=0;
           var F = k[K].effects;
	   for (var M in F) {
            x++;
           
            if (k[K].quality >= x) {
             B++;
             I = uW.cm.thronestats.effects[F[M].id];
             z = uW.cm.thronestats.tiers[F[M].id][F[M].tier];
             C = + z.base + (k[K].level * k[K].level + k[K].level) * + z.growth * 0.5;
             if (!w[F[M].id]) {
	     	w[F[M].id] = {};
	     }
	     if (!w[F[M].id].percent) { 
	     	w[F[M].id].percent = C; 
	      } else {
	     	w[F[M].id].percent += C; 
	     }
	     w[F[M].id].name = I[1];
            }
           }
        }
        
        m+="<table border=0 width=250 cellspacing=0>";
        for (var K in w) {
             var Current =  Math.round(w[K].percent*100)/100;
             G="<tr><td align=right><b>"+ Current + " %</b></td><td align=left>" + w[K].name + "</td></tr>";
	     m+=G;
        }
        m+="</table>";
        span.innerHTML = m;
    },
  gotPlayerStatus : function (rslt, span,uid){
      var t = Tabs.AllianceList;
      if (!rslt.ok){
        span.innerHTML = rslt.errorMsg;
        return;
      }
  
      var p = rslt.data;
      if (p[uid] == true) {
        m = '<span style="color:green"><b>'+uW.g_js_strings.commonstr.online+'</b></span>';
      } else {
         m = '<span style="color:red"><b>'+uW.g_js_strings.commonstr.offline+'</b></span>';
      }  
      span.innerHTML = m + '';
    },
  
  gotPlayerLastLogin : function (rslt, span){
      var t = Tabs.AllianceList;
      if (!rslt.ok){
        span.innerHTML = rslt.errorMsg;
        return;
      }
  
      var p = rslt.playerInfo;
      var lastLogin = rslt.playerInfo.lastLogin;
      
      if (lastLogin) {
        m = '<span style="color:black">'+lastLogin+'</span>';
      } else {
         m = '<span style="color:red">?</span>';
      }  
      span.innerHTML = m + '';
  },
  exportKOCattack : function (){
     var t = Tabs.Search;
     var bulkAdds = {};
     for (i=1; i<11; i++)
       bulkAdds['lvl'+ i] = [];
     for (i=0; i<t.mapDat.length; i++){
       var lvl = parseInt (t.mapDat[i][4]);
       if (lvl>=Options.srcMinLevel && lvl<=Options.srcMaxLevel && t.mapDat[i][3]==0)
         bulkAdds['lvl'+ lvl].push({x:t.mapDat[i][0], y:t.mapDat[i][1]});
     }
     exportToKOCattackBO.doExport (bulkAdds, t.selectedCity);
  }, 
  mapCallback : function (left, top, width, rslt){
    function insertRow (x, y, msg){
      row = ById('srcOutTab').insertRow(-1);
      row.insertCell(0).innerHTML = x +','+ y;
      row.insertCell(1).innerHTML = distance (t.opt.startX, t.opt.startY, x, y);
      row.insertCell(2).innerHTML = msg;
    }
    var t = Tabs.Search;
    if (!t.searchRunning)
      return;
    if (!rslt.ok){
      t.stopSearch ('ERROR : '+ rslt.errorMsg);
      return;
    }
    map = rslt.data;
    var userInfo = rslt.userInfo;
    var alliance = rslt.allianceNames;
    for (k in map){
      if (t.opt.searchType==0 && map[k].tileType==51 && !map[k].tileCityId ) {
        type = 0;
      } else if (t.opt.searchType==1 && map[k].tileType>=10 &&  map[k].tileType<=50) {
        if (map[k].tileType == 10)
          type = 1;
        else if (map[k].tileType == 11)
          type = 2;
        else
          type = (map[k].tileType/10) + 1;
      } else if (t.opt.searchType==2 && map[k].tileCityId >= 0 && map[k].tileType > 50 && map[k].cityName) {
		  type = 7;
      } else if (t.opt.searchType==3 && map[k].tileType==54) { 
        type=9;
      } else if (t.opt.searchType==3 && map[k].tileType>100) { 
        type=9 + (map[k].tileType-100);
        
      } else {
        continue;
      }
      dist = distance (t.opt.startX, t.opt.startY, map[k].xCoord, map[k].yCoord);
      if (dist <= t.opt.maxDistance && dist >= t.opt.maxDistanceA){
		  if (t.opt.searchType==2) {
			var isMisted = map[k].tileUserId == 0 || false;		
			var uu = 'u'+map[k].tileUserId;
			var aU = 'inconnu';
			var aD = 'inconnu';
			var mightU = 0;
			var nameU = 'inconnu';
			if (isMisted) {
				nameU = 'Brume';
				mightU = 0; 
			} else {
				if (userInfo[uu] ) {
					nameU = "<a onclick=getInfoForAnUser('"+ map[k].tileUserId +"');>"+ userInfo[uu].n +"</a>";
					mightU = userInfo[uu].m; 
					aD = getDiplomacy(userInfo[uu].a);
					if ( alliance && alliance['a'+userInfo[uu].a] ) {
						aU = alliance['a'+userInfo[uu].a];
					}
					else {
						aU = '----';
						aD = 'unaligned';
					}
				}
			}
			t.mapDat.push ([map[k].xCoord, map[k].yCoord, dist, type, map[k].tileLevel, isMisted, map[k].tileCityId, map[k].tileUserId, map[k].cityName,nameU,mightU,aU,aD ]);
		} else {
			isOwned = map[k].tileUserId>0 || map[k].misted;
			var uu = 'u'+map[k].tileUserId;
			var aU = 'inconnu';
			var aD = 'inconnu';
			var nameU = 'inconnu';
			var mightU = 0;
			if (map[k].misted) {
				nameU = 'Sous la Brume';
			}else {
			 if (userInfo[uu] ) {
			   var nameU = "<a onclick=getInfoForAnUser('"+ map[k].tileUserId +"');>"+ userInfo[uu].n +"</a>";
			   mightU = userInfo[uu].m; 
			   aD = getDiplomacy(userInfo[uu].a);
					if ( alliance && alliance['a'+userInfo[uu].a] ) {
						aU = alliance['a'+userInfo[uu].a];
					}
			 }else {
			   var nameU = 'inconnu';
			 }
			}	
			t.mapDat.push ([map[k].xCoord, map[k].yCoord, dist, type, map[k].tileLevel, isOwned, map[k].tileCityId, map[k].tileUserId, map[k].cityName, nameU, mightU, aU, aD]);       
		}
			++t.tilesFound;
       }   
    }
    t.tilesSearched += (40*40);
    ById('statSearched').innerHTML = lang.Search.find+': '+ t.tilesSearched;
    t.dispMapTable();
    t.curX += 40;
    if (t.curX > t.lastX){
      t.curX = t.firstX;
      t.curY += 40;
      if (t.curY > t.lastY){
        t.stopSearch ('Finish');
        return;
      }
    }
    var x = t.normalizeCoord(t.curX);
    var y = t.normalizeCoord(t.curY);
    document.getElementById ('statStatus').innerHTML = uW.g_js_strings.commonstr.research+' : '+ x +','+ y;
    setTimeout (function(){Map.request (x, y, 40, t.mapCallback)}, MAP_DELAY);
  },
};

/*********************************  Cresting Tab ***********************************/
 Tabs.Crest = {
  tabOrder: 17,
  tabLabel: lang.BoiteLabelCrest,
  myDiv : null,
  rallypointlevel:null,
  error_code: 0,
  knt:{},
  init : function (div){
    var t = Tabs.Crest;
    Options.crestMarchError = 0;

    setInterval(t.sendCrestReport, 1*60*1000);	
    setTimeout(function(){ t.Rounds(1,0,0);}, 5*1000);
    setTimeout(function() { 

	AddSubTabLink('TS', t.toggleCrestState, 'pbautotstab');
	
	if (Options.crestRunning == false)
	 updatebotbutton(lang.BoiteLabelCrest+" - OFF", 'pbautotstab');
	else
	 updatebotbutton(lang.BoiteLabelCrest+" - ON", 'pbautotstab');
 	 
   },500);

    t.myDiv = div;
    var selbut=0;
    var m = '<DIV id=pbTowrtDivF class=boStat>'+lang.crest.title+'</div><TABLE id=pbcrestfunctions width=100% height=0% class=pbTab><TR align="center">';
     if (Options.crestRunning == false) {
	       m += '<TD><INPUT id=Cresttoggle type=submit value="'+lang.BoiteLabelCrest+' = OFF"></td>';
	   } else {
	       m += '<TD><INPUT id=Cresttoggle type=submit value="'+lang.BoiteLabelCrest+' = ON"></td>';
	   }



    m += '<TD colspan=2><INPUT id=CrestHelp type=submit value="'+lang.crest.help+'">';
    m += '<INPUT id=showCrestTargets type=submit value="'+lang.crest.target+'"><br>'+lang.crest.interval+' <INPUT type=text size=3 value='+Options.Crestinterval+' id=pbcrest_interval /> '+lang.General.and+' <INPUT disabled title="(CrestInterval/2)+CrestInterval" type=text size=3 value='+Options.CrestintervalAnd+' id=IdCrestInteAnd /> '+lang.General.secs+'</td>';
    m += '<TD><INPUT id=pbsendreport type=checkbox '+ (Options.crestreport?' CHECKED':'') +'\> '+lang.crest.sendrpt+'&nbsp;';
    m += '<INPUT id=pbsendcrestreportint value='+ Options.CrestMsgInterval +' type=text size=3 \> '+lang.General.hours+' - <input type=button value="'+uW.g_js_strings.modal_auto_attack.now+'" id=bosendreportnow><br>';
    m += lang.crest.keep+' <INPUT id=bocrestslot value='+Options.CrestSlot+' type=text size=2 \> '+lang.crest.keep2+'</td></table>';
    m += '<DIV id=pbOpt class=boStat>OPTIONS</div><TABLE id=pbcrestopt	 width=100% height=0% class=pbTab><TR align="center"></table>';
    m += '<DIV style="margin-bottom:10px;">'+uW.g_js_strings.commonstr.from+' : <span id=crestcity></span></div>';
    m += '<TABLE class=ptTab><TR><TD>'+uW.g_js_strings.commonstr.location+' : &nbsp;&nbsp;X:<INPUT id=pbcrestx type=text size=3 maxlength=3 value=""></td>';
    m += '<TD>Y:<INPUT id=pbcresty type=text size=3 maxlength=3 value=""></td></tr></table>';
    m += '<TABLE class=ptTab><TR><TD>'+lang.crest.wave+' <b>1</b>: </td><TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_1_30.png></td><TD><INPUT id=R1ST type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_2_30.png></td><TD><INPUT id=R1MM type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_3_30.png></td><TD><INPUT id=R1Scout type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_4_30.png></td><TD><INPUT id=R1Pike type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_5_30.png></td><TD><INPUT id=R1Sword type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_6_30.png></td><TD><INPUT id=R1Arch type=text size=6 maxlength=6 value=0></td></tr>';
    m += '<tr><td></td><TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_7_30.png></td><TD><INPUT id=R1LC type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_8_30.png></td><TD><INPUT id=R1HC type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_9_30.png></td><TD><INPUT id=R1SW type=text size=7 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_10_30.png></td><TD><INPUT id=R1Ball type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_11_30.png></td><TD><INPUT id=R1Ram type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_12_30.png></td><TD><INPUT id=R1Cat type=text size=6 maxlength=6 value=0></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr>';
    
    m += '<TR><TD>'+lang.crest.wave+' <b>2</b>: </td><TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_1_30.png></td><TD><INPUT id=R2ST type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_2_30.png></td><TD><INPUT id=R2MM type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_3_30.png></td><TD><INPUT id=R2Scout type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_4_30.png></td><TD><INPUT id=R2Pike type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_5_30.png></td><TD><INPUT id=R2Sword type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_6_30.png></td><TD><INPUT id=R2Arch type=text size=6 maxlength=6 value=0></td></tr>';
    m += '<tr><td></td><TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_7_30.png></td><TD><INPUT id=R2LC type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_8_30.png></td><TD><INPUT id=R2HC type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_9_30.png></td><TD><INPUT id=R2SW type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_10_30.png></td><TD><INPUT id=R2Ball type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_11_30.png></td><TD><INPUT id=R2Ram type=text size=6 maxlength=6 value=0></td>';
    m += '<TD>&nbsp;&nbsp;<img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_12_30.png></td><TD><INPUT id=R2Cat type=text size=6 maxlength=6 value=0></td></tr></table>';
    m += '<DIV style="text-align:center; margin-top:15px"><INPUT id=pbSaveRouteCrest type=submit value="'+lang.crest.add+'"></div>';
    
    t.myDiv.innerHTML = m;
	document.getElementById('bocrestslot').addEventListener('change', function(){
	  if (parseIntNan(document.getElementById('bocrestslot').value)>9) document.getElementById('bocrestslot').value=1;
		Options.CrestSlot = document.getElementById('bocrestslot').value;
		saveOptions();
	}, false);
	
	document.getElementById('pbsendreport').addEventListener('change', function(){
		Options.crestreport = document.getElementById('pbsendreport').checked;
		saveOptions();
	}, false);
	ById('pbsendcrestreportint').addEventListener('change', function(){
		Options.CrestMsgInterval = parseIntNan(document.getElementById('pbsendcrestreportint').value);
		saveOptions();
	}, false);
    ById("pbcrest_interval").addEventListener('change', function(e){	
       		if (parseIntNan(e.target.value)<1) e.target.value=1;
    		Options.Crestinterval = parseIntNan(e.target.value);
    		Options.CrestintervalAnd = parseIntNan((Options.Crestinterval/2)+Options.Crestinterval);
    		ById("IdCrestInteAnd").value = Options.CrestintervalAnd;
    		saveOptions();
	},false);
    for (var i=0;i<Seed.cities.length;i++){
		if (CrestOptions.CrestCity == Seed.cities[i][0]){
			selbut=i;
			break;
		}
	}
		
    t.tcp = new CdispCityPicker ('crestcityselect', document.getElementById('crestcity'), true, t.clickCitySelect, selbut);
    
    if (CrestOptions.CrestCity == 0) {
    	CrestOptions.CrestCity = t.tcp.city.id
    }
    ById('bosendreportnow').addEventListener('click', function() {
	t.sendCrestReportNow();
	
	}, false);
	
      document.getElementById('pbcrestx').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('pbcrestx').value)) document.getElementById('pbcrestx').value='' ;
      }, false);

      document.getElementById('pbcresty').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('pbcresty').value)) document.getElementById('pbcresty').value='' ;
      }, false);

      document.getElementById('R1ST').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1ST').value)) document.getElementById('R1ST').value=0 ;
      }, false);

      document.getElementById('R1MM').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1MM').value)) document.getElementById('R1MM').value=0 ;
      }, false);

      document.getElementById('R1Pike').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1Pike').value)) document.getElementById('R1Pike').value=0 ;
      }, false);

      document.getElementById('R1Scout').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1Scout').value)) document.getElementById('R1Scout').value=0 ;
      }, false);

      document.getElementById('R1Sword').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1Sword').value)) document.getElementById('R1Sword').value=0 ;
      }, false);

      document.getElementById('R1Arch').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1Arch').value)) document.getElementById('R1Arch').value=0 ;
      }, false);

      document.getElementById('R1LC').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1LC').value)) document.getElementById('R1LC').value=0 ;
      }, false);

      document.getElementById('R1HC').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1HC').value)) document.getElementById('R1HC').value=0 ;
      }, false);

      document.getElementById('R1SW').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1SW').value)) document.getElementById('R1SW').value=0 ;
      }, false);

      document.getElementById('R1Ball').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1Ball').value)) document.getElementById('R1Ball').value=0 ;
      }, false);

      document.getElementById('R1Ram').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1Ram').value)) document.getElementById('R1Ram').value=0 ;
      }, false);

      document.getElementById('R1Cat').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R1Cat').value)) document.getElementById('R1Cat').value=0 ;
      }, false);
	  
      document.getElementById('R2ST').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2ST').value)) document.getElementById('R2ST').value=0 ;
      }, false);

      document.getElementById('R2MM').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2MM').value)) document.getElementById('R2MM').value=0 ;
      }, false);

      document.getElementById('R2Pike').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2Pike').value)) document.getElementById('R2Pike').value=0 ;
      }, false);

      document.getElementById('R2Scout').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2Scout').value)) document.getElementById('R2Scout').value=0 ;
      }, false);

      document.getElementById('R2Sword').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2Sword').value)) document.getElementById('R2Sword').value=0 ;
      }, false);

      document.getElementById('R2Arch').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2Arch').value)) document.getElementById('R2Arch').value=0 ;
      }, false);

      document.getElementById('R2LC').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2LC').value)) document.getElementById('R2LC').value=0 ;
      }, false);

      document.getElementById('R2HC').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2HC').value)) document.getElementById('R2HC').value=0 ;
      }, false);

      document.getElementById('R2SW').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2SW').value)) document.getElementById('R2SW').value=0 ;
      }, false);

      document.getElementById('R2Ball').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2Ball').value)) document.getElementById('R2Ball').value=0 ;
      }, false);

      document.getElementById('R2Ram').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2Ram').value)) document.getElementById('R2Ram').value=0 ;
      }, false);

      document.getElementById('R2Cat').addEventListener('keyup', function(){
          if (isNaN(document.getElementById('R2Cat').value)) document.getElementById('R2Cat').value=0 ;
      }, false);
         
    document.getElementById('crestcity').addEventListener('click', function(){CrestOptions.CrestCity = t.tcp.city.id;} , false);
    document.getElementById('Cresttoggle').addEventListener('click', function(){t.toggleCrestState(this)} , false);
    document.getElementById('pbcrestx').addEventListener('change', function(){CrestOptions.X = document.getElementById('pbcrestx').value;;} , false);
    document.getElementById('pbcresty').addEventListener('change', function(){CrestOptions.Y = document.getElementById('pbcresty').value;} , false);
    document.getElementById('R1ST').addEventListener('change', function(){CrestOptions.R1ST = document.getElementById('R1ST').value;} , false);
    document.getElementById('R1MM').addEventListener('change', function(){CrestOptions.R1MM = document.getElementById('R1MM').value;} , false);
    document.getElementById('R1Scout').addEventListener('change', function(){CrestOptions.R1Scout = document.getElementById('R1Scout').value;} , false);
    document.getElementById('R1Pike').addEventListener('change', function(){CrestOptions.R1Pike = document.getElementById('R1Pike').value;} , false);
    document.getElementById('R1Sword').addEventListener('change', function(){CrestOptions.R1Sword = document.getElementById('R1Sword').value;} , false);
    document.getElementById('R1Arch').addEventListener('change', function(){CrestOptions.R1Arch = document.getElementById('R1Arch').value;} , false);
    document.getElementById('R1LC').addEventListener('change', function(){CrestOptions.R1LC = document.getElementById('R1LC').value;} , false);
    document.getElementById('R1HC').addEventListener('change', function(){CrestOptions.R1HC = document.getElementById('R1HC').value;} , false);
    document.getElementById('R1SW').addEventListener('change', function(){CrestOptions.R1SW = document.getElementById('R1SW').value;} , false);
    document.getElementById('R1Ball').addEventListener('change', function(){CrestOptions.R1Ball = document.getElementById('R1Ball').value;} , false);
    document.getElementById('R1Ram').addEventListener('change', function(){CrestOptions.R1Ram = document.getElementById('R1Ram').value;} , false);
    document.getElementById('R1Cat').addEventListener('change', function(){CrestOptions.R1Cat = document.getElementById('R1Cat').value;} , false);
    document.getElementById('R2ST').addEventListener('change', function(){CrestOptions.R2ST = document.getElementById('R2ST').value;} , false);
    document.getElementById('R2MM').addEventListener('change', function(){CrestOptions.R2MM = document.getElementById('R2MM').value;} , false);
    document.getElementById('R2Scout').addEventListener('change', function(){CrestOptions.R2Scout = document.getElementById('R2Scout').value;} , false);
    document.getElementById('R2Pike').addEventListener('change', function(){CrestOptions.R2Pike = document.getElementById('R2Pike').value;} , false);
    document.getElementById('R2Sword').addEventListener('change', function(){CrestOptions.R2Sword = document.getElementById('R2Sword').value;} , false);
    document.getElementById('R2Arch').addEventListener('change', function(){CrestOptions.R2Arch = document.getElementById('R2Arch').value;} , false);
    document.getElementById('R2LC').addEventListener('change', function(){CrestOptions.R2LC = document.getElementById('R2LC').value;} , false);
    document.getElementById('R2HC').addEventListener('change', function(){CrestOptions.R2HC = document.getElementById('R2HC').value;} , false);
    document.getElementById('R2SW').addEventListener('change', function(){CrestOptions.R2SW = document.getElementById('R2SW').value;} , false);
    document.getElementById('R2Ball').addEventListener('change', function(){CrestOptions.R2Ball = document.getElementById('R2Ball').value;} , false);
    document.getElementById('R2Ram').addEventListener('change', function(){CrestOptions.R2Ram = document.getElementById('R2Ram').value;} , false);
    document.getElementById('R2Cat').addEventListener('change', function(){CrestOptions.R2Cat = document.getElementById('R2Cat').value;} , false);
    document.getElementById('CrestHelp').addEventListener('click', function(){t.helpPop();} , false);
    document.getElementById('pbSaveRouteCrest').addEventListener('click', function(){CrestOptions.active="Actif";t.addCrestRoute();}, false);
    document.getElementById('showCrestTargets').addEventListener('click', function(){t.showCrestRoute();}, false);
  },
  
  
helpPop : function (){
    var helpText = lang.crest.helpText;
    var pop = new CPopup ('ArmoiriesHelp', 0, 0, 585, 400, true);
    pop.centerMe (mainPop.getMainDiv());  
    pop.getMainDiv().innerHTML = helpText;
    pop.getTopDiv().innerHTML = '<CENTER><B>'+lang.crest.helpTitle+'</b></center>';
    pop.show (true);
  },
    addCrestRoute : function () {
		if(CrestOptions.X == "" || CrestOptions.Y == "") {
		        alert(lang.crest.nolocation);
			return;
		}
		var t = Tabs.Crest;
		var CrestLength = CrestData.length;
		CrestData[CrestLength] = new CrestFunc(CrestOptions);
		saveCrestData();
    },
    showCrestRoute : function () {
		var t = Tabs.Crest;
		var popCrestTargets = null;
		t.popCrestTargets = new CPopup('pbShowCrestTargets', 0, 0, 1100, 500, true, function() {clearTimeout (1000);});
		var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbShowCrestTargets" id="pbCrestTargets">';       
		t.popCrestTargets.getMainDiv().innerHTML = '</table></div>' + m;
		t.popCrestTargets.getTopDiv().innerHTML = '<TD><B>'+lang.crest.popCrest+'</td>';
		t.paintCrestTargets();
		t._addTabHeader();
		t.popCrestTargets.show(true);

    },
	
	

/** add header **/
    _addTabHeader : function () {
		var row = document.getElementById('pbCrestTargets').insertRow(0);
		row.vAlign = 'top';
	     	row.insertCell(0).innerHTML = uW.g_js_strings.commonstr.target;
	     	row.insertCell(1).innerHTML = lang.crest.wave + " #";
	     	row.insertCell(2).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_1_30.png>";
	     	row.insertCell(3).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_2_30.png>";
	     	row.insertCell(4).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_3_30.png>";
	     	row.insertCell(5).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_4_30.png>";
	     	row.insertCell(6).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_5_30.png>";
	     	row.insertCell(7).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_6_30.png>";
	     	row.insertCell(8).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_7_30.png>";
	     	row.insertCell(9).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_8_30.png>";
	     	row.insertCell(10).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_9_30.png>";
	     	row.insertCell(11).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_10_30.png>";
	     	row.insertCell(12).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_11_30.png>";
	     	row.insertCell(13).innerHTML = "<img width=25 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_12_30.png>";
	     	row.insertCell(14).innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;";
	     	row.insertCell(14).innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    },
	
	

/** paintCrestTargets **/
    paintCrestTargets : function () {
		t = Tabs.Crest;

		for(var i = 0; i < CrestData.length; i++) {
			t._addTabCrest(i, uW.g_js_strings.commonstr.location+' : <a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">(' + CrestData[i].X + ',' + CrestData[i].Y+')</a>', "<b>2</b>", CrestData[i].R2ST, CrestData[i].R2MM, CrestData[i].R2Scout, CrestData[i].R2Pike, CrestData[i].R2Sword, CrestData[i].R2Arch, CrestData[i].R2LC, CrestData[i].R2HC, CrestData[i].R2SW, CrestData[i].R2Ball, CrestData[i].R2Ram, CrestData[i].R2Cat, " "," ");
			if (CrestData[i].active=="Actif")
			 t._addTabCrest(i, CrestData[i].CrestCity, "<b>1</b>", CrestData[i].R1ST, CrestData[i].R1MM, CrestData[i].R1Scout, CrestData[i].R1Pike, CrestData[i].R1Sword, CrestData[i].R1Arch, CrestData[i].R1LC, CrestData[i].R1HC, CrestData[i].R1SW, CrestData[i].R1Ball, CrestData[i].R1Ram, CrestData[i].R1Cat, uW.g_js_strings.commonstr.remove, lang.crest.actif);
			else
			 t._addTabCrest(i, CrestData[i].CrestCity, "<b>1</b>", CrestData[i].R1ST, CrestData[i].R1MM, CrestData[i].R1Scout, CrestData[i].R1Pike, CrestData[i].R1Sword, CrestData[i].R1Arch, CrestData[i].R1LC, CrestData[i].R1HC, CrestData[i].R1SW, CrestData[i].R1Ball, CrestData[i].R1Ram, CrestData[i].R1Cat, uW.g_js_strings.commonstr.remove, lang.crest.inactif);
			
			t._addTabCrest(i, "","","","","","","","","","","","","","","","");
		}

	},
	
	

/** Add Tab Crest **/
    _addTabCrest : function (QueID, col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, col14, col15) {
		var t = Tabs.Crest;
		var row = document.getElementById('pbCrestTargets').insertRow(0);

		for (var i = 0; i <= 15; i++) {
			if (i == 14 && col14 == uW.g_js_strings.commonstr.remove) {
				row.insertCell(i).innerHTML = "<a id=pbCrestDel_" + QueID + " value=" + i + ">"+uW.g_js_strings.commonstr.remove+"</a>";
				document.getElementById('pbCrestDel_' + QueID).addEventListener('click', function(){t.cancelCrestTarget(QueID);}, false);
			} else if (col14 == uW.g_js_strings.commonstr.remove && i == 0) {
				row.insertCell(i).innerHTML = Cities.byID[col0].name;
			} else if  (i == 15 && col14 == uW.g_js_strings.commonstr.remove) {
			
			  if (CrestData[QueID].active=="Actif") {
			   row.insertCell(i).innerHTML = "<a id=BOCrestAct_" + QueID + " value=" + i + ">"+lang.crest.actif+"</a>";
			     document.getElementById('BOCrestAct_' + QueID).addEventListener('click', function(){ CrestData[QueID].active="De-Actif";saveCrestData();t.showCrestRoute();  }, false);
			  } else if (CrestData[QueID].active=="De-Actif") {
			   row.insertCell(i).innerHTML = "<a id=BOCrestAct_" + QueID + " value=" + i + ">"+lang.crest.inactif+"</a>";
			     document.getElementById('BOCrestAct_' + QueID).addEventListener('click', function(){ CrestData[QueID].active="Actif";saveCrestData();t.showCrestRoute();  }, false);
			  
			  }
			
			  
			
			
			}else{
				row.insertCell(i).innerHTML = eval("col" + i) + "&nbsp; &nbsp;";
			}
			
			
		}
		
    },
	
	

/** Cancel Crest Target **/
    cancelCrestTarget : function (QueID) {
	     var t = Tabs.Crest;
	     var queueId = parseInt(QueID);
	     CrestData.splice(queueId, 1);
	     saveCrestData();
	     t.showCrestRoute();
    },
	
	

	getRallypointLevel: function(cityId){
		var t = Tabs.Crest;
		for (var o in Seed.buildings[cityId]){
			var buildingType = parseInt(Seed.buildings[cityId][o][0]);
			var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
			if (buildingType == 12) 
				t.rallypointlevel=parseInt(buildingLevel);
		}
	},
  
 

	getAtkKnight : function(cityID){
		var t = Tabs.Crest;
		t.knt = new Array();
		for (k in Seed.knights[cityID]){
			if (Seed.knights[cityID][k]["knightStatus"] == 1 && Seed.leaders[cityID]["resourcefulnessKnightId"] != Seed.knights[cityID][k]["knightId"] && Seed.leaders[cityID]["politicsKnightId"] != Seed.knights[cityID][k]["knightId"] && Seed.leaders[cityID]["combatKnightId"] != Seed.knights[cityID][k]["knightId"] && Seed.leaders[cityID]["intelligenceKnightId"] != Seed.knights[cityID][k]["knightId"]){
     			t.knt.push ({
     				Name:   Seed.knights[cityID][k]["knightName"],
     				Combat:	parseInt(Seed.knights[cityID][k]["combat"]),
     				ID:		Seed.knights[cityID][k]["knightId"],
     			});
     		}
		}
		t.knt = t.knt.sort(function sort(a,b) {a = parseInt(a['Combat']);b = parseInt(b['Combat']);return a == b ? 0 : (a > b ? -1 : 1);});
	},
   

   
 	sendMarch: function(p,callback,r,retry, CrestDataNum){
		var t = Tabs.Crest;
		
		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {	
			 method: "post",
			 parameters: p,
			 loading: true,
			 onSuccess: function (transport) {	
			     try {
				var rslt = eval("(" + transport.responseText + ")");
				if (rslt.ok) {
			 actionLog("AutoCrest", uW.g_js_strings.modal_barracks_train.attack+': '+p.xcoord+','+p.ycoord);
					var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
					var ut = unsafeWindow.unixtime();
					var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
					var resources=[0,0,0,0,0,0,0,0,0,0,0,0,0];
					for(i = 0; i <= unitsarr.length; i++){
						if(p["u"+i]){
							unitsarr[i] = p["u"+i];
						}
					}

					var currentcityid = p.cid;
					unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, p.xcoord, p.ycoord, unitsarr, p.type, p.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
					unsafeWindow.update_seed(rslt.updateSeed)
				
					if (rslt.updateSeed) {
						unsafeWindow.update_seed(rslt.updateSeed);
					}
			 		var now = new Date().getTime()/1000.0;
					now = now.toFixed(0);	
					if(r==1){
											Options.Crest1Count++;
											r = 2;
											CrestData[CrestDataNum].lastRoundTwo = now;
					} else {
											Options.Crest2Count++;
					}				
								
										
					
					saveCrestData();
					t.timer = setTimeout (function(){callback(r,0,CrestDataNum);}, ((Math.random()*(Options.Crestinterval-Options.CrestintervalAnd))+Options.CrestintervalAnd)*1000);	
					return;
					
				} else {

					if (rslt.user_action) {
						actionLog("AutoCrest","<b><font color=red>"+lang.General.DetectionCaptcha+"</font></b>");
						new CdialogCancelContinue('<SPAN class=boldRed>'+lang.General.Captcha+': Crest</span>', null, null, mainPop.getMainDiv);
						t.timer = setTimeout (function(){callback(r,retry,CrestDataNum);},5*60*1000);
						
						return;
					}
					t.timer = setTimeout (function(){callback(r,retry,CrestDataNum);}, Options.Crestinterval*1000);
					return;
				}
			   } catch(err) {
			     t.timer = setTimeout (function(){callback(r,retry,CrestDataNum);}, 1000);	
			     return;
			   }
			},
			 onFailure: function () {
			 actionLog("AutoCrest", 'Fail '+uW.g_js_strings.modal_barracks_train.attack+': '+p.xcoord+','+p.ycoord);
				setTimeout (function(){callback(r,retry,CrestDataNum);}, Options.Crestinterval*1000);
				return;
			 }
  		});	
	},
	

	
	abandonWilderness: function(tid,x,y,cid,callback,retry, CrestDataNum){
		var t = Tabs.Crest;		
		if (!Options.crestRunning) return;
		
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		var cityID = cid;
		var tileid = tid;
		params.tid=tid;
		params.cid=cid;
		params.x=x;
  		params.y=y; 		  		
  		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/abandonWilderness.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
  		    parameters: params,
  		    loading: true,
  		    onSuccess:function(transport){
				var rslt=eval("("+transport.responseText+")");
				if (rslt.ok) {
					t.error_code = 0;	
					if (rslt.returningMarches) {
						var cities = Object.keys(rslt.returningMarches);
						for (var i = 0; i < cities.length; i++) {
							for (var j = 0; j < rslt.returningMarches[cities[i]].length; j++) {
				                var cid = cities[i].split("c")[1];
				                var mid = rslt.returningMarches[cities[i]][j];
				                var march = Seed.queue_atkp["city" + cid]["m" + mid];
								if (march) {
									var marchtime = Math.abs(parseInt(march.destinationUnixTime) - parseInt(march.marchUnixTime));
				                    var ut = unsafeWindow.unixtime();
				                    Seed.queue_atkp["city" + cid]["m" + mid].destinationUnixTime = ut;
				                    Seed.queue_atkp["city" + cid]["m" + mid].marchUnixTime = ut - marchtime;
				                    Seed.queue_atkp["city" + cid]["m" + mid].returnUnixTime = ut + marchtime;
				                    Seed.queue_atkp["city" + cid]["m" + mid].marchStatus = 8
				                }
				            }
				        }
				    }
					if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
				    if (Object.keys(Seed.wilderness["city" + cityID]).length == 1) {
						Seed.wilderness["city" + cityID] = []
  		         	} else	{
						delete Seed.wilderness["city"+cityID]["t"+tileid];
  		         	}
				} else {
					if (rslt.error_code != 401) {
						t.error_code = rslt.error_code; 
               			
               		}
  		        }				
  		    },
  		    onFailure: function () {}
  		});
    },
    
	
	
	Rounds : function (r, retry, CrestDataNum) {
		var t = Tabs.Crest;
		
		clearTimeout(t.timer);
		
		if (!Options.crestRunning) return;
		
		if (CrestData.length == 0)
			return;
			
		if (CrestDataNum >= CrestData.length)
			CrestDataNum = 0;
		
		if (CrestData[CrestDataNum].active=="De-Actif") {
		    t.timer =setTimeout(function() { t.Rounds(1,0,parseInt(CrestDataNum+1)); },1000);
		    return;
		}
		
		
		cityID = 'city' + CrestData[CrestDataNum].CrestCity;
		retry++;
		
		
		for (var k in Seed.wilderness[cityID] ){
			if (Seed.wilderness[cityID][k]['xCoord']==CrestData[CrestDataNum].X && Seed.wilderness[cityID][k]['yCoord']==CrestData[CrestDataNum].Y && t.error_code!=401) {
				t.abandonWilderness(Seed.wilderness[cityID][k]['tileId'],Seed.wilderness[cityID][k]['xCoord'],Seed.wilderness[cityID][k]['yCoord'],CrestData[CrestDataNum].CrestCity,t.Rounds,retry,CrestDataNum);
			}
		}

		switch (retry) {
			case 10:
				t.timer =setTimeout(function(){ t.Rounds(r,retry,CrestDataNum);},30000);
				return;
				break;
			case 20:
				t.timer =setTimeout(function(){ t.Rounds(r,retry,CrestDataNum);},30000);
				return;
				break;
			case 50:
				//reloadKOC();
				return;
				break;
		}

		if (parseInt(Seed.units[cityID]['unt1']) < CrestData[CrestDataNum].R1ST || parseInt(Seed.units[cityID]['unt2']) < CrestData[CrestDataNum].R1MM || parseInt(Seed.units[cityID]['unt3']) < CrestData[CrestDataNum].R1Scout || parseInt(Seed.units[cityID]['unt4']) < CrestData[CrestDataNum].R1Pike || parseInt(Seed.units[cityID]['unt5']) < CrestData[CrestDataNum].R1Sword || parseInt(Seed.units[cityID]['unt6']) < CrestData[CrestDataNum].R1Arch || parseInt(Seed.units[cityID]['unt7']) < CrestData[CrestDataNum].R1LC || parseInt(Seed.units[cityID]['unt8']) < CrestData[CrestDataNum].R1HC || parseInt(Seed.units[cityID]['unt9']) < CrestData[CrestDataNum].R1SW || parseInt(Seed.units[cityID]['unt10']) < CrestData[CrestDataNum].R1Ball || parseInt(Seed.units[cityID]['unt11']) < CrestData[CrestDataNum].R1Ram || parseInt(Seed.units[cityID]['unt12']) < CrestData[CrestDataNum].R1Cat || parseInt(Seed.units[cityID]['unt1']) < CrestData[CrestDataNum].R2ST || parseInt(Seed.units[cityID]['unt2']) < CrestData[CrestDataNum].R2MM || parseInt(Seed.units[cityID]['unt3']) < CrestData[CrestDataNum].R2Scout || parseInt(Seed.units[cityID]['unt4']) < CrestData[CrestDataNum].R2Pike || parseInt(Seed.units[cityID]['unt5']) < CrestData[CrestDataNum].R2Sword || parseInt(Seed.units[cityID]['unt6']) < CrestData[CrestDataNum].R2Arch || parseInt(Seed.units[cityID]['unt7']) < CrestData[CrestDataNum].R2LC || parseInt(Seed.units[cityID]['unt8']) < CrestData[CrestDataNum].R2HC || parseInt(Seed.units[cityID]['unt9']) < CrestData[CrestDataNum].R2SW || parseInt(Seed.units[cityID]['unt10']) < CrestData[CrestDataNum].R2Ball || parseInt(Seed.units[cityID]['unt11']) < CrestData[CrestDataNum].R2Ram || parseInt(Seed.units[cityID]['unt12']) < CrestData[CrestDataNum].R2Cat) {
			if (CrestData.length == 1) {
				t.timer =setTimeout(function(){ t.Rounds(r,retry,CrestDataNum);},Options.Crestinterval*1000);
				return;
			 } else
				t.timer =setTimeout(function(){ t.Rounds(1,retry,parseInt(CrestDataNum)+1);},Options.Crestinterval*1000);
			return;
		}

		t.getAtkKnight(cityID);
		slots=0;
		
		for (z in Seed.queue_atkp[cityID]) {
			slots++;
		}
		if  (Seed.queue_atkp[cityID].toSource() == "[]")
			slots=0;
		
		slots=parseInt(slots)+parseInt(Options.CrestSlot); // protection slots
		t.getRallypointLevel(cityID);
				switch (t.rallypointlevel) {
					case 12:
						t.rallypointlevel = t.rallypointlevel - 1;
					default:
						if (t.rallypointlevel <= slots) {
							if (CrestData.length == 1) {
								t.timer = setTimeout(function(){ t.Rounds(r,retry,CrestDataNum);},Options.Crestinterval*1000);
							} else {
								t.timer = setTimeout(function(){ t.Rounds(1,retry,parseInt(CrestDataNum)+1);},Options.Crestinterval*1000);
							}
							return;
							break;
						}
				}


       
		if  (t.knt.toSource() == "[]") {
			t.timer = setTimeout(function(){ t.Rounds(1,retry,parseInt(CrestDataNum)+1);},Options.Crestinterval*1000);
			return;
		} 
		var kid = t.knt[0].ID;
		if (CrestData[CrestDataNum].R1ST == 0 && CrestData[CrestDataNum].R1MM == 0 && CrestData[CrestDataNum].R1Scout == 0 && CrestData[CrestDataNum].R1Pike == 0 && CrestData[CrestDataNum].R1Sword == 0 && CrestData[CrestDataNum].R1Arch == 0 && CrestData[CrestDataNum].R1LC == 0 && CrestData[CrestDataNum].R1HC == 0 && CrestData[CrestDataNum].R1SW == 0 && CrestData[CrestDataNum].R1Ball == 0 && CrestData[CrestDataNum].R1Ram == 0 && CrestData[CrestDataNum].R1Cat == 0) {
		   r=2;
	   	}else {
			var now = new Date().getTime()/1000.0;
			now = now.toFixed(0);
			if (now > (parseInt(CrestData[CrestDataNum].lastRoundTwo) + 300)) { // 3 minutes entre les premières vagues 
				r=1;
			}
		}

		switch(r) {
			case 1:
				if ((t.rallypointlevel-slots) < 2) {
					t.timer =setTimeout(function(){ t.Rounds(1,retry,(parseInt(CrestDataNum)+1));},Options.Crestinterval*1000);
					return;
				}
				var params 		= 	unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
				params.cid		= 	CrestData[CrestDataNum].CrestCity;
				params.type		=	4;
				params.kid		= 	kid;
				params.xcoord 	= 	CrestData[CrestDataNum].X;
				params.ycoord 	= 	CrestData[CrestDataNum].Y;
				if (now < (parseInt(CrestData[CrestDataNum].lastRoundTwo) + 300)) { 
				
					params.u2 	= 	(CrestData[CrestDataNum].R1MM / 10);
					params.u2 	= 	params.u2.toFixed(0);
					
					if (params.u2 < (CrestData[CrestDataNum].R1MM / 10)) 
						params.u2++;
				} else {
					params.u2	= 	CrestData[CrestDataNum].R1MM;
				}
				params.u1 		= 	CrestData[CrestDataNum].R1ST;
				params.u2 		= 	CrestData[CrestDataNum].R1MM;
				params.u3 		= 	CrestData[CrestDataNum].R1Scout;
				params.u4 		= 	CrestData[CrestDataNum].R1Pike;
				params.u5 		= 	CrestData[CrestDataNum].R1Sword;
				params.u6 		= 	CrestData[CrestDataNum].R1Arch;
				params.u7 		= 	CrestData[CrestDataNum].R1LC;
				params.u8 		= 	CrestData[CrestDataNum].R1HC;
				params.u9 		= 	CrestData[CrestDataNum].R1SW;
				params.u10 		= 	CrestData[CrestDataNum].R1Ball;
				params.u11 		= 	CrestData[CrestDataNum].R1Ram;
				params.u12 		= 	CrestData[CrestDataNum].R1Cat;
				
				t.sendMarch(params,t.Rounds,r,retry, CrestDataNum);
				break;
			default:
				var params 		= 	unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
				params.cid		= 	CrestData[CrestDataNum].CrestCity;
				params.type		= 	4;
				params.kid		= 	kid;
				params.xcoord 	= 	CrestData[CrestDataNum].X;
				params.ycoord 	= 	CrestData[CrestDataNum].Y;
				params.u1 		= 	CrestData[CrestDataNum].R2ST;
				params.u2 		= 	CrestData[CrestDataNum].R2MM;
				params.u3 		= 	CrestData[CrestDataNum].R2Scout;
				params.u4 		= 	CrestData[CrestDataNum].R2Pike;
				params.u5 		= 	CrestData[CrestDataNum].R2Sword;
				params.u6 		= 	CrestData[CrestDataNum].R2Arch;
				params.u7 		= 	CrestData[CrestDataNum].R2LC;
				params.u8 		= 	CrestData[CrestDataNum].R2HC;
				params.u9 		= 	CrestData[CrestDataNum].R2SW;
				params.u10 		= 	CrestData[CrestDataNum].R2Ball;
				params.u11 		= 	CrestData[CrestDataNum].R2Ram;
				params.u12 		= 	CrestData[CrestDataNum].R2Cat;
				t.sendMarch(params,t.Rounds,r,retry, CrestDataNum);
				break;
		}

	},
	

	
	toggleCrestState: function(obj) {
		var t = Tabs.Crest;
		obj = ById('Cresttoggle');
			if (Options.crestRunning == true) {
				Options.crestRunning = false;
				if (obj) obj.value = lang.BoiteLabelCrest+" = OFF";
				updatebotbutton(lang.BoiteLabelCrest+' - OFF', 'pbautotstab');
				saveOptions();
			} else {
				Options.crestRunning = true;
				if (obj) obj.value = lang.BoiteLabelCrest+" = ON";
				updatebotbutton(lang.BoiteLabelCrest+' - ON', 'pbautotstab');
				Options.Creststatus={1101:0,1102:0,1103:0,1104:0,1105:0,1106:0,1107:0,1108:0,1109:0,1110:0,1111:0,1112:0,1113:0,1114:0,1115:0,9:0,36:0,37:0,38:0,55:0,57:0,261:0,262:0,271:0,272:0,351:0,361:0,362:0,911:0,3000:0,3001:0,3002:0,3003:0,3007:0,3008:0,3009:0,3011:0,931:0,932:0,285:0,};
				for (crest in Options.Creststatus) {
					owned = Seed.items['i'+crest];
					if (owned == undefined) {
						owned=0;
					}
					Options.Creststatus[crest] = owned;
					Options.Crest1Count = 0;
					Options.Crest2Count = 0;
				}
				var now = new Date().getTime()/1000.0;
				now = now.toFixed(0);
				Options.LastCrestReport = now;
				saveOptions();
				t.timer =setTimeout(function(){ t.Rounds(1,0,0);}, 1000);
			}
	},
	 sendCrestReportNow: function(){
	    	var t = myBO.Crest;
	    	var now = new Date().getTime()/1000.0;
	        now = now.toFixed(0);   	
	    	var total = 0;
	    	var wildtype = '';
		
		var message = lang.crest.msg1+' %0A';
		message += '%0A '+lang.crest.msg2+'%0A';

		for (crest in Options.Creststatus) {
			owned = Seed.items['i'+crest];
			if (owned == undefined) 
				owned =	0;
			if ((owned - Options.Creststatus[crest]) > 0) 
				message	+= 	'<DIV><B>' + unsafeWindow.itemlist['i'+crest]['name'] +': '+ (owned - Options.Creststatus[crest]) +'%0A </b></div>';
			total += (owned - Options.Creststatus[crest]);
			Options.Creststatus[crest] = owned;
		
		}
		message += '%0A '+lang.crest.msg3+' ' + timestr(now-Options.LastCrestReport) + '%0A'
		message += '%0A '+lang.crest.msg4+' '+ total +'%0A';
		message += '%0A '+lang.crest.msg5+' '+ Options.Crest1Count +'%0A';
		message += ''+lang.crest.msg6+' '+ Options.Crest2Count +'%0A';

	    	Options.Crest1Count = 0;
	    	Options.Crest2Count = 0;
	    	Options.Crest3Count = 0;
	    	Options.Crest4Count = 0;
	      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	      params.emailTo = Seed.player['name'];
	      params.subject = lang.crest.msg7;
	      params.message = message;
	      params.requestType = "COMPOSED_MAIL";
	      new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
	          method: "post",
	          parameters: params,
	          onSuccess: function (message) {
	              var rslt = eval("(" + message.responseText + ")");
	              if (rslt.ok) {
	              		Options.LastCrestReport = now;
	              } else {
	              }
	          },
	          onFailure: function () {
	          },
	      });
	      saveOptions();
      },  
	sendCrestReport: function(){
		if(!Options.crestreport || !CrestOptions.Running) 
			return;
			
		var t = Tabs.Crest;
		var now = new Date().getTime()/1000.0;
		now = now.toFixed(0);
		
		if (now < (parseInt(Options.LastCrestReport)+(Options.CrestMsgInterval*60*60))) 
			return;

		var total = 0;
		var wildtype = 	'';
		
		var message = 'Crest Stats: %0A';
		message += '%0A Crests Gained%0A';

		for (crest in Options.Creststatus) {
			owned = Seed.items['i'+crest];
			if (owned == undefined) 
				owned =	0;
			if ((owned - Options.Creststatus[crest]) > 0) 
				message	+= 	'<DIV><B>' + unsafeWindow.itemlist['i'+crest]['name'] +': '+ (owned - Options.Creststatus[crest]) +'%0A </b></div>';
			else 
				message	+= 	unsafeWindow.itemlist['i'+crest]['name'] +': '+ (owned - Options.Creststatus[crest]) +'%0A';
				
			total += (owned - Options.Creststatus[crest]);
			Options.Creststatus[crest] = owned;
		}
		
		message += '%0A Total Crests gained: '+ total +'%0A';
		message += '%0A Numbers of 1st Wave send: '+ Options.Crest1Count +'%0A';
		message += 'Numbers of 2nd Wave send: '+ Options.Crest2Count +'%0A';

		Options.Crest1Count = 0;
		Options.Crest2Count = 0;

		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
		params.emailTo = Seed.player['name'];
		params.subject = lang.crest.msg7;
		params.message = message;
		params.requestType = "COMPOSED_MAIL";
		
		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getEmail.php" + unsafeWindow.g_ajaxsuffix, {
			method: "post",
			parameters: params,
			onSuccess: function (message) {
				var rslt = eval("(" + message.responseText + ")");
				if (rslt.ok) {
					Options.LastCrestReport = now;
				} 
			},
			onFailure: function () {
			},
		});

		saveOptions();
	},	


	hide : function (){
		var t = Tabs.Crest;
	},

	show : function (){
	 var t = Tabs.Crest;
	if (ById ('maparea_map').style.display!="none") {
	         ById ('pbcrestx').value = ById ('mapXCoor').value;
                 ById ('pbcresty').value = ById ('mapYCoor').value;
                 CrestOptions.X = ById('pbcrestx').value;
                 CrestOptions.Y = ById('pbcresty').value;
         }
	},
 };
/** End Cresting tab **/

/*********************************** Players TAB ***********************************/
Tabs.AllianceList = {
  tabOrder: 5,
  tabLabel: uW.g_js_strings.commonstr.player,
  cont : null,
  nombre: null,
  state : null,
  dat : [],

  show : function (){ 
  },

  hide : function (){
  },

  init : function (div){
     var t = Tabs.AllianceList;
        t.cont = div;
        t.nombre=0;
        uW.BoPTgetMembers = t.eventGetMembers;
        uW.PTPaintMembers = t.GetDataForMap;
        uW.BoPTDme = t.eventGetLienMember;
        uW.BoPTpd = t.clickedPlayerDetail;
        uW.BoPTpl = t.clickedPlayerLeaderboard;
        uW.BoPTpl2 = t.clickedPlayerLeaderboard2;
        uW.BoPCplo = t.clickedPlayerGetLastLogin;
        uW.BoPTalClickPrev = t.eventListPrev;
        uW.BoPTalClickNext = t.eventListNext;
        uW.BOGetThrone = t.clickedPlayerGetThrone;
   
    if (t.state == null){
      if (getMyAlliance()[0] == 0) {
        t.cont.innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.membersInfo.youmustbelong+'</center>';
        t.state = 1;
        return;
      }
      var m = '<DIV class=ptentry><TABLE width=100% cellpadding=0>\
          <TR><TD class=xtab align=right></td><TD class=xtab>'+uW.g_js_strings.modal_fow_leaderboard.searchuser+': &nbsp;</td>\
            <TD class=xtab><INPUT id=allPlayName type=text /> &nbsp; <INPUT id=playSubmit type=submit value="'+uW.g_js_strings.modal_fow_leaderboard.searchuser+'" /></td>\
            <TD class="xtab ptErrText"><SPAN id=ptplayErr></span></td></tr>\
          <TR><TD class=xtab>&nbsp;</td><TD class=xtab>'+uW.g_js_strings.setDiplomacyWindow.srchalli+' : &nbsp;</td>\
            <TD class=xtab><INPUT id=allAllName type=text /> &nbsp; <INPUT id=allSubmit type=submit value="'+uW.g_js_strings.modal_fow_leaderboard.findalli+'" /></td>\
            <TD class="xtab ptErrText"><SPAN id=ptallErr></span></td></tr>\
            <TR><TD class=xtab>&nbsp;</td><TD class=xtab> &nbsp;\
            <INPUT align=left id=allListSubmit type=submit value="'+uW.g_js_strings.modal_alliance.allilist+'" /></td>\
            <TD class=xtab><INPUT align=right id=allGotoPage type=submit value="Page" />\
             <INPUT align=right id=idPageNum type="text" value='+t.curPage+' size=4 />\
             <INPUT align=left id="idMyAllSubmit" type=submit value="'+ getMyAlliance()[1] +'"/>\
             <INPUT align=left id="idMyTHSubmit" type=submit value="TOP 100"/>\
             <span align=right <b>'+uW.g_js_strings.commonstr.estimatedtime+': </b></span></td>\
	                  <TD class=xtab ><div><select id="idFindETASelect">\
	             <option value="0" > -- '+lang.General.Select+' -- </option>\
 	<option value="1" >'+uW.unitcost["unt1"][0]+'</option>\
        <option value="2" > '+uW.unitcost["unt2"][0]+' </option>\
        <option value="3" > '+uW.unitcost["unt3"][0]+' </option>\
        <option value="4" > '+uW.unitcost["unt4"][0]+' </option>\
        <option value="5" > '+uW.unitcost["unt5"][0]+' </option>\
        <option value="6" > '+uW.unitcost["unt6"][0]+' </option>\
        <option value="7" > '+uW.unitcost["unt7"][0]+' </option>\
        <option value="8" > '+uW.unitcost["unt8"][0]+' </option>\
        <option value="9" > '+uW.unitcost["unt9"][0]+' </option>\
        <option value="10" > '+uW.unitcost["unt10"][0]+' </option>\
        <option value="11" > '+uW.unitcost["unt11"][0]+' </option>\
        <option value="12" > '+uW.unitcost["unt12"][0]+' </option>\
        </select></div>\
        </td></tr>\
          </table><span style="vertical-align:middle;" id=altInput></span></div>\
          <SPAN id=allListOut></span>';
      t.cont.innerHTML = m;
      
      ById('allSubmit').addEventListener ('click', t.eventSubmit, false);
      ById('playSubmit').addEventListener ('click', t.eventPlayerSubmit, false);
      ById('allAllName').addEventListener ('focus', function (){ById('ptallErr').innerHTML='';}, false);
      ById('idMyTHSubmit').addEventListener ('click', t.eventListTHSubmit, false);
      ById('allPlayName').addEventListener ('focus', function (){ById('ptplayErr').innerHTML='';}, false);
      ById('allListSubmit').addEventListener ('click', t.eventListSubmit, false);
      ById('allGotoPage').addEventListener ('click', t.gotoPage, false);
      ById('idMyAllSubmit').addEventListener ('click', t.showMyAlliance, false);
      ById('allGotoPage').disabled = true;
      ById('idFindETASelect').addEventListener ('click', t.handleEtaSelect, false);
      ById('idFindETASelect').disabled = true;
        
      t.ModelCity=Cities.cities[0];
      t.curPage = 0;
      t.MaxPage = -1;
      t.state = 1;
    }
  },

  pName : '',
  eventPlayerSubmit : function (){
    var t = Tabs.AllianceList;
    ById('ptplayErr').innerHTML='';
    var name = ById('allPlayName').value;
     name = name.replace(/\'/g,"_");
    t.pName = name;
    if (name.length < 3){
      ById('ptplayErr').innerHTML = uW.g_js_strings.getAllianceSearchResults.entryatleast3;
      return;
    }
    ById('altInput').innerHTML = '';
     ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'</center>';
    t.fetchPlayerList (name, t.eventGotPlayerList);
  },
  eventGetLienMember: function(name) {
    var t = Tabs.AllianceList;
    ById('allPlayName').value = name;
    t.eventPlayerSubmit();   
  }, 
  eventGotPlayerList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      ById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    t.playerList = rslt.matchedUsers;
        var uList = [];
        for (k in rslt.matchedUsers)
          uList.push (rslt.matchedUsers[k].userId);     
          t.fetchPlayerStatus (uList, function(r) {t.eventGotPlayerOnlineList(r)});    
      },    
        
      eventGotPlayerOnlineList : function (rslt){
        var t = Tabs.AllianceList;
        if (!rslt.ok){
          ById('allListOut').innerHTML = rslt.errorMsg;
          return;
    }
    var m = '<DIV class=boStat>'+uW.g_js_strings.recommendSelectedFriends.playersrch+' : <b>"'+ t.pName +'"</b></div>\
      <DIV style="height:575px; max-height:575px; overflow-y:auto">\
      <TABLE width=95% align=center class=ptTab cellspacing=0><TR style="font-weight:bold"><TD width=20%>'+uW.g_js_strings.commonstr.nametx+'</td>\
      <TD align=right>'+uW.g_js_strings.commonstr.might+' &nbsp;&nbsp;&nbsp;&nbsp;</td><td>KOCMon<TD> &nbsp; '+uW.g_js_strings.commonstr.online+'</td><TD width=60%>'+uW.g_js_strings.commonstr.search+' </td></tr>';
    var row=0;
    var cl='';
    for (k in t.playerList){
      var u = t.playerList[k];
      if (++row % 2)
        cl = 'class=ptOddrow ';
      else
        cl = '';
        if (u.allianceName) { var alliancenammme=u.allianceName; }else {var alliancenammme="---"; }
      m += '<TR '+ cl +'valign=top><TD><A target="_tab" href="http://kocmon.com/'+getServerId()+'/players/'+ u.userId +'">'+ u.genderAndName +'</a><br>'+alliancenammme+'<br><A target="_tab" href="http://www.facebook.com/profile.php?id='+ u.fbuid +'">'+uW.g_js_strings.commonstr.profile+'</a></td><TD align=center>&nbsp;'+ addCommasInt(u.might) +'&nbsp;</td><td><a target=_blank href="http://kocmon.com/'+uW.domainName +'/players/'+ u.userId +'">Info KOCmon</a></td>\
          <TD>'+ (rslt.data[u.userId]?"&nbsp;<SPAN class=boldDarkRed>"+uW.g_js_strings.commonstr.online+"</span>":"") +'</td>\
         <TD><SPAN onclick="BoPTpd(this, '+ u.userId +')"><A>'+uW.g_js_strings.modaltitles.memberdetails+'</a> &nbsp; <BR></span><span onclick="BoPTpl2(this,'+ u.userId+','+rslt.data[u.userId]+')"><A>'+uW.g_js_strings.modaltitles.leaderboard+'</a></span>&nbsp;<br><SPAN onclick="BoPCplo(this, \''+ u.userId +'\')"><A>'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+'</a></span>\
         <br><DIV style="" onclick="BOGetThrone(this, '+ u.userId +')"><A>'+uW.g_js_strings.commonstr.throneroom+'</a></div></td></tr>';
    }
    m += '</table></div>';
    ById('allListOut').innerHTML = m;
  },
  fetchPlayerThrone : function (uid, notify){
  var t = Tabs.AllianceList;
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        	params.ctrl="throneRoom\\ThroneRoomServiceAjax";
	    		params.action ="getEquipped";
    		params.playerId = uid;
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/_dispatch53.php" + unsafeWindow.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          onSuccess: function (rslt) {
            notify (rslt);
          },
          onSuccess: function (rslt) {
            notify (rslt);
          },
      });
  },
  
  clickedPlayerGetThrone: function(span, uid) {
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = uW.g_js_strings.commonstr.loadingddd+"...";
    t.fetchPlayerThrone (uid, function (r) {t.gotThronePlayer(r, span)});
  
  },
  gotThronePlayer : function (rslt, span){
        var t = Tabs.AllianceList;
        if (!rslt.ok){
          span.innerHTML = "None";
          return;
        }
        var B=0, w={}, x, C;
        var k=rslt.items;
        var m="";
        for (var K in k) {
           x=0;
           var F = k[K].effects;
	   for (var M in F) {
            x++;
           
            if (k[K].quality >= x) {
             B++;
             I = uW.cm.thronestats.effects[F[M].id];
             z = uW.cm.thronestats.tiers[F[M].id][F[M].tier];
             C = + z.base + (k[K].level * k[K].level + k[K].level) * + z.growth * 0.5;
             if (!w[F[M].id]) {
	     	w[F[M].id] = {};
	     }
	     if (!w[F[M].id].percent) { 
	     	w[F[M].id].percent = C; 
	      } else {
	     	w[F[M].id].percent += C; 
	     }
	     w[F[M].id].name = I[1];
            }
           }
        }
        
        m+="<table border=0 width=250 cellspacing=0>";
        for (var K in w) {
             var Current =  Math.round(w[K].percent*100)/100;
             G="<tr><td align=right><b>"+ Current + " %</b></td><td align=left>" + w[K].name + "</td></tr>";
	     m+=G;
        }
        m+="</table>";
        span.innerHTML = m;
    },

  clickedPlayerDetail : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = uW.g_js_strings.commonstr.search +': '+ uW.g_js_strings.modaltitles.memberdetails + " ...";
    t.fetchPlayerInfo (uid, function (r) {t.gotPlayerDetail(r, span)});
  },

  clickedPlayerLeaderboard : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = uW.g_js_strings.commonstr.search +': '+ uW.g_js_strings.modaltitles.leaderboard + " ...";
    t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard(r, span)});
  },
  clickedPlayerLeaderboard2 : function (span, uid,status){
      var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = uW.g_js_strings.commonstr.search +': '+ uW.g_js_strings.modaltitles.leaderboard + " ...";
    t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard2(r, span,uid,status)});
  },
  
   clickedPlayerGetLastLogin : function (span, uid){
      var t = Tabs.AllianceList;
      span.onclick = '';
      span.innerHTML = uW.g_js_strings.commonstr.search +': '+ uW.g_js_strings.modal_messages_viewreports_view.lastlogin + " ...";
      t.fetchPlayerLastLogin (uid, function (r) {t.gotPlayerLastLogin(r, span)});
    },
   gotPlayerLeaderboard2 : function (rslt,span,uid,status){
      var t = Tabs.AllianceList;
      if (!rslt.ok){
        span.innerHTML = rslt.errorMsg;
        return;
      }
      if (rslt.totalResults == 0){
        span.innerHTML = '<B>'+uW.g_js_strings.commonstr.leaderboard+': </b>'+uW.itemlist.i10021.name+'?<BR>';
        return;
      }
      var myA = getMyAlliance ();
      t.dat = [];
      var p = rslt.results[0];
          if ( myA[0] == p.allianceId)
             t.friendEta = true;
          else
             t.friendEta = false;
          for (var c=0; c<p.cities.length; c++){
                   t.dat.push ([p.displayName, parseInt(p.might), p.officerType, parseInt(p.numCities), parseInt(p.cities[c].tileLevel),
		                parseInt(p.cities[c].xCoord), parseInt(p.cities[c].yCoord), p.cities[c].cityName, 0, c, p.userId, p.avatarId, p.playerSex, p.rank, status, 'NA']);
         
          }
          t.setDistances (Cities.cities[0].x, Cities.cities[0].y);
          t.ModelCity=Cities.cities[0];
          t.setEta();
          t.fetchPlayerLastLogin (uid, function (r) {t.displayPlayer(p.allianceName,r)});
  },
  gotPlayerLeaderboard : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    if (rslt.totalResults == 0){
      span.innerHTML =  '<B>'+uW.g_js_strings.commonstr.leaderboard+': </b>'+uW.itemlist.i10021.name+'?<BR>';
      return;
    }
    var p = rslt.results[0];
    var an = p.allianceName;
    if (!an || an=='' || p.officerType==4)
      an = 'Aucune';
    else
      an += ' ('+ officerId2String(p.officerType) +')';
    m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>'+uW.g_js_strings.commonstr.leaderboard+': </b></td><TD colspan=2> '+uW.g_js_strings.commonstr.might+': '+ p.might  +' &nbsp; '+uW.g_js_strings.commonstr.alliance+': '+ an +'</td></tr>'; 
    for (var i=0; i<p.cities.length; i++){
      var c = p.cities[i];
      var created = '';
      if (c.dateCreated && c.dateCreated.substr(0,2)=='20')
        created = ' &nbsp; &nbsp; Created: ' + c.dateCreated.substr(0,10);
      m += '<TR><TD align=right><B>'+uW.g_js_strings.commonstr.city+' #'+ (i+1) +':</b></td><TD> &nbsp; '+ c.cityName 
        + '&nbsp;<a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ c.xCoord +',' +c.yCoord+ ')</a>'
        + '</td><TD width=75%> &nbsp; '+uW.g_js_strings.commonstr.level+': '
        + c.tileLevel +' &nbsp; &nbsp; '+uW.g_js_strings.commonstr.status+': '+ cityStatusString (c.cityStatus) + created +'</td></tr>';
    }  
    span.innerHTML = m + '</table>';
  },
 displayPlayer : function (allName,rslt){
   var t = Tabs.AllianceList;
    function alClickSort (e){
      var t = Tabs.AllianceList;
      var newColNum = e.id.substr(8);
      ById('clickCol'+t.sortColNum).className = 'clickable';
      e.className='clickable clickableSel';
      if (newColNum == t.sortColNum)
        t.sortDir *= -1;
      else
        t.sortColNum = newColNum;
      t.reDisp();
    }
    uW.PTalClickSort = alClickSort;
    var m = '<STYLE>.clickable{background-color:#ddd; border:2px outset; border-color:#555; padding-left:5px; padding-right:5px}\
            .clickableSel{background-color:#ffffcc;}\
            .xxtab{background-color:none; padding-left:5px; padding-right:5px;} </style>\
            <DIV class=boStat ><TABLE id=tabAllMembers cellpadding=0  width=100%><TR font-weight:bold"><TD class=xtab>'+uW.g_js_strings.commonstr.alliance+': '+ allName +'</td>\
              <TD class=xtab width=80% align=center>'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+' : <SPAN id=lastlogin>'+  rslt.playerInfo.lastLogin+'</span></td><TD class=xtab align=right></td></tr></table></div>\
      <div style="max-height:470px; height:470px; overflow-y:auto;"><TABLE id=tabAllMembers align=center cellpadding=0 cellspacing=0><THEAD style="overflow-y:hidden;">\
      <TR style="font-weight:bold"><TD id=clickCol0 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.player+'</div></a></td>\
        <TD id=clickCol1 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>'+uW.g_js_strings.commonstr.rank+'</a></div></td>\
        <TD id=clickCol3 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.cities+'</a></div></td>\
        <TD id=clickCol2 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>'+uW.g_js_strings.commonstr.alliance+'</a></div></td>\
        <TD id=clickCol9 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>'+uW.g_js_strings.commonstr.online+'</a></div></td>\
        <TD id=clickCol7 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.MapObject.cityname+'</a></div></td>\
        <TD id=clickCol4 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.lvl+'</a></div></td>\
        <TD id=clickCol5 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.coordinates+'</a></div></td>\
        <TD id=clickCol8 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.distance+'</a></div></td>\
        <TD id=clickCol10 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.attack_generateincoming.estimatedarrival+'</a></div></td>\
		<TD class=clickable><A><DIV>'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+'</a></div></td></tr></thead>\
      <TBODY id=allBody style="background-color:#ffffff;"></tbody></table></div>\
      <DIV  width:100%; style="top:670px; left:0px; position:absolute; background-color:#ffffff; border-top:1px solid; margin-top:8px; color:#700; font-weight:bold;">';
    ById('allListOut').innerHTML = m; 
    ById('altInput').innerHTML = '<HR><TABLE width=100% cellpaddding=0><TR align=center>\
        <TD class=xtab>'+uW.g_js_strings.commonstr.distance + ' ' + uW.g_js_strings.commonstr.from+' : &nbsp; X: <INPUT size=2 type=text id=plyrX /> Y: <INPUT size=2 type=text id=plyrY /> &nbsp; '+lang.General.or+' '+uW.g_js_strings.commonstr.city+': <span id=dmcoords></span></td></tr></table>';
    ById('clickCol'+t.sortColNum).className = 'clickable clickableSel';

    t.reDisp();
    new CdispCityPicker ('plyrdcp', document.getElementById ('dmcoords'), true, t.eventCoords, 0).bindToXYboxes(ById('plyrX'), ById('plyrY'));
    ById('idFindETASelect').disabled = false;
  },

  gotPlayerLastLogin : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }

    var p = rslt.playerInfo;
    var lastLogin = rslt.playerInfo.lastLogin;
    
    if (lastLogin) {
      m = '<span style="color:blue">'+lastLogin+'</span>';
    } else {
       m = '<span style="color:red">-</span>';
    }  
    span.innerHTML = m + '';
  }, 
  gotPlayerDetail : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    var u = rslt.userInfo[0];
    var a = 'Aucune';
    if (u.allianceName)
      a = u.allianceName +' ('+ getDiplomacy(u.allianceId) + ')';
    var m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>'+uW.g_js_strings.modaltitles.memberdetails+':</b> &nbsp; </td><TD>'+uW.g_js_strings.commonstr.alliance+' : '+ a +' &nbsp; '+uW.g_js_strings.commonstr.cities+' : '
          + u.cities +' &nbsp; '+uW.g_js_strings.commonstr.population+' : '+ u.population +'</td></tr><TR><TD></td><TD>'+uW.g_js_strings.commonstr.province+' : ';
    var pids = u.provinceIds.split (',');
    var p = [];
    for (var i=0; i<pids.length; i++)
      p.push(uW.provincenames['p'+pids[i]]);
    span.innerHTML = m + p.join (', ') +'</td></tr></table>';
  },

  aName : '',
  eventSubmit : function (){
    var t = Tabs.AllianceList;
    ById('ptallErr').innerHTML='';
    t.aName = ById('allAllName').value;
    if (t.aName.length < 3){
      ById('ptallErr').innerHTML = uW.g_js_strings.getAllianceSearchResults.entryatleast3;
      return;
    }
    var myA = getMyAlliance ();
    ById('altInput').innerHTML = '';
    ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'...</center>';
    if (myA[0]!=0 && myA[1].toLowerCase().indexOf(t.aName.toLowerCase())>=0 )
      t.fetchAllianceList (t.aName, myA[0], t.eventGotAllianceList);
    else
      t.fetchAllianceList (t.aName, null, t.eventGotAllianceList);
  },
  eventListSubmit : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();
    ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'...</center>';
    if (myA[0]!=0  ) {
       t.curPage=1;
       t.fetchOtherAllianceInfo ( 1, t.eventGotOtherAlliancePage);
       ById('allGotoPage').disabled = false;
    }
    else {
       ById('allListOut').innerHTML =  uW.g_js_strings.membersInfo.youmustbelong;
    }
  },
  eventListTHSubmit : function (){
      var t = Tabs.AllianceList;
      ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'...</center>';
      t.fetchUserLeaderboard (1, t.eventGetUserLeaderboard);
  },
  eventGotAllianceList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      ById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    var m = '<DIV class=boStat>'+uW.g_js_strings.commonstr.alliances+' <B>"'+ t.aName +'"</b></div>\
    <TABLE><TR style="font-weight:bold"><TD class=xtab>'+uW.g_js_strings.commonstr.alliance+'</td><TD class=xtab>'+uW.g_js_strings.commonstr.rank+'</td><TD class=xtab>'+uW.g_js_strings.commonstr.members+'</td>\
        <TD align=right class=xtab>'+uW.g_js_strings.commonstr.might+'</td><TD class=xtab>'+uW.g_js_strings.getAllianceSearchResults.currdiplo+'</td><TD class=xtab>'+uW.g_js_strings.commonstr.members+'</td><TD class=xtab>'+uW.g_js_strings.commonstr.viewmap+'</td></tr>';
    for (k in rslt.alliancesMatched){
      var all = rslt.alliancesMatched[k];
      var dip = '';
      if (all.relation && all.relation==1)
        dip = uW.g_js_strings.commonstr.friendly;
      else if (all.relation && all.relation==2)
        dip = uW.g_js_strings.commonstr.hostile;
      m += '<TR  class="'+ dip + '"><TD class=xtab>'+ all.allianceName +'</td><TD align=right class=xtab>'+ all.ranking +'</td><TD align=right class=xtab>'+ all.membersCount +'</td>\
       <TD align=right class=xtab>'+ addCommasInt(all.might) +'</td><TD class=xtab>'+ dip +'</td>\
       <TD class=xtab><a onclick="BoPTgetMembers('+ all.allianceId +')">'+uW.g_js_strings.commonstr.members+'</a></td>\
       <TD class=xtab><a onclick="PTPaintMembers('+ all.allianceId +')">'+uW.g_js_strings.commonstr.viewmap+'</a></td></tr>';
    }
    ById('allListOut').innerHTML = m;
  },
  GetDataForMap : function (allianceId) {
    var t = Tabs.AllianceList;
    var params = uW.Object.clone(uW.g_ajaxparams);
    var Data=[];
    params.perPage = 100;
    params.allianceId = allianceId;
    new MyAjaxRequest(uW.g_ajaxpath + "ajax/getUserLeaderboard.php" + uW.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
      	var city = '';
      	for (var i=0; i<rslt.results.length; i++) {
      	    if (rslt.results[i]['userId'] !=0){
	      	    player = rslt.results[i]['cities'];
	      	    for (var ii=0; ii<player.length; ii++) 
	      			Data.push ({X:player[ii]['xCoord'],Y:player[ii]['yCoord']});
	    	}  	
        }
        if (Data != []) t.PaintDataOnMap(Data);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },
  PaintDataOnMap : function(Data){
  		var provMapCoordsA = {imgWidth:710, imgHeight:708, mapWidth:670, mapHeight:670, leftMargin:31, topMargin:19};  
  		var map = '<div style="overflow:auto; height:'+(Options.HauteurBoite-140)+'px;max-height:'+(Options.HauteurBoite-140)+'px;"><DIV id=ptAlliProvMap style="height:'+ provMapCoordsA.imgHeight +'px; width:'+ provMapCoordsA.imgWidth +'px; background-repeat:no-repeat; background-image:url(\''+ URL_PROVINCE_MAP +'\')"></div></div>';
		ById('allListOut').innerHTML = map;
		var eMap =  ById('ptAlliProvMap');
		for (var cc=0; cc<Seed.cities.length; cc++) {
		    var city = Seed.cities;
		    var Xplot = parseInt((provMapCoordsA.mapWidth * parseInt(city[cc][2])) / 750);
		    var Yplot = parseInt((provMapCoordsA.mapHeight * parseInt(city[cc][3])) / 750);
		    var cf = document.createElement ('div');
		    cf.style.background = 'black';
		    cf.style.opacity = '1.0';
		    cf.style.position='relative';
		    cf.style.display='block';
		    cf.style.width='14px';
		    cf.style.height='16px';
		    cf.style.border='1px solid #fff';
		    cf.style.color = 'white';
		    cf.style.textAlign = 'center';
		    cf.style.top = (Yplot+provMapCoordsA.topMargin-(cc*16)-8) +'px';      
		    cf.style.left = (Xplot+provMapCoordsA.leftMargin-7) +'px';
		    cf.innerHTML = (cc+1) +'';
		    eMap.appendChild(cf);
		    
		}
		for (var i=0;i<Data.length;i++) {
			var x = parseInt(Data[i]['X']);
			var y = parseInt(Data[i]['Y']);
  	        var xplot = parseInt((provMapCoordsA.mapWidth * x) / 750);
  	        var yplot = parseInt((provMapCoordsA.mapHeight * y) / 750);
  	    	var ce= document.createElement ('div');
  	    		ce.style.background = 'red';
  	    		ce.style.opacity = '1.0';
  	    		ce.style.position='relative';
  	    		ce.style.display='block';
  	    		ce.style.width='4px';
  	    		ce.style.height='4px';
  	    		ce.style.color = 'white';
  	    		ce.style.textAlign = 'center';
  	    	ce.style.top = (yplot+provMapCoordsA.topMargin -(4*i)-((Seed.cities.length)*18)) +'px';      
  	    	ce.style.left = (xplot+provMapCoordsA.leftMargin -2) +'px';
  	    	ce.innerHTML = '<DIV onclick="ptGotoMap('+ x +','+ y +')">&nbsp;</div>';
  	        eMap.appendChild(ce);
  	   }	   
  },  
 showMyAlliance : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();
    ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'...</center>';
    if (myA[0]!=0  ) {
       t.eventGetMembers(myA[0]);
    }
    else {
       ById('allListOut').innerHTML =  uW.g_js_strings.membersInfo.youmustbelong;
    }
  },
 curPage : 0,
  MaxPage : 0,

  eventListNext : function (amt){
    var t = Tabs.AllianceList;
    if( parseInt(amt) >= 9999 )
       t.curPage = t.MaxPage;
    else {
	    t.curPage = parseInt(t.curPage) + parseInt(amt);
	    if ( t.curPage > t.MaxPage) {
	      t.curPage = t.MaxPage;
	    }
    }
    ById('allListOut').innerHTML = '<BR><BR><CENTER> ...</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },

  eventListPrev : function (amt){
    var t = Tabs.AllianceList;
    if(amt <= -1)
       t.curPage = 1;
    else {
	    t.curPage-=amt;
	    if ( t.curPage < 1 ) {
	      t.curPage = 1;
	    }
    }
    ById('allListOut').innerHTML = '<BR><BR><CENTER> ...</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },

  gotoPage : function (){
    var t = Tabs.AllianceList;
    var val = ById('idPageNum').value;
    if (t.MaxPage < 0 ) {
      ById('allListOut').innerHTML = 'List Alliances first.';
      return;
    }
    if (t.MaxPage < 0 || val > t.MaxPage || val < 1) {
      ById('allListOut').innerHTML = 'Page number out of range';
      return;
    }
    t.curPage = val;
    ById('allListOut').innerHTML = '<BR><BR><CENTER> ...</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },
  
  eventGetUserLeaderboard: function(rslt) {
   var t = Tabs.AllianceList;
      if (!rslt.ok){
        ById('allListOut').innerHTML = rslt.errorMsg;
        return;
    }
    var m = '<div style="overflow:auto; height:'+(Options.HauteurBoite-145)+'px;max-height:'+(Options.HauteurBoite-145)+'px;"><TABLE width="100%"><thead><TR style="font-weight:bold"> \
          <th class=xtab>'+uW.g_js_strings.commonstr.ranking+'</th><th class=xtab>'+uW.g_js_strings.commonstr.nametx+'</th><th>Avatar</th><th class=xtab>'+uW.g_js_strings.commonstr.might+'</th>\
          <th class=xtab>'+uW.g_js_strings.commonstr.alliance+'</th><th class=xtab>'+uW.g_js_strings.commonstr.rank+'</th><th class=xtab>'+uW.g_js_strings.commonstr.cities+'</th></tr></thead><tbody>';
    ById('allListOut').innerHTML = m;
    for (var i=0; i<rslt.results.length; i++) {
     var resultat = rslt.results[i];
    
     m += '<TR class=xtab><TD class=xtab align=center><b>' + resultat.rank +'</b></td>\
                <td class=xtab><a onclick=BoPTDme("' + resultat.displayName +'");><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/avatars/25/' + resultat.playerSex + '' + resultat.avatarId + '.jpg"></a></td>\
     		<TD class=xtab>' + resultat.displayName +'</td>\
     		<td class=xtab>' + resultat.might + '</td>\
     		<td class=xtab><a onclick="BoPTgetMembers('+ resultat.allianceId +')">' + resultat.allianceName + '</a></td>\
     		<td class=xtab>' + officerId2String(resultat.officerType) + '</td><td class=xtab>' + resultat.numCities + '</td>\
     		</tr>';
     m += '</div>';
     ById('allListOut').innerHTML = m;
    }
  },
  fetchUserLeaderboard: function(pagNum, notify) {
        var t = Tabs.AllianceList;
        var params = uW.Object.clone(uW.g_ajaxparams);
        params.page = pagNum;
        params.perPage = 100;
        new MyAjaxRequest(uW.g_ajaxpath + "ajax/getUserLeaderboard.php" + uW.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          onSuccess: function (rslt) {
            notify (rslt);
          },
          onFailure: function (rslt) {
            notify (rslt);
          },
      });
  },
  
  
  eventGotOtherAlliancePage : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      ById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }

    ById('idPageNum').value = t.curPage;

    t.MaxPage=rslt.noOfPages;

    var m = '<div style="overflow:auto; height:'+(Options.HauteurBoite-230)+'px;width:95%;"><TABLE><thead><TR style="font-weight:bold"> \
   <th class=xtab>'+uW.g_js_strings.commonstr.rank+'</th><th class=xtab>'+uW.g_js_strings.modaltitles.alliance+'</th><th class=xtab>'+uW.g_js_strings.commonstr.chancellor+'</th><th class=xtab>'+uW.g_js_strings.commonstr.members+'</th>\
        <th align=right class=xtab>'+uW.g_js_strings.commonstr.might+'</th><th align=right class=xtab>'+uW.g_js_strings.commonstr.glory+'</th><th class=xtab>'+uW.g_js_strings.getAllianceSearchResults.currdiplo.substr(0,10)+'</th><th class=xtab>'+uW.g_js_strings.commonstr.members+'</th><th class=xtab>'+uW.g_js_strings.commonstr.viewmap+'</th></tr></thead><tbody>';
    ById('allListOut').innerHTML = m;

    for (var i=0; i<rslt.otherAlliances.length; i++) {
      var alliance = rslt.otherAlliances[i];
      var dip = '';
      dip = getDiplomacy(alliance.allianceId);

      m += '<TR class="'+ dip + '"><TD align=right class=xtab>'+ alliance.ranking +'</td><TD class=xtab>' + alliance.name +'</td><TD class=xtab>' + alliance.hostGenderAndName +'</td><TD align=right class=xtab>'+ alliance.membersCount +'</td>\
       <TD align=right class=xtab>'+ addCommasInt(alliance.might) +'</td><TD align=right class=xtab>'+ addCommasInt(alliance.glory) +'</td><TD class=xtab>'+ dip +'</td>\
       <TD class=xtab><a onclick="BoPTgetMembers('+ alliance.allianceId +')">'+uW.g_js_strings.commonstr.members+'</a></td>\
       <TD class=xtab><a onclick="PTPaintMembers('+ alliance.allianceId +')">'+uW.g_js_strings.commonstr.viewmap+'</a></td></tr>';
    }
    m += '</tbody></TABLE><div style="font-weight:bold; height:20px;width:95%;text-align:center;"><span><center><a onclick="BoPTalClickPrev(-1)"> ['+uW.g_js_strings.commonstr.first+'] </a><a onclick="BoPTalClickPrev(10)"> [-10] </a><a onclick="BoPTalClickPrev(5)"> [-5] </a><a onclick="BoPTalClickPrev(1)"> ['+uW.g_js_strings.commonstr.previous+'] </a> \
          <a onclick="BoPTalClickNext(1)"> ['+uW.g_js_strings.commonstr.next+'] </a><a onclick="BoPTalClickNext(5)"> [+5] </a><a onclick="BoPTalClickNext(10)"> [+10] </a><a onclick="BoPTalClickNext(9999)"> [End] </a> </span></div>';
    m += '</div>';
    ById('allListOut').innerHTML = m;
 },

  showCurrentPage : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();

    ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'...</center>';
    if (myA[0]!=0  ) {
       t.fetchOtherAllianceInfo ( t.curPage, t.eventGotOtherAlliancePage);
    }
    else {
       t.fetchOtherAllianceInfo ( t.curPage, t.eventGotOtherAlliancePage);
    }

  },

  
  eventGotMemberList : function (rslt){
     var t = Tabs.AllianceList;
     if (!rslt.ok){
       ById('allListOut').innerHTML = rslt.errorMsg;
       return;
     }
     t.memberListRslt = rslt;
     var uList = [];
     for (k in rslt.results)
       uList.push (rslt.results[k].userId);     
     t.fetchPlayerStatus (uList, function(r){t.eventGotMemberOnlineList(r)});    
   },    
     
  eventGotMemberOnlineList : function (rslt){
    var t = Tabs.AllianceList;
    var numInvalid = 0;
    var numPlayers = 0;
    var myA = getMyAlliance ();
    t.dat = [];
    for (var i=0; i<t.memberListRslt.results.length; i++){
      p = t.memberListRslt.results[i];
      if (p.userId == 0){
        ++numInvalid;
      } else {
        ++numPlayers;
        if ( myA[0] == p.allianceId)
          t.friendEta = true;
	        else
           t.friendEta = false;
        for (var c=0; c<p.cities.length; c++){
           t.dat.push ([p.displayName, parseInt(p.might), p.officerType, parseInt(p.numCities), parseInt(p.cities[c].tileLevel),
               parseInt(p.cities[c].xCoord), parseInt(p.cities[c].yCoord), p.cities[c].cityName, 0, c, p.userId, p.avatarId, p.playerSex, p.rank, rslt.data[p.userId]?1:0, 'NA']);
        }
      }
    }
    t.setDistances (Cities.cities[0].x, Cities.cities[0].y);
    t.ModelCity=Cities.cities[0];
    t.setEta();
    t.displayMembers (t.memberListRslt.allianceName, numPlayers);
  },
  reDisp : function (){
    var t = Tabs.AllianceList;   
    function sortFunc (a, b){
          var t = Tabs.AllianceList;
     if (typeof(a[t.sortColNum]) == 'number'){
             if (t.sortDir > 0)
               return a[t.sortColNum] - b[t.sortColNum];
             else
               return b[t.sortColNum] - a[t.sortColNum];
           } else if (typeof(a[t.sortColNum]) == 'boolean'){
         
     	return 0;        
           } else {
             if (t.sortDir > 0)
               return a[t.sortColNum].localeCompare(b[t.sortColNum]);
             else
               return b[t.sortColNum].localeCompare(a[t.sortColNum]);
      }
    }
    t.dat.sort (sortFunc);
    var m = '';
    var tbody = ById('allBody');
    tbody.innerHTML ='';
    tbody.style.maxHeight = '';
    var csvXL="";
    for (var i=0; i<t.dat.length; i++){ 
    	if (i % 2 == 0) {
        		 tabclass = 'xxtab';
        	} else {
        		tabclass = 'xxtab_even';
    	} 
        m += '<TR><TD  class='+ tabclass +' align=left><a onclick=BoPTDme("' +  t.dat[i][0] +'");><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/avatars/25/'+t.dat[i][12]+''+t.dat[i][11]+'.jpg" align=absmiddle></a>&nbsp;<a onclick=getInfoForAnUser("'+ t.dat[i][10] +'");>'+ t.dat[i][0] +'</a></td><TD align=right class='+ tabclass +'>'+ addCommasInt(t.dat[i][1]) +'</td><TD align=center class='+ tabclass +'>'+ t.dat[i][3] +'</td>\
	                <TD class='+ tabclass +' align=left><span title="Classement : '+t.dat[i][13]+' joueur">'+ officerId2String(t.dat[i][2])  +'</span></td><TD class='+ tabclass +' align=left>'+ (t.dat[i][14]?'<center>'+butON+'</center>':'') +'</td><TD class='+ tabclass +' align=left><span title="'+ t.dat[i][7]+'">'+ t.dat[i][7].substring(0,8) +'</span></td><TD align=right class='+ tabclass +'>'+ t.dat[i][4] +'</td>\
	                <TD align=left class='+ tabclass +'>\
	                <a href="javascript:void(0)" onclick="cm.utils.CoordinateLinkController.onClick(event)" class="coordinateLink">('+ t.dat[i][5] +','+ t.dat[i][6] +')</a>\
	                </td><TD align=left class=xxtab style="padding-right:20px;">'+ t.dat[i][8].toFixed(2) +'</td>';
      	m += '<TD nowrap class=xxtab align=left>'+ (t.dat[i][15]?'<SPAN>'+ (t.dat[i][15]>0?timestr(t.dat[i][15],1):'NA') +'</span>':'<SPAN>NA</span>') +'</td><td class='+ tabclass +' align=left><SPAN onclick="BoPCplo(this, \''+ t.dat[i][10] +'\');"><A>?</a></span><td></tr>';
	csvXL += t.dat[i][0]+';'+t.dat[i][1]+';'+t.dat[i][5]+';'+t.dat[i][6]+';'+t.dat[i][4]+';'+t.dat[i][8]+';'+t.dat[i][7]+'\n';
    }
    m += '<tr><td colspan=11><textarea cols="55" rows="12" onclick="this.focus();this.select();" id="cutAndPaste" name="csv">Joueur;'+uW.g_js_strings.commonstr.might+';X;Y;Niveau;Distance;Ville\n'+csvXL+'</textarea><br><b>Export XLS (pour toi public:</b><bR>Copiez le contenu de la zone, coller ensuite le contenu dans blocnote et enregistrer le fichier en .cvs</tr>';
   
   var tbody = ById('allBody');
    tbody.style.maxHeight = '';
    tbody.innerHTML = m;
    ById("cutAndPaste").innerHTML=csvXL;
    if (parseInt(tbody.clientHeight) > 475){
      tbody.style.height = '475px';
      tbody.style.maxHeight = '475px';
    }
  },
  setDistances : function (x, y){
    var t = Tabs.AllianceList;
    for (var i=0; i<t.dat.length; i++)
      t.dat[i][8] = distance (x, y, t.dat[i][5], t.dat[i][6]);
  },
  friendEta:false,
  setEta : function (){
    var t = Tabs.AllianceList;
    for (var i=0; i<t.dat.length; i++) {
      if (t.dat[i][8]) {
        if (ById('idFindETASelect').value>0) {
         var eta = estETA(parseFloat(t.dat[i][8]), ById('idFindETASelect').value, t.ModelCity.id,4);
         if (t.friendEta)
           t.dat[i][15] = eta.friendETA;
         else
           t.dat[i][15] = eta.ETA;
        }
      }
    }
  },
  handleEtaSelect : function (){
    var t = Tabs.AllianceList;
    t.setEta();
    t.reDisp();
  },
  sortColNum : 1,
  sortDir : 1,
  displayMembers : function (allName, numPlayers){
    var t = Tabs.AllianceList;
    function alClickSort (e){
      var t = Tabs.AllianceList;
      var newColNum = e.id.substr(8);
      ById('clickCol'+t.sortColNum).className = 'clickable';
      e.className='clickable clickableSel';
      if (newColNum == t.sortColNum)
        t.sortDir *= -1;
      else
        t.sortColNum = newColNum;
      t.reDisp();
    }
    uW.PTalClickSort = alClickSort;
    var m = '<STYLE>.clickable{background-color:#ddd; border:2px outset; border-color:#555; padding-left:5px; padding-right:5px;}\
            .clickableSel{background-color:#ffffcc;}\
            .xxtab{background-color:none; padding-left:5px; padding-right:5px;} </style>\
      <DIV class=boStat><TABLE id=tabAllMembers cellpadding=0  width=100%><TR font-weight:bold"><TD class=xtab> &nbsp; '+ allName +'</td>\
        <TD class=xtab width=80% align=center>'+uW.g_js_strings.commonstr.distance + ' ' + uW.g_js_strings.commonstr.from+' <SPAN id=distFrom>'+ Cities.cities[0].name +' ('+ Cities.cities[0].x +','+ Cities.cities[0].y +')</span></td><TD class=xtab align=right>'+ numPlayers +' joueurs trouv&eacute;s &nbsp; </td></tr></table></div>';
     m += '<div style="width:800px;max-height:'+(Options.HauteurBoite-190)+'px;height:'+(Options.HauteurBoite-190)+'px;overflow:auto;">\
      <TABLE id=tabAllMembers align=center cellpadding=0 cellspacing=0><THEAD>\
      <TR style="font-weight:bold"><TD id=clickCol0 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.player+'</div></a></td>\
        <TD id=clickCol1 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>'+uW.g_js_strings.commonstr.might+'</a></div></td>\
        <TD id=clickCol3 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.cities+'</a></div></td>\
        <TD id=clickCol2 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>'+uW.g_js_strings.commonstr.rank+'</a></div></td>\
        <TD id=clickCol14 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>'+uW.g_js_strings.commonstr.online+'</a></div></td>\
        <TD id=clickCol7 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.MapObject.cityname+'</a></div></td>\
        <TD id=clickCol4 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.lvl+'</a></div></td>\
        <TD id=clickCol5 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.coordinates+'</a></div></td>\
        <TD id=clickCol8 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.commonstr.distance+'</a></div></td>\
        <TD id=clickCol15 onclick="PTalClickSort(this)" class=clickable><A><DIV>'+uW.g_js_strings.attack_generateincoming.estimatedarrival+'</a></div></td>\
        <TD class=clickable><A><DIV>'+uW.g_js_strings.modal_messages_viewreports_view.lastlogin+'</div></a></td></tr></thead>\
      <tbody id=allBody ></tbody></table></div>';
    ById('allListOut').innerHTML = m;
    ById('altInput').innerHTML = '<HR><TABLE width=100% cellpaddding=0><TR align=center>\
        <TD class=xtab>'+uW.g_js_strings.commonstr.distance + ' ' + uW.g_js_strings.commonstr.from+' : &nbsp; X: <INPUT size=2 type=text id="plyrX" /> Y: <INPUT size=2 type=text id="plyrY" /> &nbsp; '+lang.AllianceList.orcity+' <span id=dmcoords></span></td></tr></table>';
    ById('clickCol'+t.sortColNum).className = 'clickable clickableSel';
    t.reDisp();
    new CdispCityPicker ('plyrdcp', document.getElementById ('dmcoords'), true, t.eventCoords, 0).bindToXYboxes(ById('plyrX'), ById('plyrY'));
    ById('idFindETASelect').disabled = false;
    
 },
    
 eventCoords : function (city, x, y){
    var t = Tabs.AllianceList;
    var m = '';
    if (city != null)
      m = city.name +' ('+ city.x +','+ city.y +')';
    else
      m = x +','+ y;
    var distFrom = ById('distFrom');
    if (distFrom)
        distFrom.innerHTML = m;
    t.ModelCity=city;
    t.setDistances(x,y);
    t.setEta(x,y);
    t.reDisp();
  },
  
  eventGetMembers : function (aid){
    var t = Tabs.AllianceList;
    ById('allListOut').innerHTML = '<BR><BR><CENTER>'+uW.g_js_strings.commonstr.loadingddd+'...</center>';
    t.fetchAllianceMemberList (aid, null, t.eventGotMemberList);
  },

  fetchAllianceMemberList : function (allianceId, allianceName, notify) {
    var t = Tabs.AllianceList;
    var params = uW.Object.clone(uW.g_ajaxparams);
    params.perPage = 100;
    if (allianceName)
      params.allianceName = allianceName;
    if (allianceId && allianceId != 0)
      params.allianceId = allianceId;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify (rslt);
      },
    });
  },

 
  fetchLeaderboard : function (uid, notify) {
    var t = Tabs.AllianceList;
    var params = uW.Object.clone(uW.g_ajaxparams);
    params.userId = uid;
    new MyAjaxRequest(uW.g_ajaxpath + "ajax/getUserLeaderboard.php" + uW.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify (rslt);
      },
    });
  },
  fetchAllianceList : function (allianceName, myAid, notify) {
    var t = Tabs.AllianceList;
    function combineResults (rsltA, rsltM, notify){
      if (!rsltA.ok){
        if (rsltA.msg.indexOf("No alliance found under")!=0 || !rsltM.ok){
          notify (rsltA);
          return;
        }
        rsltA.ok = true;
        rsltA.count = 0;
        rsltA.alliancesMatched = {};
      }
      if (rsltM.ok){
        rsltA.alliancesMatched['a'+rsltM.allianceInfo.allianceId] = {allianceId: rsltM.allianceInfo.allianceId, allianceName: rsltM.allianceInfo.allianceName,
              membersCount: rsltM.allianceInfo.members, relation: null, might: rsltM.allianceInfo.might, ranking: rsltM.allianceInfo.ranking};
        ++rsltA.count;
      }
      notify (rsltA);
    }
    var params = uW.Object.clone(uW.g_ajaxparams);
    params.allianceName = allianceName;
    new MyAjaxRequest(uW.g_ajaxpath + "ajax/allianceGetSearchResults.php" + uW.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (myAid!=null && myAid>0)
          t.fetchMyAllianceInfo  (function (r){ combineResults (rslt, r, notify)});
        else
          notify (rslt);
      },
      onFailure: function (rslt) {
        notify (rslt);
      },
    });
  },
  fetchOtherAllianceInfo : function (pageNum, notify){
    var params = uW.Object.clone(uW.g_ajaxparams);
    params.pageNo = pageNum;
    params.cityId = unsafeWindow.currentcityid;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetOtherInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onSuccess: function (rslt) {
        notify (rslt);
      },
    });
  },

  fetchMyAllianceInfo : function (notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onSuccess: function (rslt) {
        notify (rslt);
      },
    });
  },

  fetchPlayerList : function (name, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.searchName = name;
    params.subType = "ALLIANCE_INVITE";
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/searchPlayers.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onSuccess: function (rslt) {
        notify (rslt);
      },
    });
  },

  fetchPlayerInfo : function (uid, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.uid = uid;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserGeneralInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onSuccess: function (rslt) {
        notify (rslt);
      },
    });
  },

  
    fetchPlayerLastLogin : function (uid, notify){
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.pid = uid;
      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          notify (rslt);
        },
        onSuccess: function (rslt) {
          notify (rslt);
        },
      });
  },
  fetchPlayerStatusSimple : function (uid, notify){
        var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
        params.checkArr = uid;
        new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getOnline.php" + unsafeWindow.g_ajaxsuffix, {
          method: "post",
          parameters: params,
          onSuccess: function (rslt) {
            notify (rslt);
          },
          onSuccess: function (rslt) {
            notify (rslt);
          },
        });
    },
  
  fetchPlayerStatus : function (uidArray, notify){
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.checkArr = uidArray.join(',');
      new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getOnline.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          notify (rslt);
        },
        onFailure: function (rslt) {
          notify ({errorMsg:'AJAX error'});
        },
      });
  },
 
  ModelCity : {},

};


/*************** TRANSPORT **********/
Tabs.TranspAuto = {
 tabOrder: 6,
 tabLabel: uW.g_js_strings.commonstr.transport,
 cont : null,
 displayTimer : null,
 state : null,
 curTabBut : null,
 curTabName : null,
 sourceCity : {},
 destinationCity : {},
 rows : [],
  timer: null,
  traderState: [],
  reapproState: [],
  lTR: [],
  tradeRoutes: [],
  checkdotradetimeout: null,
  count:0,
  check:false,
 show : function (){
   var t = Tabs.TranspAuto;
   if (document.getElementById ('maparea_map').style.display!="none") {
     if (t.destinationCityx) {
                      t.destinationCityx.value = document.getElementById ('mapXCoor').value;
                      t.destinationCityy.value = document.getElementById ('mapYCoor').value;
                     }
   }
   if (t.curTabBut) {
    var but=t.curTabBut;
    t.show2();
   }
 },
  clickmap:function() {
  var t = Tabs.TranspAuto;
  if (document.getElementById ('maparea_map').style.display!="none") {
      if (t.destinationCityx) {
                       t.destinationCityx.value = document.getElementById ('mapXCoor').value;
                       t.destinationCityy.value = document.getElementById ('mapYCoor').value;
                      }
   }
 },
 hide : function (){
    var t = Tabs.TranspAuto;
    clearTimeout (t.displayTimer);
    clearTimeout (t.timer);
  },
  
  init : function (div){  
   var t = Tabs.TranspAuto;
   unsafeWindow.BOestimeres = t.estimerRes;
   t.traderState = {running: false,};
   t.reapproState = {running: false,city:-1,unit:9,mini:1000};
   t.readTraderState();
   t.readReapproState();
   
   t.readTradeRoutes();  
   t.e_tradeRoutes();
	    
 
   AddSubTabLink('Trp', t.toggleTraderState, 'pbtrantab');
   if (GlobalOptions.pbWideScreen) AddSubTabLink('Appro', t.toggleReapproState, 'boreapprotab');
   if (t.reapproState.running == false) {
   			if (GlobalOptions.pbWideScreen) updatebotbutton(lang.TRANSP.Appros+' - OFF', 'boreapprotab');
             } else {
    		if (GlobalOptions.pbWideScreen) updatebotbutton(lang.TRANSP.Appros+' - ON', 'boreapprotab');
       	      setTimeout(t.actionreappro,10000);
   }
   if (t.traderState.running == false) {
       	       updatebotbutton(uW.g_js_strings.commonstr.transport+' - OFF', 'pbtrantab');
             } else {
       	       updatebotbutton(uW.g_js_strings.commonstr.transport+' - ON', 'pbtrantab');
    }
    window.addEventListener('unload', t.onUnload, false);
    t.cont = div;
    t.cont.innerHTML = '<TABLE class=ptTab align=center><TR><TD><INPUT class=bopbSubtab ID=BoTrpSubM type=submit value="'+lang.TRANSP.Manu+'"></td>\
             <TD><INPUT class=bopbSubtab ID=BoTrpSubA type=submit  value="'+lang.TRANSP.Auto+'"></td><TD><INPUT class=bopbSubtab ID=BoTrpSubR type=submit  value="'+lang.TRANSP.Appros+'"></td></tr></table>\
         <DIV id="BoTrpOutput" style="margin-top:5px; background-color:white; height:'+(Options.HauteurBoite-65)+'px;max-height:'+(Options.HauteurBoite-65)+'px;overflow-y:auto"></div>';
        t.TransportDiv = ById('BoTrpOutput'); 
  ById('BoTrpSubA').addEventListener('click', e_butSubtab, false);
  ById('BoTrpSubM').addEventListener('click', e_butSubtab, false);
  ById('BoTrpSubR').addEventListener('click', e_butSubtab, false);
  
  
  
  
     changeSubtab (ById('BoTrpSubM'));  

      function e_butSubtab (evt){
          changeSubtab (evt.target);   
      }
    
      function changeSubtab (but){
          if (but == t.curTabBut)
            return;
          if (t.curTabBut){
            t.curTabBut.className='bopbSubtab'; 
            t.curTabBut.disabled=false;
          }
          t.curTabBut = but;
          but.className='bopbSubtab bopbSubtabSel'; 
          but.disabled=true;
          t.curTabName = but.id.substr(8);
          t.show2();
      }  
      var final = 0;
      if (t.reapproState.city>=0) {
      for(var i=0; i<Cities.numCities; i++) {
          var x2 = parseInt(Cities.cities[i].x);
          var x1 = parseInt(Cities.cities[t.reapproState.city].x);
          var y2 = parseInt(Cities.cities[i].y);
          var y1 = parseInt(Cities.cities[t.reapproState.city].y);
          var dist = distance (x1, y1, x2, y2);
          var m = estETA(dist,t.reapproState.unit,Cities.cities[t.reapproState.city].id,1);  
           if (m.friendETA>final)
            final=m.friendETA;
        }
        Options.reapprointerval = parseInt(final/60*2+10);
       }    
  },
   show2 : function (){
     var t = Tabs.TranspAuto
     t.state = null;
     clearTimeout (t.displayTimer);
     clearTimeout (t.timer);
     if (t.curTabName == 'M')
       t.showManuel();
     else  if (t.curTabName == 'R')
       t.showReappro();
     else {
       t.showAuto();
       t.showTimer();	
     }
  },
  showTimer: function() {
   var t = Tabs.TranspAuto;
   t.updateTroops();
   t.updateResources();  
   t.timer = setTimeout (t.showTimer, 1000); 
  },
  showReappro: function () {
   var t = Tabs.TranspAuto;
   var m = '<DIV id=pbTowrtDivF class=boStat>'+lang.TRANSP.Appro.Title1+' - <input type=button value="?" id=boaideappro class=boAide></div><TABLE id=pbtraderfunctions width=100% height=0% class=pbTab><TR align="center">';
   if (t.reapproState.running == false) {
               m += '<TD><INPUT id=boReapproState type=submit value="'+lang.TRANSP.Appros+' = OFF"></td>';
     	       updatebotbutton(lang.TRANSP.Appros+' - OFF', 'boreapprotab');
           } else {
               m += '<TD><INPUT id=boReapproState type=submit value="'+lang.TRANSP.Appros+' = ON"></td>';
     	      updatebotbutton(lang.TRANSP.Appros+' - ON', 'boreapprotab');
   }
   m += '<td><input type=button value="'+lang.TRANSP.Appro.ValuesAuto+'" id=BORecupReappro></td><td><input type=button value="'+lang.General.save+'" id="boReappro"><td><span title="'+lang.TRANSP.Appro.CulTime+'">'+lang.TRANSP.Appro.Interval+': <INPUT id=pbreapprointerval type=text size=2 READONLY value="'+Options.reapprointerval+'"\> '+lang.General.mins+'</td></tr></table>';
   m += '<DIV id=pbReapproDivDRoute class=boStat>'+lang.TRANSP.Appro.Title2+'</div>';
   m += '<TABLE id=pbaddReapproroute width=95% height=0% class=pbTab><TR align="left">';
   m += '<TR align="left"><TD colspan=2>'+lang.TRANSP.Appro.CityProv+':</td> <TD colspan=3><DIV style="margin-bottom:10px;"><span id=borescity></span></div></td><td colspan=4>'+uW.g_js_strings.commonstr.troops+': <select id="BOApproUnit"><option value=9>'+uW.unitcost["unt9"][0]+'</option><option value=7>'+uW.unitcost["unt7"][0]+'</option><option value=8>'+uW.unitcost["unt8"][0]+'</option></select> &nbsp; Min: <input type=text size=5 value="0" id=BOApproMin></td></tr>';
  
  var Types = ['gold','food','wood','stone','iron','aetherstone'];
   
    m += '<TR align="left"><td colspan=2>&nbsp;</td>';
   for (var y=0; y< Seed.cities.length;y++)
    m += '<td>'+Seed.cities[y][1]+'</td>';
   for (var i=0;i<=5;i++) {
    m += '</tr><tr><td align=center valign=middle rowspan=2><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/'+Types[i]+'_30.png"></td><td>&nbsp;</td>';
    for (var y=0; y< Seed.cities.length;y++)
     m += '<td><span id="ReappRec_'+y+'_'+i+'"></span></td>';
    m += '</tr><tr><td>'+lang.TRANSP.Appro.MinKeep+'</td>';
        for (var y=0; y< Seed.cities.length;y++)
     m += '<td><input id="ReappRes_'+y+'_'+i+'" type=text size=10 maxlength=12 value=0></td>';  
    m +='</tr>';
   }
   m += '</table><br>'+lang.TRANSP.Appro.Explanation;
   t.TransportDiv.innerHTML = m; 
   if (t.reapproState.city==undefined ||t.reapproState.city==-1) {
    
    t.reapproState.city=0;
   }
   ById('boaideappro').addEventListener('click', function(){
       	 window.open(sitesupport+"?page=aide_appro");
    	} , false);
   t.reacp = new CdispCityPicker ('botrader', ById('borescity'), true, t.updateResources2, t.reapproState.city);
   ById('BOApproMin').addEventListener('change', function(){
    t.reapproState.mini = ById('BOApproMin').value;
    t.saveReappro();
    }, false); 
   ById('boReapproState').addEventListener('click', function(){t.toggleReapproState(this);}, false);
   ById('boReappro').addEventListener('click', function(){t.saveReappro();}, false);
   
   ById('pbreapprointerval').addEventListener('keyup', function(){
      		if (isNaN(ById('pbreapprointerval').value)){ ById('pbreapprointerval').value=60 ;}
      		Options.reapprointerval = ById('pbreapprointerval').value;
      		saveOptions();
   }, false);
   
   ById('BORecupReappro').addEventListener('click', function(){t.RecupReappro();}, false);
   ById('BOApproUnit').value = t.reapproState.unit;
   ById('BOApproMin').value = parseIntNan(t.reapproState.mini);
   ById('BOApproUnit').addEventListener('change', function(){
    t.reapproState.unit = ById('BOApproUnit').value;
    t.saveReappro();
    
   }, false);
   
   t.updateResources2();
  },
  RecupReappro:function() {
   var t = Tabs.TranspAuto;
   var r = t.tradeRoutes;
   for (var y=0; y< Seed.cities.length;y++) {
    for (var i=0;i<(r.length);i++) {
     if (parseInt(Seed.cities[y][0]) == r[i].city) {
   ById('ReappRes_'+y+'_0').value=r[i].target_Gold;
   ById('ReappRes_'+y+'_1').value=r[i].target_Food;
   ById('ReappRes_'+y+'_2').value=r[i].target_Wood;
   ById('ReappRes_'+y+'_3').value=r[i].target_Stone;
   ById('ReappRes_'+y+'_4').value=r[i].target_Ore;
   ById('ReappRes_'+y+'_5').value=r[i].target_Astone;
   
     }
    } 
   }
   t.saveReappro();
   
   
  },
  saveReapproState: function(){
    var t = Tabs.TranspAuto;
    var serverID = getServerId();
    saveValue('reapproState_' + serverID, JSON2.stringify(t.reapproState));
  },
  saveReappro:function() {
   var t = Tabs.TranspAuto;
   for (var y=0; y< Seed.cities.length;y++) {
    t.reapproState['ReappRes_'+y+'_0'] = parseIntNan(ById('ReappRes_'+y+'_0').value);
    for (var i=1;i<=5;i++) {
     t.reapproState['ReappRes_'+y+'_'+i] = parseIntNan(ById('ReappRes_'+y+'_'+i).value);
    }
   }
   t.saveReapproState();
  },
  readReapproState: function(){
             var t = Tabs.TranspAuto;
             var serverID = getServerId();
             s = loadValue('reapproState_' + serverID);
             if (s != null) {
                 state = JSON2.parse(s);
                 for (k in state)
                     t.reapproState[k] = state[k];
             }
  },
  toggleReapproState: function(obj){
     	   var t = Tabs.TranspAuto;
     	   obj = ById('boReapproState');
             if (t.reapproState.running == true) {
                 t.reapproState.running = false;
                 if (obj)  obj.value = lang.TRANSP.Appros+" = OFF";
     	       updatebotbutton(lang.TRANSP.Appros+' - OFF', 'boreapprotab');
     	      clearTimeout(t.checkdoreapprotimeout);
             }
             else {
                t.reapproState.running = true;
                if (obj) obj.value = lang.TRANSP.Appros+" = ON";
     		updatebotbutton(lang.TRANSP.Appros+' - ON', 'boreapprotab');
     		t.actionreappro();
             }
  },
  retry:0,
  nbcity:-1,
  actionreappro:function() {
   var t = Tabs.TranspAuto;
   t.nbcity++;
   if (t.reapproState.running == false) {
     clearTimeout(t.checkdoreapprotimeout);
     return;
   }
   if (t.nbcity==t.reapproState.city)
   	t.nbcity++;  
   var tempsprochainevisite = 10000;
   if ((Seed.cities.length-1)<t.nbcity) {
    tempsprochainevisite = Options.reapprointerval*60*1000;
    t.nbcity=-1;
   } else {
     var besoin=[0,0,0,0,0,0]; 
     var stock=[0,0,0,0,0,0];
     qtemin = parseIntNan(t.reapproState['ReappRes_'+t.nbcity+'_0']);
     qtest = parseIntNan(Seed.citystats["city" + Seed.cities[t.nbcity][0]]['gold'][0]);
     if (qtest<qtemin)
        besoin[0] = parseInt(qtemin - qtest);
     stock[0] = parseIntNan(Seed.citystats["city" + Seed.cities[t.reapproState.city][0]]['gold'][0]);
     for (var i=1;i<=5;i++) {
        qtemin = parseIntNan(t.reapproState['ReappRes_'+t.nbcity+'_'+i]);
        if(i==5) {
         qtest = parseInt(Seed.resources["city" + Seed.cities[t.nbcity][0]]['rec'+i][0]);
         qtstock = parseInt(Seed.resources["city" + Seed.cities[t.reapproState.city][0]]['rec'+i][0]);
        }else {
         qtest = parseInt(Seed.resources["city" + Seed.cities[t.nbcity][0]]['rec'+i][0]/3600);
         qtstock= parseInt(Seed.resources["city" + Seed.cities[t.reapproState.city][0]]['rec'+i][0]/3600);
        }
        if (qtest<qtemin)
        besoin[i] = parseInt(qtemin - qtest);
        stock[i] = qtstock;
     }   
     var rallypointlevel = t.getRallypoint('city' + Cities.cities[t.reapproState.city].id);
     if(rallypointlevel == 12) rallypointlevel = 11;
     var slots = 0;
     var cityId = 'city'+ Cities.cities[t.reapproState.city].id;
     for (var k in Seed.queue_atkp[cityId]){   
         	         march = Seed.queue_atkp[cityId][k];
         	         if (typeof (march) == 'object'){
         	           slots++;
         	         }
     }
     if(slots >= rallypointlevel){
      		actionLog(lang.TRANSP.Appros,uW.g_js_strings.commonstr.transport+": "+Cities.cities[t.reapproState.city].name+" "+lang.TRANSP.Appro.To+" "+Cities.cities[t.nbcity].name+" <font color=red>"+lang.TRANSP.Automatic.PointFull+"!</font>");
      		return;
     }
     if (besoin[0]>0 || besoin[1]>0|| besoin[2]>0 || besoin[3]>0 || besoin[4]>0 || besoin[5]>0) {
     //actionLog("Appro","Transport de "+Cities.cities[t.reapproState.city].name+" vers "+Cities.cities[t.nbcity].name+" : pierre:" + besoin[3] +"<"+stock[3]+" && mine: "+besoin[4]+"<"+stock[4]+"");
     if (besoin[0]<=stock[0] && besoin[1]<=stock[1] && besoin[2]<=stock[2] && besoin[3]<=stock[3] && besoin[4]<=stock[4] && besoin[5]<=stock[5]) {
          var unit = 'unt' + t.reapproState.unit
       	  Troops = parseInt(Seed.units['city' + Seed.cities[t.reapproState.city][0]][unit]);
       	     var untid=t.reapproState.unit;
	     var techLoadBoost=parseInt(Seed.tech.tch10)*0.1;
	     var loadEffectBoost=0;
	     if(Seed.playerEffects.loadExpire>uW.unixtime()){loadEffectBoost=0.25}
	     var loadBoostBase=(EffetTronePrc(6).percent*0.01)+loadEffectBoost+techLoadBoost;
	     var loadBoost=loadBoostBase;
	     if(uW.cm.unitFrontendType[untid]=="horsed"){
	       loadBoost+=(EffetTronePrc(48).percent*0.01)
	     }
       	  var LoadUnit=parseInt(parseInt(uW.unitstats["unt"+untid][5])*(1+loadBoost));
       	  TroopsNeeded = (besoin[0] + besoin[1] + besoin[2] + besoin[3] + besoin[4] + (besoin[5]*5))  / LoadUnit;
       	  TroopsNeeded = TroopsNeeded.toFixed(0);
       	  if (TroopsNeeded < ((besoin[0] + besoin[1] + besoin[2] + besoin[3] + besoin[4] + (besoin[5]*5))  / LoadUnit )) TroopsNeeded++;
       	  var rallypointlevel = t.getRallypoint('city' +Seed.cities[t.reapproState.city][0]);	
  	  if (rallypointlevel == 11) rallypointlevel = 15;
	  if (rallypointlevel == 12) rallypointlevel = 20;
       	  if (parseInt(TroopsNeeded) > parseInt(rallypointlevel*10000)){ 
       	   TroopsNeeded = (rallypointlevel*10000); 
       	   var lemax=LoadUnit*TroopsNeeded;
       	   var totalb=lemax;
       	   for (var i=1;i<=5;i++) {
       	    if (besoin[i]>=totalb)
       	    	besoin[i]=totalb;
       	    totalb=totalb-besoin[i];
       	   }
       	  }
       	  if (parseIntNan(TroopsNeeded)<=parseIntNan(Troops) && parseIntNan(TroopsNeeded)>=parseIntNan(t.reapproState.mini)) { 
       	   var city = Seed.cities[t.reapproState.city][0]
       	   var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
	   params.gold =besoin[0];
	   params.r1 =besoin[1];
	   params.r2 =besoin[2];
	   params.r3 =besoin[3];
	   params.r4 =besoin[4];
	   params.r5 =besoin[5];
   	   params.kid = 0;
   	   params.type = "1";
       	   params.cid=city;
       	   switch (unit){
	            case 'unt1': params.u1 = TroopsNeeded;break;
	            case 'unt2': params.u2 = TroopsNeeded;break;
	            case 'unt3': params.u3 = TroopsNeeded;break;
	            case 'unt4': params.u4 = TroopsNeeded;break;
	            case 'unt5': params.u5 = TroopsNeeded;break;
	            case 'unt6': params.u6 = TroopsNeeded;break;
	            case 'unt7': params.u7 = TroopsNeeded;break;
	            case 'unt8': params.u8 = TroopsNeeded;break;
	            case 'unt9': params.u9 = TroopsNeeded;break;
	            case 'unt10': params.u10 = TroopsNeeded;break;
	            case 'unt11': params.u11 = TroopsNeeded;break;
	            case 'unt12': params.u12 = TroopsNeeded;break;
           }
       	   params.xcoord = Seed.cities[t.nbcity][2];
   	   params.ycoord = Seed.cities[t.nbcity][3];
  
       	  new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
	                       method: "post",
	                       parameters: params,
	                       loading: true,
	                       onSuccess: function (transport) {
	                       var rslt = eval("(" + transport.responseText + ")");
	                       if (rslt.ok) {
	                       var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	                       var ut = uW.unixtime();
	                       var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	                       for(i = 0; i <= unitsarr.length; i++){
	                       	if(params["u"+i]){
	                       	unitsarr[i] = params["u"+i];
	                       	}
	                       }
	                       var resources=new Array();
	                       resources[0] = params.gold;
	                       for(i=1; i<=5; i++){
	                       	resources[i] = params["r"+i];
	                       }
	                       var currentcityid = city;
	                       uW.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	                       uW.update_seed(rslt.updateSeed)
	                       if(rslt.updateSeed){uW.update_seed(rslt.updateSeed)};
	                        actionLog(lang.TRANSP.Appros,uW.g_js_strings.commonstr.transport+" "+lang.TRANSP.Appro.From+" "+Cities.cities[t.reapproState.city].name+" "+lang.TRANSP.Appro.To+" "+Cities.cities[t.nbcity].name+" "+lang.TRANSP.Appro.Of+" "+TroopsNeeded+" "+uW.unitcost[unit][0]);
	                       } else {
	  			actionLog(lang.TRANSP.Appros,uW.g_js_strings.commonstr.transport+" "+lang.TRANSP.Appro.From+" "+Cities.cities[t.reapproState.city].name+" "+lang.TRANSP.Appro.To+" "+Cities.cities[t.nbcity].name+" <font color=red>" + transport.responseText +"</font>");
	  			t.retry++;
	  			if (t.retry>4) {
	  			 t.retry=0;
	  			}else {
	  			 setTimeout(function() {t.nbcity--;t.actionreappro();},6000);
	  			}
	                       }
	                       },
	                       onFailure: function (rslt) {
	                       if (rslt.user_action) {
			       		actionLog(lang.TRANSP.Appros,"<b><font color=red>"+lang.General.DetectionCaptcha+"</font></b>");
			       	   new CdialogCancelContinue('<SPAN class=boldRed>'+lang.General.Captcha+': '+lang.TRANSP.Appros+'</span>', null, null, mainPop.getMainDiv);
		
				} else {
	                          actionLog(lang.TRANSP.Appros,"<font color=red>" + rslt.responseText +"</font>");
	                        }
	                       }
             });          	  
       	  } else {
       	   //actionLog("Appro","Transport de "+Cities.cities[t.reapproState.city].name+" vers "+Cities.cities[t.nbcity].name+" : blocage troupes minimun");
       	  }
      } else {
       actionLog(lang.TRANSP.Appros,uW.g_js_strings.commonstr.transport+" "+lang.TRANSP.Appro.From+" "+Cities.cities[t.reapproState.city].name+" "+lang.TRANSP.Appro.To+" "+Cities.cities[t.nbcity].name+" : "+lang.TRANSP.Appro.LowRes+"!");
      }
     }
   }
   t.checkdoreapprotimeout = setTimeout(function() { t.actionreappro();}, tempsprochainevisite);
  },
  showAuto: function() {
   var t = Tabs.TranspAuto;
    var m = '<DIV id=pbTowrtDivF class=boStat>'+lang.TRANSP.Automatic.Title1+'</div><TABLE id=pbtraderfunctions width=100% height=0% class=pbTab><TR align="center">';
         if (t.traderState.running == false) {
             m += '<TD><INPUT id=pbTraderState type=submit value="'+uW.g_js_strings.commonstr.transport+' = OFF"></td>';
   	       updatebotbutton(uW.g_js_strings.commonstr.transport+' - OFF', 'pbtrantab');
         } else {
             m += '<TD><INPUT id=pbTraderState type=submit value="'+uW.g_js_strings.commonstr.transport+' = ON"></td>';
   	      updatebotbutton(uW.g_js_strings.commonstr.transport+' - ON', 'pbtrantab');
         }
         m += '<TD><INPUT id=pbShowRoutes type=submit value="'+lang.TRANSP.Automatic.ShowRoute+'"></td>';
         m += '</tr></table></div>';
         m += '<DIV id=pbTraderDivDRoute class=boStat>'+lang.TRANSP.Automatic.Title2+'</div>';
         m += '<TABLE id=pbtraderfunctions width=100% height=0% class=pbTab><TR align="left">';
   	     m += '<TD colspan=2>'+lang.TRANSP.Automatic.TraspEvery+' <INPUT id=pbtransportinterval type=text size=4 value="'+Options.transportinterval+'"\> '+lang.General.mins+'</td>';
         m += '<TD colspan=4>'+lang.TRANSP.Automatic.TraspIf+' <INPUT id=pbminwagons type=text size=2 value="'+Options.minwagons+'"\> '+uW.g_js_strings.commonstr.troops+'.</td></tr></table>';
         m += '</table>';
         m += '<DIV id=pbTraderDivDRoute class=boStat>'+lang.TRANSP.Automatic.Title3+'</div>';
         m += '<TABLE id=pbaddtraderoute width=95% height=0% class=pbTab><TR align="left">';
         m += '<TR align="left"><TD>'+lang.TRANSP.Automatic.From+':</td> <TD colspan=4><DIV style="margin-bottom:10px;"><span id=ptrescity></span></div></td></tr>';
   
         m += '<TR align="left">';
         m += '<TD>'+lang.TRANSP.Automatic.To+':</td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=ptcityTo></span></div></td>';
         m += '<TD>'+lang.General.or+'</td>';
         m += '<TD>X:<INPUT id=ptcityX type=text size=3\></td>';
         m += '<TD>Y:<INPUT id=ptcityY type=text size=3\></td></tr>';
         m += '<TABLE id=pbaddtraderoute height=0% class=pbTab><TR align="left">';
         m += '<TD width=75px>'+uW.g_js_strings.commonstr.troops+':</td><TD width=150px><SELECT id="TransportTroop">';
         for (y in uW.unitcost) m+='<option value="'+y+'">'+unsafeWindow.unitcost[y][0]+'</option>';
         m+='</select></td><TD width=75px>'+uW.g_js_strings.commonstr.owned+':&nbsp;</td><TD id=TroopAmount align=left width=75px></td>';
         m+='<TD width=75px>'+uW.g_js_strings.commonstr.max+' '+uW.g_js_strings.commonstr.resources+'</td><TD id=CarryAmount align=left width=75px></td>';
         m += '<TR><TD>'+uW.g_js_strings.commonstr.troops+': </td><TD><INPUT id=TroopsToSend type=text size=6 maxlength=6 value="0">&nbsp;&nbsp;<INPUT id=MaxTroops type=submit value="Max"></td>';
         m += '<TD width=50px><INPUT id=FillInMax type=submit value="<----"></td>';
         m +='<TD id=Calc colspan=3></td></tr>';
         m += '<TABLE id=pbaddtraderoute height=0% class=pbTab><TR align="center">';
         m += '<TD width=5%><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png"></td>';
         m += '<TD id=TransRec1 align=right width=110px></td>';
         m += '<TD id=HaveRec1 align=right width=110px></td>';
         m += '<TD width=55px align=right><INPUT id=pbshipFood type=checkbox unchecked=true\></td>';
         m += '<TD width=180px  align=left>'+lang.TRANSP.Automatic.Keep+': <INPUT id=pbtargetamountFood type=text size=11 maxlength=12 value="0" disabled=true\></td>';
         m += '<TD width=100px>'+uW.g_js_strings.commonstr.transport+': <INPUT id=pbtradeamountFood type=text size=11 maxlength=12 value="0"\></td>';
         m += '<TD width=50px><INPUT id=MaxFood type=submit value="Max"></td></tr>';
         m += '<TR align="center">';
         m += '<TD width=5%><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png"></td>';
         m += '<TD id=TransRec2 align=right width=110px></td>';
         m += '<TD id=HaveRec2 align=right width=110px></td>';
         m += '<TD width=55px align=right><INPUT id=pbshipWood type=checkbox unchecked=true\></td>';
         m += '<TD width=180px align=left>'+lang.TRANSP.Automatic.Keep+': <INPUT id=pbtargetamountWood type=text size=11 maxlength=12 value="0" disabled=true\></td>';
         m += '<TD width=100px>'+uW.g_js_strings.commonstr.transport+': <INPUT id=pbtradeamountWood type=text size=11 maxlength=12 value="0"\></td>';
         m += '<TD width=50px><INPUT id=MaxWood type=submit value="Max"></td></tr>';
         m += '<TR align="center">';
         m += '<TD width=5%><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png"></td>';
         m += '<TD id=TransRec3 align=right width=110px></td>';
         m += '<TD id=HaveRec3 align=right width=110px></td>';
         m += '<TD width=55px align=right><INPUT id=pbshipStone type=checkbox unchecked=true\></td>';
         m += '<TD width=180px align=left>'+lang.TRANSP.Automatic.Keep+': <INPUT id=pbtargetamountStone type=text size=11 maxlength=12 value="0" disabled=true\></td>';
         m += '<TD width=100px>'+uW.g_js_strings.commonstr.transport+': <INPUT id=pbtradeamountStone type=text size=11 maxlength=12 value="0"\></td>';
         m += '<TD width=50px><INPUT id=MaxStone type=submit value="Max"></td></tr>';
         m += '<TR align="center">';
         m += '<TD width=5%><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png"></td>';
         m += '<TD id=TransRec4 align=right width=110px></td>';
         m += '<TD id=HaveRec4 align=right width=110px></td>';
         m += '<TD width=55px align=right><INPUT id=pbshipOre type=checkbox unchecked=true\></td>';
         m += '<TD width=180px align=left>'+lang.TRANSP.Automatic.Keep+': <INPUT id=pbtargetamountOre type=text size=11 maxlength=12 value="0" disabled=true\></td>';
         m += '<TD width=100px>'+uW.g_js_strings.commonstr.transport+': <INPUT id=pbtradeamountOre type=text size=11 maxlength=12 value="0"\></td>';
         m += '<TD width=50px><INPUT id=MaxOre type=submit value="Max"></td></tr>';
          m += '<TR align="center">';
      m += '<TD width=5%><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png"></td>';
      m += '<TD id=TransRec5 align=right width=110px></td>';
      m += '<TD id=HaveRec5 align=right width=110px></td>';
      m += '<TD width=55px align=right><INPUT id=pbshipAstone type=checkbox unchecked=true\></td>';
      m += '<TD width=180px align=left>'+lang.TRANSP.Automatic.Keep+': <INPUT id=pbtargetamountAstone type=text size=11 maxlength=12 value="0" disabled=true\></td>';
      m += '<TD width=100px>'+uW.g_js_strings.commonstr.transport+': <INPUT id=pbtradeamountAstone type=text size=11 maxlength=12 value="0"\></td>';
      m += '<TD width=50px><INPUT id=MaxAstone type=submit value="Max"></td></tr>';
      m += '<TR align="center">';
         m += '<TD width=5%><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png"></td>';
         m += '<TD id=TransGold align=right width=110px></td>';
         m += '<TD id=HaveGold align=right width=110px></td>';
         m += '<TD width=55px align=right><INPUT id=pbshipGold type=checkbox unchecked=true\></td>';
         m += '<TD width=180px align=left>'+lang.TRANSP.Automatic.Keep+': <INPUT id=pbtargetamountGold type=text size=11 maxlength=12 value="0" disabled=true\></td>';
         m += '<TD width=100px>'+uW.g_js_strings.commonstr.transport+': <INPUT id=pbtradeamountGold type=text size=11 maxlength=12 value="0"\></td>';
         m += '<TD width=50px><INPUT id=MaxGold type=submit value="Max"></td></tr>';
   
         m += '</table>';
   
         m += '<DIV style="text-align:center; margin-top:15px"><INPUT id=pbSaveRoute type=submit value="'+lang.TRANSP.Automatic.AddRoute+'"><INPUT id=pbManualSend type=submit value="'+lang.TRANSP.Automatic.TraspManu+'"></div>';
         m += '<DIV id=errorSpace></div>'
      
  	 t.TransportDiv.innerHTML = m; 
   
    ById('TransportTroop').value = 'unt9';
         
         t.tcp = new CdispCityPicker ('pttrader', ById('ptrescity'), true, t.updateResources, 0);
         t.tcpto = new CdispCityPicker ('pttraderTo', ById('ptcityTo'), true, t.clickCitySelect).bindToXYboxes(document.getElementById ('ptcityX'), document.getElementById ('ptcityY'));
         
         
       ById('TransportTroop').addEventListener('change', function(){t.updateTroops();}, false);
         ById('pbTraderState').addEventListener('click', function(){t.toggleTraderState(this);}, false);
         ById('pbSaveRoute').addEventListener('click', function(){t.addTradeRoute();}, false);
         ById('pbManualSend').addEventListener('click', function(){t.ManualTransport();}, false);
         ById('pbShowRoutes').addEventListener('click', function(){t.showTradeRoutes();}, false);
         ById('FillInMax').addEventListener('click', function(){ById('TroopsToSend').value = t.TroopsNeeded;}, false);
         
         ById('MaxTroops').addEventListener('click', function(){
   			var rallypointlevel = t.getRallypoint('city' + t.tcp.city.id);
   			if (rallypointlevel == 11) rallypointlevel = 15;
   			if (rallypointlevel == 12) rallypointlevel = 20;
   			var max = t.Troops;
   			if (t.Troops > (rallypointlevel*10000) ) max = (rallypointlevel*10000);
   			ById('TroopsToSend').value = max;
   	  }, false);
         ById('MaxFood').addEventListener('click', function(){
         		t.Food = 0;
   			var input = t.MaxLoad - (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone);
         		ById('pbtradeamountFood').value = (parseInt(input) <= parseIntCommas(ById('TransRec1').innerHTML))?input:parseIntCommas(ById('TransRec1').innerHTML);
         }, false);
         ById('MaxWood').addEventListener('click', function(){
         		t.Wood = 0;
   			var input = t.MaxLoad - (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone);
         		ById('pbtradeamountWood').value = (parseInt(input) <= parseIntCommas(ById('TransRec2').innerHTML))?input:parseIntCommas(ById('TransRec2').innerHTML);
         }, false);
         ById('MaxStone').addEventListener('click', function(){
         		t.Stone = 0;
   			var input = t.MaxLoad - (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone);
         		ById('pbtradeamountStone').value = (parseInt(input) <= parseIntCommas(ById('TransRec3').innerHTML))?input:parseIntCommas(ById('TransRec3').innerHTML);
         }, false);
         ById('MaxOre').addEventListener('click', function(){
         		t.Ore = 0;
   			var input = t.MaxLoad - (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone);
         		ById('pbtradeamountOre').value = (parseInt(input) <= parseIntCommas(ById('TransRec4').innerHTML))?input:parseIntCommas(ById('TransRec4').innerHTML);
         }, false);
         ById('MaxGold').addEventListener('click', function(){
   			t.Gold = 0;
   			var input = t.MaxLoad - (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone);
         		ById('pbtradeamountGold').value = (parseInt(input) <= parseIntCommas(ById('TransGold').innerHTML))?input:parseIntCommas(ById('TransGold').innerHTML);
         }, false);
   	   ById('MaxAstone').addEventListener('click', function(){
         		t.Astone = 0;
   			var input = t.MaxLoad - (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone);
         		ById('pbtradeamountAstone').value = (parseInt(input) <= parseIntCommas(ById('TransRec5').innerHTML))?input:parseIntCommas(ById('TransRec5').innerHTML);
         }, false);
         
         ById('pbtransportinterval').addEventListener('keyup', function(){
   		if (isNaN(ById('pbtransportinterval').value)){ ById('pbtransportinterval').value=60 ;}
   		Options.transportinterval = ById('pbtransportinterval').value;
   		saveOptions();
         }, false);
         
         ById('pbtargetamountFood').addEventListener('keyup', function(){
             if (isNaN(ById('pbtargetamountFood').value)) ById('pbtargetamountFood').value=0 ;
         }, false);
         ById('pbtargetamountWood').addEventListener('keyup', function(){
             if (isNaN(ById('pbtargetamountWood').value)) ById('pbtargetamountWood').value=0 ;
         }, false);
         ById('pbtargetamountStone').addEventListener('keyup', function(){
             if (isNaN(ById('pbtargetamountStone').value)) ById('pbtargetamountStone').value=0 ;
         }, false);
         ById('pbtargetamountOre').addEventListener('keyup', function(){
             if (isNaN(ById('pbtargetamountOre').value)) ById('pbtargetamountOre').value=0 ;
         }, false);
   	  ById('pbtargetamountAstone').addEventListener('keyup', function(){
             if (isNaN(ById('pbtargetamountAstone').value)) ById('pbtargetamountAstone').value=0 ;
         }, false);
         ById('pbtargetamountGold').addEventListener('keyup', function(){
             if (isNaN(ById('pbtargetamountGold').value)) ById('pbtargetamountGold').value=0 ;
         }, false);
         ById('pbtradeamountFood').addEventListener('keyup', function(){
             if (isNaN(ById('pbtradeamountFood').value)) ById('pbtradeamountFood').value=0 ;
         }, false);
         ById('pbtradeamountWood').addEventListener('keyup', function(){
             if (isNaN(ById('pbtradeamountWood').value)) ById('pbtradeamountWood').value=0 ;
         }, false);
         ById('pbtradeamountStone').addEventListener('keyup', function(){
             if (isNaN(ById('pbtradeamountStone').value)) ById('pbtradeamountStone').value=0 ;
         }, false);
         ById('pbtradeamountOre').addEventListener('keyup', function(){
             if (isNaN(ById('pbtradeamountOre').value)) ById('pbtradeamountOre').value=0 ;
         }, false);
   	  ById('pbtradeamountAstone').addEventListener('keyup', function(){
             if (isNaN(ById('pbtradeamountAstone').value)) ById('pbtradeamountAstone').value=0 ;
         }, false);
         ById('pbtradeamountGold').addEventListener('keyup', function(){
             if (isNaN(ById('pbtradeamountGold').value)) ById('pbtradeamountGold').value=0 ;
         }, false);
        ById('pbminwagons').addEventListener('keyup', function(){
            if (isNaN(ById('pbminwagons').value)) ById('pbminwagons').value=100 ;
            Options.minwagons = parseInt(ById('pbminwagons').value);
            saveOptions();
        }, false)
         
         ById('pbshipFood').addEventListener('click', function(){
             if (ById('pbshipFood').checked==false) {
                 ById('pbtargetamountFood').disabled = true;
             }
             else {
               ById('pbtargetamountFood').disabled = false;
             }
         },false);
         ById('pbshipWood').addEventListener('click', function(){
             if (ById('pbshipWood').checked==false) {
                 ById('pbtargetamountWood').disabled = true;
             }
             else {
               ById('pbtargetamountWood').disabled = false;
             }
         },false);
         ById('pbshipStone').addEventListener('click', function(){
             if (ById('pbshipStone').checked==false) {
                 ById('pbtargetamountStone').disabled = true;
             }
             else {
               ById('pbtargetamountStone').disabled = false;
             }
         },false);
         ById('pbshipOre').addEventListener('click', function(){
             if (ById('pbshipOre').checked==false) {
                 ById('pbtargetamountOre').disabled = true;
             }
             else {
               ById('pbtargetamountOre').disabled = false;
             }
         },false);
   	   ById('pbshipAstone').addEventListener('click', function(){
             if (ById('pbshipAstone').checked==false) {
                 ById('pbtargetamountAstone').disabled = true;
             }
             else {
               ById('pbtargetamountAstone').disabled = false;
             } 
         },false);
          ById('pbshipGold').addEventListener('click', function(){
             if (ById('pbshipGold').checked==false) {
                 ById('pbtargetamountGold').disabled = true;
             }
             else {
               ById('pbtargetamountGold').disabled = false;
             }
         },false);
  
       },
       updateResources2 : function (){
       var t = Tabs.TranspAuto
       t.reapproState.city = t.reacp.city.idx;
       for (var y=0; y< Seed.cities.length;y++) {
         if (t.reacp.city.id==Seed.cities[y][0]) {
          ById('ReappRes_'+y+'_0').value="0";
          ById('ReappRes_'+y+'_0').disabled=true;
         }else {
          ById('ReappRes_'+y+'_0').disabled=false;
          ById('ReappRes_'+y+'_0').value=parseIntNan(t.reapproState['ReappRes_'+y+'_0']);
          ById('ReappRec_'+y+'_0').innerHTML = addCommas ( parseIntNan(Seed.citystats["city" + Seed.cities[y][0]]['gold'][0]) );
          }
         for (var i=1;i<=5;i++) {
          if (t.reacp.city.id==Seed.cities[y][0]) {
            ById('ReappRes_'+y+'_'+i).value="0";
            ById('ReappRes_'+y+'_'+i).disabled=true;
          } else{
            ById('ReappRes_'+y+'_'+i).value= parseIntNan(t.reapproState['ReappRes_'+y+'_'+i]);
            ById('ReappRes_'+y+'_'+i).disabled=false;
          }
          if(i==5)
              ById('ReappRec_'+y+'_'+i).innerHTML = addCommas ( parseIntNan(Seed.resources["city" + Seed.cities[y][0]]['rec'+i][0]) );
          else 
              ById('ReappRec_'+y+'_'+i).innerHTML = addCommas ( parseIntNan(Seed.resources["city" + Seed.cities[y][0]]['rec'+i][0]/3600));    
         }
        
       }
       
       },
       updateResources : function (){
       	var t = Tabs.TranspAuto
       	var ToCity = null;
       	for (var i=1;i<=5;i++)
   			if(i==5)
   			   ById('TransRec'+i).innerHTML = addCommas ( parseInt(Seed.resources["city" + t.tcp.city.id]['rec'+i][0]) );
   			else 
                          ById('TransRec'+i).innerHTML = addCommas ( parseInt(Seed.resources["city" + t.tcp.city.id]['rec'+i][0]/3600) );
       	ById('TransGold').innerHTML = addCommas ( parseInt(Seed.citystats["city" + t.tcp.city.id]['gold'][0]) );
       	for (ii in Seed.cities)
           if (Seed.cities[ii][2] == document.getElementById ('ptcityX').value && Seed.cities[ii][3] == document.getElementById ('ptcityY').value)
             ToCity = Seed.cities[ii][0];
         for (var i=1;i<=5;i++)
             if (ToCity != null)
   			if(i==5)
   			   ById('HaveRec'+i).innerHTML = addCommas ( parseInt(Seed.resources["city" + ToCity]['rec'+i][0]) );
   			else
                  ById('HaveRec'+i).innerHTML = addCommas ( parseInt(Seed.resources["city" + ToCity]['rec'+i][0]/3600) );
       	  else ById('HaveRec'+i).innerHTML = "----";
         if (ToCity != null) ById('HaveGold').innerHTML = addCommas ( parseInt(Seed.citystats["city" + ToCity]['gold'][0]) );
         else  ById('HaveGold').innerHTML =  "----";   
       },
       
       updateTroops : function (city){
       	var t = Tabs.TranspAuto;
       	var fontcolor = 'black';
       	t.Food = parseInt(ById('pbtradeamountFood').value);
         	t.Wood = parseInt(ById('pbtradeamountWood').value);
         	t.Stone = parseInt(ById('pbtradeamountStone').value);
         	t.Ore = parseInt(ById('pbtradeamountOre').value);
         	t.Gold = parseInt(ById('pbtradeamountGold').value);
   		t.Astone = parseInt(ById('pbtradeamountAstone').value*5);
       	var unit = ById('TransportTroop').value;
       	t.Troops = parseInt(Seed.units['city' + t.tcp.city.id][unit]);
      	var untid=ById('TransportTroop').value;
	var techLoadBoost=parseInt(Seed.tech.tch10)*0.1;
	var loadEffectBoost=0;
	if(Seed.playerEffects.loadExpire>uW.unixtime()){loadEffectBoost=0.25}
	var loadBoostBase=(EffetTronePrc(6).percent*0.01)+loadEffectBoost+techLoadBoost;
	var loadBoost=loadBoostBase;
	if(uW.cm.unitFrontendType[untid]=="horsed"){
	 loadBoost+=(EffetTronePrc(48).percent*0.01)
	}
        var LoadUnit=parseInt(parseInt(uW.unitstats[untid][5])*(1+loadBoost));
       	var GlobalMaxLoad = t.Troops * LoadUnit;
       	t.MaxLoad = parseInt(ById('TroopsToSend').value) * LoadUnit;
        	t.TroopsNeeded = (t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone) / LoadUnit;
        	t.TroopsNeeded = t.TroopsNeeded.toFixed(0);	
   		if (t.TroopsNeeded < ((t.Food + t.Wood + t.Stone + t.Ore + t.Gold + t.Astone) / LoadUnit)) t.TroopsNeeded++;	
           
           if ( t.TroopsNeeded > t.Troops) fontcolor = 'red';
       	if (t.Troops > 0 ) ById('TroopAmount').innerHTML = '<FONT color='+fontcolor+'>' + addCommas(t.Troops) + '</font>';
       	else ById('TroopAmount').innerHTML = 0;
       	if (GlobalMaxLoad > 0) ById('CarryAmount').innerHTML = addCommas(GlobalMaxLoad);
       	else  ById('CarryAmount').innerHTML = 0;
       	ById('Calc').innerHTML = uW.g_js_strings.commonstr.resources+': ' +  addCommas(t.Food + t.Wood + t.Stone + t.Ore + t.Gold  + t.Astone) + ' / ' + addCommas(t.MaxLoad) + '&nbsp;&nbsp;('+lang.TRANSP.Automatic.TroopsNeeded+': <FONT color='+fontcolor+'>' + addCommas(t.TroopsNeeded) + '</font> )' ;
       },    
       getRallypoint: function(cityId){
         var t = Tabs.TranspAuto;
         for (var o in Seed.buildings[cityId]){
   		var buildingType = parseInt(Seed.buildings[cityId][o][0]);
   		var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
   		if (buildingType == 12){
   			return parseInt(buildingLevel);
   			break;
   		}
   	   }
   	  return 0;
       },
      e_tradeRoutes: function(){
         var t = Tabs.TranspAuto;
         var now = new Date();
         clearTimeout(t.timer);
         if (t.traderState.running == true)    {
         	var now = new Date().getTime()/1000.0;
         	now = now.toFixed(0);
         	var last = Options.lasttransport;
          		if ( now > (parseInt(last) + (Options.transportinterval*60))){
   				  t.checkdoTrades();
         		}
         }
   	 t.timer = setTimeout(function(){ t.e_tradeRoutes();}, Options.transportinterval*1000);
   	  
       },
       	
   	delTradeRoutes: function() {
   		var t = Tabs.TranspAuto;	
   		t.tradeRoutes= [];
   	},
   	
   	checkcoords : function (obj){
   		var t = Tabs.TranspAuto;
   		if(obj.id == 'pbok'){
   			t.check = true;
   			t.addTradeRoute();
   		}
   		return;			
   	},
   	
   	addTradeRoute: function () {
   		var valid = true;
   		var t = Tabs.TranspAuto;
   		var city = t.tcp.city.id;
   		if (ById('ptcityX').value==0 && ById('ptcityY').value ==0 && !t.check)
   		{
   			return;
   		}
   		var ship_Food = ById('pbshipFood').checked;
   		var ship_Wood = ById('pbshipWood').checked;
   		var ship_Stone = ById('pbshipStone').checked;
   		var ship_Ore = ById('pbshipOre').checked;
   		var ship_Astone = ById('pbshipAstone').checked;
   		var ship_Gold = ById('pbshipGold').checked;
   		var target_Food = ById('pbtargetamountFood').value;
   		var target_Wood = ById('pbtargetamountWood').value;
   		var target_Stone = ById('pbtargetamountStone').value;
   		var target_Ore = ById('pbtargetamountOre').value;
   		var target_Astone = ById('pbtargetamountAstone').value;
   		var target_Gold = ById('pbtargetamountGold').value;
   		var trade_Food = ById('pbtradeamountFood').value;
   		var trade_Wood = ById('pbtradeamountWood').value;
   		var trade_Stone = ById('pbtradeamountStone').value;
   		var trade_Ore = ById('pbtradeamountOre').value;
   		var trade_Astone = ById('pbtradeamountAstone').value;
   		var trade_Gold = ById('pbtradeamountGold').value;
   		var target_x = ById('ptcityX').value;
   		var target_y = ById('ptcityY').value;
   		var TroopType = ById('TransportTroop').value;
   		var route_state = true;
   				
   		if (valid == true) {
   			var lTR = t.tradeRoutes;
   			lTR.push({
   				city:				city,
   				ship_Food:			ship_Food,
   				target_Food:		target_Food,
   				trade_Food: 		trade_Food,
   				ship_Wood:			ship_Wood,
   				target_Wood:		target_Wood,
   				trade_Wood: 		trade_Wood,
   				ship_Stone:			ship_Stone,
   				target_Stone:		target_Stone,
   				trade_Stone: 		trade_Stone,
   				ship_Ore:			ship_Ore,
   				target_Ore:			target_Ore,
   				trade_Ore:	 		trade_Ore,
   				ship_Astone:	    ship_Astone,
   				target_Astone:		target_Astone,
   				trade_Astone:	 	trade_Astone,
   				ship_Gold:			ship_Gold,
   				target_Gold:		target_Gold,
   				trade_Gold: 		trade_Gold,
   				target_x: 			target_x,
   				target_y: 			target_y,
   				TroopType:      TroopType,
   				route_state: 		"true"
   			});
   		}
   		ById('pbTraderDivDRoute').style.background ='#99FF99';
   		setTimeout(function(){ (ById('pbTraderDivDRoute').style.background =''); }, 500);
   	},
   	showTradeRoutes: function () {
   		var t = Tabs.TranspAuto;
   		if (t.popTradeRoutes == null) {
   		 t.popTradeRoutes = new CPopup('pbShowTrade', 0, 0, 750, 500, true, function() {clearTimeout (1000);});
   		 t.popTradeRoutes.centerMe (mainPop.getMainDiv());
   		}
   		var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbTab" id="pbRoutesQueue">';       
   		t.popTradeRoutes.getMainDiv().innerHTML = '</table></div>' + m;
   		t.popTradeRoutes.getTopDiv().innerHTML = '<TD><B>'+lang.TRANSP.Automatic.Title4+': </td>';
   		t.paintTradeRoutes();
   		t.popTradeRoutes.show(true)	;
   	},
   	paintTradeRoutes: function(){
   	        var t = Tabs.TranspAuto;
   	        var r = t.tradeRoutes;
   	        var cityname;
   	        var citynameTo = null;
   	    var m= '<TABLE id=paintRoutes class=pbTab><tr><td colspan=4><input type=button id=BOTrpQG value="QG"></tr>'; 
   			for (var i=0;i<(r.length);i++) {
   			  citynameTo = null;
   				for (var y=0; y< Seed.cities.length;y++) {
   					if ( parseInt(Seed.cities[y][0]) == r[i].city) var cityname = Seed.cities[y][1];
   					if ( parseInt(Seed.cities[y][2]) == r[i].target_x && parseInt(Seed.cities[y][3]) == r[i].target_y) var citynameTo = Seed.cities[y][1];
   				}    
   				var queueId = i;
   				if (citynameTo == null) var TO = r[i].target_x +','+ r[i].target_y;
   				else TO = citynameTo;
   				if (r[i].route_state) var status = '<FONT color=green>'+lang.TRANSP.Automatic.Active+'</font>';
   				else var status = '<FONT color=red>'+lang.TRANSP.Automatic.Deactive+'</font>';
   				if (r[i].TroopType == undefined) var unit = 'unt9';
           else var unit = r[i].TroopType;
   				m += '<TR><TD TD width=12px>&nbsp;&nbsp;</td></tr>';
           m +='<TR><TD width=20px>'+(i+1)+'</td><TD width=175px>'+lang.TRANSP.Automatic.From+':&nbsp;&nbsp;'+ cityname +'</TD><TD width=175px>'+lang.TRANSP.Automatic.To+':&nbsp;&nbsp;'+ TO +'</td><TD width=175px>'+status+'</td>';
           m +='<TD width=60px><A onclick="traceEdit('+queueId+')">'+lang.General.edit+'</a></td><TD width=60px><A onclick="traceDelete('+queueId+')">'+uW.g_js_strings.commonstr.deletetx+'</a></td></tr>';
           m += '<TR><TD></td><TD>'+uW.g_js_strings.commonstr.troops+':&nbsp;&nbsp;'+unsafeWindow.unitcost[unit][0]+'</td></tr>';
           if (r[i].ship_Food) m += '<TR><TD></td><TD align=center><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png"></td><TD>Target: '+ addCommas(r[i].target_Food) +'</td><TD>Trade: '+ addCommas(r[i].trade_Food)+'</td>';
   				if (r[i].ship_Wood) m += '<TR><TD></td><TD align=center><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png"></td><TD>Target: '+ addCommas(r[i].target_Wood) +'</td><TD>Trade: '+ addCommas(r[i].trade_Wood)+'</td>';
   				if (r[i].ship_Stone) m += '<TR><TD></td><TD align=center><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png"></td><TD>Target: '+ addCommas(r[i].target_Stone) +'</td><TD>Trade: '+ addCommas(r[i].trade_Stone)+'</td>';
   				if (r[i].ship_Ore) m += '<TR><TD></td><TD align=center><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png"></td><TD>Target: '+ addCommas(r[i].target_Ore) +'</td><TD>Trade: '+ addCommas(r[i].trade_Ore)+'</td>';
   				if (r[i].ship_Astone) m += '<TR><TD></td><TD align=center><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png"></td><TD>Target: '+ addCommas(r[i].target_Astone) +'</td><TD>Trade: '+ addCommas(r[i].trade_Astone)+'</td>';
   				if (r[i].ship_Gold) m += '<TR><TD></td><TD align=center><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png"></td><TD>Target: '+ addCommas(r[i].target_Gold) +'</td><TD>Trade: '+ addCommas(r[i].trade_Gold)+'</td>';
          }
   	     m +='</table>';
   	     ById('pbRoutesQueue').innerHTML= m; 
   	     ById("BOTrpQG").addEventListener('click', function(){
   	      if (!Options.alertConfig.MonQG && parseIntNan(Options.alertConfig.hq)>0) {
   	      
   	       var mavilleId=Cities.byID[Options.alertConfig.hq];
	       if (mavilleId) {
	        var r = t.tradeRoutes;
	        for (var i=0;i<(r.length);i++) {
	        
	           r[i].target_x=mavilleId.x;
	           
	           
	            r[i].target_y=mavilleId.y;
	       
	        }
	        t.showTradeRoutes();
	       }
		  
   	      
   	      }
   	     
   	     },false);
          unsafeWindow.traceEdit = t.editQueueElement;
          unsafeWindow.traceDelete = t.cancelQueueElement;
   	    },
   	  
   	 cancelQueueElement: function(queueId){
   	     var t = Tabs.TranspAuto;
   	     var queueId = parseInt(queueId);
   	     t.tradeRoutes.splice(queueId, 1);
   	     t.showTradeRoutes();
   	 },
   	 
   	 editQueueElement: function(queueId){
   	     var t = Tabs.TranspAuto;
   	     var r = t.tradeRoutes;
          var queueId = parseInt(queueId);
   	     var cityname;
   	     var citynameTo = null;
   	     var Types = ['food','wood','stone','iron','aetherstone','gold'];
   	     for (var y=0; y< Seed.cities.length;y++) {
   					if ( parseInt(Seed.cities[y][0]) == r[queueId].city) var cityname = Seed.cities[y][1];
   					if ( parseInt(Seed.cities[y][2]) == r[queueId].target_x && parseInt(Seed.cities[y][3]) == r[queueId].target_y) var citynameTo = Seed.cities[y][1];
   			 }
          if (citynameTo == null) var TO = "x:<input type=text size=3 id='pbbtargetx' value='"+r[queueId].target_x+"'> y:<input type=text size=3 id='pbbtargety' value='"+r[queueId].target_y+"'>";
   			 else TO = citynameTo; 
          var n = '<TABLE id=editRoutes class=pbTab>';
   	     n +='<TD>'+lang.TRANSP.Automatic.From+':&nbsp;'+ cityname +'</td><TD>'+lang.TRANSP.Automatic.To+':&nbsp;'+ TO +'</td>';
   	     n +='<TD><INPUT id=TradeStatus type=checkbox>&nbsp;Activ&eacute; la route</td>';
   	     n += '<TD width=150px>'+uW.g_js_strings.commonstr.troops+' :<SELECT id="pbbTransportTroop">';
          for (y in unsafeWindow.unitcost) n+='<option value="'+y+'">'+unsafeWindow.unitcost[y][0]+'</option>';
          n+='</select></td></table><BR><TABLE  id=editRoutes class=pbTab>';
          for (var i=0;i<Types.length;i++){
   	    var icon = Types[i];
            n += '<TR><TD width=50px align=center><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/'+icon+'_30.png"></td>';
            n += '<TD width=50px align=center><INPUT id=pbbship'+Types[i]+' type=checkbox></td>';
            n += '<TD width=125px>'+lang.TRANSP.Automatic.Keep+': <INPUT id=pbbtargetamount'+Types[i]+' type=text size=11 maxlength=12 value="0"></td>';
            n += '<TD width=125px>'+uW.g_js_strings.commonstr.transport+': <INPUT id=pbbtradeamount'+Types[i]+' type=text size=11 maxlength=12 value="0"\></td></tr>';
          }
          n+='</table><BR><TABLE id=editRoutes class=pbTab><TR><TD><a class="button20" id="Cancel"><span>'+uW.g_js_strings.commonstr.cancel+'</span></a></td>';
          n+='<TD><a class="button20" id="Save"><span>'+lang.General.save+'</span></a></td></tr>';
          n +='</table>';
          
          ById('pbRoutesQueue').innerHTML= n;
          ById('TradeStatus').checked = r[queueId].route_state;
          if (r[queueId].TroopType == undefined) var unit = 'unt9';
          else var unit = r[queueId].TroopType;
          ById('pbbTransportTroop').value = unit;
	         ById('pbbshipfood').checked = r[queueId].ship_Food;
	         ById('pbbshipwood').checked = r[queueId].ship_Wood;
	         ById('pbbshipstone').checked = r[queueId].ship_Stone;
	         ById('pbbshipiron').checked = r[queueId].ship_Ore;
	  	   ById('pbbshipaetherstone').checked = r[queueId].ship_Astone;
	         ById('pbbshipgold').checked = r[queueId].ship_Gold;
	         ById('pbbtargetamountfood').value = r[queueId].target_Food;
	         ById('pbbtargetamountwood').value = r[queueId].target_Wood;
	         ById('pbbtargetamountstone').value = r[queueId].target_Stone;
	         ById('pbbtargetamountiron').value = r[queueId].target_Ore;
	  	   ById('pbbtargetamountaetherstone').value = r[queueId].target_Astone;
	         ById('pbbtargetamountgold').value = r[queueId].target_Gold;
	         ById('pbbtradeamountfood').value = r[queueId].trade_Food;
	         ById('pbbtradeamountwood').value = r[queueId].trade_Wood;
	         ById('pbbtradeamountstone').value = r[queueId].trade_Stone;
	         ById('pbbtradeamountiron').value = r[queueId].trade_Ore;
	  	   ById('pbbtradeamountaetherstone').value = r[queueId].trade_Astone;
	         ById('pbbtradeamountgold').value = r[queueId].trade_Gold;
	         ById('Cancel').addEventListener('click', function(){t.showTradeRoutes();}, false);
	         ById('Save').addEventListener('click', function(){
	              if (ById("pbbtargetx")) {
		 	         
		 	   r[queueId].target_x = ById('pbbtargetx').value;      
		 	   r[queueId].target_y = ById('pbbtargety').value;      
		 	         
	              }
	              r[queueId].route_state = ById('TradeStatus').checked;
	              r[queueId].TroopType = ById('pbbTransportTroop').value;
	              r[queueId].ship_Food = ById('pbbshipfood').checked;
	              r[queueId].ship_Wood = ById('pbbshipwood').checked;
	              r[queueId].ship_Stone = ById('pbbshipstone').checked;
	              r[queueId].ship_Ore = ById('pbbshipiron').checked;
	  			r[queueId].ship_Astone = ById('pbbshipaetherstone').checked;
	              r[queueId].ship_Gold = ById('pbbshipgold').checked;
	              r[queueId].target_Food = ById('pbbtargetamountfood').value;
	              r[queueId].target_Wood = ById('pbbtargetamountwood').value;
	              r[queueId].target_Stone = ById('pbbtargetamountstone').value;
	              r[queueId].target_Ore = ById('pbbtargetamountiron').value;
	  			r[queueId].target_Astone = ById('pbbtargetamountaetherstone').value;
	              r[queueId].target_Gold = ById('pbbtargetamountgold').value;
	              r[queueId].trade_Food = ById('pbbtradeamountfood').value;
	              r[queueId].trade_Wood = ById('pbbtradeamountwood').value;
	              r[queueId].trade_Stone = ById('pbbtradeamountstone').value;
	              r[queueId].trade_Ore = ById('pbbtradeamountiron').value;
	  			r[queueId].trade_Astone = ById('pbbtradeamountaetherstone').value;
	              r[queueId].trade_Gold = ById('pbbtradeamountgold').value;
	              t.showTradeRoutes();
	          }, false);
	 },
   	   
   	saveTradeRoutes: function(){
   		var t = Tabs.TranspAuto;
           var serverID = getServerId();
           saveValue('tradeRoutes_' + serverID, JSON2.stringify(t.tradeRoutes));
       },
     readTradeRoutes: function(){
           var t = Tabs.TranspAuto;
           var serverID = getServerId();
           s = loadValue('tradeRoutes_' + serverID);
           if (s != null) {
               route = JSON2.parse(s);
               for (k in route)
                   t.tradeRoutes[k] = route[k];
           }
       },
   	saveTraderState: function(){
   		var t = Tabs.TranspAuto;
           var serverID = getServerId();
           saveValue('traderState_' + serverID, JSON2.stringify(t.traderState));
       },
       readTraderState: function(){
           var t = Tabs.TranspAuto;
           var serverID = getServerId();
           s = loadValue('traderState_' + serverID);
           if (s != null) {
               state = JSON2.parse(s);
               for (k in state)
                   t.traderState[k] = state[k];
           }
       },
       toggleTraderState: function(obj){
   	   var t = Tabs.TranspAuto;
   	   obj = ById('pbTraderState');
           if (t.traderState.running == true) {
               t.traderState.running = false;
               if (obj)  obj.value = uW.g_js_strings.commonstr.transport+" = OFF";
   	       updatebotbutton(uW.g_js_strings.commonstr.transport+' - OFF', 'pbtrantab');
   	       clearTimeout(t.checkdotradetimeout);
   	       t.count = 0;
   	       Options.lasttransport = 0;
	       saveOptions();
           }
           else {
               t.traderState.running = true;
               if (obj) obj.value = uW.g_js_strings.commonstr.transport+" = ON";
   		updatebotbutton(uW.g_js_strings.commonstr.transport+' - ON', 'pbtrantab');
   			t.e_tradeRoutes();
           }
       },
   	
   	checkdoTrades: function(){
   	var t = Tabs.TranspAuto;
   	if(t.tradeRoutes.length==0) return;
   	t.doTrades(t.count);
   	t.count++;
   	if(t.count < t.tradeRoutes.length){
   			  t.checkdotradetimeout = setTimeout(function() { t.checkdoTrades();}, 10000);
   			} else {
   			  var now = new Date().getTime()/1000.0;
   			  now = now.toFixed(0);
   			  Options.lasttransport = now;
   			  saveOptions();	
   			  t.count = 0;
   			}
   	},
       
     doTrades: function(count){
       var t = Tabs.TranspAuto;
   
      	if(t.tradeRoutes.length==0) return;
      	if(!t.tradeRoutes[count]["route_state"]) return;
      	
      	var city = t.tradeRoutes[count]["city"];
      	if(!Cities.byID[city]) return;
	   		
	var xcoord = t.tradeRoutes[count]["target_x"];
       	var ycoord = t.tradeRoutes[count]["target_y"];
   	var cityID = 'city' + city;
   	for (var zz=0; zz< Seed.cities.length;zz++) {
	   if (parseInt(Seed.cities[zz][0]) == city) 
	      var cityname = Seed.cities[zz][1];
	}                     
   		
      	var rallypointlevel = t.getRallypoint(cityID);
	if(rallypointlevel == 12) rallypointlevel = 11;
        var slots = 0;
	for (var k in Seed.queue_atkp[cityID]){   
	         	         march = Seed.queue_atkp[cityID][k];
	         	         if (typeof (march) == 'object'){
	         	           slots++;
	         	         }
	}
	if(slots >= rallypointlevel){
	      		actionLog("Transport",uW.g_js_strings.commonstr.transport+" "+lang.TRANSP.Automatic.From+" "+cityname+" "+lang.TRANSP.Automatic.To+" " + xcoord + "," + ycoord + " <font color=red>"+lang.TRANSP.Automatic.PointFull+"!</font>");
	      		return;
        }
      	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
   		params.gold =0;
   		params.r1 =0;
   		params.r2 =0;
   		params.r3 =0;
   		params.r4 =0 ;
   		params.r5 =0 ;
   		params.kid = 0;
   		
   		var carry_amount= 0;
   		var wagons_needed=0;
   		var citymax = 0;
   		
   		

       	var trade_Food = t.tradeRoutes[count]["trade_Food"];
       	var trade_Wood = t.tradeRoutes[count]["trade_Wood"];
       	var trade_Stone = t.tradeRoutes[count]["trade_Stone"];
       	var trade_Ore = t.tradeRoutes[count]["trade_Ore"];
   	    var trade_Astone = t.tradeRoutes[count]["trade_Astone"];
       	var trade_Gold = t.tradeRoutes[count]["trade_Gold"];
       	var target_Food = t.tradeRoutes[count]["target_Food"];
       	var target_Wood = t.tradeRoutes[count]["target_Wood"];
       	var target_Stone = t.tradeRoutes[count]["target_Stone"];
       	var target_Ore = t.tradeRoutes[count]["target_Ore"];
   		var target_Astone = t.tradeRoutes[count]["target_Astone"];
       	var target_Gold = t.tradeRoutes[count]["target_Gold"];
       	var ship_Food = t.tradeRoutes[count]["ship_Food"];
       	var ship_Wood = t.tradeRoutes[count]["ship_Wood"];
       	var ship_Stone = t.tradeRoutes[count]["ship_Stone"];
       	var ship_Ore = t.tradeRoutes[count]["ship_Ore"];
   		var ship_Astone = t.tradeRoutes[count]["ship_Astone"];
       	var ship_Gold = t.tradeRoutes[count]["ship_Gold"];
       	var citymax_Food = parseIntNan(Seed.resources[cityID]['rec1'][0] / 3600);
       	var citymax_Wood = parseIntNan(Seed.resources[cityID]['rec2'][0] / 3600);
       	var citymax_Stone = parseIntNan(Seed.resources[cityID]['rec3'][0] / 3600);
       	var citymax_Ore = parseIntNan(Seed.resources[cityID]['rec4'][0] / 3600);
   		var citymax_Astone = parseIntNan(Seed.resources[cityID]['rec5'][0]);
       	var citymax_Gold = parseIntNan(Seed.citystats[cityID]['gold']);
       	var carry_Food = parseIntNan(citymax_Food - target_Food);
       	var carry_Wood = parseIntNan(citymax_Wood - target_Wood);
       	var carry_Stone = parseIntNan(citymax_Stone - target_Stone);
       	var carry_Ore = parseIntNan(citymax_Ore - target_Ore);
   		var carry_Astone = parseIntNan(citymax_Astone - target_Astone);
       	var carry_Gold = 0;
       	if (carry_Food < 0 || ship_Food==false) carry_Food = 0;
       	if (carry_Wood < 0 || ship_Wood==false) carry_Wood = 0;
       	if (carry_Stone < 0 || ship_Stone==false) carry_Stone = 0;
       	if (carry_Ore < 0 || ship_Ore==false) carry_Ore = 0;
   		if (carry_Astone < 0 || ship_Astone==false) carry_Astone = 0;
       	if (trade_Food > 0 && (carry_Food > trade_Food)) carry_Food = parseIntNan(trade_Food);
       	if (trade_Wood > 0 && (carry_Wood > trade_Wood)) carry_Wood = parseIntNan(trade_Wood);
       	if (trade_Stone > 0 && (carry_Stone > trade_Stone)) carry_Stone = parseIntNan(trade_Stone);
       	if (trade_Ore > 0 && (carry_Ore > trade_Ore)) carry_Ore = parseIntNan(trade_Ore);
   	if (trade_Astone > 0 && (carry_Astone > trade_Astone)) carry_Astone = parseIntNan(trade_Astone);
   		carry_Astone *= 5;         
         if (t.tradeRoutes[count]['TroopType'] == undefined) var wagons = parseInt(Seed.units[cityID]['unt'+ 9]); 
         else var wagons =  parseInt(Seed.units[cityID][t.tradeRoutes[count]['TroopType']]);
         var rallypointlevel = t.getRallypoint(cityID);	
   		  if (rallypointlevel == 11) rallypointlevel = 15;
   		  if (rallypointlevel == 12) rallypointlevel = 20;
       	if (parseInt(wagons) > parseInt(rallypointlevel*10000)){ wagons = (rallypointlevel*10000); }   	
         if (t.tradeRoutes[count]['TroopType'] == undefined) var unit = 'unt9';
         else var unit = t.tradeRoutes[count]['TroopType'];
         var Troops = parseInt(Seed.units[cityID][unit]);
   	  if(parseInt(Troops)>parseInt(wagons)) Troops = wagons;
         var featherweight = parseInt(Seed.tech.tch10);
       	var Load = parseInt(unsafeWindow.unitstats[unit]['5'])
         var maxloadperwagon = (featherweight * ((Load/100)*10)) + Load;
   		  var maxload = (maxloadperwagon * Troops);
   		  if(wagons <= 0) {return; }
   		  var shift_Food = parseIntNan(maxload / 9);
   		  var shift_Wood = parseIntNan(maxload / 9);
   		  var shift_Stone = parseIntNan(maxload / 9);
   		  var shift_Ore = parseIntNan(maxload / 9);
   		  var shift_Astone = parseIntNan(maxload / 9 * 5); 	
   		  if ((maxload - carry_Food - carry_Wood - carry_Stone - carry_Ore - carry_Astone) < 0){
   			 var shift_num=0;
   			 var shift_spare=0;
   			if (carry_Food < shift_Food) {
   				shift_spare += (shift_Food - carry_Food);
   				shift_Food = carry_Food;
   			}
   			if (carry_Wood < shift_Wood) {
   				shift_spare += (shift_Wood - carry_Wood);
   				shift_Wood = carry_Wood;	
   			}
   			if (carry_Stone < shift_Stone) {
   				shift_spare += (shift_Stone - carry_Stone);
   				shift_Stone = carry_Stone;
   			}
   			if (carry_Ore < shift_Ore) {
   				shift_spare += (shift_Ore - carry_Ore);
   				shift_Ore = carry_Ore;
   			}
               if (carry_Astone < shift_Astone) {
   				shift_spare += (shift_Astone - carry_Astone);
   				shift_Astone = carry_Astone;
   			}						
   			 
   		  while (shift_spare >1) {
   				 if (carry_Food < (shift_Food + shift_spare)){
   				    shift_spare = shift_spare - carry_Food;;
   				    shift_Food = carry_Food;
   				 }
   				 else{
   				  shift_Food = (shift_Food + shift_spare);
   				  shift_spare = shift_spare- shift_spare;
   				}
   				 if (carry_Wood < (shift_Wood + shift_spare)){
   				    shift_spare = shift_spare - carry_Wood;;
   				    shift_Wood = carry_Wood;
   				 }
   				 else{
   				  shift_Wood = shift_Wood + shift_spare;
   				  shift_spare = shift_spare- shift_spare;
   				}
           		if (carry_Stone < (shift_Stone + shift_spare)){
   				    shift_spare = shift_spare - carry_Stone;
   				    shift_Stone = carry_Stone;
   				 }
   				 else{
   				  shift_Stone = shift_Stone + shift_spare;
   				  shift_spare = shift_spare- shift_spare;
   				}
   				 if (carry_Ore < (shift_Ore + shift_spare)){
   				    shift_spare = shift_spare - carry_Ore;
   				    shift_Ore = carry_Ore;
   				 }
   				 else{
   				  shift_Ore = shift_Ore + shift_spare;
   				  shift_spare = shift_spare- shift_spare;
   				}
   				if (carry_Astone < (shift_Astone + shift_spare)){
   				    shift_spare = shift_spare - carry_Astone;
   				    shift_Astone = carry_Astone;
   				 }
   				 else{
   				  shift_Astone = shift_Astone + shift_spare;
   				  shift_spare = shift_spare- shift_spare;
   				}
   			 }
   
   		carry_Food = shift_Food;
   		carry_Wood = shift_Wood;
   		carry_Stone = shift_Stone;
   		carry_Ore = shift_Ore;
   		carry_Astone = shift_Astone;
   		}
   		
   		if (maxload > (carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone) && ship_Gold==true) {
   		    if ((maxload-(carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone)) > (citymax_Gold - target_Gold)){
   		    	  carry_Gold = (citymax_Gold - target_Gold);
   		    	  if (carry_Gold < 0 ) carry_Gold = 0;
   		   	}
   		    else carry_Gold = (maxload-(carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone));
   		    if (trade_Gold > 0 && (carry_Gold > trade_Gold)) carry_Gold = parseInt(trade_Gold);
   		}
   		
   		wagons_needed = ((carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone + carry_Gold) / maxloadperwagon);
   		wagons_needed = wagons_needed.toFixed(0);	
   		if (wagons_needed < ((carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone + carry_Gold) / maxloadperwagon)) wagons_needed++;	
   		if ( wagons_needed < Options.minwagons ) { return; }
           
   		params.cid= city;
   		params.type = "1";
   		params.xcoord = xcoord;
   		params.ycoord = ycoord;
   		params.r1 = carry_Food;
   		params.r2 = carry_Wood;
   		params.r3 = carry_Stone;
   		params.r4 = carry_Ore;
   		params.r5 = parseInt(carry_Astone/5);
   		params.gold = carry_Gold;
   		
   		switch (unit){
         case 'unt1': params.u1 = wagons_needed;break;
         case 'unt2': params.u2 = wagons_needed;break;
         case 'unt3': params.u3 = wagons_needed;break;
         case 'unt4': params.u4 = wagons_needed;break;
         case 'unt5': params.u5 = wagons_needed;break;
         case 'unt6': params.u6 = wagons_needed;break;
         case 'unt7': params.u7 = wagons_needed;break;
         case 'unt8': params.u8 = wagons_needed;break;
         case 'unt9': params.u9 = wagons_needed;break;
         case 'unt10': params.u10 = wagons_needed;break;
         case 'unt11': params.u11 = wagons_needed;break;
         case 'unt12': params.u12 = wagons_needed;break;
       }
      if ((carry_Food + carry_Wood + carry_Stone + carry_Ore + carry_Astone + carry_Gold) > 0) {
    
            new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
                     method: "post",
                     parameters: params,
                     loading: true,
                     onSuccess: function (transport) {
                     var rslt = eval("(" + transport.responseText + ")");
                     if (rslt.ok) {
                     var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
                     var ut = unsafeWindow.unixtime();
                     var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
                     for(i = 0; i <= unitsarr.length; i++){
                     	if(params["u"+i]){
                     	unitsarr[i] = params["u"+i];
                     	}
                     }
                     var resources=new Array();
                     resources[0] = params.gold;
                     for(i=1; i<=5; i++){
                     	resources[i] = params["r"+i];
                     }
                     var currentcityid = city;
                     unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
                     unsafeWindow.update_seed(rslt.updateSeed)
                     if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
                      actionLog("Transport",uW.g_js_strings.commonstr.transport+": " + cityname + " "+lang.TRANSP.Automatic.To+": " + xcoord + ',' + ycoord + "  -> "+ unsafeWindow.unitcost[unit][0] +": " + wagons_needed);
                     } else {
			          actionLog("Transport",uW.g_js_strings.commonstr.transport+": " + cityname + " "+lang.TRANSP.Automatic.To+": " + xcoord + ',' + ycoord + "<br><font color=red>" + transport.responseText + "</font>");
                     }
                     },
                     onFailure: function (transport) {
                     var rslt = eval("(" + transport.responseText + ")");
                     if (rslt.user_action) {
		     						actionLog("Transport","<b><font color=red>"+lang.General.DetectionCaptcha+"</font></b>");
		     						new CdialogCancelContinue('<SPAN class=boldRed>'+lang.General.Captcha+': TRANSPORTAUTO</span>', null, null, mainPop.getMainDiv);
		     }else{		
                      actionLog("Transport",uW.g_js_strings.commonstr.transport+": " + cityname + " "+lang.TRANSP.Automatic.To+": " + xcoord + ',' + ycoord + "<br><font color=red>" + transport.responseText + "</font>");
                     }
                     }
             });
           }
   	},
   	
   ManualTransport: function(){
       var t = Tabs.TranspAuto;
 
    if (document.getElementById ('ptcityX').value == "" || document.getElementById ('ptcityY').value == "") return;
    if ( t.TroopsNeeded > t.Troops) return;
       
      	var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
       var unitType = ById('TransportTroop').value;
      // var LoadUnit = (parseInt(Seed.tech.tch10) * ((parseInt(unsafeWindow.unitstats[unitType]['5'])/100)*10)) + parseInt(unsafeWindow.unitstats[unitType]['5']);
        	     var untid=ById('TransportTroop').value;
       	     var techLoadBoost=parseInt(Seed.tech.tch10)*0.1;
    var loadEffectBoost=0;
    if(Seed.playerEffects.loadExpire>uW.unixtime()){loadEffectBoost=0.25}
    var loadBoostBase=(EffetTronePrc(6).percent*0.01)+loadEffectBoost+techLoadBoost;
       	     var loadBoost=loadBoostBase;
       	      if(uW.cm.unitFrontendType[untid]=="horsed"){
       	       loadBoost+=(EffetTronePrc(48).percent*0.01)
       	      }
       	  var LoadUnit=parseInt(parseInt(uW.unitstats[untid][5])*(1+loadBoost));
       var MaxLoad =  parseInt(Seed.units['city' + t.tcp.city.id][unitType]) * LoadUnit;
       document.getElementById ('errorSpace').innerHTML = '';
         	
   	params.kid = 0;
        params.cid=  t.tcp.city.id;
   	params.type = "1";
   	params.xcoord = parseInt(document.getElementById ('ptcityX').value);
   	params.ycoord = parseInt(document.getElementById ('ptcityY').value);
   	params.r1 = parseInt(document.getElementById ('pbtradeamountFood').value);
   	params.r2 = parseInt(document.getElementById ('pbtradeamountWood').value);
   	params.r3 = parseInt(document.getElementById ('pbtradeamountStone').value);
   	params.r4 = parseInt(document.getElementById ('pbtradeamountOre').value);
   	params.r5 = parseInt(document.getElementById ('pbtradeamountAstone').value);
   	params.gold = parseInt(document.getElementById ('pbtradeamountGold').value);
   		
       switch (unitType){
         case 'unt1': params.u1 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt2': params.u2 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt3': params.u3 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt4': params.u4 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt5': params.u5 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt6': params.u6 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt7': params.u7 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt8': params.u8 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt9': params.u9 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt10': params.u10 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt11': params.u11 = parseInt(document.getElementById ('TroopsToSend').value);break;
         case 'unt12': params.u12 = parseInt(document.getElementById ('TroopsToSend').value);break;
       }
   
       if ((params.r1 + params.r2 + params.r3 + params.r4 + params.r5 + params.gold) > 0) {   
            new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
                     method: "post",
                     parameters: params,
                     loading: true,
                     onSuccess: function (transport) {
                     var rslt = eval("(" + transport.responseText + ")");
                     if (rslt.ok) {                  
   		                  var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
   		                  var ut = unixTime();
   		                  var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
   		                  for(i = 0; i <= unitsarr.length; i++){
   		                  	if(params["u"+i]){
   		                  	unitsarr[i] = params["u"+i];
   		                  	}
   		                  }
   		                  var resources=new Array();
   		                  resources[0] = params.gold;
   		                  for(i=1; i<=5; i++){
   		                  	resources[i] = params["r"+i];
   		                  }
   		                  var currentcityid = t.tcp.city.id;
   		                  unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
   		                  if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
   		                  document.getElementById ('errorSpace').innerHTML = 'Envoy&eacute;: ' + addCommas(params.r1+params.r2+params.r3+params.r4+params.r5+params.gold) + ' Ressources avec ' + addCommas(parseInt(document.getElementById ('TroopsToSend').value)) + ' ' + unsafeWindow.unitcost[unitType][0];
   		                  document.getElementById ('pbtradeamountFood').value = 0;
   		                  document.getElementById ('pbtradeamountWood').value = 0;
   		                  document.getElementById ('pbtradeamountStone').value = 0;
   		                  document.getElementById ('pbtradeamountOre').value = 0;
   						  document.getElementById ('pbtradeamountAstone').value = 0;
   		                  document.getElementById ('pbtradeamountGold').value = 0;
   		                  document.getElementById ('TroopsToSend').value = 0;
                     } else {
   		                  var errorcode =  'err_' + rslt.error_code;
   		                  if (rlst.msg == undefined)document.getElementById ('errorSpace').innerHTML = '<HR><FONT COLOR=red>Error: ' + unsafeWindow.g_js_strings.errorcode[errorcode] +'</font>';
   		                  else document.getElementById ('errorSpace').innerHTML = '<HR><FONT COLOR=red>Error : ' + rslt.msg +'</font>'; 
                     }
                     },
                     onFailure: function () {}
             });
           }
   	},
	
  onUnload: function(){
     var t = Tabs.TranspAuto;
     if (!ResetAll) t.saveTradeRoutes();
     if (!ResetAll) t.saveTraderState();
     if (!ResetAll) t.saveReapproState();
  },
  showManuel : function() {
   var t = Tabs.TranspAuto
   var rownum = 0;

   var ModelCity = {};
   
   function _row (name, row, noTotal){
      if (rownum++ % 2)
        style = '';
      else
        style = ' style = "background: #e8e8e8"';
      var tot = 0;
      var m = [];
      m.push ('<TR style="background: #fff" align=right');
      m.push (style);
      m.push ('><TD');
      m.push (style);
      m.push ('><B>');
      m.push (name);
      m.push ('</td>');
      if (noTotal){
        m.push ('<TD');
        m.push (style);
        m.push ('>&nbsp;</td>');
      } else {
        for (i=0; i<row.length; i++)
          tot += row[i];
        m.push ('<TD style="background: #ffc">');
        m.push (addCommas(tot));
        m.push ('</td>');
      }
      for (i=0; i<row.length; i++){
        m.push ('<TD');
        m.push (style);
        m.push ('>');
        m.push (addCommas(row[i]));
        m.push ('</td>');
      }
      m.push ('</tr>');
      return m.join('');
    }
    dt = new Date ();
    dt.setTime (Seed.player.datejoinUnixTime * 1000);
    if (t.state == null) {  
      m = "<DIV class=boStat>"+lang.TRANSP.Manual.Title+"</div>";
      m +="<div id='statpourTr'></div>";
      m += "<TABLE width=100% class=ptTab border=0>\
       <tr align=center><td colspan=2><HR></td></tr>\
       <tr align=center valign=top><td colspan=1 width=50%><b><u>"+lang.TRANSP.Manual.From+"</b></u><br><span id=srcptspeedcity></span></td>\
       <td colspan=1 width=50%  rowspan=2><b><u>"+lang.TRANSP.Manual.To+"</b></u><br><span id=desptspeedcity></span><br>\
       <a id=boclickmap href='javascript:void(0);'>"+lang.General.or+" "+uW.g_js_strings.commonstr.coordinates+"</a><br>X: <input type=text size=4 id=typetrpx value=0>&nbsp;Y: <input type=text size=4 id=typetrpy value=0><br><a href='javascript:void(0);' id='chargelistelieux'>"+uW.g_js_strings.commonstr.members+"</a> : <select id='BOlisteFavori'></select><br><br><INPUT id='ptttButTransport' type=submit value='"+uW.g_js_strings.commonstr.transport+"' style='font-weight:bold'>\
       </td></tr>\
       <tr align=center><td colspan=1>"+uW.g_js_strings.commonstr.troops+": <select id=typetrp><option selected value='1'>"+uW.unitcost["unt1"][0]+"</option><option selected value='9'>"+uW.unitcost["unt9"][0]+"</option><option value='7'>"+uW.unitcost["unt7"][0]+"</option><option value='8'>"+uW.unitcost["unt8"][0]+"</option></select>\
       <br>"+lang.TRANSP.Manual.Amount+": <input type=text size=6 value='1000' id='Choixnbwagon'><input type=button id='trswagmax' value='Max'\><br><i>("+lang.TRANSP.Manual.ResTroops+")</i>\
       <br><b>"+uW.g_js_strings.commonstr.resources+":</b><input type=radio id='ChoixRess0' name='ChoixRess' value='gold' style='visibility:hidden'><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png onclick=document.getElementById('ChoixRess0').checked=true;BOestimeres(); height=20>\
       <input type=radio id='ChoixRess1' name='ChoixRess' value='rec1' style='visibility:hidden'><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png onclick=document.getElementById('ChoixRess1').checked=true;BOestimeres(); height=20>\
       <input type=radio id='ChoixRess2' name='ChoixRess' value='rec2' style='visibility:hidden'><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png onclick=document.getElementById('ChoixRess2').checked=true;BOestimeres(); height=20>\
       <input type=radio id='ChoixRess3' name='ChoixRess' value='rec3' style='visibility:hidden'><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png onclick=document.getElementById('ChoixRess3').checked=true;BOestimeres(); height=20>\
       <input type=radio id='ChoixRess4' name='ChoixRess' value='rec4' style='visibility:hidden'><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png onclick=document.getElementById('ChoixRess4').checked=true;BOestimeres(); height=20>\
       <input type=radio id='ChoixRess5' name='ChoixRess' value='rec5' style='visibility:hidden'><img src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png onclick=document.getElementById('ChoixRess5').checked=true;BOestimeres(); height=20>\
       </td></tr>\
       <tr><td colspan=2>"+lang.TRANSP.Manual.AmountRes+": <span id=BOEstimationR></td></tr>\
       </table>\
       <TABLE align=center width=100% class=ptTab><TR><TD><div id=ptTranportStatus style='text-align:center;overflow-y:auto; max-height:78px; height: 78px;'></div></td></tr></table>";
    t.TransportDiv.innerHTML = m; 
    t.destinationCityx = document.getElementById ('typetrpx');
    t.destinationCityy = document.getElementById ('typetrpy');
    
    t.destinationCityx.addEventListener ('change', t.estimerRes, false);
    t.destinationCityy.addEventListener ('change', t.estimerRes, false);
    document.getElementById ('ChoixRess0').addEventListener ('click', t.estimerRes, false);
    document.getElementById ('ChoixRess1').addEventListener ('click', t.estimerRes, false);
    document.getElementById ('ChoixRess2').addEventListener ('click', t.estimerRes, false);
    document.getElementById ('ChoixRess3').addEventListener ('click', t.estimerRes, false);
    document.getElementById ('ChoixRess4').addEventListener ('click', t.estimerRes, false);
    document.getElementById ('ChoixRess5').addEventListener ('click', t.estimerRes, false);     
    t.listeFavoris = document.getElementById ('BOlisteFavori');
    t.estimationRes = document.getElementById ('BOEstimationR');
    t.chargelistelieux = document.getElementById ('chargelistelieux');
    t.chargelistelieux.addEventListener ('click', t.chercherFavoris, false);
    t.listeFavoris.addEventListener ('change', t.SelectFavoris, false);   
    var dcp1 = new CdispCityPicker ('ptspeed1', ById('desptspeedcity'), false, t.clickCityDestinationSelect, 1);
    t.TTbutTransport = document.getElementById ('ptttButTransport');
    t.TTbutTransport.addEventListener ('click', t.clickTransportDo, false);
    t.divTranportStatus = document.getElementById ('ptTranportStatus');
    t.statpourTr = document.getElementById ('statpourTr');
    t.typetrp = document.getElementById ('typetrp');
    t.typetrp.addEventListener ('click', t.estimerRes, false); 
    t.trswagmax = document.getElementById ('trswagmax');
    t.trswagmax.addEventListener ('click', t.clickUniteMax, false);
    t.Choixnbwagon  = document.getElementById ('Choixnbwagon');
    t.Choixnbwagon.addEventListener ('keyup', t.verifierWagons, false);
    ById("boclickmap").addEventListener ('click',t.clickmap, false);
    var dcp0 = new CdispCityPicker ('ptspeed0', ById('srcptspeedcity'), false, t.clickCitySourceSelect, Cities.byID[unsafeWindow.currentcityid].idx);
    t.state = 1;
   }
   if (t.state == 1) {
    if (document.getElementById ('maparea_map').style.display!="none") {
       t.destinationCityx.value = document.getElementById ('mapXCoor').value;
       t.destinationCityy.value = document.getElementById ('mapYCoor').value;
       t.destinationCityx.style.backgroundColor="#FF9999";
       t.destinationCityy.style.backgroundColor="#FF9999";
       setTimeout(function() {
             t.destinationCityx.style.backgroundColor="#fff";
       t.destinationCityy.style.backgroundColor="#fff";
       }, 3000);
                    
    }
    t.state = 2;
   }
   rows=[];
   rows[0]=[];
   m = "<TABLE class=ptTabLined cellspacing=0><TR valign=top align=right><TD width=65></td><TD width=88 style='background: #ffc'><B>"+lang.General.tot.toUpperCase()+"</b></td>";
      for(i=0; i<Cities.numCities; i++)
         m += '<TD width=81><B>'+ Cities.cities[i].name.substring(0,20) +'</b></td>';
      for(i=0; i<Cities.numCities; i++) {
        cityID = 'city'+ Cities.cities[i].id;
        rows[0][i] = parseInt(Seed.citystats[cityID].gold[0]);
      }
      for (r=1; r<6; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
           if (r==5)
	    rows[r][i] = parseInt(Seed.resources[cityID]['rec'+r][0]);
	            else
           rows[r][i] = parseInt(Seed.resources[cityID]['rec'+r][0] / 3600);
        }
      }
      m += _row ('<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/gold_30.png>', rows[0]);
      m += _row ('<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/food_30.png>', rows[1]);
      m += _row ('<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/wood_30.png>', rows[2]);
      m += _row ('<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/stone_30.png>', rows[3]);
      m += _row ('<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/iron_30.png>', rows[4]);
      m += _row ('<img height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/aetherstone_30.png>', rows[5]);
      m += '<TR><TD><font size=1><BR></td></tr>';
      row = [];
      var totalbouffe = 0;
      for(i=0; i<Cities.numCities; i++) {
	var rp = getResourceProduction (Cities.cities[i].id);
	//var usage = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][3]);
	row[i] = rp[1];
      }
      m += _row ('Prod', row, false,  0);
      for(i=0; i<Cities.numCities; i++) {
                    if (row[i] >= 0)
                      row[i] = '----';
                    else {
                      var timeLeft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0]) / 3600 / (0-row[i]) * 3600;
                      if (timeLeft > 86313600)
                        row[i] = '----';
                      else {
                        if (Options.enableFoodWarn && timeLeft<(Options.foodWarnHours*3600))
                          row[i] = '<SPAN class=whiteOnRed>'+ timestrShort(timeLeft) +'</span>';
                        else
                          row[i] = timestrShort(timeLeft);
                      }
                    }
      }    
      m += _row ('Aut.', row, true, 0);
      m += '<TR><TD><font size=1><BR></td></tr>';
      for (r=1; r<13; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
          rows[r][i] = parseInt(Seed.units[cityID]['unt'+r]);
        }
      }
      m += _row ('<img height=20 title="'+unsafeWindow.unitcost['unt1'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_1_30_s34.jpg>', rows[1]);
      m += _row ('<img height=20 title="'+unsafeWindow.unitcost['unt7'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_7_30_s34.jpg>', rows[7]);
      m += _row ('<img height=20 title="'+unsafeWindow.unitcost['unt8'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_8_30_s34.jpg>', rows[8]);
      m += _row ('<img height=20 title="'+unsafeWindow.unitcost['unt9'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_9_30_s34.jpg>', rows[9]);
          row = [];
    for(i=0; i<Cities.numCities; i++) {
    	        var cityId = 'city'+ Cities.cities[i].id;
    	        var slots = 0;
    	        for (var k in Seed.queue_atkp[cityId]){   
    	         march = Seed.queue_atkp[cityId][k];
    	         if (typeof (march) == 'object'){
    	           slots++;
    	         }
    	        }
	var niveauPointRall=parseInt(getCityBuilding (Cities.cities[i].id, 12).maxLevel);
	if (niveauPointRall==12) niveauPointRall=11;
    	row[i] = '<SPAN><B>'+ slots +'/'+ niveauPointRall +'</b></span>';
     }
    m += _row ('PR', row, true, 0);   m += "</table>";
     t.statpourTr.innerHTML = m;
     clearTimeout (t.displayTimer);
     t.displayTimer = setTimeout (t.showManuel, 4000);
  },
  
  SelectFavoris:function() {
   var t = Tabs.TranspAuto;
   if (t.listeFavoris.value!='') {
    var valeur=t.listeFavoris.value;
    var x=valeur.substr(0, valeur.lastIndexOf(','));
    var y=valeur.substr(valeur.lastIndexOf(',')+1, valeur.length);
    t.destinationCityx.value = x;
    t.destinationCityy.value = y;
   }
   t.estimerRes();
  },
  
  chercherFavoris: function() {
   var t = Tabs.TranspAuto;
   var myA = getMyAlliance ();
   if (myA[0]!=0) {
      var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
      params.perPage = 100;
      params.allianceId = myA[0];
          new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
	        method: "post",
	        parameters: params,
	        onSuccess: function (rslt) {
	          if (rslt.ok){
	           var z=0;
	           var m="";
	           for (var i=0; i<rslt.results.length; i++){
     		      p = rslt.results[i];
		      if (p.userId != 0){
		       for (var c=0; c<p.cities.length; c++){
		         if (Seed.player.name!=p.displayName) {
		          m += "<option value='" + p.cities[c].xCoord + ","+ p.cities[c].yCoord+"'>" + p.displayName + " - "+unsafeWindow.g_js_strings.commonstr.city+" " + (c+1) + " - " + p.cities[c].xCoord + "," + p.cities[c].yCoord+"</option>";
		         }
		       }  	       
		      } 
      	            } 
      	            t.listeFavoris.innerHTML="<option value=''>"+lang.General.Select+"...</option>"+m;
	          }
	        },
	        onFailure: function (rslt) {
	          t.listeFavoris.innerHTML="<option>Error</option>";
	        },
    	});
   } else {
     t.listeFavoris.innerHTML="<option>No alliance!</option>";
   }   
  },
  verifierWagons: function() {
   var t = Tabs.TranspAuto;
   var maxw=parseInt(rows[t.typetrp.value][t.sourceCity.idx]);
   var saisw=parseInt(t.Choixnbwagon.value);
   if (saisw > maxw) {
      t.Choixnbwagon.value=maxw;
      t.divTranportStatus.innerHTML = '<FONT COLOR=#550000>'+lang.TRANSP.Manual.Exceed+' '+maxw+' !</font>';
   }
   t.estimerRes();
  },
  estimerRes: function() {
   var t = Tabs.TranspAuto;
   var cityID = 'city'+ t.sourceCity.id,ic=0,resact=0,ic_ty="gold",ic_text=" "+uW.g_js_strings.commonstr.gold;
   if (ById("ChoixRess1").checked) { ic_ty="rec1";ic=1;ic_text=" "+unsafeWindow.g_js_strings.commonstr.food; }
   if (ById("ChoixRess2").checked) { ic_ty="rec2";ic=2;ic_text=" "+uW.g_js_strings.commonstr.wood; }
   if (ById("ChoixRess3").checked) { ic_ty="rec3";ic=3;ic_text=" "+uW.g_js_strings.commonstr.stone; }
   if (ById("ChoixRess4").checked) { ic_ty="rec4";ic=4;ic_text=" "+uW.g_js_strings.commonstr.ore; }
   if (ById("ChoixRess5").checked) { ic_ty="rec5";ic=5;ic_text=" "+uW.g_js_strings.commonstr.aetherstone; }
   if (ById("ChoixRess0").checked) { ic_ty="gold";ic=0;ic_text=" "+uW.g_js_strings.commonstr.gold; } 
   var esti = 0;
   
   var total_units=t.Choixnbwagon.value;
   var untid=t.typetrp.value;
   var techLoadBoost=parseInt(Seed.tech.tch10)*0.1;
   var loadEffectBoost=0;
   if(Seed.playerEffects.loadExpire>uW.unixtime()){loadEffectBoost=0.25}
   var loadBoostBase=(EffetTronePrc(6).percent*0.01)+loadEffectBoost+techLoadBoost;
   var loadBoost=loadBoostBase;
   if(uW.cm.unitFrontendType[untid]=="horsed"){
     loadBoost+=(EffetTronePrc(48).percent*0.01)
   }
   esti=parseInt(total_units*parseInt(uW.unitstats["unt"+untid][5])*(1+loadBoost));

   if (ic==5) {
    esti = parseInt(esti / 5);
   }
   var x1 = parseInt(t.sourceCity.x);
   var x2 = parseInt(t.destinationCityx.value);
   var y1 = parseInt(t.sourceCity.y);
   var y2 = parseInt(t.destinationCityy.value);
   var dist = distance (x1, y1, x2, y2);
   var m = estETA(dist,ById('typetrp').value,t.sourceCity.id,1);
   var a="";
   switch(ic){
    case 0:a=unsafeWindow.g_js_strings.commonstr.gold;break;
    case 1:a=unsafeWindow.g_js_strings.commonstr.food;break;
    case 2:a=unsafeWindow.g_js_strings.commonstr.wood;break;
    case 3:a=unsafeWindow.g_js_strings.commonstr.stone;break;
    case 4:a=unsafeWindow.g_js_strings.commonstr.ore;break;
    case 5:a=unsafeWindow.g_js_strings.commonstr.aetherstone;break;
   }
   t.estimationRes.innerHTML = "<b>" + addCommas(esti) + " "+a+"</b>";
   t.estimationRes.innerHTML += "<br>"+uW.g_js_strings.commonstr.estimatedtime+": <b>" + m.friendEtaStr + "</b>" ; 
   
     if (ic==5)
      resact = parseIntNan(Seed.resources[cityID][ic_ty][0]);
     else {
      if (ic==0)
       resact = parseIntNan(Seed.citystats[cityID].gold[0]);
      else
       resact = parseIntNan(Seed.resources[cityID][ic_ty][0] / 3600);
     } 
    if (resact < esti) {
     var untid=t.typetrp.value;
     		     var techLoadBoost=parseInt(Seed.tech.tch10)*0.1;
     var loadEffectBoost=0;
     if(Seed.playerEffects.loadExpire>uW.unixtime()){loadEffectBoost=0.25}
     		     var loadBoostBase=(EffetTronePrc(6).percent*0.01)+loadEffectBoost+techLoadBoost;
     		     var loadBoost=loadBoostBase;
     		      if(uW.cm.unitFrontendType[untid]=="horsed"){
     		       loadBoost+=(EffetTronePrc(48).percent*0.01)
     		      }
    var nbparunit=parseInt(uW.unitstats["unt"+untid][5])*(1+loadBoost);
    if (ic==5) nbparunit=nbparunit/5;
    var uniteness = Math.floor(resact / nbparunit);
    if (uniteness<1) uniteness=0;
    t.Choixnbwagon.value = uniteness;
    t.TTbutTransport.disabled = false;  
    t.estimerRes();
   }
  }, 
  clickUniteMax: function() {
    var t = Tabs.TranspAuto;
    var maxw=parseInt(rows[t.typetrp.value][t.sourceCity.idx]);
    var niveauPointRall=parseInt(getCityBuilding (t.sourceCity.id, 12).maxLevel); 
        var e=1;
      var f=unsafeWindow.unixtime();
      if(Seed.playerEffects.aurasExpire){
      if(Seed.playerEffects.aurasExpire>f){e=1.15}}
      if(Seed.playerEffects.auras2Expire){if(Seed.playerEffects.auras2Expire>f){e=1.3}}  
    var maxtroupe=parseInt(niveauPointRall*10000*e);
    if (niveauPointRall==11) maxtroupe=parseInt(150000*e);
    if (niveauPointRall==12) maxtroupe=parseInt(200000*e);
    var q=EffetTronePrc(66).percent;
    maxtroupe=Math.floor(maxtroupe*(1+q/100));
    
    if (maxw>maxtroupe) maxw=maxtroupe;
    t.Choixnbwagon.value=maxw;
    t.estimerRes();
  },
  clickTransportDo: function() { 
   var t = Tabs.TranspAuto;
   var SourceId = t.sourceCity.id;
   var DestinationId = t.destinationCity.id;
   if (!ById("ChoixRess0").checked && !ById("ChoixRess1").checked && !ById("ChoixRess2").checked && !ById("ChoixRess3").checked && !ById("ChoixRess4").checked && !ById("ChoixRess5").checked) {
       t.divTranportStatus.innerHTML = '<FONT COLOR=#550000>'+lang.TRANSP.Manual.ChoseRes+'!</font>';
      return;
   }
   if (t.sourceCity.x==t.destinationCityx.value && t.sourceCity.y==t.destinationCityy.value) {
      t.divTranportStatus.innerHTML = '<FONT COLOR=#550000>'+lang.TRANSP.Manual.SameCity+'!</font>';
     return;
   }
   if (parseInt(t.Choixnbwagon.value)=="0") {
   t.divTranportStatus.innerHTML = '<FONT COLOR=#550000>'+lang.TRANSP.Manual.ErrorTroops+'... pfff !</font>';
     return;
   }
   var x=t.destinationCityx.value;
   var y=t.destinationCityy.value;
   if (x == 0 && y == 0) {
      t.divTranportStatus.innerHTML = '<FONT COLOR=#550000>'+lang.TRANSP.Manual.ErrorDest+'!</font>';
     return;
   }
   t.TTbutTransport.disabled=true; 
   var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
   params.kid = 0;
   params.cid= t.sourceCity.id;
   params.type = "1";
   params.xcoord = x;
   params.ycoord = y;
   params.r1 = 0;
   params.r2 = 0; 
   params.r3 = 0; 
   params.r4 = 0; 
   params.r5 = 0; 
   params.gold = 0; 
   params.u9 = 0;
   var untid=t.typetrp.value
   var techLoadBoost=parseInt(Seed.tech.tch10)*0.1;
   var loadEffectBoost=0;
   if(Seed.playerEffects.loadExpire>uW.unixtime()){loadEffectBoost=0.25}
   var loadBoostBase=(EffetTronePrc(6).percent*0.01)+loadEffectBoost+techLoadBoost;
   var loadBoost=loadBoostBase;
   if(uW.cm.unitFrontendType[untid]=="horsed"){
   		       loadBoost+=(EffetTronePrc(48).percent*0.01)
   }
   var esti=parseInt(t.Choixnbwagon.value * parseInt(uW.unitstats["unt"+untid][5])*(1+loadBoost));
   if (ById("ChoixRess5").checked) { 
    esti = parseInt(esti / 5);
   }
   if (ById("ChoixRess0").checked) { params.gold = esti; }
   if (ById("ChoixRess1").checked) { params.r1 = esti; }
   if (ById("ChoixRess2").checked) { params.r2 = esti; }
   if (ById("ChoixRess3").checked) { params.r3 = esti; }
   if (ById("ChoixRess4").checked) { params.r4 = esti; }
   if (ById("ChoixRess5").checked) { params.r5 = esti; }	
   if (t.typetrp.value==1)  params.u1 = t.Choixnbwagon.value;
   if (t.typetrp.value==9)  params.u9 = t.Choixnbwagon.value;
   if (t.typetrp.value==7)  params.u7 = t.Choixnbwagon.value;
   if (t.typetrp.value==8)  params.u8 = t.Choixnbwagon.value;

  t.divTranportStatus.innerHTML = "<i><b>"+uW.g_js_strings.commonstr.loadingddd+"....</b></i>";
   new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
              method: "post",
              parameters: params,
              loading: true,
              onSuccess: function (transport) {
                  var t = Tabs.TranspAuto;  
                  var rslt = transport;
                  if (rslt.ok) {
		   var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
                   var ut = unsafeWindow.unixtime();
                   var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
                   for(i = 0; i <= unitsarr.length; i++){
                   	if(params["u"+i]){
                  	unitsarr[i] = params["u"+i];
                  	}
                   }
                   var resources=new Array();
                   resources[0] = params.gold;
                   for(i=1; i<=4; i++){
                  	resources[i] = params["r"+i];
                   }
                   var currentcityid =  t.sourceCity.id;
                   unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
                   //unsafeWindow.update_seed(rslt.updateSeed)
                   if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
                   t.divTranportStatus.innerHTML = "<font size='3px'><b>"+lang.TRANSP.Manual.TranspDone+".</b>";
                   t.TTbutTransport.disabled=false;
                  } else {
		    t.divTranportStatus.innerHTML ="<font color=red size='3px'><b>"+lang.TRANSP.Manual.ErrorTrasp+"!<b></font>";
		     if (rslt.msg) {
		       t.divTranportStatus.innerHTML +="<br><font color=black size='2px'>" + rslt.msg +"</font>";
		       t.TTbutTransport.disabled=false;
         	     } else {
         	      t.divTranportStatus.innerHTML +="<br>"+lang.TRANSP.Manual.Tentative2+"!</font>";
         	      setTimeout(function() { t.clickTransportDo(); }, 2000);
         	     }
                  }
                  },
                  onFailure: function (rslt) {
                   var t = Tabs.TranspAuto;
                   if (rslt.user_action) {
                    t.divTranportStatus.innerHTML ="<font color=red size='3px'><b>"+lang.General.DetectionCaptcha+"<b></font>";
                   } else {
                    
                    t.divTranportStatus.innerHTML ="<font color=red size='3px'><b>"+lang.TRANSP.Manual.ErrorTrasp+"!<b></font>";
                   }
                    t.TTbutTransport.disabled=false;
                  }
          });
  },
  clickCitySourceSelect : function (city){
    var t = Tabs.TranspAuto;
    t.sourceCity = city;
    t.TTbutTransport.disabled=false;
    var maxw=parseInt(rows[t.typetrp.value][t.sourceCity.idx]);
    var saisw=parseInt(t.Choixnbwagon.value);
    if (saisw > maxw)  t.Choixnbwagon.value=maxw;
    t.estimerRes();
   },
   clickCityDestinationSelect : function (city){
    var t = Tabs.TranspAuto;
    t.destinationCity = city;
    t.destinationCityx.value=t.destinationCity.x;
    t.destinationCityy.value=t.destinationCity.y;
    t.TTbutTransport.disabled=false;
    t.estimerRes();
   }, 
 
}

/*************** REASSIGNER **********/
var troops = {1:'SupplyTroops',
			  2:'Militiaman',
			  3:'Scout',
			  4:'Pikeman',
			  5:'Swordsman',
			  6:'Archer',
			  7:'Cavalry',
			  8:'HeavyCavalry',
			  9:'SupplyWagon',
			  10:'Ballista',
			  11:'BatteringRam',
			  12:'Catapult'}; 
Tabs.Reassign = {
  tabOrder: 7,
  tabLabel: uW.g_js_strings.commonstr.reassign,
 cont : null,
 displayTimer : null,
 state : null,
 curTabBut : null,
 curTabName : null,
 sourceCity : {},
 destinationCity : {},
 rows : [],
  timer: null,
  reassignState: [],
  lRE: [],
  reassignRoutes: [],
  rallypointlevel:null,
  count:0,
  check:false,
 show : function (){
 },
 hide : function (){
    var t = Tabs.Reassign;
    t.state = null;
    clearTimeout (t.displayTimer);
    clearTimeout (t.timer);
  },
  init : function (div){  
   var t = Tabs.Reassign;
   t.cont = div;
 
   t.reassignState = {                running: false,    };
   t.readReassignState();
   t.readReassignRoutes();
   t.e_reassignRoutes();
    		
   AddSubTabLink('Reassign', t.toggleReassignState, 'pbsigntab');
  if (t.reassignState.running == false) {
       	       updatebotbutton(uW.g_js_strings.commonstr.reassign+' - OFF', 'pbsigntab');
             } else {
       	      updatebotbutton(uW.g_js_strings.commonstr.reassign+' - ON', 'pbsigntab');
        }
  window.addEventListener('unload', t.onUnload, false);
  t.cont = div;
  t.cont.innerHTML = '<TABLE class=ptTab align=center><TR><TD><INPUT class=bopbSubtab ID=BoReeSubM type=submit value="'+lang.REASSIGN.Manu+'"></td>\
             <TD><INPUT class=bopbSubtab ID=BoReeSubA type=submit  value="'+lang.REASSIGN.Auto+'"></td></tr></table>\
         <DIV id="BoReeOutput" style="margin-top:5px; background-color:white; height:'+(Options.HauteurBoite-65)+'px;max-height:'+(Options.HauteurBoite-65)+'px;overflow-y:auto"></div>';
  t.ReassignDiv = ById('BoReeOutput'); 
  ById('BoReeSubA').addEventListener('click', e_butSubtab, false);
  ById('BoReeSubM').addEventListener('click', e_butSubtab, false);
  changeSubtab (ById('BoReeSubM'));  
  function e_butSubtab (evt){
          changeSubtab (evt.target);   
      }
  function changeSubtab (but){
          if (but == t.curTabBut)
            return;
          if (t.curTabBut){
            t.curTabBut.className='bopbSubtab'; 
            t.curTabBut.disabled=false;
          }
          t.curTabBut = but;
          but.className='bopbSubtab bopbSubtabSel'; 
          but.disabled=true;
          t.curTabName = but.id.substr(8);
          t.show2();
      }  
    
  },
   show2 : function (){
    var t = Tabs.Reassign ;
        t.state = null;
     clearTimeout (t.displayTimer);
     if (t.curTabName == 'M')
       t.showManuel();
     else
          t.showAuto();
     },
     
  showAuto: function() {   
      var t = Tabs.Reassign ; 
       clearTimeout (t.timer);
    if (t.state == null) {
  
      t.state = 1;  
      
           var m = '<DIV id=pbReMainDivF class=boStat>'+lang.REASSIGN.Automatic.title+'</div><TABLE id=pbtraderfunctions width=100% height=0% class=pbTab><TR align="center">';
      if (t.reassignState.running == false) {
          m += '<TD><INPUT id=pbReassignState type=submit value="'+uW.g_js_strings.commonstr.reassign+'  = OFF"></td>';
	       updatebotbutton(uW.g_js_strings.commonstr.reassign+' - OFF', 'pbsigntab');
      } else {
          m += '<TD><INPUT id=pbReassignState type=submit value="'+uW.g_js_strings.commonstr.reassign+' = ON"></td>';
	      updatebotbutton(uW.g_js_strings.commonstr.reassign+' - ON', 'pbsigntab');
      }
      m += '<TD><INPUT id=pbReassShowRoutes type=submit value="'+lang.REASSIGN.Automatic.Route+'"></td>';
      m += '</tr></table></div>';
      m += '<DIV id=pbReassignDivD class=boStat>'+lang.REASSIGN.Automatic.AddRoute.toUpperCase()+'</div>';

      m += '<TABLE id=pbaddreasignroute width=95% height=0% class=pbTab><TR align="left">';
      m += '<TD width=20px>'+lang.REASSIGN.Automatic.From+' '+uW.g_js_strings.commonstr.city+':</td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=ptassigncity></span></div></td></tr>';

      m += '<TR align="left">';
      m += '<TD width=20px>'+lang.REASSIGN.Automatic.To+' '+uW.g_js_strings.commonstr.city+':</td> <TD width=310px><DIV style="margin-bottom:10px;"><span id=ptassigncityTo></span></div></td>';
	  
	    m += '<TR align="left">';
	    m += '<TD colspan=4>'+lang.REASSIGN.Automatic.Delay+': <INPUT id=pbreassigninterval type=text size=2 value="'+Options.reassigninterval+'"\> '+lang.General.mins+'</td></tr>';
	    m += '<TR><TD colspan=4><INPUT id=autofilloff type=checkbox unchecked=true\> '+lang.REASSIGN.Automatic.Block+'</TR></TD></table>';
      m += '';
      m += '<TABLE id=pbaddreasignroute width=100% height=0% class=pbTab><TR align="center">';
      
      m += '<TR><TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_1_50.jpg?6545"></td>';
      m += '<TD>'+unsafeWindow.unitcost['unt1'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_2_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt2'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_3_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt3'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_4_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt4'][0]+'</td></tr>'
      m += '<TR><TD><INPUT id=pbSupplyTroops type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetSupplyTroops disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbMilitiaman type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetMilitiaman disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbScout type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetScout disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbPikeman type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetPikeman disabled=true type=text size=10 maxlength=10 value="0"\></td></tr>';
      
      m += '<TR><TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_5_50.jpg?6545"></td>';
      m += '<TD>'+unsafeWindow.unitcost['unt5'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_6_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt6'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_7_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt7'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_8_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt8'][0]+'</td></tr>'
      m += '<TR><TD><INPUT id=pbSwordsman type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetSwordsman disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbArcher type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetArcher disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbCavalry type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetCavalry disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbHeavyCavalry type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetHeavyCavalry disabled=true type=text size=10 maxlength=10 value="0"\></td></tr>';
      
      m += '<TR><TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_9_50.jpg?6545"></td>';
      m += '<TD>'+unsafeWindow.unitcost['unt9'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://0cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_10_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt10'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_11_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt11'][0]+'</td>'
      m += '<TD rowspan="2"><img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_12_50.jpg?6545"></td>'
      m += '<TD>'+unsafeWindow.unitcost['unt12'][0]+'</td></tr>'
      m += '<TR><TD><INPUT id=pbSupplyWagon type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetSupplyWagon disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbBallista type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetBallista disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbBatteringRam type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetBatteringRam disabled=true type=text size=10 maxlength=10 value="0"\></td>';
      m += '<TD><INPUT id=pbCatapult type=checkbox unchecked=true\>';
      m += '<INPUT id=pbtargetCatapult disabled=true type=text size=10 maxlength=10 value="0"\></td></tr></table>';
      
      m += '<DIV style="text-align:center; margin-top:15px"><INPUT id=pbSaveRouteReassign type=submit value="'+lang.REASSIGN.Automatic.AddRoute+'"></div>';
      
      t.ReassignDiv.innerHTML = m;
      
      t.tcp = new CdispCityPicker ('ptreassign', ById('ptassigncity'), true, null, 0);
	  t.tcpto = new CdispCityPicker ('ptreassignTo', ById('ptassigncityTo'), true);
	  for(var k in troops){
      ById('pbtarget'+troops[k]).value = parseInt(Seed.units['city' + t.tcp.city.id]['unt'+k]);
	  }

      ById('ptassigncity').addEventListener('click', function(){
		  if(ById('autofilloff').checked == false)
	    for(var k in troops)
        ById('pbtarget'+troops[k]).value = parseInt(Seed.units['city' + t.tcp.city.id]['unt'+k]);
      }, false);
      
      ById('pbReassignState').addEventListener('click', function(){
      	t.toggleReassignState(this);
      }, false);
      ById('pbSaveRouteReassign').addEventListener('click', function(){
      t.addReassignRoute();
      }, false);
      ById('pbReassShowRoutes').addEventListener('click', function(){
      t.showReassignRoutes();
      }, false);
      
      ById('pbreassigninterval').addEventListener('change', function(){
      	if (isNaN(ById('pbreassigninterval').value)<10){ ById('pbreassigninterval').value=10 ;}
		Options.reassigninterval = ById('pbreassigninterval').value;
		saveOptions();
      }, false);
      
      ById('pbtargetSupplyTroops').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetSupplyTroops').value)) ById('pbtargetSupplyTroops').value=0 ;
      }, false);
      ById('pbtargetMilitiaman').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetMilitiaman').value)) ById('pbtargetMilitiaman').value=0 ;
      }, false);
      ById('pbtargetScout').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetScout').value)) ById('pbtargetScout').value=0 ;
      }, false);
      ById('pbtargetPikeman').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetPikeman').value)) ById('pbtargetPikeman').value=0 ;
      }, false);
      ById('pbtargetSwordsman').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetSwordsman').value)) ById('pbtargetSwordsman').value=0 ;
      }, false);
      ById('pbtargetArcher').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetArcher').value)) ById('pbtargetArcher').value=0 ;
      }, false);
      ById('pbtargetCavalry').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetCavalry').value)) ById('pbtargetCavalry').value=0 ;
      }, false);
      ById('pbtargetHeavyCavalry').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetHeavyCavalry').value)) ById('pbtargetHeavyCavalry').value=0 ;
      }, false);
      ById('pbtargetSupplyWagon').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetSupplyWagon').value)) ById('pbtargetSupplyWagon').value=0 ;
      }, false);
      ById('pbtargetBallista').addEventListener('keyup', function(){
          if (isNaN(ById('pbtargetBallista').value)) ById('pbtargetBallista').value=0 ;
      }, false);
     ById('pbtargetBatteringRam').addEventListener('keyup', function(){
         if (isNaN(ById('pbtargetBatteringRam').value)) ById('pbtargetBatteringRam').value=0 ;
     }, false);
     ById('pbtargetCatapult').addEventListener('keyup', function(){
         if (isNaN(ById('pbtargetCatapult').value)) ById('pbtargetCatapult').value=0 ;
     }, false);
     
      
      ById('pbSupplyTroops').addEventListener('click', function(){
          if (ById('pbSupplyTroops').checked==false) {
              ById('pbtargetSupplyTroops').disabled = true;
          }
          else {
            ById('pbtargetSupplyTroops').disabled = false;
          }
      },false);
      ById('pbMilitiaman').addEventListener('click', function(){
          if (ById('pbMilitiaman').checked==false) {
              ById('pbtargetMilitiaman').disabled = true;
          }
          else {
            ById('pbtargetMilitiaman').disabled = false;
          }
      },false);
      ById('pbScout').addEventListener('click', function(){
          if (ById('pbScout').checked==false) {
              ById('pbtargetScout').disabled = true;
          }
          else {
            ById('pbtargetScout').disabled = false;
          }
      },false);
      ById('pbPikeman').addEventListener('click', function(){
          if (ById('pbPikeman').checked==false) {
              ById('pbtargetPikeman').disabled = true;
          }
          else {
            ById('pbtargetPikeman').disabled = false;
          }
      },false);
      ById('pbSwordsman').addEventListener('click', function(){
          if (ById('pbSwordsman').checked==false) {
              ById('pbtargetSwordsman').disabled = true;
          }
          else {
            ById('pbtargetSwordsman').disabled = false;
          }
      },false);
      ById('pbArcher').addEventListener('click', function(){
          if (ById('pbArcher').checked==false) {
              ById('pbtargetArcher').disabled = true;
          }
          else {
            ById('pbtargetArcher').disabled = false;
          }
      },false);
      ById('pbCavalry').addEventListener('click', function(){
          if (ById('pbCavalry').checked==false) {
              ById('pbtargetCavalry').disabled = true;
          }
          else {
            ById('pbtargetCavalry').disabled = false;
          }
      },false);
      ById('pbHeavyCavalry').addEventListener('click', function(){
          if (ById('pbHeavyCavalry').checked==false) {
              ById('pbtargetHeavyCavalry').disabled = true;
          }
          else {
            ById('pbtargetHeavyCavalry').disabled = false;
          }
      },false);
      ById('pbSupplyWagon').addEventListener('click', function(){
          if (ById('pbSupplyWagon').checked==false) {
              ById('pbtargetSupplyWagon').disabled = true;
          }
          else {
            ById('pbtargetSupplyWagon').disabled = false;
          }
      },false);
      ById('pbBallista').addEventListener('click', function(){
          if (ById('pbBallista').checked==false) {
              ById('pbtargetBallista').disabled = true;
          }
          else {
            ById('pbtargetBallista').disabled = false;
          }
      },false);
      ById('pbBatteringRam').addEventListener('click', function(){
          if (ById('pbBatteringRam').checked==false) {
              ById('pbtargetBatteringRam').disabled = true;
          }
          else {
            ById('pbtargetBatteringRam').disabled = false;
          }
      },false);
      ById('pbCatapult').addEventListener('click', function(){
          if (ById('pbCatapult').checked==false) {
              ById('pbtargetCatapult').disabled = true;
          }
          else {
            ById('pbtargetCatapult').disabled = false;
          }
      },false);
      
        } else {
        
      
    	 } 
  t.timer = setTimeout (t.showAuto, 3000);   
  }, 
    getRallypoint: function(cityId){
        var t = Tabs.Reassign;
        for (var o in Seed.buildings[cityId]){
  		var buildingType = parseInt(Seed.buildings[cityId][o][0]);
  		var buildingLevel = parseInt(Seed.buildings[cityId][o][1]);
  		if (buildingType == 12) t.rallypointlevel=parseInt(buildingLevel);
  	   }  
  	},
        	  
      
  
  	e_reassignRoutes: function(){
        var t = Tabs.Reassign;
        var now = new Date();
        if (t.reassignState.running == true)    {
        	var now = new Date().getTime()/1000.0;
        	now = now.toFixed(0);
        	var last = Options.lastreassign;
         		if ( now > (parseInt(last) + (Options.reassigninterval*60))){
      			  t.checkdoReassign();
        		}
        }
        setTimeout(function(){ t.e_reassignRoutes();}, Options.reassigninterval*1000);
        
      },
      	
  	delReassignRoutes: function() {
      	
  		var t = Tabs.Reassign;
      	
  		t.reassignRoutes= [];
      
  	},
  	checkcoords : function (obj){
  		var t = Tabs.Reassign;
  		if(obj.id == 'pbok'){
  			t.check = true;
  			t.addReassignRoute();
  		}
  		return;			
  	},
  	addReassignRoute: function () {
  		var t = Tabs.Reassign;
  		var city = t.tcp.city.id;
  		if(t.tcpto.city == null)return;
  		if(t.tcp.city.id == t.tcpto.city.id)return;
  		t.check = false;
  		var SendSupplyTroop = ById('pbSupplyTroops').checked;
  		var SendMilitiaman = ById('pbMilitiaman').checked;
  		var SendScout = ById('pbScout').checked;
  		var SendPikeman = ById('pbPikeman').checked;
  		var SendSwordsman = ById('pbSwordsman').checked;
  		var SendArchers = ById('pbArcher').checked;
  		var SendCavalry = ById('pbCavalry').checked;
  		var SendHeavyCavalry = ById('pbHeavyCavalry').checked;
  		var SendSupplyWagons = ById('pbSupplyWagon').checked;
  		var SendBallista = ById('pbBallista').checked;
  		var SendBatteringRam = ById('pbBatteringRam').checked;
  		var SendCatapult = ById('pbCatapult').checked;
  		var SupplyTroop = ById('pbtargetSupplyTroops').value;
  		var Militiaman = ById('pbtargetMilitiaman').value;
  		var Scout = ById('pbtargetScout').value;
  		var Pikeman = ById('pbtargetPikeman').value;
  		var Swordsman = ById('pbtargetSwordsman').value;
  		var Archers = ById('pbtargetArcher').value;
  		var Cavalry = ById('pbtargetCavalry').value;
  		var HeavyCavalry = ById('pbtargetHeavyCavalry').value;
  		var SupplyWagons = ById('pbtargetSupplyWagon').value;
  		var Ballista = ById('pbtargetBallista').value;
  		var BatteringRam = ById('pbtargetBatteringRam').value;
  		var Catapult = ById('pbtargetCatapult').value;
  		var target_x = t.tcpto.city.x;
  		var target_y = t.tcpto.city.y;
  				
  		var lRE = t.reassignRoutes;
  			lRE.push({
  				city:				city,
  				target_x:			target_x,
  				target_y:			target_y,
  				SendSupplyTroop:	SendSupplyTroop,
  				SupplyTroop:		SupplyTroop,
  				SendMilitiaman:		SendMilitiaman,
  				Militiaman:			Militiaman,
  				SendScout:			SendScout,
  				Scout:				Scout,
  				SendPikeman: 		SendPikeman,
  				Pikeman: 			Pikeman,
  				SendSwordsman:		SendSwordsman,
  				Swordsman:			Swordsman,
  				SendArchers:		SendArchers,
  				Archers:			Archers,
  				SendCavalry: 		SendCavalry,
  				Cavalry: 			Cavalry,
  				SendHeavyCavalry:	SendHeavyCavalry,
  				HeavyCavalry:		HeavyCavalry,
  				SendSupplyWagons:	SendSupplyWagons,
  				SupplyWagons:		SupplyWagons,
  				SendBallista: 		SendBallista,
  				Ballista: 			Ballista,
  				SendBatteringRam:	SendBatteringRam,
  				BatteringRam:		BatteringRam,
  				SendCatapult:		SendCatapult,
  				Catapult:			Catapult,
  			});
  		ById('pbReassignDivD').style.background ='#99FF99';
  		setTimeout(function(){ (ById('pbReassignDivD').style.background =''); }, 1000);
  	},
  	showReassignRoutes: function () {
  		var t = Tabs.Reassign;
  		var popReassignRoutes = null;
  		t.popReassignRoutes = new CPopup('pbShowTrade', 0, 0, 1100, 500, true, function() {clearTimeout (1000);});
  		var m = '<DIV style="max-height:460px; height:460px; overflow-y:auto"><TABLE align=center cellpadding=0 cellspacing=0 width=100% class="pbShowReassignRoutes" id="pbRoutesQueue">';       
  		t.popReassignRoutes.getMainDiv().innerHTML = '</table></div>' + m;
  		t.popReassignRoutes.getTopDiv().innerHTML = '<TD><B>'+lang.REASSIGN.Automatic.Routes+':</td>';
  		t.paintReassignRoutes();
  		t._addTabHeader();
  		t.popReassignRoutes.show(true)	;
  	},
  	paintReassignRoutes: function(){
  	        var t = Tabs.Reassign;
  	        var r = t.reassignRoutes;
  	        var cityname;
  			for (var i = (r.length-1); i>=0; i--) {
  				for (var y=0; y< Seed.cities.length;y++) {
  					if ( parseInt(Seed.cities[y][0]) == r[i].city) var cityname = Seed.cities[y][1];
  				}    
  				var queueId = i;
  				t._addTab(queueId,cityname, r[i].target_x, r[i].target_y, r[i].SendSupplyTroop,r[i].SupplyTroop, r[i].SendMilitiaman, r[i].Militiaman, r[i].SendScout, r[i].Scout, r[i].SendPikeman, r[i].Pikeman, r[i].SendSwordsman, r[i].Swordsman, r[i].SendArchers, r[i].Archers, r[i].SendCavalry, r[i].Cavalry, r[i].SendHeavyCavalry, r[i].HeavyCavalry, r[i].SendSupplyWagons, r[i].SupplyWagons, r[i].SendBallista, r[i].Ballista, r[i].SendBatteringRam, r[i].BatteringRam, r[i].SendCatapult, r[i].Catapult);
  	        }
  	    },
  	  
  	 _addTab: function(queueId,cityname,target_x,target_y,SendSupplyTroop,SupplyTroop,SendMilitiaman,Militiaman,SendScout,Scout,SendPikeman,Pikeman,SendSwordsman,Swordsman,SendArchers,Archers,SendCavalry,Cavalry,SendHeavyCavalry,HeavyCavalry,SendSupplyWagons,SupplyWagons,SendBallista,Ballista,SendBatteringRam,BatteringRam,SendCatapult,Catapult){
  	 	var t = Tabs.Reassign;
  	     var row = ById('pbRoutesQueue').insertRow(0);
  	     row.vAlign = 'top';
  	     row.insertCell(0).innerHTML = queueId;
  	     row.insertCell(1).innerHTML = cityname;
  	     row.insertCell(2).innerHTML = target_x + ',' + target_y;
  	     row.insertCell(3).innerHTML = SendSupplyTroop;
  	     row.insertCell(4).innerHTML = addCommas(SupplyTroop);
  	     row.insertCell(5).innerHTML = SendMilitiaman;
  	     row.insertCell(6).innerHTML = addCommas(Militiaman);
  	 	 row.insertCell(7).innerHTML = SendScout;
  	 	 row.insertCell(8).innerHTML = addCommas(Scout);
  	 	 row.insertCell(9).innerHTML = SendPikeman;
  	 	 row.insertCell(10).innerHTML = addCommas(Pikeman);
  	 	 row.insertCell(11).innerHTML = SendSwordsman;
  	 	 row.insertCell(12).innerHTML = addCommas(Swordsman);
  	 	 row.insertCell(13).innerHTML = SendArchers;
  	 	 row.insertCell(14).innerHTML = addCommas(Archers);
  	 	 row.insertCell(15).innerHTML = SendCavalry;
  	 	 row.insertCell(16).innerHTML = addCommas(Cavalry);
  	 	 row.insertCell(17).innerHTML = SendHeavyCavalry;
  	 	 row.insertCell(18).innerHTML = addCommas(HeavyCavalry);
  	 	 row.insertCell(19).innerHTML = SendSupplyWagons;
  	 	 row.insertCell(20).innerHTML = addCommas(SupplyWagons);
  	 	 row.insertCell(21).innerHTML = SendBallista;
  	 	 row.insertCell(22).innerHTML = addCommas(Ballista);
  	 	 row.insertCell(23).innerHTML = SendBatteringRam;
  	 	 row.insertCell(24).innerHTML = addCommas(BatteringRam);
  	 	 row.insertCell(25).innerHTML = SendCatapult;
  	 	 row.insertCell(26).innerHTML = addCommas(Catapult);
  	     row.insertCell(27).innerHTML = '<a class="button20" id="tradecancel_' + queueId + '"><span>'+uW.g_js_strings.commonstr.remove+'</span></a>';
  	     ById('tradecancel_' + queueId).addEventListener('click', function(){
  	        t.cancelQueueElement(queueId);
  	     }, false);
  	 },
  	 
  	 _addTabHeader: function() {
  	     var t = Tabs.Reassign;
  	     var row = ById('pbRoutesQueue').insertRow(0);
  	     row.innerHTML='<td colspan=10><input type=button value="QG" id=botradeQG>&nbsp;</td>';
  	     ById('botradeQG').addEventListener('click', function(){
  	      if (!Options.alertConfig.MonQG && parseIntNan(Options.alertConfig.hq)>0) {
   	       var mavilleId=Cities.byID[Options.alertConfig.hq];
	       if (mavilleId) {
	        var r = t.reassignRoutes;
	        for (var i = (r.length-1); i>=0; i--) {
	           r[i].target_x=mavilleId.x;
          	   r[i].target_y=mavilleId.y;
	        }
	        t.showReassignRoutes();
	       } 
	      }
  	     }, false);
  	     
  	     var row = ById('pbRoutesQueue').insertRow(0);
  	     row.vAlign = 'top';
  	     row.insertCell(0).innerHTML = "ID";
  	     row.insertCell(1).innerHTML = uW.g_js_strings.commonstr.from;
  	     row.insertCell(2).innerHTML = lang.General.to;
  	     row.insertCell(3).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt1'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_1_30_s34.jpg>';
  	     row.insertCell(4).innerHTML = "";
  	     row.insertCell(5).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt2'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_2_30_s34.jpg>';
  	     row.insertCell(6).innerHTML = "";
  	     row.insertCell(7).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt3'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_3_30_s34.jpg>';
  	     row.insertCell(8).innerHTML = "";
  	     row.insertCell(9).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt4'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_4_30_s34.jpg>';
  	     row.insertCell(10).innerHTML = "";
  	     row.insertCell(11).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt5'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_5_30_s34.jpg>';
  	     row.insertCell(12).innerHTML = "";
  	     row.insertCell(13).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt6'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_6_30_s34.jpg>';
  	     row.insertCell(14).innerHTML = "";
  	     row.insertCell(15).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt7'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_7_30_s34.jpg>';
  	     row.insertCell(16).innerHTML = "";
  	     row.insertCell(17).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt8'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_8_30_s34.jpg>';
  	     row.insertCell(18).innerHTML = "";
  	     row.insertCell(19).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt9'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_9_30_s34.jpg>';
  	     row.insertCell(20).innerHTML = "";
  	     row.insertCell(21).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt10'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_10_30_s34.jpg>';
  	     row.insertCell(22).innerHTML = "";
  	     row.insertCell(23).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt11'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_11_30_s34.jpg>';
  	     row.insertCell(24).innerHTML = "";
  	     row.insertCell(25).innerHTML = '<img height=20 title="'+unsafeWindow.unitcost['unt12'][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_12_30_s34.jpg>';
  	     row.insertCell(26).innerHTML = "";
  	     row.insertCell(27).innerHTML = "X";
  	   },   
  	   
  	 cancelQueueElement: function(queueId){
  	     var t = Tabs.Reassign;
  	     var queueId = parseInt(queueId);
  	     t.reassignRoutes.splice(queueId, 1);
  	     t.showReassignRoutes();
  	 },
  	   
  	saveReassignRoutes: function(){
  		var t = Tabs.Reassign;
          var serverID = getServerId();
          saveValue('reassignRoutes_' + serverID, JSON2.stringify(t.reassignRoutes));
      },
      readReassignRoutes: function(){
          var t = Tabs.Reassign;
          var serverID = getServerId();
          s = loadValue('reassignRoutes_' + serverID);
          if (s != null) {
              route = JSON2.parse(s);
              for (k in route)
                  t.reassignRoutes[k] = route[k];
          }
      },
      saveReassignState: function(){
  		var t = Tabs.Reassign;
          var serverID = getServerId();
          saveValue('reassignState_' + serverID, JSON2.stringify(t.reassignState));
      },
      readReassignState: function(){
          var t = Tabs.Reassign;
          var serverID = getServerId();
          s = loadValue('reassignState_' + serverID);
          if (s != null) {
              state = JSON2.parse(s);
              for (k in state)
                  t.reassignState[k] = state[k];
          }
      },
      toggleReassignState: function(obj){
  		var t = Tabs.Reassign;
  	obj = ById('pbReassignState');
          if (t.reassignState.running == true) {
              t.reassignState.running = false;
              if (obj) obj.value = uW.g_js_strings.commonstr.reassign+" = OFF";
  		updatebotbutton(uW.g_js_strings.commonstr.reassign+'  - OFF', 'pbsigntab');
  			t.checkdoreassigntimeout = null;
  			t.count = 0;
  			  		  Options.lastreassign = 0;
			  		  saveOptions();	
  		 
          }
          else {
              t.reassignState.running = true;
              if (obj) obj.value = uW.g_js_strings.commonstr.reassign+"  = ON";
  		updatebotbutton(uW.g_js_strings.commonstr.reassign+'  - ON', 'pbsigntab');
  			t.e_reassignRoutes();
          }
      },
  	
     checkdoReassign: function(){
  	var t = Tabs.Reassign;
  	t.doReassign(t.count);
  	t.count++;
  		if(t.count < t.reassignRoutes.length && t.reassignState.running){
  		  t.checkdoreassigntimeout = setTimeout(function() { t.checkdoReassign();}, 5000);
  		} else {
  		  var now = new Date().getTime()/1000.0;
  		  now = now.toFixed(0);
  		  Options.lastreassign = now;
  		  saveOptions();	
  		  t.count = 0;
  		}
  	},
      
      doReassign: function(count){
      	var t = Tabs.Reassign;
     		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
     		if(t.reassignRoutes.length==0) return;
     		var send=[];
     		var citytotal=0;
     		var totalsend=0;
  		params.u1 = 0;
  		params.u2 = 0;
  		params.u3 = 0;
  		params.u4 = 0;
  		params.u5 = 0;
  		params.u6 = 0;
  		params.u7 = 0;
  		params.u8 = 0;
  		params.u9 = 0;
  		params.u10 = 0;
  		params.u11 = 0;
  		params.u12 = 0;	
  				
     	 	var city = t.reassignRoutes[count]["city"];
     	 	var xcoord = t.reassignRoutes[count]["target_x"];
     	 	var ycoord = t.reassignRoutes[count]["target_y"];
      	
      	var cityID = 'city' + city;
  		if(!Cities.byID[city]) return;
  		var marching = getMarchInfoBOT(cityID);
      	t.getRallypoint(cityID);
  		if(t.rallypointlevel == 11) t.rallypointlevel = 15;
      	var maxsend = (t.rallypointlevel * 10000);
      	totalsend=0;
      	
      	var troopsselect=["SupplyTroop","Militiaman","Scout","Pikeman","Swordsman","Archers","Cavalry","HeavyCavalry","SupplyWagons","Ballista","BatteringRam","Catapult"];
      	for (k=0; k<troopsselect.length; k++) {
  			var citytroops = Seed.units[cityID]['unt'+(parseInt(k)+1)];
  			var marchtroops = marching.marchUnits[parseInt(k)+1];
  			citytotal = parseInt(citytroops) + parseInt(marchtroops);
  			if(t.reassignRoutes[count]['Send'+troopsselect[k]]==false) {continue; }
  			if(citytotal > t.reassignRoutes[count][troopsselect[k]]){
  				var sendtroops = parseInt(citytotal) - parseInt(t.reassignRoutes[count][troopsselect[k]]);
  				if (parseInt(sendtroops) > parseInt(citytroops)) sendtroops = citytroops;
  				if (parseInt(sendtroops) < 0) sendtroops = 0;
  				send[(parseInt(k)+1)] = sendtroops;
  				totalsend += send[(parseInt(k)+1)];
  				
  			}
  			if(totalsend > maxsend){
  				totalsend -= send[(parseInt(k)+1)];
  				send[(parseInt(k)+1)] = parseInt(maxsend-totalsend);
  				totalsend += send[(parseInt(k)+1)];
  				break;
  			}
         	}
      	
      	for (var zz=0; zz< Seed.cities.length;zz++) {
      		if ( parseInt(Seed.cities[zz][0]) == city) var cityname = Seed.cities[zz][1];
      	}
      	
    		params.cid= city;
  		params.type = "5";
  		params.kid=0;
  		params.xcoord = xcoord;
  		params.ycoord = ycoord;
  		params.u1 = send[1];
  		params.u2 = send[2];
  		params.u3 = send[3];
  		params.u4 = send[4];
  		params.u5 = send[5];
  		params.u6 = send[6];
  		params.u7 = send[7];
  		params.u8 = send[8];
  		params.u9 = send[9];
  		params.u10 = send[10];
  		params.u11 = send[11];
  		params.u12 = send[12];	
  		
     		if (totalsend >0) {
        		new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
                    method: "post",
                    parameters: params,
                    loading: true,
                    onSuccess: function (transport) {
                    var rslt = eval("(" + transport.responseText + ")");
                    if (rslt.ok) {
                    var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
                    var ut = unixTime();
                    var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
                    					for(i = 0; i <= unitsarr.length; i++){
                    						if(params["u"+i]){
                    								unitsarr[i] = params["u"+i];
                    						}
                    					}
                    var resources=[0,0,0,0,0,0,0,0,0,0,0,0,0];
                    var currentcityid = city;
                    unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
                    if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
                    actionLog("Reassign",uW.g_js_strings.commonstr.reassign+": " + cityname + " "+lang.REASSIGN.Automatic.To+": " + xcoord + ',' + ycoord + "    ->   "+uW.g_js_strings.commonstr.troops+" : " + totalsend);
                    } else {
                    actionLog("Reassign","<font color=red>" + transport.responseText + "</font>");
                    }
                    },
                    onFailure: function (transport) {
                      var rslt = eval("(" + transport.responseText + ")");
                      if (rslt.user_action) {
		      						actionLog("Reassign","<b><font color=red>"+lang.General.DetectionCaptcha+"</font></b>");
		      						new CdialogCancelContinue('<SPAN class=boldRed>C'+lang.General.Captcha+': REASSIGN AUTO</span>', null, null, mainPop.getMainDiv);
			} else {		
                      actionLog("Reassign","<font color=red>" + transport.responseText + "</font>");
                    
                    }
                    }
            });
     	 }      
  	},
      show: function(){
  		var t = Tabs.Reassign;
      },
  	hide: function(){
          var t = Tabs.Reassign;
      },
      onUnload: function(){
          var t = Tabs.Reassign;
          if (!ResetAll) t.saveReassignRoutes();
  	  if (!ResetAll) t.saveReassignState();
    },
  showManuel: function() {
    var t = Tabs.Reassign;
    var ModelCity = {};
    var rownum = 0;
    var rownum2 = 0;
    function _row (name, row, noTotal){
          if (rownum++ % 2)
            style = '';
          else
            style = ' style = "background: #e8e8e8"';
          var tot = 0;
          var m = [];
          m.push ('<TR style="background: #fff" align=right');
          m.push (style);
          m.push ('><TD');
          m.push (style);
          m.push ('><B>');
          m.push (name);
          m.push ('</td>');
          if (noTotal){
            m.push ('<TD');
            m.push (style);
            m.push ('>&nbsp;</td>');
          } else {
            for (i=0; i<row.length; i++)
              tot += row[i];
            m.push ('<TD style="background: #ffc">');
            m.push (addCommas(tot));
            m.push ('</td>');
          }
          for (i=0; i<row.length; i++){
            m.push ('<TD');
            m.push (style);
            m.push ('>');
            m.push (addCommas(row[i]));
            m.push ('</td>');
          }
          m.push ('</tr>');
          return m.join('');
    }
    if (t.state == null) {  
      m = "<DIV class=boStat>"+lang.REASSIGN.Manual.title+"</div>";
      m +="<div id='statpourREA'></div>";
      m += "<TABLE width='450px' class=ptTab border=0 align=left>\
        <tr align=center valign=middle><td colspan=1 width=100><b><u>Source</b></u><br><span id=REAsrcRptspeedcity></span></td>\
        <td colspan=1 width='100px'><input type=button style='font-weight:bold' id=REAaction value='"+uW.g_js_strings.commonstr.reassign+"'></td>\
        <td colspan=1 width='100px'><b><u>Destination</b></u><br><span id=REAdesRptspeedcity></span></td><td width=150 colspan=1><b><u>"+uW.g_js_strings.attack_generateincoming.estimatedarrival+"</b></u><br>&nbsp;"+uW.g_js_strings.commonstr.distance+": <span id='BOEstimationREAD'>&nbsp;</span></td></tr>\
        <tr align=center valign=top><td width=100><div id=REAstatsource></div></td>\
        <td ><table cellspacing=0 cellpadding=0 width=99%>";
         for (r=1; r<13; r++){
         if (rownum++ % 2)
	             style = '';
	           else
            style = ' style = "background: #e8e8e8"';
	     m += '<tr '+style+'><td  align=right><img height=20 title="'+unsafeWindow.unitcost['unt'+r][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg></td><td align=left><input style="border:1px solid black;height:16px;font-size:11px;" id="REAnbunit'+r+'" type=text size=7 value="0"></td></tr>';
   	}
   	     
        m += "</table></td><td><div id=REAstatdest></div></td>";
        m += "<td colspan=2><table cellspacing=0 cellpadding=0 width=80%>";
        for (r=1; r<13; r++){
        if (rownum++ % 2)
	            style = '';
	          else
            style = 'background: #e8e8e8;';
		    m += '<tr style="'+style+' height:16px;font-size:11px;"><td width=50% height=20 align=center><span id="BOEstimationREAZ'+r+'">&nbsp;</span></td></tr>';
   	}
      m += "</tr></table>";
      m += "</tr><tr><td colspan=4>"+uW.g_js_strings.commonstr.knight+": <SELECT id='REApiKnight' type=list></tr><tr><td colspan=4><div id='ptREAStatus' style='text-align:center;overflow-y:auto; max-height:30px; height: 30px;'></div></td></tr></table>";
      t.ReassignDiv.innerHTML = m; 
      t.statpourREA = document.getElementById ('statpourREA');
      t.statutREA = document.getElementById ('ptREAStatus');
      t.actionREA = document.getElementById ('REAaction');
      t.actionREA.addEventListener ('click', t.clickReassigneDo, false);
      var dcp1 = new CdispCityPicker ('ptREA1', ById('REAdesRptspeedcity'), false, t.clickREACityDestinationSelect, 1);
      var dcp0 = new CdispCityPicker ('ptREA0', ById('REAsrcRptspeedcity'), false, t.clickREACitySourceSelect, Cities.byID[unsafeWindow.currentcityid].idx);
      t.state = 1;
      t.estimerTemps();
    }
    rows = [];
    rows[0]=[];
    m = "<TABLE class=ptTabLined cellspacing=0><TR valign=top align=right><TD width=20></td><TD width=88 style='background: #ffc'><B>"+lang.General.tot.toUpperCase()+"</b></td>";
    for(i=0; i<Cities.numCities; i++) {
             m += '<TD width=81><B>'+ Cities.cities[i].name.substring(0,20) +'</b></td>';
    }
    for (r=1; r<13; r++){
            rows[r] = [];
            for(i=0; i<Cities.numCities; i++) {
              cityID = 'city'+ Cities.cities[i].id;
              rows[r][i] = parseInt(Seed.units[cityID]['unt'+r]);
            }
    }
    for (r=1; r<13; r++){
     m += _row ('<img height=18 title="'+unsafeWindow.unitcost['unt'+r][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg>', rows[r]);
    }
     row = [];
    for(i=0; i<Cities.numCities; i++) {
    	        var cityId = 'city'+ Cities.cities[i].id;
    	        var slots = 0;
    	        for (var k in Seed.queue_atkp[cityId]){   
    	         march = Seed.queue_atkp[cityId][k];
    	         if (typeof (march) == 'object'){
    	           slots++;
    	         }
    	        }
	  var niveauPointRall=parseInt(getCityBuilding (Cities.cities[i].id, 12).maxLevel);t
	 if (niveauPointRall==12) niveauPointRall=11;
    	        row[i] = '<SPAN><B>'+ slots +'/'+ niveauPointRall +'</b></span>';
     }
    m += _row ('PR', row, true, 0);    
    m += "</table>";
    t.statpourREA.innerHTML = m;   
    clearTimeout (t.displayTimer);
    t.displayTimer = setTimeout (t.showManuel, 4000);
  },
  estimerTemps: function() {
       var t = Tabs.Reassign;
       var x1 = parseInt(t.sourceCity.x);
       var x2 = parseInt(t.destinationCity.x);
       var y1 = parseInt(t.sourceCity.y);
       var y2 = parseInt(t.destinationCity.y);
       var dist = distance (x1, y1, x2, y2);
       ById("BOEstimationREAD").innerHTML = "<b>" + dist + "</b>";     
       for (r=1; r<13; r++){
          var m = estETA(dist, r, t.sourceCity.id,5);
          ById("BOEstimationREAZ"+r).innerHTML = "<b>" + m.friendEtaStr + "</b>";
       }
    },
  clickReassigneDo: function() {
   var t = Tabs.Reassign;
   t.statutREA.innerHTML = '';
    var totalunit=0;
   for (r=1; r<13; r++){
       if (parseInt(ById("REAnbunit"+r).value) > parseInt(ById("REAdestunit"+r).value)) {
         ById("REAnbunit"+r).style.backgroundColor="red";
         return false;
       }
       totalunit=totalunit+parseInt(ById("REAnbunit"+r).value);
       ById("REAnbunit"+r).style.backgroundColor="";
   }
   if (t.sourceCity.id==t.destinationCity.id) {
         t.statutREA.innerHTML = '<FONT COLOR=#550000>Impossible sur les memes villes !.</font>';
        return;
   }
   if (totalunit==0) {
      t.statutREA.innerHTML = '<FONT COLOR=#550000>'+uW.g_js_strings.modal_attack_do.sendtroop+'</font>';
        return;
   }
       var e=1;
         var f=uW.unixtime();
         if(Seed.playerEffects.aurasExpire){
         if(Seed.playerEffects.aurasExpire>f){e=1.15}}
      if(Seed.playerEffects.auras2Expire){if(Seed.playerEffects.auras2Expire>f){e=1.3}}
      var q=EffetTronePrc(66).percent;
      
   var niveauPointRall=parseInt(getCityBuilding (t.sourceCity.id, 12).maxLevel);
         var maxtroupe=parseInt(niveauPointRall*10000*e);
         if (niveauPointRall==11) maxtroupe=parseInt(150000*e);
         if (niveauPointRall==12) maxtroupe=parseInt(200000*e);
      
      maxtroupe=Math.round(maxtroupe*(1+q/100));      
         
   if (totalunit>maxtroupe) {
    t.statutREA.innerHTML = '<FONT COLOR=#550000>Impossible de reassigner plus de '+maxtroupe+' unit&eacute;es a la fois.</font>';
    return;
   }
  t.actionREA.disabled=true;
  var x=t.destinationCity.x;
  var y=t.destinationCity.y;
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.u1 = ById("REAnbunit1").value;
  params.u2 = ById("REAnbunit2").value;
  params.u3 = ById("REAnbunit3").value;
  params.u4 = ById("REAnbunit4").value;
  params.u5 = ById("REAnbunit5").value;
  params.u6 = ById("REAnbunit6").value;
  params.u7 = ById("REAnbunit7").value;
  params.u8 = ById("REAnbunit8").value;
  params.u9 = ById("REAnbunit9").value;;
  params.u10 = ById("REAnbunit10").value;
  params.u11 = ById("REAnbunit11").value;
  params.u12 = ById("REAnbunit12").value;	
  params.cid= t.sourceCity.id;
  params.type = "5";
  params.kid= ById("REApiKnight").value;
  params.xcoord = x;
  params.ycoord = y;
  t.statutREA.innerHTML ="<font size='2px'><b><i>Merci de patienter...</i></b></font>";
  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/march.php" + unsafeWindow.g_ajaxsuffix, {
	method: "post",
	parameters: params,
	loading: true,
	onSuccess: function (transport) {
	 var t = Tabs.Reassign;
	 var rslt = transport;
	 if (rslt.ok) {
	  var timediff = parseInt(rslt.eta) - parseInt(rslt.initTS);
	  var ut = unsafeWindow.unixtime();
    	  var unitsarr=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	  for(i = 0; i <= unitsarr.length; i++){
	    if(params["u"+i]){	unitsarr[i] = params["u"+i];	}
	  }
	  var resources=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	  var currentcityid = t.sourceCity.id;
	  unsafeWindow.attach_addoutgoingmarch(rslt.marchId, rslt.marchUnixTime, ut + timediff, params.xcoord, params.ycoord, unitsarr, params.type, params.kid, resources, rslt.tileId, rslt.tileType, rslt.tileLevel, currentcityid, true);
	  //if(rslt.updateSeed){unsafeWindow.update_seed(rslt.updateSeed)};
	  t.clickREACitySourceSelect(t.sourceCity);
	  t.statutREA.innerHTML ="<font size='2px'><b>R&eacute;assignation termin&eacute;e - Temps : " + timestr(timediff)+"</font>";
	  t.actionREA.disabled=false;
	 } else {
          t.statutREA.innerHTML ="<font color=red size='2px'>Erreur, merci de recommencer </font>";
          if (rslt.msg) {
           t.statutREA.innerHTML +="<br><font color=black size='2px'>" + rslt.msg +"</font>";
           t.actionREA.disabled=false;
          } else {
             t.statutREA.innerHTML +="<br>Tentative dans 2 secondes !</font>";
             setTimeout(function() { t.clickReassigneDo(); }, 2000);
          }
          
        }
       },
       onFailure: function () {
        var t = Tabs.Reassign;
         t.statutREA.innerHTML ="<font color=red>R&eacute;assignation en erreur....</font>";
         t.actionREA.disabled=false;
       }
    });
 },
 clickREACitySourceSelect : function (city){
   var t = Tabs.Reassign;
   var rownum=0;
   if (t.sourceCity!=city) {
         t.sourceCity = city; 
    for (r=1; r<13; r++){
     ById("REAnbunit"+r).value="0";
    }      
   } else {
    var cityID = 'city'+ t.sourceCity.id;
    for (r=1; r<13; r++){  
    
      if (parseInt(Seed.units[cityID]['unt'+r]) < ById("REAnbunit"+r).value)  ById("REAnbunit"+r).value="0";
    }
   }
   t.actionREA.disabled=false;
   var m="";
   m="<table cellspacing=0 cellpadding=0 width=80%>";
   var cityID = 'city'+ t.sourceCity.id;
   for (r=1; r<13; r++){  
       if (rownum++ % 2)
   	            style = '';
   	          else
            style = 'background: #e8e8e8;';
     m += '<tr style="'+style+'"><td align=right><img title="'+unsafeWindow.unitcost['unt'+r][0]+'" height=20 src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg></td>\
           <td align=left><input style="border:1px solid black;height:16px;font-size:11px;" id="REAdestunit'+r+'" type=text size=7 readonly value="'+parseInt(Seed.units[cityID]['unt'+r])+'">&nbsp;\
           <input type=button value=">" id="REApdestunit'+r+'"  style="border:1px solid black;height:16px;font-size:11px;"></td></tr>';
   }
   m += "</table>";
   ById("REAstatsource").innerHTML = m;
   var knt = new Array();
   ById('REApiKnight').innerHTML="";
   var o = document.createElement("option");
   o.text = uW.g_js_strings.modal_attack.dchooseknightd;
	  o.value = 0;
   	  ById("REApiKnight").options.add(o);
   	  for (k in Seed.knights['city' + t.sourceCity.id]){
          		if (Seed.knights['city' + t.sourceCity.id][k]["knightStatus"] == 1 && Seed.leaders['city' + t.sourceCity.id]["resourcefulnessKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"] && Seed.leaders['city' + t.sourceCity.id]["politicsKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"] && Seed.leaders['city' + t.sourceCity.id]["combatKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"] && Seed.leaders['city' + t.sourceCity.id]["intelligenceKnightId"] != Seed.knights['city' + t.sourceCity.id][k]["knightId"]){
          			knt.push ({
          				Name:   Seed.knights['city' + t.sourceCity.id][k]["knightName"],
          				Combat:	Seed.knights['city' + t.sourceCity.id][k]["combat"],
          				ID:	Seed.knights['city' + t.sourceCity.id][k]["knightId"],
          			});
          		}
          }
   knt = knt.sort(function sort(a,b) {a = parseInt(a['Combat']);b = parseInt(b['Combat']);return a == b ? 0 : (a > b ? -1 : 1);}); 
   for (k in knt){
       			if (knt[k]["Name"] !=undefined){
   	    			var o = document.createElement("option");
   	    			o.text = (knt[k]["Name"] + ' (' + knt[k]["Combat"] +')')
   	    			o.value = knt[k]["ID"];
   	    			ById("REApiKnight").options.add(o);
       			}
   }
   for (r=1; r<13; r++){
     ById("REApdestunit"+r).addEventListener ('click', function() {
       var nomcha=this.id.replace("REApdest","REAdest");
       var nomcha2=this.id.replace("REApdestunit","REAnbunit");
       ById(nomcha2).value=0;
           var e=1;
               var f=uW.unixtime();
               if(Seed.playerEffects.aurasExpire){
               if(Seed.playerEffects.aurasExpire>f){e=1.15}}
            if(Seed.playerEffects.auras2Expire){if(Seed.playerEffects.auras2Expire>f){e=1.3}}
            var q=EffetTronePrc(66).percent;
            
         var niveauPointRall=parseInt(getCityBuilding (t.sourceCity.id, 12).maxLevel);
               var maxtroupe=parseInt(niveauPointRall*10000*e);
               if (niveauPointRall==11) maxtroupe=parseInt(150000*e);
               if (niveauPointRall==12) maxtroupe=parseInt(200000*e);
            
      maxtroupe=Math.round(maxtroupe*(1+q/100));  
       var nbunitto=0;
       for (r=1; r<13; r++) {
         nbunitto+=parseInt(ById("REAnbunit"+r).value);
       }
       var libre = parseInt(maxtroupe - nbunitto);
       if (ById(nomcha).value>=libre) {
         ById(nomcha2).value = libre;
       }  else {
         ById(nomcha2).value= ById(nomcha).value;
       }  
      }, false);
   }
   t.estimerTemps();
 },
 clickREACityDestinationSelect : function (city){
    var t = Tabs.Reassign;
    var rownum=0;
    t.destinationCity = city;
    var m="";
    m="<table cellspacing=0 cellpadding=0 width=80%>";
    for (r=1; r<13; r++){
       if (rownum++ % 2)
   	            style = '';
   	          else
            style = 'background: #e8e8e8;';
         cityID = 'city'+ t.destinationCity.id;
         m += '<tr style="'+style+'"><td align=right><img height=20 title="'+unsafeWindow.unitcost['unt'+r][0]+'" src=http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/units/unit_'+r+'_30_s34.jpg></td><td align=left><input style="border:1px solid black;height:16px;font-size:11px;" type=text size=7 readonly value="'+parseInt(Seed.units[cityID]['unt'+r])+'"></td></tr>';
    }
    m += "</table>";
    ById("REAstatdest").innerHTML = m;
    t.estimerTemps();
  },    
}

Tabs.autoFormation= {
 tabOrder: 9,
 tabLabel: 'Auto'+uW.g_js_strings.commonstr.train,
 cont : null,
 nbfil : 0,
 crfil : 0,
 timer:null,
 city : 0,
 numcity :-1,
 init : function (div){
   var t = Tabs.autoFormation;
   t.cont = div;
   t.state = null;
   AddSubTabLink('Formation', t.toggleautoFormationState, 'pbformtab');
   if (TrainOptions.Running == false) {
      updatebotbutton(uW.g_js_strings.commonstr.train+' - OFF', 'pbformtab');
   } else {
      updatebotbutton(uW.g_js_strings.commonstr.train+' - ON', 'pbformtab');
      t.timer=setTimeout(t.Start,5000);
   }
   if (TrainOptions.timelauch<5) { 
    TrainOptions.timelauch=5;
    saveTrainingOptions();
   
   }
   return t.cont;
  },
 Start: function() {
  var t = Tabs.autoFormation;
  if (!TrainOptions.Running) {
    clearTimeout(t.timer);
    return;
  }
  if (t.numcity<Cities.numCities-1) {
      t.numcity++;
    } else {
     t.numcity=-1; 
     clearTimeout(t.timer);
     
     t.timer=setTimeout(t.Start,parseIntNan(TrainOptions.timelauch*60)*1000);
     return;
  }
  var c=t.numcity;
  var cityId=Cities.cities[c].id;
  if (!TrainOptions.listactif[cityId]) t.Start();
  var populationdispo = 0;
  if(!TrainOptions.listlabour[cityId]) {
   populationdispo = parseIntNan(Seed.citystats['city'+cityId].pop[0]) - parseIntNan(Seed.citystats['city'+cityId].pop[3]);	
  }else {
    populationdispo = parseIntNan(Seed.citystats['city'+cityId].pop[0]).toFixed(0); 
  }
  var availableTrainingSlots = 0;
  try{
   	var barracksTotal = getCityBuilding(cityId, 13).count;
   	var trainingSlotsUsed = Seed.queue_unt['city'+cityId].length;
   	if(trainingSlotsUsed!=null){
   	  availableTrainingSlots = barracksTotal-trainingSlotsUsed;
   	}
  }finally{
	
   } 
   maxunite = t.unitemax(cityId, TrainOptions.list[Cities.cities[c].id],(c+1));
   var resources = t.checkresources(cityId, c);
   if (!resources) {
    actionLog("AutoForm",Cities.cities[c].name+ " - ERROR : "+lang.AUTOTRAIN.ErrorPop+": "+maxunite+"/"+parseInt(TrainOptions.unitemin[Cities.cities[c].id]));     
    return;
   }  
   if(availableTrainingSlots>0 && maxunite>=parseIntNan(TrainOptions.unitemin[Cities.cities[c].id]) && TrainOptions.listactif[Cities.cities[c].id]) {
       var unitId = TrainOptions.list[cityId]; 
       var num = parseInt(maxunite);
       if (TrainOptions.unitemax[Cities.cities[c].id] != undefined) {
        var maxnum = TrainOptions.unitemax[Cities.cities[c].id];
        if (num>parseInt(TrainOptions.unitemax[Cities.cities[c].id])) num=parseInt(TrainOptions.unitemax[Cities.cities[c].id]);
       }
       var gam= TrainOptions.listboost[cityId];
       var time = unsafeWindow.modal_barracks_traintime(unitId, num);
         var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
         params.cid = cityId;
         params.type = unitId;
         params.quant = num;
         //params.items = 0;
         if (parseInt(TrainOptions.Item[(c+1)])) {
          params.items = TrainOptions.Item[(c+1)];
         }
         params.gambleId = gam;
         new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/train.php" + unsafeWindow.g_ajaxsuffix, {
           method: "post",
           parameters: params,
           loading: true,
           onSuccess: function(transport) {
            var rslt = eval("(" + transport.responseText + ")");
             if (rslt.ok) {
               var resourceFactors=[],resourceLost;
	              if(gam!=null){
	                time=rslt.timeNeeded;
	       	      }
	               for(var i=1;i<5;i++){
	               if(rslt.gamble){
	                resourceFactors.push(rslt.gamble[i.toString()]);
	               }else{
	               resourceFactors.push(1);
	               }
	               resourceLost=parseInt(unsafeWindow.unitcost["unt"+unitId][i])*3600*parseInt(num);resourceLost=resourceLost*resourceFactors[i-1];
	               unsafeWindow.seed.resources["city"+cityId]["rec"+i][0]=parseInt(unsafeWindow.seed.resources["city"+cityId]["rec"+i][0])-resourceLost;
       }
   unsafeWindow.seed.citystats["city"+cityId].gold[0]=parseInt(unsafeWindow.seed.citystats["city"+cityId].gold[0])-parseInt(unsafeWindow.unitcost["unt"+unitId][5])*parseInt(num);
         unsafeWindow.seed.citystats["city"+cityId].pop[0]=parseInt(unsafeWindow.seed.citystats["city"+cityId].pop[0])-parseInt(unsafeWindow.unitcost["unt"+unitId][6])*parseInt(num);
         unsafeWindow.seed.queue_unt["city"+cityId].push([unitId,num,rslt.initTS,parseInt(rslt.initTS)+time,0,time,null]);
         
	if(rslt.updateSeed) { unsafeWindow.update_seed(rslt.updateSeed) }
         actionLog("AutoForm",Cities.cities[c].name+" - " + num+" "+unsafeWindow.unitcost['unt'+ TrainOptions.list[Cities.cities[c].id]][0]+" OK");
             } else {
              actionLog("AutoForm",Cities.cities[c].name+ " - " + num+" "+unsafeWindow.unitcost['unt'+ TrainOptions.list[Cities.cities[c].id]][0]+"<br><font color=red>" + transport.responseText +"</font>");
             }
           },
           onFailure: function(o) {
            actionLog("AutoForm",Cities.cities[c].name+ " - " + num+" "+unsafeWindow.unitcost['unt'+ TrainOptions.list[Cities.cities[c].id]][0]+"<br><font color=red>" +o.responseText+"</font>");
           }
  	});
   } else {  
    if (availableTrainingSlots<=0) {
       //actionLog("AutoForm",Cities.cities[c].name+ " - ERROR : Slot non dispo");  
    }
    if (maxunite<parseInt(TrainOptions.unitemin[Cities.cities[c].id])) {
       actionLog("AutoForm",Cities.cities[c].name+ " - ERROR: "+lang.AUTOTRAIN.ErrorPopRes+": "+maxunite+"/"+parseInt(TrainOptions.unitemin[Cities.cities[c].id]));     
    }
   }
   
   var cityNo = t.numcity + 1;
   		if (TrainOptions.doTraps[cityNo])
   			t.doAutoTraps(cityNo);
   		if (TrainOptions.doCalrops[cityNo])
   			t.doAutoCaltrops(cityNo);
   		if (TrainOptions.doSpikes[cityNo])
   			t.doAutoSpikes(cityNo);
   		if (TrainOptions.doXbows[cityNo])
			t.doAutoCrossbows(cityNo);
   		if (TrainOptions.doTrebu[cityNo])
			t.doAutoTrebu(cityNo);
			

    clearTimeout(t.timer);
    t.timer=setTimeout(function() { t.Start(); },5000);
 
 },
 doAutoTraps: function (cityNo) {
 		var t = Tabs.autoFormation;
 		wall = {};
 		var cityId = Cities.cities[cityNo - 1].id
 		var cityID = 'city'+ cityId;
 		getWallInfo (cityId, wall);
 		availableSpace = wall.fieldSpace - wall.fieldSpaceUsed;
 		if (availableSpace > 0 && wall.slotsBusy < 3) {
 			var food = parseInt (Seed.resources['city'+cityId].rec1[0]/3600);
 			var wood = parseInt (Seed.resources['city'+cityId].rec2[0]/3600);
 			var stone = parseInt (Seed.resources['city'+cityId].rec3[0]/3600);
 			var ore = parseInt (Seed.resources['city'+cityId].rec4[0]/3600);
 			availableSlots = 3 - wall.slotsBusy;
 			var foodRes = TrainOptions.keepFood[cityNo];
 			var woodRes = TrainOptions.keepWood[cityNo];
 			var stoneRes = TrainOptions.keepStone[cityNo];
 			var oreRes = TrainOptions.keepOre[cityNo];
 			var availFood = food - foodRes;
 			var availWood = wood - woodRes;
 			var availStone = stone - stoneRes;
 			var availOre = ore - oreRes;
 		        secsPerTrap = Cities.byID[cityId]['Def60Time'];
 			if (secsPerTrap > 0 && availableSpace > 4 && availableSlots > 0) {
 				if (availFood > 400 && availWood > 800 & availStone > 200 & availOre > 400) {
 					var numberToTrain = 9999999999;
 					if ((availFood / 400) < numberToTrain)
 						numberToTrain = parseInt(availFood / 400);
 					if ((availWood / 800) < numberToTrain)
 						numberToTrain = parseInt(availWood / 800);
 					if ((availStone / 200) < numberToTrain)
 						numberToTrain = parseInt(availStone / 200);
 					if ((availOre / 400) < numberToTrain)
 						numberToTrain = parseInt(availOre / 400);
 					if (numberToTrain > 5)
 						numberToTrain = 5;
 					if (wall.Trap + wall.TrapTraining < 10 || availableSpace < 15) {
 						numberToTrain = 1;
 					} 
 					actionLog("AutoForm",Cities.byID[cityId].name + ' - '+uW.g_js_strings.commonstr.build+' ' + numberToTrain + ' '+uW.fortcost.frt60[0]);
 					doDefTrain (cityId, 0, 60, numberToTrain);
 				}
 			}
 		}
  },
 doAutoCaltrops: function (cityNo) {
 		var t = Tabs.autoFormation;
 		var wall = {};
 		var cityId = Cities.cities[cityNo - 1].id;
 		var cityID = 'city'+ cityId;
 		getWallInfo (cityId, wall);
 		availableSpace = wall.fieldSpace - wall.fieldSpaceUsed;
 		if (availableSpace > 0 && wall.slotsBusy < 3) {
 			var food = parseInt (Seed.resources['city'+cityId].rec1[0]/3600);
 			var wood = parseInt (Seed.resources['city'+cityId].rec2[0]/3600);
 			var stone = parseInt (Seed.resources['city'+cityId].rec3[0]/3600);
 			var ore = parseInt (Seed.resources['city'+cityId].rec4[0]/3600);
 			availableSlots = 3 - wall.slotsBusy;
 			var foodRes = TrainOptions.keepFood[cityNo];
 			var woodRes = TrainOptions.keepWood[cityNo];
 			var stoneRes = TrainOptions.keepStone[cityNo];
 			var oreRes = TrainOptions.keepOre[cityNo];
 			var availFood = food - foodRes;
 			var availWood = wood - woodRes;
 			var availStone = stone - stoneRes;
 			var availOre = ore - oreRes;
 			secsPerCaltrop = Cities.byID[cityId]['Def61Time'];
 			if (secsPerCaltrop > 0 && availableSpace > 1 && availableSlots > 0) {
 				if (availFood > 100 && availOre > 400) {
 					var numberToTrain = 9999999999;
 					if ((availFood / 100) < numberToTrain)
 						numberToTrain = parseInt(availFood / 100);
 					if ((availOre / 400) < numberToTrain)
 						numberToTrain = parseInt(availOre / 400);
 					if (numberToTrain > 5)
 						numberToTrain = 5;
 					if (wall.Caltrops + wall.CaltropsTraining < 10 || availableSpace < 15) {
 						numberToTrain = 1;						
 					}
 					actionLog("AutoForm",Cities.byID[cityId].name + ' - '+uW.g_js_strings.commonstr.build+' ' + numberToTrain + ' '+uW.fortcost.frt61[0]);
 					doDefTrain (cityId,0,61,numberToTrain); 					
 				}
 			}
 		}
	},
	doAutoSpikes: function (cityNo) {
		var t = Tabs.autoFormation;
		wall = {};
		var cityId = Cities.cities[cityNo - 1].id
		var cityID = 'city'+ cityId;
		getWallInfo (cityId, wall);
		availableSpace = wall.fieldSpace - wall.fieldSpaceUsed;
		if (availableSpace > 0 && wall.slotsBusy < 3) {
			var food = parseInt (Seed.resources['city'+cityId].rec1[0]/3600);
			var wood = parseInt (Seed.resources['city'+cityId].rec2[0]/3600);
			var stone = parseInt (Seed.resources['city'+cityId].rec3[0]/3600);
			var ore = parseInt (Seed.resources['city'+cityId].rec4[0]/3600);
			availableSlots = 3 - wall.slotsBusy;
			var foodRes = T