var mapobject=null;var NONE=0;var PLAYER_MAP=1;var CLAN_MAP=2;var DEFAULT_LON=19.5;var DEFAULT_LAT=52;var DEFAULT_SCALE=6;var playerIcons=new Array();var playerMagicIcons=new Array();var clanIcons=new Array();var clanMagicIcons=new Array();var playerWeaponIcons=new Array();var playerDressIcons=new Array();var clanWeaponIcons=new Array();var clanDressIcons=new Array();var flagMapActive=false;var mapProperties=null;var mapRemoting=null;function buildMap(A){if(A==true){mapobject=new GMap2(document.getElementById("map_canvas"));mapobject.setCenter(new GLatLng(DEFAULT_LAT,DEFAULT_LON),DEFAULT_SCALE);mapobject.addControl(new GHierarchicalMapTypeControl());mapobject.addControl(new GLargeMapControl3D());mapobject.addMapType(G_PHYSICAL_MAP);var B=new GScaleControl();mapobject.addControl(B)}}function initMap(A){if(A==true){mapRemoting=Seam.Component.getInstance("mapAction");Seam.Remoting.startBatch();mapRemoting.getPlayerMapAreas(getPlayerMapAreasCallback);mapRemoting.getClanMapAreas(getClanMapAreasCallback);mapRemoting.getPlayerEquipment(getPlayerEquipmentCallback);mapRemoting.getClanEquipment(getClanEquipmentCallback);mapRemoting.getMapProperties(getMapPropertiesCallback);Seam.Remoting.executeBatch()}}function centerMap(){if(flagMapActive==false){return }setCenterAndZoom(DEFAULT_LAT,DEFAULT_LON,DEFAULT_SCALE);mapProperties.lon=DEFAULT_LON;mapProperties.lat=DEFAULT_LAT;mapProperties.scale=DEFAULT_SCALE;mapRemoting.setMapProperties(mapProperties,reloadPageCallback)}function setCenterAndZoom(B,C,A){mapobject.setCenter(new GLatLng(B,C));mapobject.setZoom(A)}function onOffPlayerMap(){if(flagMapActive==false){return }if(mapProperties.drawMapType!=PLAYER_MAP){mapProperties.drawMapType=PLAYER_MAP;showIconsByName("clanIcon",false);showIconsByName("clanMagicIcon",false);showIconsByName("clanWeaponIcon",false);showIconsByName("clanDressIcon",false);showIconsByName("playerIcon",true);showIconsByName("playerMagicIcon",true);showIconsByName("playerWeaponIcon",true);showIconsByName("playerDressIcon",true)}mapRemoting.getPlayerMapAreas(centerMapCallback)}function onOffClanMap(){if(flagMapActive==false){return }if(mapProperties.drawMapType!=CLAN_MAP){mapProperties.drawMapType=CLAN_MAP;showIconsByName("playerIcon",false);showIconsByName("playerMagicIcon",false);showIconsByName("playerWeaponIcon",false);showIconsByName("playerDressIcon",false);showIconsByName("clanIcon",true);showIconsByName("clanMagicIcon",true);showIconsByName("clanWeaponIcon",true);showIconsByName("clanDressIcon",true)}mapRemoting.getClanMapAreas(centerMapCallback)}function showIconsByName(E,B){var D=new Array();if(E=="playerIcon"){D=playerIcons}else{if(E=="playerMagicIcon"){D=playerMagicIcons}else{if(E=="playerWeaponIcon"){D=playerWeaponIcons}else{if(E=="playerDressIcon"){D=playerDressIcons}else{if(E=="clanIcon"){D=clanIcons}else{if(E=="clanMagicIcon"){D=clanMagicIcons}else{if(E=="clanWeaponIcon"){D=clanWeaponIcons}else{if(E=="clanDressIcon"){D=clanDressIcons}}}}}}}}for(var C=0;C<D.length;C++){var A=D[C];if(B){mapobject.addOverlay(A)}else{mapobject.removeOverlay(A)}}}function getPlayerMapAreasCallback(A){if(A!=null){playerIcons=new Array();playerMagicIcons=new Array();for(var C=0;C<A.length;C++){if(A[C].magic==false){var D=new GIcon();D.image="gfx/map/tereny_gracza_niemagiczne.png";D.iconSize=new GSize(50,49);D.shadowSize=new GSize(50,49);D.infoWindowAnchor=new GPoint(25,0);D.iconAnchor=new GPoint(25,49);var E=new GLatLng(A[C].lat,A[C].lon);var B=new GMarker(E,{icon:D});setTooltip(B,A[C]);playerIcons.push(B)}else{var D=new GIcon();D.image="gfx/map/tereny_gracza_magiczne.png";D.iconSize=new GSize(50,49);D.shadowSize=new GSize(50,49);D.infoWindowAnchor=new GPoint(25,0);D.iconAnchor=new GPoint(25,49);var E=new GLatLng(A[C].lat,A[C].lon);var B=new GMarker(E,{icon:D});setTooltip(B,A[C]);playerMagicIcons.push(B)}}}}function getClanMapAreasCallback(A){if(A!=null){clanIcons=new Array();clanMagicIcons=new Array();for(var C=0;C<A.length;C++){if(A[C].magic==false){var D=new GIcon();D.image="gfx/map/tereny_klanu_niemagiczne.png";D.iconSize=new GSize(50,35);D.shadowSize=new GSize(50,35);D.infoWindowAnchor=new GPoint(9,2);D.iconAnchor=new GPoint(25,35);var E=new GLatLng(A[C].lat,A[C].lon);var B=new GMarker(E,{icon:D});setClanTooltip(B,A[C]);clanIcons.push(B)}else{var D=new GIcon();D.image="gfx/map/tereny_klanu_magiczne.png";D.iconSize=new GSize(50,35);D.shadowSize=new GSize(50,35);D.infoWindowAnchor=new GPoint(9,2);D.iconAnchor=new GPoint(25,35);var E=new GLatLng(A[C].lat,A[C].lon);var B=new GMarker(E,{icon:D});setClanTooltip(B,A[C]);clanMagicIcons.push(B)}}}}function getPlayerEquipmentCallback(A){if(A!=null){playerWeaponIcons=new Array();playerDressIcons=new Array();for(var C=0;C<A.length;C++){if(A[C].equipmentLocation.equipment.category=="DRESS"){var D=new GIcon();D.image="gfx/map/armor.png";D.iconSize=new GSize(32,32);D.shadowSize=new GSize(32,32);D.infoWindowAnchor=new GPoint(16,0);D.iconAnchor=new GPoint(16,32);var E=new GLatLng(A[C].equipmentLocation.lat,A[C].equipmentLocation.lon);var B=new GMarker(E,{icon:D});setEquipmentTooltip(B,A[C].equipmentLocation.equipment,A[C].foundAt);playerDressIcons.push(B)}else{var D=new GIcon();D.image="gfx/map/sword_axe.png";D.iconSize=new GSize(32,32);D.shadowSize=new GSize(32,32);D.infoWindowAnchor=new GPoint(16,0);D.iconAnchor=new GPoint(16,32);var E=new GLatLng(A[C].equipmentLocation.lat,A[C].equipmentLocation.lon);var B=new GMarker(E,{icon:D});setEquipmentTooltip(B,A[C].equipmentLocation.equipment,A[C].foundAt);playerWeaponIcons.push(B)}}}}function getClanEquipmentCallback(A){if(A!=null){clanWeaponIcons=new Array();clanDressIcons=new Array();for(var C=0;C<A.length;C++){if(A[C].equipmentLocation.equipment.category=="DRESS"){var D=new GIcon();D.image="gfx/map/armor.png";D.iconSize=new GSize(32,32);D.shadowSize=new GSize(32,32);D.infoWindowAnchor=new GPoint(16,0);D.iconAnchor=new GPoint(16,32);var E=new GLatLng(A[C].equipmentLocation.lat,A[C].equipmentLocation.lon);var B=new GMarker(E,{icon:D});setEquipmentTooltip(B,A[C].equipmentLocation.equipment,A[C].foundAt);clanDressIcons.push(B)}else{var D=new GIcon();D.image="gfx/map/sword_axe.png";D.iconSize=new GSize(32,32);D.shadowSize=new GSize(32,32);D.infoWindowAnchor=new GPoint(16,0);D.iconAnchor=new GPoint(16,32);var E=new GLatLng(A[C].equipmentLocation.lat,A[C].equipmentLocation.lon);var B=new GMarker(E,{icon:D});setEquipmentTooltip(B,A[C].equipmentLocation.equipment,A[C].foundAt);clanWeaponIcons.push(B)}}}}function centerMapCallback(K){if(K!=null&&K.length>0){var D=-90;var I=-180;var B=90;var G=180;var J;for(var E=0;E<K.length;E++){J=K[E];if(J.lat<B){B=J.lat}if(J.lat>D){D=J.lat}if(J.lon<G){G=J.lon}if(J.lon>I){I=J.lon}}var C=0;var H=0;var F=0;var A=new GLatLngBounds(new GLatLng(B,G),new GLatLng(D,I));F=mapobject.getBoundsZoomLevel(A);C=(D+B)/2;H=(I+G)/2;setCenterAndZoom(C,H,F)}}function getMapPropertiesCallback(A){if(A!=null){mapProperties=A;flagMapActive=true;if((mapProperties.lon==null)||(mapProperties.lat==null)||(mapProperties.scale==null)){mapProperties.lon=DEFAULT_LON;mapProperties.lat=DEFAULT_LAT;mapProperties.scale=DEFAULT_SCALE;onOffPlayerMap()}else{if(mapProperties.drawMapType==PLAYER_MAP){showIconsByName("clanIcon",false);showIconsByName("clanMagicIcon",false);showIconsByName("clanWeaponIcon",false);showIconsByName("clanDressIcon",false);showIconsByName("playerIcon",true);showIconsByName("playerMagicIcon",true);showIconsByName("playerWeaponIcon",true);showIconsByName("playerDressIcon",true)}else{if(mapProperties.drawMapType==CLAN_MAP){showIconsByName("playerIcon",false);showIconsByName("playerMagicIcon",false);showIconsByName("playerWeaponIcon",false);showIconsByName("playerDressIcon",false);showIconsByName("clanIcon",true);showIconsByName("clanMagicIcon",true);showIconsByName("clanWeaponIcon",true);showIconsByName("clanDressIcon",true)}}setCenterAndZoom(mapProperties.lat,mapProperties.lon,mapProperties.scale)}}else{window.location.reload()}}function reloadPageCallback(A){if(A==false){window.location.reload()}}function setTooltip(B,A){var C="<div style='font-size:12px;'><strong>"+A.name;if(A.magic==true){C+=" (teren magiczny)"}C+="</strong><br/><br/>data zdobycia: "+A.occupedAtString;C+="</div>";GEvent.addListener(B,"click",function(){B.openInfoWindowHtml(C)})}function setClanTooltip(B,A){var C="<div style='font-size:12px;'><strong>"+A.name;if(A.magic==true){C+=" (teren magiczny)"}C+="</strong><br/><br/>w&#322;a&#347;ciciel: "+A.owner.handle;C+="<br/>data zdobycia: "+A.occupedAtString;C+="</div>";GEvent.addListener(B,"click",function(){B.openInfoWindowHtml(C)})}function setEquipmentTooltip(A,E,H){var G="<div style='font-size:12px; text-align: center'><strong>"+E.wwwFullName+"</strong><br/><img src='gfx/equipment/"+E.imageSmall+"' width='80px' height='80px'/><br/><br/>data znalezienia: "+formatDate(H,"yyyy-MM-dd HH:mm");if(E.category=="DRESS"){G+="<br/>stopie&#324; obrony: "}else{G+="<br/>si&#322;a obra&#380;e&#324;: "}G+=E.level;var B=E.destCharacterLevels;if(B!=null&&B!=""){var D=B.split(",");G+="<br/>Wi&#281;ksza si&#322;a na:";for(var C=0;C<D.length;C++){var F=D[C].split("=");if(F[0]=="MAN"){G+="<br/>&bull; Ludzi (+"+F[1]+")"}else{if(F[0]=="VAMPIRE"){G+="<br/>&bull; Wampiry (+"+F[1]+")"}else{if(F[0]=="WEREWOLF"){G+="<br/>&bull; Wilko&#322;aki (+"+F[1]+")"}}}}}if(E.category!="DRESS"){G+="<br/>zasi&#281;g (w metrach): "+E.maxDistance}G+="<br/><br/>Aby pobra&#263; przedmiot <strong>zbli&#380; si&#281;</strong> ";G+="<br/>do niego <strong>dostatecznie blisko</strong>";G+="<br/> i wy&#347;lij: <strong>WEZ "+E.name;G+=" na numer do gry</strong></div>";GEvent.addListener(A,"click",function(){A.openInfoWindowHtml(G)})}function getDateString(C){var A=d.getDate();var E=d.getMonth();var B=d.getFullYear();var D=B+"-"+E+"-"+A+" "}var MONTH_NAMES=new Array("January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var DAY_NAMES=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat");function LZ(A){return(A<0||A>9?"":"0")+A}function formatDate(f,a){a=a+"";var J="";var T=0;var e="";var D="";var I=f.getYear()+"";var F=f.getMonth()+1;var b=f.getDate();var N=f.getDay();var L=f.getHours();var V=f.getMinutes();var P=f.getSeconds();var R,S,B,Q,g,C,Z,Y,W,O,j,L,i,G,A,X;var U=new Object();if(I.length<4){I=""+(I-0+1900)}U.y=""+I;U.yyyy=I;U.yy=I.substring(2,4);U.M=F;U.MM=LZ(F);U.MMM=MONTH_NAMES[F-1];U.NNN=MONTH_NAMES[F+11];U.d=b;U.dd=LZ(b);U.E=DAY_NAMES[N+7];U.EE=DAY_NAMES[N];U.H=L;U.HH=LZ(L);if(L==0){U.h=12}else{if(L>12){U.h=L-12}else{U.h=L}}U.hh=LZ(U.h);if(L>11){U.K=L-12}else{U.K=L}U.k=L+1;U.KK=LZ(U.K);U.kk=LZ(U.k);if(L>11){U.a="PM"}else{U.a="AM"}U.m=V;U.mm=LZ(V);U.s=P;U.ss=LZ(P);while(T<a.length){e=a.charAt(T);D="";while((a.charAt(T)==e)&&(T<a.length)){D+=a.charAt(T++)}if(U[D]!=null){J=J+U[D]}else{J=J+D}}return J}function convertDate(C){var B=C.toLocaleString();var A=B.length-9;B=B.substring(0,A);return B}Seam.Remoting.displayLoadingMessage=function(){};Seam.Remoting.hideLoadingMessage=function(){};