if (typeof hbConfig == 'undefined') hbConfig={}; if (!hbConfig.version) hbConfig.version='1.5';

if (typeof hbConfig == "undefined") hbConfig={};
hbConfig.version = hbConfig.version || "current";
hbConfig.arcgisVersion = hbConfig.arcgisVersion || (esri && esri.version) || "1.5";

// CONFIGURATION PROPERTIES

hbConfig.arcgisUrl = 'http://services.maps.lt/arcgis_js_api/library/'+hbConfig.arcgisVersion+'/arcgis/';
hbConfig.baseUrl = '//services.maps.lt/maps_js_api/'+hbConfig.version+'/'; // workaround for bug http://bugs.dojotoolkit.org/ticket/9816
hbConfig.servicesUrl = 'http://services.maps.lt/mapsk/';
hbConfig.servicesAoUrl = 'http://services.maps.lt/maps_services_ao/';
hbConfig.servicesProxyUrl = 'http://services.maps.lt/mapsk_services/';
hbConfig.adsImagesUrl = 'http://www.maps.lt/map/images/_ads/';
hbConfig.layerDefs = {
    vector: {
        title: {lt:'Žemėlapis', en:'Map'},
        url: 'http://services.maps.lt/mapsk_services/mapslt/MapServer',
        tilesUrls: ['http://dc1.maps.lt/cache/mapslt'],
        group: 'bg',        
		alt: {id:"vector_2_5d", extent:{xmin:565000,ymin:6048700,xmax:596600,ymax:6077900}, minScale:6000},
        visible:true
    },    
	vector_2_5d: {
        title: {lt:'2.5D Vilniaus žemėlapis (beta)', en:'2.5D Vilnius map (beta)'},
        url: 'http://www.maps.lt/maps_services/vilnius_25d/MapServer',
        tilesUrls: ['http://dc1.maps.lt/cache/vilnius_25d'],
        visible:true
    },
    orthophoto: {
        title: {lt:'Ortofoto', en:'Orthophoto'},
        url: 'http://services.maps.lt/mapsk_services/mapslt_ortofoto/MapServer',
        tilesUrls: [
            'http://dc1.maps.lt/cache/mapslt_ortofoto'
        ],
        group:'bg'
    },
    hybrid: {
        title: {lt:'Mišrus', en:'Hybrid'},
        url: 'http://services.maps.lt/mapsk_services/mapslt_ortofoto/MapServer',
        tilesUrls: [
            'http://dc1.maps.lt/cache/mapslt_ortofoto'
        ],
        group: 'bg',
        children: ['hybrid_overlay']
    },
    hybrid_overlay: {
        url:'http://services.maps.lt/mapsk_services/mapslt_ortofoto_overlay/MapServer',
        tilesUrls: [
            'http://dc1.maps.lt/cache/mapslt_ortofoto_overlay'
        ],
        visible:true
    },
    relief: {
        title: {lt:'Reljefas', en:'Relief'},
        url: 'http://services.maps.lt/mapsk_services/mapslt_relief/MapServer',
		tilesUrls: [
            'http://dc1.maps.lt/cache/mapslt_relief'
        ],
        group: 'bg'
    },
    hotels: {
        title: {lt:'Viešbučiai, kavinės, laisvalaikio objektai', en:'Hotels, cafes, leisure objects'},
        url: 'http://services.maps.lt/mapsk_services/mapslt_hotels/MapServer',
        tilesUrls: ['http://www.maps.lt/cache/mapslt_hotels']
    },
    other: {
        title: {lt:'Kiti objektai', en:'Other objects'},
        url: 'http://services.maps.lt/mapsk_services/mapslt_other/MapServer',
        tilesUrls: ['http://www.maps.lt/cache/mapslt_other']
    },
    topo: {
        title: {lt:'Topinimika', en:'Toponymics'},
        url: 'http://services.maps.lt/mapsk_services/mapslt_topo/MapServer',
        type: 'dynamic'
    }
};
hbConfig.copyrights = {
    author: "© UAB Hnit-Baltic, " + (new Date()).getFullYear(),
    link: "http://www.maps.lt/apie/autorines",
    providers: [
        "© Anykščių rajono savivaldybė, 2001",
        "© SĮ Panevėžio planas, 2000",
        "© SĮ Vilniaus planas, 2001",
        "LTDBK50000-V © Nacionalinė žemės tarnyba prie ŽŪM, 1996-2005",
        "ORT10LT © Nacionalinė žemės tarnyba prie ŽŪM, 2005-2006",
        "Adresų ir gatvių duomenys &copy; VĮ Registrų Centras, 2009",
        "Lietuvos Respublikos saugomų teritorijų valstybės kadastro duomenys <br />&copy; Valstybinė saugomų teritorijų tarnyba prie Aplinkos ministerijos, 2008"
    ]
};

hbConfig.configScriptLocations = ['http://localhost', 'http://services.maps.lt'];


// CONFIGURATION ACTIONS

// Update dojo config
if (typeof dojo == 'undefined'){
    if (typeof djConfig == 'undefined') djConfig = {};
    if (!djConfig.baseUrl) djConfig.baseUrl = hbConfig.arcgisUrl + 'dojo/';
    if (typeof djConfig.modulePaths == 'undefined') djConfig.modulePaths = {};
    djConfig.modulePaths.hb = hbConfig.baseUrl + 'js/hb';
    djConfig.locale = 'lt';
} else {
	if (!dojo.baseUrl) dojo.baseUrl = hbConfig.arcgisUrl + 'dojo/';
    dojo.registerModulePath('hb', hbConfig.baseUrl + 'js/hb');
}
hbConfig.client='jcd';
/*
	Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


if(!dojo._hasResource["hb.hb"]){dojo._hasResource["hb.hb"]=true;dojo.provide("hb.hb");dojo.require("dojo.io.script");dojo.require("dojox.io.xhrWindowNamePlugin");dojo.require("hb.TiledMapServiceLayer");if(typeof hb==="undefined"){hb={};}dojo.mixin(hb,{init:function(){try{hb.tipSize={width:180,height:100};hb.enableAnim=true;hb.tr=hb.label;var _1=hb._getConfigScriptParams();if(!hbConfig.client){hbConfig.client=_1.cl;}dojo.mixin(hb,hbConfig);dojo.addOnLoad(hb,hb._onLoad);hb.toggleAnim(this.enableAnim);}catch(e){hb.err(e);}},toggleAnim:function(_2){var _3=esriConfig.defaults.map;_3.panRate=_2?2:0;_3.panDuration=_2?180:1;_3.zoomRate=_2?2:0;_3.zoomDuration=_2?180:1;},filter:function(_4,_5){var _6={};for(i in _4){if(_5(_4[i],i)){_6[i]=_4[i];}}return _6;},construct:function(_7,_8){var _9=dojo.getObject(_7);function F(){return _9.apply(this,_8);};F.prototype=_9.prototype;return new F();},distance:function(p0,p1){var x0=p0.x||p0[0];var y0=p0.y||p0[1];var x1=p1.x||p1[0];var y1=p1.y||p1[1];var dx=x1-x0;var dy=y1-y0;return Math.sqrt(dy*dy+dx*dx);},encode:function(s){s=encodeURIComponent(s);s=s.replace(/\'/g,"&#39;");return s;},urlParams:function(url){var i=url.indexOf("?");if(i===-1){i=url.indexOf("#");}if(i===-1){return {};}var _16=url.substring(i+1).replace("#","&");var _17={};var _18=_16.split("&");for(var j=0; j<_18.length; j++){var _1a=_18[j];var i=_1a.indexOf("=");if(i<1){continue;}var key=decodeURIComponent(_1a.substr(0,i));var val=decodeURIComponent(_1a.substring(i+1)).replace(/\+/g," ");if(val.charAt(0)==="["&&val.charAt(val.length-1)==="]"){var _1d=val.substr(1,val.length-2);if(_1d){val=_1d.split(",");}else{val=[];}}_17[key]=val;}return _17;},formatDist:function(_1e){_1e=Math.round(_1e);if(Math.abs(_1e)<1000){return _1e+"&nbsp;m";}else{_1e=_1e/1000;var _1f={places:Math.abs(_1e)<10?2:(Math.abs(_1e)<100?1:0)};return dojo.number.format(_1e,_1f)+"&nbsp;km";}},formatTime:function(_20){var h=Math.floor(_20/60);var min=Math.round(_20-h*60);var _23=dojo.i18n.getLocalization("hb","mapslt_api");return (h?h+" "+_23.hours+" ":"")+min+" "+_23.minutes;},scale:function(_24){if(_24 instanceof esri.Map){var _25=_24.getLayer(_24.layerIds[0]);return _25.tileInfo.lods[_24.getLevel()].scale;}else{if(_24.extent&&(_24.width||_24.height)){var _26=_24.width?_24.extent.getWidth()/_24.width:_24.extent.getHeight()/_24.height;return _26*96/0.0254;}}this.warn("hb.scale: bad 'param' argument",_24);return NaN;},level:function(_27){if(_27 instanceof esri.Map){return _27.getLevel();}else{if(_27.map&&_27.scale){var _28=0;var _29=_27.map.getLayer(_27.map.layerIds[0]);var _2a=_29.tileInfo.lods;for(var i in _2a){if(Math.abs(_2a[_28].scale-_27.scale)>Math.abs(_2a[i].scale-_27.scale)){_28=i;}}return _28;}}this.warn("hb.level: bad 'param' argument",_27);return NaN;},extent:function(_2c){if(_2c.center&&_2c.scale&&_2c.width&&_2c.height){var _2d=_2c.scale*0.0254/96;var _2e=new esri.geometry.Extent(0,0,_2d*_2c.width,_2d*_2c.height);return _2e.centerAt(_2c.center);}this.warn("hb.extent: bad 'param' argument",_2c);return null;},center:function(_2f){if(_2f instanceof esri.geometry.Point){return _2f;}if(_2f instanceof esri.geometry.Polyline){var _30=Math.floor((_2f.paths.length-1)/2);var _31=Math.floor((_2f.paths[_30].length-1)/2);return _2f.getPoint(_30,_31);}if(_2f instanceof esri.geometry.Polygon){return _2f.getExtent().getCenter();}if(_2f instanceof esri.geometry.Extent){return _2f.getCenter();}throw "hb.center(): unsupported geometry type "+typeof _2f;},infoWindow:function(map){var _33=map.infoWindow;var iw=dojo.getObject("hb.dijit.InfoWindow");if(iw&&iw.get(map)){_33=iw.get(map);}return _33;},label:function(arg){if(dojo.isString(arg)){return arg;}var _36=dojo.locale;if(arg[_36]){return arg[_36];}_36=_36.substr(0,2);if(_36.length>2&&arg[_36]){return arg[_36];}for(var i in arg){return arg[i];}},log:function(){if(console){try{var f=arguments.callee.caller;console.log(f.name||"function",": ",f.arguments);}catch(e){hb.err(e);}}},stack:function(e){var s=[];var fns=[];var _3c=arguments.callee.caller;while(_3c){if(dojo.indexOf(fns,_3c)!==-1){break;}fns.push(_3c);var fn=_3c.toString();s.push(fn);_3c=_3c.caller;}return s;},err:function(e){if(console){var out=e;if(dojo.isIE){var out=[e.message,""];out=out.concat(hb.stack(e)).join("\n");}if(console.error&&dojo.isFunction(console.error)){console.error(e,out);}else{console.log(out);}}},warn:function(){if(console){if(console.warn&&dojo.isFunction(console.warn)){console.warn(arguments);}else{console.log(arguments);}}},print:function(map){hb.printDirections(map,null);},printDirections:function(map,_42){var _43=hb._getMapState(map);if(_42){var _44=_42.getDirectionsPrintInfo();if(_44){_43.directions=_44;}}var _45="hbPrint_"+Math.round(Math.random()*10000);window.open("",_45);var _46=dojo.create("form",{action:hb.servicesUrl+"print.aspx?lang="+dojo.locale,method:"POST",target:_45},dojo.body());dojo.create("input",{name:"state",value:dojo.toJson(_43),type:"hidden"},_46);_46.submit();dojo.destroy(_46);},addMapsltLayer:function(map,_48,_49){var _4a=hb.layerDefs;if(_4a&&_4a[_48]){var _4b=hb.createLayer(_48,_4a[_48],_49);map.addLayer(_4b);hb._updateCopyright(map,1);_4b._hbVisChangeEv=dojo.connect(_4b,"onVisibilityChange",function(_4c){hb._updateCopyright(map,_4c?1:-1);});_4b._hbRemoveEv=dojo.connect(map,"onLayerRemove",function(l){if(l.id!==_4b.id){return;}dojo.disconnect(_4b._hbVisChangeEv)&&(_4b._hbVisChangeEv=null);dojo.disconnect(_4b._hbRemoveEv)&&(_4b._hbRemoveEv=null);});return _4b;}else{throw {message:"Invalid maps.lt layer name: "+_48,layerDefs:_4a};}},createLayer:function(id,_4f,_50){var url=_4f.url;if(hb.client){url+=(url.indexOf("?")==-1?"?cl=":"&cl=")+hb.client;}var _52={id:id,visible:true,opacity:_4f.opacity};if(_50){dojo.mixin(_52,_50);}if(_4f.type=="dynamic"){layer=new esri.layers.ArcGISDynamicMapServiceLayer(url,_52);if(_4f.filters){layer.setLayerDefinitions(_4f.filters);}}else{if(_4f.tilesUrls){_52.tilesUrls=_4f.tilesUrls;layer=new hb.TiledMapServiceLayer(url,_52);}else{layer=new esri.layers.ArcGISTiledMapServiceLayer(url,_52);}}return layer;},_logStat:function(_53){if(document.location.host!="localhost"){dojo.xhrPost({url:hb.servicesUrl+"statistics.ashx",content:{action:_53,cl:hb.client,token:hb.token}});}},_onLoad:function(){dojox.io.xhrWindowNamePlugin(hb.servicesUrl);setTimeout(function(){hb._logStat("mapShown");},1000);hb.toggleAnim(hb.enableAnim);var s=dojo.body().style;if(!(s.WebkitBoxShadow!==undefined||s.MozBoxShadow!==undefined||s.BoxShadow!==undefined||s.boxShadow!==undefined)){dojo.addClass(dojo.body(),"hbNoShadows");}if(hb.Territories&&hb.Territories.init){hb.Territories.init(hb.territories);}if(hb.Classes&&hb.Classes.init){hb.Classes.init(hb.classes);}},_checkAuthorization:function(_55){if(_55&&_55.statusCode==2){var _56=dojo.byId("copyright");_56.innerHTML="<img src='"+hb.baseUrl+"images/alert.png' class='png' style='vertical-align:bottom' /> "+b.innerHTML;}},_updateCopyright:function(map,_58){var _59=dojo.query(".hb-copyright",map.container);if(!_59||!_59.length){_59=dojo.doc.createElement("div");dojo.attr(_59,{innerHTML:"&copy; "+(new Date()).getFullYear()+", UAB Hnit-Baltic"+", <a href=\"http://www.maps.lt/apie/autorines\" target=\"_blank\">"+hb.tr({lt:"Duomenų tiekėjai",en:"Data providers"})+"</a>"+" <img src=\""+hb.baseUrl+"/images/maps_44x15.png\" alt=\"\" class=\"png\" style=\"position:relative; bottom:-4px\" />","class":"hb-copyright",style:{position:"absolute",right:0,bottom:0,margin:"2px",fontSize:"10px",zIndex:100,color:"black",textShadow:"0.1em 0 0.2em white"}});dojo.place(_59,map._root||map.__root||dojo.byId(map.id+"_root"));map._hbCopyrightCounter=0;}else{_59=_59[0];}map._hbCopyrightCounter+=_58;dojo.style(_59,"display",map._hbCopyrightCounter>0?"":"none");},_addStylesheet:function(url,_5b){if(!hb._stylesheets){hb._stylesheets=[];}if(!hb._stylesheets[url]){var _5c=document.createElement("link");_5c.setAttribute("type","text/css");_5c.setAttribute("rel","stylesheet");if(!/^http:\/\//.test(url)){url=hb.baseUrl+url;}_5c.setAttribute("href",url);document.getElementsByTagName("head")[0].appendChild(_5c);if(_5b){_5c.onload=_5b;}hb._stylesheets.push(url);}},_getMapState:function(map){var _5e,_5f=[],_60=[],_61=map.graphics.graphics;var _62=map.getLayer(map.layerIds[0]);if(_62.tileInfo){_5e=[];dojo.forEach(_62.tileInfo.lods,function(lod){_5e.push({level:lod.level,resolution:lod.resolution,scale:lod.scale});});}var _64=this;dojo.forEach(map.layerIds,function(_65){_5f.push(_64._getLayerState(map.getLayer(_65)));});dojo.forEach(_61,function(_66){var _67=_66.geometry;if(_67 instanceof esri.geometry.Point){if(!map.extent.contains(_67)){return;}}else{if(!map.extent.intersects(_67.getExtent())){return;}}var gfx=_66.toJson();if(_66.symbol instanceof esri.symbol.PictureMarkerSymbol){gfx.symbol.width=_66.symbol.width;gfx.symbol.height=_66.symbol.height;}delete gfx.attributes;_60.push(gfx);});return {extent:map.extent.toJson(),scale:this.scale(map),lods:_5e,layers:_5f,graphics:_60};},_getLayerState:function(_69){var _6a=null;if(_69.tileInfo){_6a=[];dojo.forEach(_69.tileInfo.lods,function(lod){_6a.push(lod.scale);});}var _6c={id:_69.id,type:_69.declaredClass,url:_69.url,visible:_69.visible,opacity:_69.opacity,layerDefs:_69.layerDefinitions||null,layers:_69.visibleLayers||null,scales:_6a,format:_69.imageFormat||_69.tileInfo.format};return _6c;},_getConfigScriptParams:function(){if(!hbConfig||!hbConfig.configScriptLocations){return {};}var _6d=new RegExp("^("+hbConfig.configScriptLocations.join("|")+").*\\/mapslt_config(_\\w+)?\\.js(\\?(.*))?");var _6e=document.getElementsByTagName("script");for(var i=0; i<_6e.length; i++){var url=_6e[i].src;if(!url){continue;}if(url.match(_6d)){return hb.urlParams(url);}}return {};}});hb.init();}hb._addStylesheet('css/default.css');