var lon=19.56;var lat=48.73;var zoom=8;var maxZoom=15;var topoZooms=3;var fullscreen=false;var gpxLoadedFromUrl=false;var lastZoom=false;var poiLayers=new Array();var hpMarkers=new Array();var tztResolutions=[76.43702827148438,38.21851413574219,19.109257067871095,9.554628533935547,4.777314266967774];var poiResolutions=[152.87405654296876,76.43702827148438,38.21851413574219,19.109257067871095,9.554628533935547,4.777314266967774];var lavinyResolutions=[19.109257067871095,9.554628533935547,4.777314266967774];var topoResolutions=[38.21851413574219,19.109257067871095,9.554628533935547,4.777314266967774];var map,layer,formats,drawControls,selectControl,overview,fPos,selectedFeature,stylePointer,results_count,projWGS;var projGoogle,alert;var bGPhy,bGSat,bTOPO;var lVectors,lFeatures,lTZT,lPoints,lLines,lChaty,lLimba,lFoto,lGC,lLaviny,lHPtracks,lHPdraw;var selectChata,selectLimba,selectFoto,selectGC;var contextMenuPopup,positionFeature,oClick,kbDefaults,hpTrackFeatures,hpTrackFeaturesBounds,hpUploadedFeatures,hpUploadedFeatures;var fileUploadContent="";var featuresToKeep,uploadFileExt;var hpFirstTrackFeature=new Object();var urlDefault='http://mapy.hiking.sk/';var urlDefaultDocument='';var urlRouteParam="?trasa=";var gaLayerLogged=new Array();var gaEventLogged=new Array();var HikingMaps={VERSION_NUMBER:"Release 3.0.0",_getScriptLocation:(function(){var r=new RegExp("(^|(.*?\\/))(OpenLayers\.js)(\\?|$)"),s=document.getElementsByTagName('script'),src,m,l="";for(var i=0,len=s.length;i<len;i++){src=s[i].getAttribute('src');if(src){var m=src.match(r);if(m){l=m[1];break;}}}
return(function(){return l;});})()};var uiText=new Array();uiText['attribTOPO']='Topografický podklad © SHOCart';uiText['attribTZT']='Značky a rázcestia © HIKING.SK';uiText['attribLaviny']='Lavínová mapa © HZS, HIKING.SK';uiText['cPermalink']='Stály odkaz';uiText['cBaseLbl']='Podkladová mapa';uiText['cDataLbl']='Vrstvy';uiText['lNameGPhy']='Terén - Google';uiText['lNameGSat']='Satelit - Google';uiText['lNameTOPO']='Turistická mapa - SHOCart';uiText['lNameTZT']='Turistické chodníky';uiText['lNameChaty']='Chaty, útulne, salaše, búdy';uiText['lNameFoto']='Fotografie z <a href="http://hiking.sk/hk/li/sluzby-galeria.html" target="_blank">Galérie</a>';uiText['lNameLaviny']='Lavínové dráhy';uiText['lNamePramene']='Pramene';uiText['lNameGC']='Geocaching skrýše';uiText['lNameHrady']='Hrady, zámky, zrúcaniny';uiText['lNamePralesy']='Pralesy';uiText['uiCoordsTitle']='GPS súradnica';uiText['uiPermalinkTooltip']='Tip: stály odkaz môžeš poslať svojim priateľom, aby sa dostali na túto pozíciu v mape automaticky.';uiText['uiAddPhotoTitle']='Pridaj fotku do Galérie';uiText['uiAddPhotoDesc']='<p>Kliknutím na doleuvedené tlačítko sa po odsúhlasení pravidiel otvorí pridávací formulár používateľskej '
+'<a href="http://hiking.sk/hk/li/sluzby-galeria.html" target="_blank">Galérie HIKING.SK</a> s predvyplnenou súradnicou '
+'vybraného bodu. Aby všetko fungovalo musíš byť registrovaný a prihlásený.</p>'
+'<p>Galéria má dve hlavné úlohy – zhromažďovať fotky výstavného charakteru a reportážne fotky, ktoré'
+'používateľom uľahčia orientáciu, či plánovanie túr.</p>'
+'<p>Po úspešnom pridaní sa fotka bude zobrazovať aj tu na Turistickej Mape.</p>';uiText['uiAddPhotoButton']='Pridaj fotku';uiText['uiAddPOITitle']='Pridaj bod do GPS databázy';uiText['uiAddPOIDesc']='<p>Kliknutím na doleuvedené tlačítko sa otvorí pridávací formulár používateľskej '
+'<a href="http://hiking.sk/hk/li/sluzby-gps_databaza.html" target="_blank">GPS databázy</a> s predvyplnenou súradnicou '
+'vybraného bodu. Aby všetko fungovalo musíš byť registrovaný a prihlásený.</p>'
uiText['uiAddPOIButton']='Pridaj bod';uiText['uiReportBugTitle']='Chyba v mape?';uiText['uiReportBugDesc']='<p>Ak sa podľa teba v mape nachádza chyba, budeme radi, keď nám o tom napíšeš. Naprv však identifikuj, v ktorej vrstve je problém a podľa toho postupuj.</p>'
+'<p><b>Zlý priebeh turistickej značky?</b><br />Vrstvu turistických značiek spravuje Hiking.sk a svoje podnety smeru do tohto <a href="http://hiking.sk/hk/fo/6280/turisticke_znackovane_trasy.html" target="_blank">diskusného fóra</a>. Pokiaľ máš aj GPS tracklog, uľahčíš nám prácu, keď nám ho pošleš.</p>'
+'<p><b>Chyba v správaní sa mapy?</b><br />Keď sa používateľské rozhranie mapy chová divne alebo nefunguje, napíš nám o tom do tohto <a href="http://hiking.sk/hk/fo/3451/turistickamapask_forum.html" target="_blank">diskusného fóra</a>.</p>'
+'<p><b>Nezrovnalosti v podklade?</b><br />Ak sú chyby v turistickom topografickom podklade, smeruj svoje podnety <a href="http://www.shocart.cz/" target="_blank">vydavateľstvu SHOCart</a>, ktoré je jeho autorom.</p>'
+'<p>Ďakujeme za pomoc pri vylepšovaní mapy,<br /><i>Hiking.sk team</i></p>';uiText['uiQueryLavinyTitle']='Vrstva lavínových dráh';uiText['uiQueryLavinyDesc']='<p>Doplňujúce informácie o lavínových dráhach v mieste, ktoré bolo označené na mape:</p>';uiText['uiQueryLavinyFooter']='<p>Viac informácií o lavínovej problematike nájdete na <a href="http://www.laviny.sk" target="_blank">www.laviny.sk</a>.</p>'
+'<p>Táto vrstva je vytvorená v spolupráci s Horskou záchrannou službou. Je informatívna a jej použitie je na vlastnú zodpovednosť. '
+'<a href="#" class="dialog lLaviny terms">Detailné podmienky použitia</a></p>'
+'<p>Pozor: pokrytie tejto vrstvy zahŕňa výhradne územie Slovenska.</p>';uiText['uiTerms']='Podmienky použitia';uiText['uiHPoutOfRange']='V blízkosti zvoleného bodu sa nenachádza žiadne rázcestie.';uiText['uiHPerrNoStart']='Chýba začiatočné rázcestie.';uiText['uiHPerrNoEnd']='Chýba konečné rázcestie.';uiText['uiHPerrNoThru']='Začiatok a koniec trasy je v rovnakom bode, musíš preto zadať aspoň jeden medzibod.';uiText['uiHPerrEqThru']='Po sebe idúce medzibody nesmú byť identické.';uiText['uiHPerrStartThru']='Prvý medzibod je zhodný so začiatočným rázcestím.';uiText['uiHPerrEndThru']='Posledný medzibod je zhodný s konečným rázcestím.';uiText['uiHPerrNoOpt']='Nebolo zadané optimalizačné kritérium.';uiText['uiHPprintTitle']='Trasa podľa služby HIKEPLANNER';uiText['uiHPprintDetails']='Tlač detailný rozpis';uiText['uiHPsaved']='Uložená trasa z Hikeplannera';uiText['badBrowser']="Tvoj prehliadač nepodporuje požadovanú funkčnosť. Pre plné využitie mapy skús radšej aktuálnu verziu jedného z nasledovných prehliadačov: Chrome, Safari, Firefox.";uiText['buttonCancel']="Zrušiť";uiText['buttonSave']="Uložiť";uiText['buttonClose']="Zavrieť";uiText['formInputError']="Formulár nie je správne vyplnený. Skontroluj, či sú vyplnené všetky polia.";uiText['uploadFormatError']="Zaslaný súbor sa nepodarilo korektne interpretovať. Skotroluj, či je správny formát.";uiText['uploadWrongExt']="Podporované sú iba súbory GPX a KML";uiText['uploadSuccess']="Odoslaný súbor bol úspešne spracovaný. Pomocou záložky \"kresliť a editovať\" môžeš pridané prvky editovať a/alebo uložiť pre ďalšie zdieľanie.";uiText['uploadNoFile']="Musíš vybrať súbor!";uiText['featureProcessing']="Spracovávam dáta...";uiText['featurePoint']="Bod";uiText['featureLine']="Etapa";uiText['featurePolygon']="Plocha";uiText['featureOther']="Iné";uiText['featureEditTip1']="Tip: názov možno zmeniť kliknutím naň.";uiText['featureLengthTotal']="Celková dĺžka etáp:";uiText['featureSaveErr1']="Nie sú zadané žiadne prvky.";uiText['featureSaveErr2']="Názov musí mať aspoň 4 znaky.";uiText['featureSaveSuccess']="<b>Trasa bola uložená.</b> Priateľom môžeš zaslať tento stály link: ";uiText['featureSavedTitle']="Uložená trasa";uiText['featureSavedDist']="dĺžka";uiText['featureSavedClimb']="stúpanie";uiText['featureSavedDescent']="klesanie";uiText['featureSavedStage']="etapa";uiText['featureSavedStages1']="etapy";uiText['featureSavedStages2']="etáp";uiText['featureSavedAcCount']="zobrazené";uiText['featureSavedSaved']="uložené";uiText['featureSavedEdit']="editovať";uiText['featureSavedDistSum']="celková dĺžka";uiText['userNotLoggedIn']="Táto funkcia je prístupná iba prihláseným používateľom.";uiText['alertTitle']="Upozornenie";uiText['pralesyDescIntro']="Detailný popis a fotografie tejto lokality je k dispozíciii na tejto adrese:";uiText['pralesyTitleSingle']="Prales";HikingMaps.isLoggedIn=function(){return isNumber($('#uid').text());}
HikingMaps._GETvar=function(q){get_string=document.location.search.replace("[]","%5B%5D");q=q.replace("[]","%5B%5D");return_value='';var ii=0;do{name_index=get_string.indexOf(q+'=');if(name_index!=-1){get_string=get_string.substr(name_index+q.length+1,get_string.length-name_index);end_of_value=get_string.indexOf('&');if(end_of_value!=-1)
value=get_string.substr(0,end_of_value);else
value=get_string;if(return_value==''||value=='')
return_value+=value;else
return_value+=', '+value;ii++;}}while(name_index!=-1)
space=return_value.indexOf('+');while(space!=-1){return_value=return_value.substr(0,space)+' '+
return_value.substr(space+1,return_value.length);space=return_value.indexOf('+');}
return(return_value);}
function isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n);}
function formatPosition(lonlat,type,decimals){var out=new Object();var dec=Math.pow(10,decimals);if(type=="decimal"){out.lon="E"+Math.round(lonlat.lon*dec)/(dec);out.lat="N"+Math.round(lonlat.lat*dec)/(dec);}else if(type=="minutes"){var degLon=Math.floor(lonlat.lon);var degLat=Math.floor(lonlat.lat);var minLon=Math.round(60*(lonlat.lon-degLon)*dec)/(dec);var minLat=Math.round(60*(lonlat.lat-degLat)*dec)/(dec);out.lon="E"+degLon+'°'+minLon+"'";out.lat="N"+degLat+'°'+minLat+"'";}else if(type=="decimal_number"){out.lon=Math.round(lonlat.lon*dec)/(dec);out.lat=Math.round(lonlat.lat*dec)/(dec);}
return out;}
HikingMaps.setHighlightDiv=function(targetSelector,messageHtml){$('body > div.default-highlight').clone().removeClass('.default-hightlight').appendTo(targetSelector).show().find('.message').html(messageHtml);}
HikingMaps.setErrorDiv=function(targetSelector,messageHtml){$('body > div.default-error').clone().removeClass('.default-error').appendTo(targetSelector).show().find('.message').html(messageHtml);}
HikingMaps.alert=function(messageHtml,title){title=typeof(title)!='undefined'?title:uiText['alertTitle'];var elemId='alertDiv';$('body').append('<div style="display: none" id="'+elemId+'" title="'+title+'">'+messageHtml+'</div>');$('#'+elemId).dialog({modal:true,height:200,width:350,buttons:[{text:"OK",click:function(){$(this).dialog("close");}}],close:function(){$('#'+elemId).remove();}});}
HikingMaps._updateFormats=function(){var in_options={'internalProjection':map.baseLayer.projection,'externalProjection':new OpenLayers.Projection("EPSG:4326")};var out_options={'internalProjection':map.baseLayer.projection,'externalProjection':new OpenLayers.Projection("EPSG:4326")};var gmlOptions={featureType:"feature",featureNS:"http://example.com/feature"};var gmlOptionsIn=OpenLayers.Util.extend(OpenLayers.Util.extend({},gmlOptions),in_options);var gmlOptionsOut=OpenLayers.Util.extend(OpenLayers.Util.extend({},gmlOptions),out_options);HikingMaps.formats={'in':{wkt:new OpenLayers.Format.WKT(in_options),gml2:new OpenLayers.Format.GML.v2(gmlOptionsIn),gml3:new OpenLayers.Format.GML.v3(gmlOptionsIn),kml:new OpenLayers.Format.KML(in_options),gpx:new OpenLayers.Format.GPX(in_options),json:new OpenLayers.Format.GeoJSON(in_options)},'out':{wkt:new OpenLayers.Format.WKT(out_options),gml2:new OpenLayers.Format.GML.v2(gmlOptionsOut),gml3:new OpenLayers.Format.GML.v3(gmlOptionsOut),kml:new OpenLayers.Format.KML(out_options),gpx:new OpenLayers.Format.GPX(out_options),json:new OpenLayers.Format.GeoJSON(out_options)}};}
function getParameterFromStringByName(name,string)
{name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(string);if(results==null)
return"";else
return decodeURIComponent(results[1].replace(/\+/g," "));}
HikingMaps.Layers=function(){}
HikingMaps.Layers.add=function(){bGPhy=new OpenLayers.Layer.Google(uiText['lNameGPhy'],{type:google.maps.MapTypeId.TERRAIN,sphericalMercator:true,isBaseLayer:true,animationEnabled:false});bGSat=new OpenLayers.Layer.Google(uiText['lNameGSat'],{type:google.maps.MapTypeId.HYBRID,sphericalMercator:true,isBaseLayer:true,animationEnabled:false});bTOPO=new OpenLayers.Layer.XYZ(uiText['lNameTOPO'],"http://mapy.hiking.sk/layers/topo/${z}/${x}/${y}.png",{attribution:uiText['attribTOPO'],sphericalMercator:true,buffer:1,transitionEffect:'resize',isBaseLayer:true});lTZT=new OpenLayers.Layer.TileCache(uiText['lNameTZT'],"http://mapy.hiking.sk/layers/","tzt",{attribution:uiText['attribTZT'],sphericalMercator:true,buffer:0,resolutions:tztResolutions,isBaseLayer:false});lLaviny=new OpenLayers.Layer.TileCache(uiText['lNameLaviny'],"http://mapy.hiking.sk/layers/","laviny",{attribution:uiText['attribLaviny'],sphericalMercator:true,buffer:0,resolutions:lavinyResolutions,isBaseLayer:false,visibility:false,eventListeners:{"visibilitychanged":HikingMaps.Layers.onVisibilityChanged}});lChaty=HikingMaps.Layers.getPoi('clanky_chaty',uiText['lNameChaty'],150);lFoto=HikingMaps.Layers.getPoiCluster('foto',uiText['lNameFoto'],1000);lPramene=HikingMaps.Layers.getPoi('pramene',uiText['lNamePramene'],150);lGC=HikingMaps.Layers.getPoi('geocache',uiText['lNameGC'],200);lHrady=HikingMaps.Layers.getPoi('hrady',uiText['lNameHrady'],150);lPralesy=HikingMaps.Layers.getKML('pralesy',uiText['lNamePralesy']);styleMap=HikingMaps.Styles.gpx();styleMap2=HikingMaps.Styles.basic();styleHPtrack=HikingMaps.Styles.hpTrack();styleHPdraw=HikingMaps.Styles.hpDraw();lVectors=new OpenLayers.Layer.Vector("GPX imports",{styleMap:styleMap,displayInLayerSwitcher:false});lHPtracks=new OpenLayers.Layer.Vector("Hikeplanner routes",{styleMap:styleHPtrack,displayInLayerSwitcher:false});lHPdraw=new OpenLayers.Layer.Vector("Drawed features",{styleMap:styleHPdraw,displayInLayerSwitcher:false});lFeatures=new OpenLayers.Layer.Vector("Features",{styleMap:styleMap2,displayInLayerSwitcher:false});lMarkers=new OpenLayers.Layer.Markers("Markers",{displayInLayerSwitcher:false});poiLayers=[lChaty,lFoto,lPramene,lGC,lHrady];map.addLayers([bGPhy,bGSat,bTOPO,lPralesy,lLaviny,lHPtracks,lTZT,lHPdraw,lVectors,lFeatures,lChaty,lFoto,lPramene,lGC,lHrady,lMarkers]);selectControl=new OpenLayers.Control.SelectFeature([lChaty,lFoto,lPramene,lGC,lHrady,lPralesy],{clickout:true,toggle:true,multiple:false,hoover:false});map.addControl(selectControl);drawControls={point:new OpenLayers.Control.DrawFeature(lHPdraw,OpenLayers.Handler.Point),line:new OpenLayers.Control.DrawFeature(lHPdraw,OpenLayers.Handler.Path),polygon:new OpenLayers.Control.DrawFeature(lHPdraw,OpenLayers.Handler.Polygon),modify:new OpenLayers.Control.ModifyFeature(lHPdraw)};for(var key in drawControls){map.addControl(drawControls[key]);}
HikingMaps.Layers.setEventHandlers();selectControl.activate();HikingMaps.Layers.onChangeBaseLayer();}
HikingMaps.Layers.onChangeBaseLayer=function(){if(map.baseLayer==bGSat){$(".olControlAttribution").addClass('bGSat');}else{$(".olControlAttribution").removeClass('bGSat');}}
HikingMaps.Layers.getPoi=function(typename,caption,maxfeatures){return new OpenLayers.Layer.Vector(caption,{strategies:[new OpenLayers.Strategy.BBOX({ratio:1})],protocol:new OpenLayers.Protocol.HTTP({url:"http://mapy.hiking.sk/wfs/get_gml.php?",params:{TYPENAME:typename,MAXFEATURES:maxfeatures,SRS:'EPSG:4326'},format:new OpenLayers.Format.GML({extractAttributes:true})}),styleMap:HikingMaps.Styles.poi(),projection:'EPSG:4326',visibility:false,resolutions:poiResolutions,eventListeners:{"visibilitychanged":HikingMaps.Layers.onVisibilityChanged}});}
HikingMaps.Layers.getKML=function(typename,caption){return new OpenLayers.Layer.Vector(caption,{strategies:[new OpenLayers.Strategy.BBOX({ratio:1})],protocol:new OpenLayers.Protocol.HTTP({url:"http://mapy.hiking.sk/wfs/kml.php?",params:{type:typename,SRS:'EPSG:4326'},format:new OpenLayers.Format.KML({extractAttributes:true})}),styleMap:HikingMaps.Styles.kml(typename),projection:'EPSG:4326',visibility:false,resolutions:poiResolutions,eventListeners:{"visibilitychanged":HikingMaps.Layers.onVisibilityChanged}});}
HikingMaps.Layers.getPoiCluster=function(typename,caption,maxfeatures){return new OpenLayers.Layer.Vector(caption,{strategies:[new OpenLayers.Strategy.BBOX(),new OpenLayers.Strategy.Cluster()],protocol:new OpenLayers.Protocol.HTTP({url:"http://mapy.hiking.sk/wfs/get_gml.php?",params:{TYPENAME:typename,MAXFEATURES:maxfeatures,SRS:'EPSG:4326'},format:new OpenLayers.Format.GML({extractAttributes:true})}),styleMap:HikingMaps.Styles.poiCluster(),projection:'EPSG:4326',visibility:false,resolutions:poiResolutions,renderers:["Canvas","SVG","VML"]});}
HikingMaps.Layers.forceRefresh=function(layer){if(layer.getVisibility()){layer.loaded=false;layer.setVisibility(true);layer.refresh({force:true});}}
HikingMaps.Layers.onVisibilityChanged=function(event){logName="";switch(event.object){case lLaviny:if(event.object.visibility==true){HikingMaps.dialog('#lLavinyDiscailmerDiv');}
logName='lLaviny';break;case lChaty:logName='lChaty';break;case lFoto:logName='lFoto';break;case lPramene:logName='lPramene';break;case lGC:logName='lGC';break;case lHrady:logName='lHrady';break;case lPralesy:logName='lPralesy';break;}
if(event.object.visibility==true&&logName!=""){if(gaLayerLogged[logName]!=1){_gaq.push(['_trackEvent','mapa','layer',logName]);gaLayerLogged[logName]=1;}}}
HikingMaps.dialog=function(selector,dWidth,dHeight){var width=typeof(dWidth)!='undefined'?dWidth:450;var height=typeof(dHeight)!='undefined'?dHeight:350;$(selector).dialog({autoOpen:true,height:height,width:width,modal:true,buttons:{"OK":function(){$(this).dialog("close");}},close:function(){}});}
HikingMaps.Layers.setEventHandlers=function(){lHPdraw.events.on({"beforefeatureadded":function(e){var label;var h=1;for(var n=0;n<this.features.length;n++){if(this.features[n].geometry.CLASS_NAME==e.feature.geometry.CLASS_NAME)h++;if(this.features[n]===e.feature)break;}
switch(e.feature.geometry.CLASS_NAME){case"OpenLayers.Geometry.Point":label=uiText['featurePoint'];break;case"OpenLayers.Geometry.LineString":label=uiText['featureLine'];break;case"OpenLayers.Geometry.Polygon":label=uiText['featurePolygon'];break;default:label=uiText['featureOther'];}
var nameValid=false;if(typeof e.feature.attributes.name!='undefined'){if(e.feature.attributes.name.trim()!=''){e.feature.attributes.label=e.feature.attributes.name;nameValid=true;}}
if(!nameValid){e.feature.attributes.label=label+' '+h;e.feature.attributes.name=label+' '+h;}},"featureadded":function(e){HikingMaps.Hikeplanner.updateFeaturesMapDraw();},"featureremoved":function(e){HikingMaps.Hikeplanner.updateFeaturesMapDraw();},"featuremodified":function(e){HikingMaps.Hikeplanner.updateFeaturesMapDraw();}});lFoto.events.on({"featureselected":function(e){var innerHTML="";var f=e.feature;if(f.cluster){innerHTML='<div class="layerPopup foto cluster">';for(var i=0;i<f.cluster.length;i++){innerHTML+='<a href="'+f.cluster[i].attributes.link+'" target="_blank">';innerHTML+='<img src="'+f.cluster[i].attributes.thumb+'" title="'+f.cluster[i].attributes.nazov+'" /></a> ';}
innerHTML+='</div>';}else{innerHTML="<div style='font-size:.7em; width:250px'><b>"+f.attributes.nazov
+'</b><br/><img style="float: left; margin: 5px 0px 5px 0px;" src="'+f.attributes.thumb
+'" height="180" width="240" />'+f.attributes.popis+' <a style="color: blue" target="_blank" href="'
+f.attributes.link+'">»&nbsp;link</a><br/></div>';}
HikingMaps.Popups.create(e.feature,innerHTML);$('.layerPopup.foto.cluster a > img').tipsy({gravity:'s'});$('.layerPopup.foto.cluster').scroll(function(event){$('.layerPopup.foto.cluster a > img').each(function(index){$(this).tipsy('hide');});event.stopImmediatePropagation();});},"featureunselected":function(e){HikingMaps.Popups.onUnselect(e.feature);}});lChaty.events.on({"featureselected":function(e){if(e.feature.attributes.popis.length>284){popis=e.feature.attributes.popis.substr(0,284)+'...';}else{popis=e.feature.attributes.popis;}
var innerHTML='<div class="layerPopup chaty"><h1>'
+e.feature.attributes.nazov+'</h1><img class="float" src="'
+e.feature.attributes.thumb+'"/>'+'<p>'+popis+'</p>'
+'<div class="footnote">Viac info o tomto objekte nájdete na <a target="_blank" href="'+e.feature.attributes.link+'">»&nbsp;HIKING.SK</a></div></div>';HikingMaps.Popups.create(e.feature,innerHTML);},"featureunselected":function(e){HikingMaps.Popups.onUnselect(e.feature);}});lPramene.events.on({"featureselected":function(e){var poznamka;if(typeof(e.feature.attributes.poznamka)=='string'){poznamka=e.feature.attributes.poznamka;}else{poznamka="<i>bez bližšieho popisu</i>";}
var innerHTML='<div class="layerPopup pramene"><h1>'+e.feature.attributes.nazov+'</h1><span class="subtitle">'+e.feature.attributes.vyska+' m n.m.</span><p>'
+poznamka+'</p><div class="footnote">Pozn.: dáta sú z používateľskej '
+'<a href="http://hiking.sk/hk/li/sluzby-gps_databaza.html" target="_blank">GPS databázy</a>.</div></div>';HikingMaps.Popups.create(e.feature,innerHTML);},"featureunselected":function(e){HikingMaps.Popups.onUnselect(e.feature);}});lGC.events.on({"featureselected":function(e){var innerHTML;var gcAttr=e.feature.attributes;innerHTML='<div class="layerPopup GC"><h1>'+gcAttr.nazov+'</h1>';innerHTML+='<table border="0"><tr>';innerHTML+='<td class="first-child">waypoint<br />typ / veľkosť<br />založil(a)<br />dátum vzniku<br />obtiaž. / terén<br />stav<br />obľúbenosť<br />viac info</td>';innerHTML+='<td>';innerHTML+=gcAttr.wpt+'<br />'+gcAttr.type+' / '+gcAttr.velkost+'<br />'+gcAttr.autor+'<br /> '+gcAttr.zalozena+'<br />';innerHTML+=gcAttr.obtiaznost.replace("/"," / ")+'<br />'+gcAttr.stav+'<br /><a href="http://gcvote.com" target="_blank"><img src="http://gcvote.com/gcvote.php?bannertype=stars4&waypoint=';innerHTML+=gcAttr.wpt+'&"/><br /><a target="_blank" href="'+gcAttr.link+'">»&nbsp;Geocaching.sk</a></a>';innerHTML+='</td></tr></table>';innerHTML+='</div>';HikingMaps.Popups.create(e.feature,innerHTML);},"featureunselected":function(e){HikingMaps.Popups.onUnselect(e.feature);}});lHrady.events.on({"featureselected":function(e){var img="";var popis="";if(typeof e.feature.attributes.obrazok!="undefined"&&e.feature.attributes.obrazok!=null)img='<img class="float" src="'+e.feature.attributes.obrazok+'" />';if(typeof e.feature.attributes.popis!="undefined"&&e.feature.attributes.obrazok!=null){if(e.feature.attributes.popis.length>284){popis=e.feature.attributes.popis.substr(0,284)+'...';}else{popis=e.feature.attributes.popis;}}
var innerHTML='<div class="layerPopup hrady"><h1>'+e.feature.attributes.nazov+'</h1>';innerHTML+=img+'<p>'+popis+'</p>'+'<div class="footnote">Viac info na <a target="_blank" href="'+e.feature.attributes.link+'">»&nbsp;Hrady.sk</a></div></div>';HikingMaps.Popups.create(e.feature,innerHTML);},"featureunselected":function(e){HikingMaps.Popups.onUnselect(e.feature);}});lPralesy.events.on({"featureselected":function(e){var innerHTML='<div class="layerPopup chaty"><h1>Prales: '+e.feature.attributes.name+'</h1>';if(e.feature.attributes.description!=""){innerHTML+='<p>'+uiText['pralesyDescIntro']+'<br />'+e.feature.attributes.description+'</p>';}
HikingMaps.Popups.create(e.feature,innerHTML);},"featureunselected":function(e){HikingMaps.Popups.onUnselect(e.feature);}});}
HikingMaps.Styles=function(){}
HikingMaps.Styles.gpx=function(){var style=OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);style.fillOpacity=0.3;style.fillColor='none';style.strokeOpacity=0.7;style.strokeWidth=4;return style;}
HikingMaps.Styles.hpTrack=function(){var style=new OpenLayers.Style({},{rules:[new OpenLayers.Rule({symbolizer:{"Point":{},"Line":{strokeOpacity:0.5,strokeWidth:11,strokeColor:'#ff6666'}}})]});return style;}
HikingMaps.Styles.kml=function(typename){var kmlStyleMap=new OpenLayers.StyleMap({"default":OpenLayers.Util.applyDefaults({label:"${getName}",fontSize:"8pt",fontWeight:'bold',fontColor:'#330033',strokeWidth:2,pointRadius:4,strokeColor:'#cc0000',strokeOpacity:1,fillOpacity:0,fillColor:'#cc0000'},OpenLayers.Feature.Vector.style["default"]),"select":OpenLayers.Util.applyDefaults({fontColor:'black',pointRadius:4,strokeWidth:3,strokeColor:'#ff0000',fillColor:'#ff0000',fillOpacity:0.1},OpenLayers.Feature.Vector.style["select"]),"temporary":OpenLayers.Util.applyDefaults({strokeColor:'#cc33cc',strokeWidth:3,pointRadius:4},OpenLayers.Feature.Vector.style["temporary"])});kmlStyleMap.styles["default"].context={getName:function(feature){return(typeof feature.attributes.name!="undefined")?uiText['pralesyTitleSingle']+" - "+feature.attributes.name:"";}};return kmlStyleMap;}
HikingMaps.Styles.hpDraw=function(){var hpDrawStyleMap=new OpenLayers.StyleMap({"default":OpenLayers.Util.applyDefaults({label:"${getName}",labelYOffset:-8,fontSize:"8pt",fontWeight:'bold',fontColor:'#330033',externalGraphic:"${getGfx}",graphicWidth:40,graphicHeight:40,graphicOpacity:1,graphicYOffset:-38,graphicXOffset:-20,strokeWidth:3,pointRadius:4,strokeColor:'#993399',strokeOpacity:1,fillOpacity:0.2,fillColor:'#993399'},OpenLayers.Feature.Vector.style["default"]),"select":OpenLayers.Util.applyDefaults({fontColor:'black',pointRadius:4,strokeWidth:3,strokeColor:'#cc33cc'},OpenLayers.Feature.Vector.style["select"]),"temporary":OpenLayers.Util.applyDefaults({strokeColor:'#cc33cc',strokeWidth:3,pointRadius:4},OpenLayers.Feature.Vector.style["temporary"])});hpDrawStyleMap.styles["default"].context={getName:HikingMaps.Styles.getDrawnFeatureName,getGfx:HikingMaps.Styles.getDrawnFeatureGfx};return hpDrawStyleMap;}
HikingMaps.Styles.getDrawnFeatureName=function(feature){var label=feature.attributes.label;if(typeof label!="undefined"){return label;}else{return"";}}
HikingMaps.Styles.getDrawnFeatureGfx=function(feature){if(feature.state=='Insert'){return"/images/map-icons/v3/pin-violet.png";}else{return'';}}
HikingMaps.Styles.poi=function(){var icons={'clanky_chaty':{externalGraphic:'/images/map-icons/icons/hostel.png',graphicWidth:32,graphicHeight:37},'hrady':{externalGraphic:'/images/map-icons/icons/castle.png',graphicWidth:32,graphicHeight:37},'pramene':{externalGraphic:'/images/map-icons/icons/pramen.png',graphicWidth:32,graphicHeight:37},'geocache':{externalGraphic:'/images/map-icons/icons/geocache.gif',graphicWidth:12,graphicHeight:10,graphicYOffset:-6,graphicXOffset:-5},'foto':{externalGraphic:"${getGraphics}",graphicHeight:"${getHeight}",graphicWidth:"${getWidth}",graphicYOffset:"${getYOffset}",graphicXOffset:"${getXOffset}",backgroundGraphic:"/images/map-icons/SVG/7-icon-set/Photos$170469334855686.svg",backgroundHeight:"${getBgWidth}",backgroundWidth:"${getBgWidth}"}};var context={getHeight:function(feature){var height=parseInt(10+(feature.attributes.hodnotenie/15));var zoomC=Math.floor((map.getZoom()-9)*3);height=((height+zoomC)<10)?10:height+zoomC;return height;},getWidth:function(feature){var width=Math.round((context.getHeight(feature)*1.48));return width;},getBgWidth:function(feature){var zoomC=Math.floor((map.getZoom()-9)*3);var bgWidth=((15+zoomC)<10)?10:15+zoomC;return bgWidth;},getGraphics:function(feature){var eG=feature.attributes.thumb;eG=eG.replace("/rand/","/prew/");return eG;},getYOffset:function(feature){var offset=Math.round(context.getHeight(feature)*(-0.5));return offset;},getXOffset:function(feature){var offset=Math.round(context.getWidth(feature)*(-0.5));return offset;}};var style=new OpenLayers.Style({graphicOpacity:1,graphicYOffset:-35,graphicXOffset:-15},{context:context});styleMap=new OpenLayers.StyleMap(style);styleMap.addUniqueValueRules("default","typ",icons);return styleMap;}
HikingMaps.Styles.poiCluster=function(){var style=new OpenLayers.Style({fillColor:"#ffcc66",strokeColor:"#cc6633",fillOpacity:1,strokeWidth:2,strokeOpacity:1,fontColor:'#cc0000',externalGraphic:"/images/map-icons/SVG/hiking/noun_project_473.svg",graphicWidth:"${width}",graphicHeight:"${height}"},{context:{radius:function(feature){var fCount=Math.pow(feature.attributes.count,0.5);return Math.min(Math.round(fCount),12)+5;},width:function(feature){var fCount=Math.pow(feature.attributes.count,0.5);return(Math.min(Math.round(fCount),12)+6)*2;},height:function(feature){var fCount=Math.pow(feature.attributes.count,0.5);return Math.min(Math.min(Math.round(fCount),12)+6)*1.5;}}});var ua=$.browser;if((ua.mozilla&&ua.version.slice(0,3)=="1.9")||(ua.msie&&(ua.version*1)<9)){style.defaultStyle.externalGraphic="/OpenLayers/img/features/image.gif";}
var clusterStyleMap=new OpenLayers.StyleMap({"default":style,"select":{fillColor:"#8aeeef",strokeColor:"#32a8a9"}});return clusterStyleMap;}
HikingMaps.Styles.basic=function(){var style=new OpenLayers.Style({},{rules:[new OpenLayers.Rule({symbolizer:{"Point":{graphicYOffset:-38,graphicXOffset:-20,externalGraphic:"/images/map-icons/v3/pin-red.png",graphicWidth:40,graphicHeight:40,fillColor:"#FF0000",fillOpacity:1,strokeWidth:1,strokeOpacity:1,strokeColor:"white"},"Line":{strokeWidth:3,strokeOpacity:0.9,strokeColor:"#FF0000",strokeDashstyle:"dash"}}})]});return style;}
HikingMaps.Popups=function(){}
HikingMaps.Popups.create=function(e,innerHTML){popup=new OpenLayers.Popup.FramedCloud("popupCloud",e.geometry.getBounds().getCenterLonLat(),null,innerHTML,null,true,HikingMaps.Popups.onClose);popup.maxSize=new OpenLayers.Size(500,250);popup.minSize=new OpenLayers.Size(300,250);popup.panMapIfOutOfView=true;e.popup=popup;map.addPopup(popup);}
HikingMaps.Popups.onClose=function(e){this.toggle();}
HikingMaps.Popups.onUnselect=function(e){map.removePopup(e.popup);e.popup.destroy();e.popup=null;}
HikingMaps.UiEvents=function(){}
HikingMaps.UiEvents.register=function(){$('#buttonLayerSwitcher').click(function(){$('#myLayerSwitcher').slideToggle();});$('#fullscreenSwitcher').click(function(){if(fullscreen==false){$('#map').css("z-index","90");$('#map').animate({height:$(document).height(),width:$(document).width()},350,'easeOutExpo',function(){$('#myMapControl').addClass("fullscreen");$('#fullscreenSiwtcherImg').attr("src","http://mapy.hiking.sk/images/icons/arrow_in.png");$('#myMapControl').fadeIn();map.updateSize();map.pan(1,1);fullscreen=true;});}else{var newWidth=$(document).width()-321;var newHeight=$(document).height()-80;$('#myMapControl').fadeOut();$('#map').animate({height:newHeight,width:newWidth},350,'easeOutExpo',function(){$('#fullscreenSiwtcherImg').attr("src","http://mapy.hiking.sk/images/icons/arrow_out.png");$('#myMapControl').removeClass("fullscreen");$('#myMapControl').fadeIn();$('#map').css("z-index","1");map.updateSize();map.pan(-1,-1);fullscreen=false;});}});$('input, textarea, select').focus(function(){kbDefaults.deactivate();});$('input, textarea, select').blur(function(){kbDefaults.activate();});$('.button').hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});$('.button').click(function(event){$(this).toggleClass('selected');});$('#myButtons .button').click(function(event){var clickedButton=$('#myButtons .button').index(this);HikingMaps.UiEvents.leftDefaultView();$('#myContent > div').hide();$('#myContent > div.tab:eq('+clickedButton+')').show();$(this).toggleClass('selected');});$('#myContent div.myCloseButton').click(function(){HikingMaps.UiEvents.leftDefaultView();HikingMaps.Hikeplanner.resetMapClicks();if(typeof positionFeature=="object")lFeatures.removeFeatures(positionFeature);});$('#userLogoff').click(function(event){$.ajax({type:'POST',url:'/user/map_login.php',data:{userLogout:'1'},success:function(data){window.parent.location=urlDefault+urlDefaultDocument;}});return false;});$('#userLogin').click(function(event){$('#userLoginDialog').dialog({autoOpen:true,height:250,width:300,modal:true,buttons:[{text:"OK",click:function(){var userLoginAuto=($('#userLoginAuto').is(":checked"))?"on":"off";if($('#userLoginFailed').is(":visible"))$('#userLoginFailed').fadeOut();$.ajax({type:'POST',url:'/user/map_login.php',dataType:'json',data:{userLoginName:$('#userLoginName').val(),userLoginPass:$('#userLoginPass').val(),userLoginAuto:userLoginAuto},success:function(data){if(data.success){$('#myLogin .logged-off').hide();$('#userName').text(data.user_name);$('#uid').text(data.user_id);$('#myLogin .logged-in').show();$('#userLoginDialog').dialog("close");HikingMaps.Hikeplanner.getMyDrawn();HikingMaps.Hikeplanner.getHpRoutes();_gaq.push(['_trackEvent','mapa-user','login',data.user_name]);}else{$('#userLoginFailed').fadeIn();}}});}},{text:uiText['buttonCancel'],click:function(){$(this).dialog("close");}}],close:function(){$('#userLoginName').val('');$('#userLoginPass').val('');$('#userLoginFailed').hide();}});return false;});$('#userRegister').click(function(event){$('#userRegisterDialog').dialog({autoOpen:true,height:350,width:450,modal:true,buttons:[{text:"OK",click:function(){if($('#userRegisterDialog .ui-widget.msg').is(":visible"))$('#userRegisterDialog .ui-widget.msg').fadeOut();if($('#userRegisterDialog .ui-widget.disclaimer').is(":hidden"))$('#userRegisterDialog .ui-widget.disclaimer').fadeIn();$.ajax({type:'POST',url:'/user/map_login.php',dataType:'json',data:{userRegisterName:$('#userRegisterName').val(),userRegisterEmail:$('#userRegisterEmail').val(),spam1:$('#userRegisterCode').val(),spam2:$('#userRegisterDialog input[name="userRegisterCaptcha"]').val()},success:function(data){if(data.success){$('#userRegisterDialog .ui-widget.disclaimer').hide();$('#userRegisterDialog .ui-widget.msg.info span.response').html(data.response);$('#userRegisterDialog .ui-widget.msg.info').fadeIn();_gaq.push(['_trackEvent','mapa-user','register']);}else{if(typeof data.response!="undefined"){$('#userRegisterDialog .ui-widget.msg.error span.response').html(data.response);}else{$('#userRegisterDialog .ui-widget.msg.error span.response').html(uiText['formInputError']);}
$('#userRegisterDialog .ui-widget.msg.error').fadeIn();}}});}},{text:uiText['buttonCancel'],click:function(){$(this).dialog("close");}}],close:function(){$('#userRegisterName').val('');$('#userRegisterEmail').val('');$('#userRegisterCode').val('');$('#userRegisterDialog .ui-widget.msg').hide();$('#userRegisterDialog .ui-widget.disclaimer').show();}});});$('#whatsNewLink').click(function(event){$('#whatsNewDialog').dialog({autoOpen:true,height:480,width:640,modal:true,buttons:[{text:"OK",click:function(){$(this).dialog("close");}},{text:uiText['buttonCancel'],click:function(){$(this).dialog("close");}}],close:function(){}});_gaq.push(['_trackEvent','mapa','static-content','whats-new']);return false;});$('#terms > a').click(function(event){$('#termsDialog').dialog({autoOpen:true,height:480,width:640,modal:true,buttons:[{text:"OK",click:function(){$(this).dialog("close");}},{text:uiText['buttonCancel'],click:function(){$(this).dialog("close");}}],close:function(){}});return false;});$('#hpUploadForm').iframePostForm({json:false,xml:true,iframeID:'hpUploadIframe',post:function(){var filename=$('#hpUploadForm input[type="file"]').val();$('#hpCreateFromGPX div.results').html('');if(filename!=""){uploadFileExt=typeof filename!="undefined"?filename.substring(filename.lastIndexOf(".")+1,filename.length).toLowerCase():false;if(uploadFileExt=='kml'||uploadFileExt=='gpx'){$('#hpCreateFromGPX div.results').html('<img src="/images/ajax-load.gif" />').show();_gaq.push(['_trackEvent','mapa-hikeplanner','upload',uploadFileExt]);}else{uploadFileExt='';HikingMaps.setErrorDiv('#hpCreateFromGPX div.results',uiText['uploadWrongExt']);return false;}}else{HikingMaps.setErrorDiv('#hpCreateFromGPX div.results',uiText['uploadNoFile']);return false;}},complete:function(response){$('#hpCreateFromGPX div.results').html('');try{hpUploadedFeatures=HikingMaps.Hikeplanner.addFeatures(lHPdraw,response,uploadFileExt,10);HikingMaps.setHighlightDiv('#hpCreateFromGPX div.results',uiText['uploadSuccess']);}catch(err){HikingMaps.setErrorDiv('#hpCreateFromGPX div.results',uiText['uploadFormatError']);}
$('#hpUploadForm input[name="fileUpload"]').val('');}});document.getElementById('map').oncontextmenu=function(e){e=e?e:window.event;if(e.preventDefault)e.preventDefault();else return false;};OpenLayers.Control.Click=OpenLayers.Class(OpenLayers.Control,{defaultHandlerOptions:{'single':true,'double':true,'pixelTolerance':0,'stopSingle':false,'stopDouble':false},handleRightClicks:true,initialize:function(options){this.handlerOptions=OpenLayers.Util.extend({},this.defaultHandlerOptions);OpenLayers.Control.prototype.initialize.apply(this,arguments);this.handler=new OpenLayers.Handler.Click(this,this.eventMethods,this.handlerOptions);},CLASS_NAME:"OpenLayers.Control.Click"});oClick=new OpenLayers.Control.Click({eventMethods:{'rightclick':function(e){var lonlat=map.getLonLatFromViewPortPx(e.xy);var lLavinyHidden=(!lLaviny.visibility)?"hidden":"";var innerHTML='<ul><li class="ul-section first-child">Možnosti miesta</li>'+'<li id="contextMenuQueryLaviny" class="menuItem '+lLavinyHidden+' highlight">Info o lavínovej dráhe</li>'+'<li id="contextMenuShowCoord"   class="menuItem">Zobraz GPS súradnicu</li>'+'<li id="contextMenuAddPhoto"    class="menuItem">Pošli foto do Galérie</li>'+'<li id="contextMenuReportBug"   class="menuItem">Pošli info o chybe</li>'+'<li class="ul-section">Hikeplanner</li>'+'<li id="contextMenuHPstart"     class="menuItem">Začni trasu</li>'+'<li id="contextMenuHPthru"      class="menuItem">Pridaj medzibod trasy</li>'+'<li id="contextMenuHPend"       class="menuItem">Ukonči trasu</li>'+'</ul>'+'<div id="contextMenuLon" style="display: none" ></div>'+'<div id="contextMenuLat" style="display: none" ></div>';contextMenuPopup=new OpenLayers.Popup("contextMenu",lonlat,new OpenLayers.Size(155,180),innerHTML,false);contextMenuPopup.panMapIfOutOfView=true;map.addPopup(contextMenuPopup,true);$('#contextMenuLon').html(lonlat.lon);$('#contextMenuLat').html(lonlat.lat);$('#contextMenu .menuItem').hover(function(){$(this).toggleClass('rollover');},function(){$(this).toggleClass('rollover');});$('#contextMenu ul>li.menuItem').click(function(e){var lonlat,ll,html;var id=$(this).attr('id');var hpAction=false;var layerQuery=false;var sid=$('#sid').text();lonlat=new OpenLayers.LonLat($('#contextMenuLon').html(),$('#contextMenuLat').html());lFeatures.removeFeatures(positionFeature);positionFeature=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat));lFeatures.addFeatures(positionFeature);lonlat.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));dl=formatPosition(lonlat,"decimal",5);nl=formatPosition(lonlat,"decimal_number",5);ml=formatPosition(lonlat,"minutes",3);html="";switch(id){case'contextMenuShowCoord':html='<h2>'+uiText['uiCoordsTitle']+'</h2>';html+='<div class="lonlat">'+dl.lat+' '+dl.lon+'</div>';html+='<div class="lonlat">'+ml.lat+' '+ml.lon+'</div>';html+='<p>Stálny odkaz: <input type="text" onclick="this.select();" value="'+urlDefault+'?x='+nl.lon+'&y='+nl.lat+'" class="permalink" /></p>';html+='<p>'+uiText['uiPermalinkTooltip']+'</p>';break;case'contextMenuAddPhoto':html='<h2>'+uiText['uiAddPhotoTitle']+'</h2>';html+=uiText['uiAddPhotoDesc'];html+='<form action="http://hiking.sk/" method="get" target="_blank"><input type="hidden" name="user" value="photo_add" />'
+'<input type="hidden" name="x" value="'+nl.lon+'" /><input type="hidden" name="y" value="'+nl.lat+'" />'
+'<input type="submit" name="a" value="'+uiText['uiAddPhotoButton']+'" class="button cyan" ></form>';break;case'contextMenuAddPOI':html='<h2>'+uiText['uiAddPOITitle']+'</h2>';html+=uiText['uiAddPOIDesc'];html+='<form action="http://hiking.sk/hk/li/sluzby-gps_databaza.html" method="get" target="_blank"><input type="hidden" name="from" value="map" />'
+'<input type="hidden" name="x" value="'+nl.lon+'" /><input type="hidden" name="y" value="'+nl.lat+'" />'
+'<input type="submit" name="a" value="'+uiText['uiAddPOIButton']+'" class="button cyan" ></form>';break;case'contextMenuReportBug':html='<h2>'+uiText['uiReportBugTitle']+'</h2>';html+=uiText['uiReportBugDesc'];break;case'contextMenuHPstart':hpAction="start";break;case'contextMenuHPthru':hpAction="thru";break;case'contextMenuHPend':hpAction="end";break;case'contextMenuQueryLaviny':layerQuery="true";html='<h2>'+uiText['uiQueryLavinyTitle']+'</h2>';html+=uiText['uiQueryLavinyDesc'];$.get(urlDefault+"wfs/query.php",{sid:sid,x:lonlat.lon,y:lonlat.lat,layer:'laviny'},function(data){html='<h2>'+uiText['uiQueryLavinyTitle']+'</h2>';html+=uiText['uiQueryLavinyDesc'];html+=data;html+='<img src="/images/hzs/hzs_26x30.png" class="logo margin-default" />';html+='<img src="/images/hzs/slp_26x30.png" class="logo margin-default" />';html+=uiText['uiQueryLavinyFooter'];$('#myContent div.contextResults>div.content').html(html);$('a.dialog.lLaviny.terms').click(function(){HikingMaps.dialog('#lLavinyDiscailmerDiv',500,500);return false;});});break;}
if(typeof contextMenuPopup!='undefined')map.removePopup(contextMenuPopup);HikingMaps.UiEvents.leftDefaultView();if(!hpAction&&!layerQuery){$('#myContent div.contextResults>div.content').html(html);$('#myContent > div').hide();$('#myContent div.contextResults').show();}else if(!layerQuery){lFeatures.removeFeatures(positionFeature);HikingMaps.Hikeplanner.handleMapClicks(nl.lon,nl.lat,hpAction);}else{html+='<img src="/images/ajax-load.gif" alt="loading..." />';$('#myContent div.contextResults>div.content').html(html);$('#myContent > div').hide();$('#myContent div.contextResults').show();}});},'click':function(e){if(typeof contextMenuPopup!='undefined')map.removePopup(contextMenuPopup);},'dblclick':function(e){if(typeof contextMenuPopup!='undefined')map.removePopup(contextMenuPopup);},'dblrightclick':function(e){if(typeof contextMenuPopup!='undefined')map.removePopup(contextMenuPopup);}}});map.addControl(oClick);oClick.activate();$('#hpTypeSwitcher').buttonset();$('.ui-helper-hidden-accessible').css('visibility','hidden');$('#hpTypeSwitcher > input:radio').click(function(event){var clickedButton=$('#hpTypeSwitcher > input:radio').index(this);$('#myContent > div.tab > div.content > div.subType').hide();$('#myContent > div.tab > div.content > div.subType:eq('+clickedButton+')').show();});$('#hpMapClicksReset').click(function(){HikingMaps.Hikeplanner.resetMapClicks(this);});$('#hpMapClicksSubmit').click(function(){HikingMaps.Hikeplanner.submitMapClicks(this);});$('#hpMapDrawSubmit, #hpMapDrawSave').click(HikingMaps.Hikeplanner.onlyForRegistered);$('#hpMapDrawReset').click(function(){HikingMaps.Hikeplanner.resetMapDraw(this);});$('#hpMapDrawSubmit').click(function(){HikingMaps.Hikeplanner.downloadGPX(this);});$('#hpMapDrawSave').click(function(){HikingMaps.Hikeplanner.saveDrawn(this);});$('a[rel="hpRoute"]').click(HikingMaps.Hikeplanner.onClickLinksRoute);$('a[rel="hpDrawn"]').click(HikingMaps.Hikeplanner.onClickLinksDrawn);$('#hpMapDrawAcc').accordion({autoHeight:false,navigation:true,collapsible:true});$('#hpMapDraw .toolbox input:radio').click(function(event){$('#hpMapDraw > div.comment').slideUp();selectControl.activate();for(key in drawControls){var control=drawControls[key];if($(this).val()==key&&$(this).attr('checked')){control.activate();if(key=='modify')selectControl.deactivate();}else{control.deactivate();}}});$('*[rel="tipsy"]').tipsy({fade:true});$('#searchBox input[name=q]').tipsy({trigger:'manual',gravity:'nw',fade:true});$('#searchBox > form').submit(function(event){var elemQ=$(this).find('input[name=q]');var q=elemQ.val();q=q.trim();$('#searchBox input[name=q]').tipsy("hide");if(q.length<3){$('#searchBox input[name=q]').tipsy("show");setTimeout("$('#searchBox input[name=q]').tipsy('hide')",5000);}else{HikingMaps.Search.go(q,"");}
return false;});$('a.search.shortcut').click(function(){_gaq.push(['_trackEvent','mapa','shortcut',$(this).text()]);$('#searchBox input[name=q]').val($(this).text());$('#searchBox > form').submit();$('div.searchResults > div.myCloseButton').click();return false;});$('select.search.shortcut').change(function(){if($(this).find('option:selected').val()=='false')return false;var q=$(this).find('option:selected').text();_gaq.push(['_trackEvent','mapa','shortcut',q]);$('#searchBox input[name=q]').val(q);$('#searchBox > form').submit();$('div.searchResults > div.myCloseButton').click();return false;});$('#printButtons span:first').button({icons:{primary:"ui-icon-print"}}).next().button({icons:{primary:"ui-icon-close"}});$('#printButtons span:first').click(function(){window.print();}).next().click(function(){$('link[href*="theme/print.css"]').attr("media","print");$('#printUserNotes textarea').val(' ');kbDefaults.activate();});$('#printOpen a').click(function(){_gaq.push(['_trackEvent','mapa','print',uploadFileExt]);$('link[href*="theme/print.css"]').attr("media","screen,print");kbDefaults.deactivate();return false;});$('#printUserNotes > textarea').autoResize({onResize:function(){$(this).css({opacity:0.8});},animateCallback:function(){$(this).css({opacity:1});},animateDuration:150,extraSpace:0});}
HikingMaps.UiEvents.leftDefaultView=function(){if($('#myContent div.searchResults').is(":visible"))HikingMaps.Search.resetResults();$('#myButtons .button').removeClass('selected');$('#myContent > div').hide();$('#myContent > div:first-child').show();}
HikingMaps.Hikeplanner=function(){}
HikingMaps.Hikeplanner.handleMapClicks=function(x,y,action){var url=urlDefault+"hikeplanner/getnearest.php";$('#myButtons > div.vytvorTrasu').click();$('#hpTypeSwitcherRadio1').click();$('#hpMapClicksResults').show();$('#hpMapClicksResults > div.comment').slideUp();$('#hpMapClicksResults > div.inputs').data('action',action);$('#hpMapClicksResults div.results').html('<img src="/images/ajax-load.gif" alt="loading..." style="width: 16px; height: 16px;" />');$('form#hpTrackForm input.button').hide();$.get(url,{x:x,y:y},function(data){if(data!=0){var arrIn=data.split(";");var action=$('#hpMapClicksResults > div.inputs').data('action');$('#hpMapClicksResults > div.inputs').removeData('action');var marker=HikingMaps.Hikeplanner.setMarker(arrIn[3],arrIn[2],action);$('#hpMapClicksResults span.myCloseButton').unbind('click',HikingMaps.Hikeplanner.removeNode);if(action=='thru'){var div='<div class="item">'+arrIn[1]+' <span class="ui-icon ui-icon-closethick myCloseButton"></span></div>';$('#hpMapClicksResults > div.inputs > div.thru').append(div);$('#hpMapClicksResults > div.inputs > div.thru').show();}else{var div='<div class="item">'+arrIn[1]+' </div>';$('#hpMapClicksResults > div.inputs > div.'+action).empty().append(div);}
$('#hpMapClicksResults > div.inputs > div.'+action+'> div.item:last').data('info',{id:arrIn[0],x:arrIn[3],y:arrIn[2],marker:marker});$('#hpMapClicksResults > div.inputs > div.thru').sortable();$('#hpMapClicksResults span.myCloseButton').bind('click',HikingMaps.Hikeplanner.removeNode);}else{HikingMaps.alert(uiText['uiHPoutOfRange']);}
$('#hpMapClicksResults div.results').empty();});}
HikingMaps.Hikeplanner.removeNode=function(e){try{var data=$(this).parent().data('info');lMarkers.removeMarker(data.marker);}catch(err){var a=err;}
$(this).parent().remove();}
HikingMaps.Hikeplanner.resetMapClicks=function(e){lMarkers.clearMarkers();lHPtracks.removeAllFeatures();$('#hpMapClicksResults div.start, #hpMapClicksResults div.thru, #hpMapClicksResults div.end').empty();$('#hpMapClicksResults div.results').empty();$("#hpMapClicksResults select.hpOptimize option[value='default']").attr('selected','selected');$('body > div.hpProfil').remove();}
HikingMaps.Hikeplanner.submitMapClicks=function(e){var url=urlDefault+"hikeplanner/getresults.php?";var start=0;var end=0;var thru=new Array;var err=false;var lastThru='';var firstThru='';var optimize;$('#hpMapClicksResults div.results').empty();start=$('#hpMapClicksResults div.start div.item:first').data('info');end=$('#hpMapClicksResults div.end div.item:first').data('info');thru=$('#hpMapClicksResults div.thru div.item');optimize=$('#hpMapClicksResults select.hpOptimize').val();thru.each(function(index,domElem){var id=$(domElem).data('info').id;if(lastThru==id){HikingMaps.Hikeplanner.setErrDiv('#hpMapClicksResults div.results',uiText['uiHPerrEqThru']);err=true;}else if(lastThru==''){url+='&hpThru[]='+id;firstThru=id;}else{url+='&hpThru[]='+id;}
lastThru=id;});if(optimize=='default')err=HikingMaps.Hikeplanner.setErrDiv('#hpMapClicksResults div.results',uiText['uiHPerrNoOpt']);if(typeof(start)=='undefined'||typeof(end)=='undefined'){if(typeof(start)=='undefined')err=HikingMaps.Hikeplanner.setErrDiv('#hpMapClicksResults div.results',uiText['uiHPerrNoStart']);if(typeof(end)=='undefined')err=HikingMaps.Hikeplanner.setErrDiv('#hpMapClicksResults div.results',uiText['uiHPerrNoEnd']);}else{if(firstThru==start.id)err=HikingMaps.Hikeplanner.setErrDiv('#hpMapClicksResults div.results',uiText['uiHPerrStartThru']);if(lastThru==end.id)err=HikingMaps.Hikeplanner.setErrDiv('#hpMapClicksResults div.results',uiText['uiHPerrEndThru']);if((start.id==end.id)&&(thru.length==0))err=HikingMaps.Hikeplanner.setErrDiv('#hpMapClicksResults div.results',uiText['uiHPerrNoThru']);}
if(!err){$('#hpMapClicksResults div.results').html('<img src="/images/ajax-load.gif" alt="loading..." style="width: 16px; height: 16px;" />');$('form#hpTrackForm input.button').hide();var stagesCount=thru.length+1;_gaq.push(['_trackEvent','mapa-hikeplanner','search',$('#userName').text(),stagesCount]);$.get(url,{mapa:'1',type:'mapa_v3',hpStart:start.id,hpEnd:end.id,optimize:optimize,hpLongDistance:$('#hpMapClicksLongDistance').attr('checked')},function(data){$('#hpMapClicksResults div.results').html(data);var url=urlDefault+"gpx/gpx_download.php";var txtHPgpx=HikingMaps.Hikeplanner.showTrackOnMap('#hpMapClicksResults');HikingMaps.Hikeplanner.showProfile('#hpMapClicksResults');$('form#hpTrackForm input[name="data"]').val(txtHPgpx);$('form#hpTrackForm input[name="name"]').val('data');$('form#hpTrackForm input[name="type"]').val('gpx');$('form#hpTrackForm input[name="sid"]').val($('#sid').text());$('form#hpTrackForm').attr('action',url);$('form#hpTrackForm').attr('target','_blank');$('form#hpTrackForm input.button').show();$('form#hpTrackForm input.button').click(HikingMaps.Hikeplanner.onlyForRegistered);var btnPrint=$('#divPriebeh a[href*="/hikeplanner/print.php?gid="]').text(uiText['uiHPprintDetails']).detach();$('#divPriebeh p:last > *').remove();$('#divPriebeh p:last').append(btnPrint);$('#hpMapClicksReset').click(function(event){$('form#hpTrackForm input.button').hide();event.stopImmediatePropagation();});$('form#hpTrackForm input[name="edit"]').unbind('click',HikingMaps.Hikeplanner.gpxEditClick);$('form#hpTrackForm input[name="edit"]').click(HikingMaps.Hikeplanner.gpxEditClick);$('form#hpTrackForm input[name="save"]').unbind('click',HikingMaps.Hikeplanner.saveRoute);$('form#hpTrackForm input[name="save"]').click(HikingMaps.Hikeplanner.saveRoute);$('form#hpTrackForm input[name="submit"]').unbind('click',HikingMaps.Hikeplanner.downloadGPXtrack);$('form#hpTrackForm input[name="submit"]').click(HikingMaps.Hikeplanner.downloadGPXtrack);});}}
HikingMaps.Hikeplanner.showFromHPid=function(hpid){if(typeof(hpid)=='undefined')return false;var url=urlDefault+"hikeplanner/load_track.php?";var html='<img src="/images/ajax-load.gif" alt="loading..." style="width: 16px; height: 16px;" />';HikingMaps.UiEvents.leftDefaultView();$('#myContent div.contextResults>div.content').html(html);$('#myContent > div').hide();$('#myContent div.contextResults').show();$.get(url,{type:'mapa_v3',hpid:hpid},function(data){var elem='#myContent div.contextResults>div.content';var html='<h2>'+uiText['uiHPsaved']+'</h2>';html+=data;$(elem).html(html);$(elem).find("h2:eq(1)").hide();HikingMaps.Hikeplanner.showTrackOnMap(elem);HikingMaps.Hikeplanner.showProfile(elem);HikingMaps.Hikeplanner.markStartEndAllFeatures(lHPtracks);var btnPrint=$('#divPriebeh a[href*="/hikeplanner/print.php?gid="]').text(uiText['uiHPprintDetails']).detach();$('#divPriebeh p:last > *').remove();$('#divPriebeh p:last').append(btnPrint);});}
HikingMaps.Hikeplanner.resetMapDraw=function(){lHPdraw.destroyFeatures();HikingMaps.Hikeplanner.updateFeaturesMapDraw();$('#hpMapDraw div.results').html('');$('#hpMapDrawName').val('');$('#hpMapDrawDesc').val('');$('#hpMapDrawForm input[name="public"]:first').attr('checked','checked');$('#hpMapDrawType > option:first').attr('selected','selected');$('#hpMapDraw div.inputs input[type="radio"]:first').attr('checked','checked');$('#hpMapDrawForm input[name="hash"]').val('');}
HikingMaps.Hikeplanner.downloadGPX=function(){var exportType=$('#hpMapDrawAcc input[name="export"]:checked').val();var name=$('#hpMapDrawName').val()||'User data export';var user=$('#userName').html()||'anonymous';var desc=$('hpMapDrawDesc').val()||' ';var url=urlDefault+"gpx/gpx_download.php";switch(exportType){case"gpx":var rte=$('#exportGPXrte').is(":checked");HikingMaps.formats['out']['gpx'].writeRoutes=rte;var metadata={name:name,desc:desc,author:user+' / TuristickaMapa.sk'}
var data=HikingMaps.formats['out']['gpx'].write(lHPdraw.features,metadata);break;case"kml":HikingMaps.formats['out']['kml'].foldersName='TuristickaMapa.sk / '+name;HikingMaps.formats['out']['kml'].foldersDesc=desc;var data=HikingMaps.formats['out']['kml'].write(lHPdraw.features);break;default:var data=HikingMaps.formats['out'][exportType].write(lHPdraw.features);}
_gaq.push(['_trackEvent','mapa-hikeplanner','download-'+exportType,$('#userName').text()]);$('form#hpMapDrawForm input[name="data"]').val(data);$('form#hpMapDrawForm input[name="name"]').val(name);$('form#hpMapDrawForm input[name="type"]').val(exportType);$('form#hpMapDrawForm input[name="sid"]').val($('#sid').text());$('form#hpMapDrawForm').attr('action',url);$('form#hpMapDrawForm').attr('target','_blank');$('form#hpMapDrawForm').submit();}
HikingMaps.Hikeplanner.downloadGPXtrack=function(){_gaq.push(['_trackEvent','mapa-hikeplanner','download-track',$('#userName').text()]);return true;}
HikingMaps.Hikeplanner.getMyDrawn=function(){var contentDiv=$('#myContent div.mojaMapa div.content div.hpDrawn');contentDiv.html('<img src="/images/ajax-load.gif" alt="loading..." style="width: 16px; height: 16px;" />');if(HikingMaps.isLoggedIn()){$.get('/hikeplanner/load_featureset.php',{myDrawn:'1'},function(response){var contentDiv=$('#myContent div.mojaMapa div.content div.hpDrawn');if(response.success==1){contentDiv.html('');var distanceSum=0;$.each(response.featuresets,function(i,featureset){var stages=HikingMaps.Hikeplanner.formatStages(featureset.stages);var html='<div class="myItem myFeatureset">';html+='<a href="/'+urlRouteParam+featureset.hash+'" rel="hpDrawn">'+featureset.name+'</a> ';html+='– '+stages+', '+Math.round(featureset.distance)+' km ';html+='</div>';distanceSum+=featureset.distance*1;contentDiv.append(html);});contentDiv.append('<div class="distacnceSum">'+uiText['featureSavedDistSum']+": "+Math.round(distanceSum)+' km </div>');$('#myContent div.mojaMapa div.content div.hpDrawn a[rel="hpDrawn"]').unbind('click');$('#myContent div.mojaMapa div.content div.hpDrawn a[rel="hpDrawn"]').click(HikingMaps.Hikeplanner.onClickLinksDrawn);}else{contentDiv.html('');}},'json');}else{contentDiv.html(uiText['userNotLoggedIn']);}}
HikingMaps.Hikeplanner.getHpRoutes=function(){var contentDiv=$('#myContent div.mojaMapa div.content div.hpRoutes');contentDiv.html('<img src="/images/ajax-load.gif" alt="loading..." style="width: 16px; height: 16px;" />');if(HikingMaps.isLoggedIn()){$.get('/hikeplanner/load_track.php',{myRoutes:'1',mapa:'1'},function(response){var contentDiv=$('#myContent div.mojaMapa div.content div.hpRoutes');if(response.success==1){contentDiv.html('<h3>Hikeplanner</h3>');$.each(response.routes,function(i,route){var html='<div class="myItem myRoute">';html+='<a href="/?hpid='+route.hash+'" rel="hpRoute">'+route.start+' → '+route.end+'</a> ';html+='<div class="detials">'+Math.round(route.vzdialenost)+' km , ';html+=uiText['featureSavedClimb']+': '+route.stupanie+' m, '+uiText['featureSavedDescent']+': '+route.klesanie+' m';html+='</div></div>';contentDiv.append(html);});$('#myContent div.mojaMapa div.content div.hpRoutes a[rel="hpRoute"]').unbind('click');$('#myContent div.mojaMapa div.content div.hpRoutes a[rel="hpRoute"]').click(HikingMaps.Hikeplanner.onClickLinksRoute);}else{contentDiv.html('');}},'json');}else{contentDiv.html('');}}
HikingMaps.Hikeplanner.formatStages=function(stages){if(stages*1==1){var out=stages+' '+uiText['featureSavedStage'];}else if(stages*1<5){var out=stages+' '+uiText['featureSavedStages1'];}else{var out=stages+' '+uiText['featureSavedStages2'];}
return out;}
HikingMaps.Hikeplanner.onClickLinksRoute=function(){var hpid=getParameterFromStringByName('hpid',$(this).attr('href'));HikingMaps.Hikeplanner.resetMapClicks();if(typeof positionFeature=="object")lFeatures.removeFeatures(positionFeature);HikingMaps.Hikeplanner.showFromHPid(hpid);return false;}
HikingMaps.Hikeplanner.onClickLinksDrawn=function(){var hash=getParameterFromStringByName('trasa',$(this).attr('href'));HikingMaps.Hikeplanner.resetMapClicks();if(typeof positionFeature=="object")lFeatures.removeFeatures(positionFeature);HikingMaps.Hikeplanner.loadDrawn(hash);return false;}
HikingMaps.Hikeplanner.loadDrawn=function(hash){$.post("/hikeplanner/load_featureset.php",{hash:hash},function(response){if(response.success==1){$.each(response.featuresets,function(i,featureset){HikingMaps.UiEvents.leftDefaultView();lHPdraw.removeAllFeatures();HikingMaps.Hikeplanner.addFeatures(lHPdraw,featureset.data,'json',0);$('#myContent div.contextResults>div.content').html(html);$('#myContent > div').hide();$('#myContent div.contextResults').show();var stages=HikingMaps.Hikeplanner.formatStages(featureset.stages);var climb=(featureset.climb)?' | '+uiText['featureSavedClimb']+' '+featureset.climb+' m':"";var elem='#myContent div.contextResults>div.content';var html='<h2>'+featureset.name+'</h2>';html+='<p class="featureset summary">'+$('#hpMapDrawType option[value="'+featureset.id_activity+'"]').text();html+=' | '+stages+' | '+Math.round(featureset.distance)+' km '+climb+'</p>';html+='<p class="featureset desc">'+featureset.desc+'</p>';html+='<p class="featureset footer">'+uiText['featureSavedSaved']+' '+$.datepicker.formatDate('d.mm.y',new Date(featureset.born_time))+' | ';html+=' '+featureset.user_login+' | '+uiText['featureSavedAcCount']+' '+featureset.access_count+'x </p>';if(featureset.user_is_owner==1){$('#hpMapDrawName').val(featureset.name);$('#hpMapDrawDesc').val(featureset.desc);$('#hpMapDrawType').val(featureset.id_activity);$('#hpMapDrawForm input[name="public"]').filter('[value="'+featureset.public+'"]').prop('checked',true);$('#hpMapDrawForm input[name="hash"]').val(hash);html+='<p><input type="button" class="button gray edit-featureset" value="'+uiText['featureSavedEdit']+'" />';}
$(elem).html(html).find('input.edit-featureset').click(function(){$('#myButtons .vytvorTrasu').click();$('#hpTypeSwitcherRadio3').click();return false;});return true;});}},"json");}
HikingMaps.Hikeplanner.saveDrawn=function(){$('#hpMapDraw div.results').html('');$('#hpMapDraw .toolbox input[type="radio"][name="type"][value="none"]').click();if(lHPdraw.features.length!=0){var data=HikingMaps.formats['out']['json'].write(lHPdraw.features);var extent=lHPdraw.getDataExtent();extent.transform(map.baseLayer.projection,new OpenLayers.Projection("EPSG:4326"))
var bbox=extent.toString();var name=$('#hpMapDrawName').val();var desc=$('#hpMapDrawDesc').val();var type=$('#hpMapDrawType').val();var pub=$('#hpMapDrawForm input[name="public"]:checked').val();var dist=$('#hpMapDrawLength > span.num').text();var stages=HikingMaps.Hikeplanner.countFeatureGeometries(lHPdraw,'LineString');var hash=$('#hpMapDrawForm input[name="hash"]').val();hash=(hash!="")?hash:false;if(stages!=0){s_lat=hpFirstTrackFeature.y;s_lon=hpFirstTrackFeature.x;}
if($.trim(name).length>=4){$.post("/hikeplanner/save_featureset.php",{name:name,bbox:bbox,desc:desc,pub:pub,data:data,activity:type,dist:dist,stages:stages,hash:hash,start_lon:s_lon,start_lat:s_lat},function(response){if(response.success==1){$('#hpMapDrawForm input[name="hash"]').val(response.hash);var url=urlDefault+urlRouteParam+response.hash;var html=uiText['featureSaveSuccess']+'<a href="'+url+'" target="_blank">'+url+'</a>';HikingMaps.Hikeplanner.getMyDrawn();$('body > div.default-highlight').clone().removeClass('.default-hightlight').appendTo('#hpMapDraw div.results').show().find('.message').html(html);}else{$('body > div.default-error').clone().removeClass('.default-error').appendTo('#hpMapDraw div.results').show().find('.message').html(response.error);}},"json");}else{$('body > div.default-error').clone().removeClass('.default-error').appendTo('#hpMapDraw div.results').show().find('.message').html(uiText['featureSaveErr2']);}}else{$('body > div.default-error').clone().removeClass('.default-error').appendTo('#hpMapDraw div.results').show().find('.message').html(uiText['featureSaveErr1']);}}
HikingMaps.Hikeplanner.countFeatureGeometries=function(layer,className){j=0;className="OpenLayers.Geometry."+className;for(var i=0;i<layer.features.length;i++){if(layer.features[i].geometry.CLASS_NAME==className){j++;var firstDone=false;if(typeof layer.features[i].geometry.components!='undefined'&&firstDone==false){var tmpLonLat=new OpenLayers.LonLat(layer.features[i].geometry.components[0].x,layer.features[i].geometry.components[0].y);tmpLonLat.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));hpFirstTrackFeature.x=tmpLonLat.lon;hpFirstTrackFeature.y=tmpLonLat.lat;firstDone=true;}}}
return j;}
HikingMaps.Hikeplanner.showProfile=function(elem){jQuery.globalEval($(elem+' .txtHPgraph').html());try{$.plot($(elem+' div.hpProfil'),hpGraphData,{series:{lines:{show:true,fill:true}}});}catch(err){}
var profil=$(elem+' div.hpProfil').detach().hide();if($('body > div.hpProfil').is('div')){$('body > div.hpProfil').fadeOut('slow',function(){$(this).unbind('hover');$(this).remove();$('#printHpSummary').after(profil);$('body > div.hpProfil').fadeIn('slow');HikingMaps.Hikeplanner.addFadingCloseButton('body > div.hpProfil');});}else{$('#printHpSummary').after(profil);$('body > div.hpProfil').show();HikingMaps.Hikeplanner.addFadingCloseButton('body > div.hpProfil');}
$('#printHpSummary').html("<h2>"+uiText['uiHPprintTitle']+"</h2>"+$('#divSummary').html());}
HikingMaps.Hikeplanner.addFadingCloseButton=function(elem){$(elem).append('<div class="myCloseButton redCloseButton"></div>');$(elem+' div.myCloseButton').css({'opacity':'1','top':'-2px','right':'-3px'}).hide().click(function(){$(this).parent().fadeOut('slow');}).parent().hover(function(){$(this).find('div.myCloseButton').fadeIn();},function(){$(this).find('div.myCloseButton').fadeOut();});}
HikingMaps.Hikeplanner.setErrDiv=function(elem,text){$(elem).append('<div class="error">'+text+'</div>');return true;}
HikingMaps.Hikeplanner.showTrackOnMap=function(elem){try{var txtHPgpx=$(elem+' .txtHPgpx').html().split("&lt;").join("<").split("&gt;").join(">").replace('\\"','"');lHPtracks.removeAllFeatures();hpTrackFeatures=HikingMaps.Hikeplanner.addFeatures(lHPtracks,txtHPgpx,'gpx',0);return txtHPgpx;}catch(err){HikingMaps.alert(err.message);return false;}}
HikingMaps.Hikeplanner.onlyForRegistered=function(event){if(!HikingMaps.isLoggedIn()){HikingMaps.alert(uiText['userNotLoggedIn']);if(typeof event!="undefined")event.stopImmediatePropagation();return false;}else{return true;}}
HikingMaps.Hikeplanner.addFeatures=function(layer,string,type,reductionTolerance){var hpTrackFeatures=new Array();if(string){try{hpTrackFeatures=HikingMaps.formats['in'][type].read(string);}catch(err){HikingMaps.alert(uiText['badBrowser']);}
var bounds;if(hpTrackFeatures){if(hpTrackFeatures.constructor!=Array){hpTrackFeatures=[hpTrackFeatures];}
for(var i=0;i<hpTrackFeatures.length;++i){if(!bounds){bounds=hpTrackFeatures[i].geometry.getBounds();}else{bounds.extend(hpTrackFeatures[i].geometry.getBounds());}}
for(var i=0;i<hpTrackFeatures.length;i++){HikingMaps.Hikeplanner.shapeReducer(hpTrackFeatures[i],reductionTolerance);}
layer.addFeatures(hpTrackFeatures);map.zoomToExtent(bounds);hpTrackFeaturesBounds=bounds;return hpTrackFeatures}else{HikingMaps.alert(err.message);}}}
HikingMaps.Hikeplanner.shapeReducer=function(feature,tolerance){if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"||tolerance<=0||feature.geometry.components.length<3){return true;}
featuresToKeep=[0,feature.geometry.components.length-1];featuresToRemove=[];HikingMaps.Hikeplanner.douglasPeuckerReduction(feature,tolerance,0,feature.geometry.components.length-1);for(var i=0;i<feature.geometry.components.length;i++){if($.inArray(i,featuresToKeep)==-1)featuresToRemove.push(feature.geometry.components[i]);}
for(var i=0;i<featuresToRemove.length;i++){feature.geometry.removeComponent(featuresToRemove[i]);}
return true;}
HikingMaps.Hikeplanner.douglasPeuckerReduction=function(feature,tolerance,firstIdx,lastIdx){if(lastIdx<=firstIdx+1){return;}
var maxDistance=0;var indexFarthest=0;firstPoint=new Object();firstPoint.lat=feature.geometry.components[firstIdx].y;firstPoint.lng=feature.geometry.components[firstIdx].x;lastPoint=new Object();lastPoint.lat=feature.geometry.components[lastIdx].y;lastPoint.lng=feature.geometry.components[lastIdx].x;for(var idx=firstIdx+1;idx<lastIdx;idx++){point=new Object();point.lat=feature.geometry.components[idx].y;point.lng=feature.geometry.components[idx].x;if(typeof point!="undefined"){distance=HikingMaps.Hikeplanner.orthogonalDistance(point,firstPoint,lastPoint);if(distance>maxDistance){maxDistance=distance;indexFarthest=idx;}}}
if(maxDistance>tolerance){featuresToKeep.push(indexFarthest);HikingMaps.Hikeplanner.douglasPeuckerReduction(feature,tolerance,firstIdx,indexFarthest);HikingMaps.Hikeplanner.douglasPeuckerReduction(feature,tolerance,indexFarthest,lastIdx);}}
HikingMaps.Hikeplanner.orthogonalDistance=function(point,lineStart,lineEnd){var area=Math.abs((lineStart.lat*lineEnd.lng
+lineEnd.lat*point.lng
+point.lat*lineStart.lng
-lineEnd.lat*lineStart.lng
-point.lat*lineEnd.lng
-lineStart.lat*point.lng)/2);var bottom=Math.sqrt(Math.pow(lineStart.lat-lineEnd.lat,2)+Math.pow(lineStart.lng-lineEnd.lng,2));return area/bottom*2.0;}
HikingMaps.Hikeplanner.gpxEditClick=function(event){_gaq.push(['_trackEvent','mapa-hikeplanner','edit-track',$('#userName').text()]);lHPtracks.removeAllFeatures(hpTrackFeatures);lHPdraw.addFeatures(hpTrackFeatures);map.zoomToExtent(hpTrackFeaturesBounds);$('label[for="hpTypeSwitcherRadio3"]').click();$('#hpTypeSwitcherRadio3').click();$('#hpMapDraw .toolbox input:radio').last().attr("checked","checked");$('#hpMapDraw .toolbox input:radio').last().click();HikingMaps.Hikeplanner.updateFeaturesMapDraw();drawControls.modify.selectControl.select(lHPdraw.features[(lHPdraw.features.length-1)]);event.stopImmediatePropagation();}
HikingMaps.Hikeplanner.saveRoute=function(event){if(typeof $('#hpResultsGid').val()!='undefined'&&typeof $('#hpResultsSid').val()!='undefined'){$('#hpSaveRouteForm').show();$('#hpSaveRouteDialog div.results').html('');$('#hpSaveRouteDialog').dialog({autoOpen:true,height:270,width:520,modal:true,buttons:[{text:uiText['buttonSave'],click:function(){$('#hpSaveRouteForm').hide();$('#hpSaveRouteDialog div.results').show();$('#hpSaveRouteDialog div.results').html('<img src="/images/ajax-load.gif" alt="loading..." style="width: 16px; height: 16px;" />');$.get('/hikeplanner/save_track.php',{sid:$('#hpResultsSid').val(),gid:$('#hpResultsGid').val(),desc:$('#hpSaveRouteDesc').val(),public:$('#hpSaveRouteDialog input[name="public"]:checked').val(),type:'mapa_v3',mapa:'1'},function(data){HikingMaps.Hikeplanner.getHpRoutes();$('#hpSaveRouteDialog div.results').html(data);});$("#hpSaveRouteDialog").parent().find(":button:contains('"+uiText['buttonSave']+"')").attr("disabled","disabled").addClass("ui-state-disabled");$("#hpSaveRouteDialog").parent().find(":button:contains('"+uiText['buttonCancel']+"')").find(".ui-button-text").text(uiText['buttonClose']);}},{text:uiText['buttonCancel'],click:function(){$(this).dialog("close");}}],close:function(){$('#hpSaveRouteDesc').val('');}});return true;}else{return false;}}
HikingMaps.Hikeplanner.markStartEndAllFeatures=function(layer){if(layer.CLASS_NAME=="OpenLayers.Layer.Vector"){if(layer.features){for(var i=0;i<layer.features.length;i++){if(layer.features[i].geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"){var first=0;var last=layer.features[i].geometry.components.length-1;var k=[first,last];for(var j=0;j<k.length;j++){var point=new Object();point.x=layer.features[i].geometry.components[k[j]].x;point.y=layer.features[i].geometry.components[k[j]].y;var lonlat=new OpenLayers.LonLat(point.x,point.y);lonlat.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));if(k[j]==0){HikingMaps.Hikeplanner.setMarker(lonlat.lon,lonlat.lat,'start',false);}else{HikingMaps.Hikeplanner.setMarker(lonlat.lon,lonlat.lat,'end',false);}}}}}else{return false;}}else{return false;}}
HikingMaps.Hikeplanner.setMarker=function(x,y,type,remove){remove=(typeof remove!='undefined')?remove:true;var size=new OpenLayers.Size(40,40);var offset=new OpenLayers.Pixel(-(size.w/2),-size.h);var out=false;var icon,marker;var lonlat=new OpenLayers.LonLat(x,y);lonlat.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));switch(type){case"thru":icon=new OpenLayers.Icon('/images/map-icons/v3/hp-inter-pin.png',size,offset);marker=new OpenLayers.Marker(lonlat,icon);hpMarkers['thru']=marker;break;case"start":icon=new OpenLayers.Icon('/images/map-icons/v3/hp-start-pin.png',size,offset);marker=new OpenLayers.Marker(lonlat,icon);if(typeof hpMarkers['start']!="undefined"&&remove)lMarkers.removeMarker(hpMarkers['start']);hpMarkers['start']=marker;break;case"end":icon=new OpenLayers.Icon('/images/map-icons/v3/hp-end-pin.png',size,offset);marker=new OpenLayers.Marker(lonlat,icon);if(typeof hpMarkers['end']!="undefined"&&remove)lMarkers.removeMarker(hpMarkers['end']);hpMarkers['end']=marker;break;}
lMarkers.addMarker(marker);return marker;}
HikingMaps.Hikeplanner.removeFeaturesMapDraw=function(e){var n=$(this).siblings(".id").html();var features=[lHPdraw.features[n]];lHPdraw.removeFeatures(features);}
HikingMaps.Hikeplanner.updateFeaturesMapDraw=function(){$('#hpMapDrawObjects span.myCloseButton').unbind('click',HikingMaps.Hikeplanner.removeFeaturesMapDraw);$('#hpMapDrawObjects').empty();var distance=0;for(var n=1 in lHPdraw.features){if(!lHPdraw.features[n]._sketch){var html='<div><span style="display: none;" class="id">'+n+'</span><span class="editable">'+lHPdraw.features[n].attributes.name+'</span> ';if(lHPdraw.features[n].geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"){var dist=lHPdraw.features[n].geometry.getGeodesicLength(new OpenLayers.Projection("EPSG:900913"))/1000;html+='<span class="distance">'+dist.toFixed(2)+' km</span>';distance+=dist*1;}
html+='<span class="ui-icon ui-icon-closethick myCloseButton"></span></div>';$('#hpMapDrawObjects').append(html);}}
$('#hpMapDrawLength > span.num').html(distance.toFixed(2));$('#hpMapDrawObjects span.myCloseButton').bind('click',HikingMaps.Hikeplanner.removeFeaturesMapDraw);$('.editable').inlineEdit({save:function(event,data){var n=$(this).siblings(".id").html();lHPdraw.features[n].attributes.label=data.value;lHPdraw.features[n].attributes.name=data.value;lHPdraw.redraw();}});$('#hpMapDrawObjects').append('<div>'+uiText['featureLengthTotal']+'<span class="distance">'+distance.toFixed(2)+' km</span></div>');$('#hpMapDrawObjects').append('<div class="tip">'+uiText['featureEditTip1']+'</div>');}
var searchResults=new Array();var fSearch=new Array();var fSearchPolygon=new Array();HikingMaps.Search=function(){}
HikingMaps.Search.matchCoords=function(q){this.decPattern='^([\\-NS]?)\\s*(\\d+[\\.,]{1}\\d+)?\\s*([\\-EW])?\\s*(\\d+[\\.,]{1}\\d+?)$';this.minPattern='^([\\-NS]?)\\s*(\\d+)[°]{1}\\s*([\\d]{1,2}([\\.,]\\d+)?)?\\\'?\\s*([\\-EW]?)\\s*(\\d+)[°]{1}\\s*([\\d]{1,2}([\\.,]\\d+)?)?\\\'?$';q=q.trim();var response=new Object();var regex=new RegExp(this.decPattern);var matches=regex.exec(q);if(matches==null){regex=new RegExp(this.minPattern);matches=regex.exec(q);if(matches==null){return false;}else{var lonDeg=matches[6];var latDeg=matches[2];var lonMin=matches[7].replace(",",".");var latMin=matches[3].replace(",",".");response.lat=(latDeg*(1))+(latMin/60);response.lon=(lonDeg*(1))+(lonMin/60);if(matches[1]=='S')response.lat=response.lat*(-1);if(matches[5]=='W')response.lon=response.lon*(-1);response.type="decimal";return response;}}else{response.type="decimal";response.lon=matches[4].replace(",",".");response.lat=matches[2].replace(",",".");response.lat=(matches[1]=='S')?response.lat*(-1):response.lat*(1);response.lon=(matches[3]=='W')?response.lon*(-1):response.lon*(1);return response;}}
HikingMaps.Search.go=function(q,targets){q=q.trim();var searchGet="http://mapy.hiking.sk/wfs/search.php?q=";searchGet+=encodeURIComponent(decodeURIComponent(q.replace(/\+/g," ")));HikingMaps.UiEvents.leftDefaultView();$('#myContent > div').hide();$('#myContent div.searchResults').show();var coords=HikingMaps.Search.matchCoords(q);if(typeof coords=="object"){$('#myContent div.searchResults > div.content').html(q);var lonlat=new OpenLayers.LonLat(coords.lon,coords.lat);lonlat.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));lFeatures.removeFeatures(positionFeature);positionFeature=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(lonlat.lon,lonlat.lat));lFeatures.addFeatures(positionFeature);map.setCenter(lonlat,13);}else{lFeatures.removeFeatures(positionFeature);if(targets.indexOf(", ")==-1){searchGet+="&st[]="+encodeURIComponent(decodeURIComponent(targets.replace(/\+/g," ")));}else{targets=decodeURIComponent(targets);targets=targets.replace(/\+/g," ").split(", ");for(var i=0;i<targets.length;i++){searchGet+="&st[]="+encodeURIComponent(targets[i]);}}
$.get(searchGet,HikingMaps.Search.handleResponse);}}
HikingMaps.Search.handleResponse=function(data){$('#myContent div.searchResults > div.content').html('<div id="divSearch">'+data+'</div>');$('#search_form_settings').click(function(){$('#search_form').toggle();$('#search_form_settings').toggleClass("selected");return false;});$('#search_form_link').click(function(){var url=urlDefault+$('#search_form_permalink_a').attr('href');$('#search_form_permalink_email').val(url);$('#search_form_permalink_blog').val('<a href="'+url+'">Turistická Mapa</a>');$('#search_form_permalink').toggle();$('#search_form_link').toggleClass("selected");return false;});$('#search_form_permalink_email, #search_form_permalink_blog').click(function(){$(this).select();});$('#search_form_frm').submit(HikingMaps.Search.goFromResults);HikingMaps.Search.resetResults();$('#search_form_submit').addClass("button").addClass("gray").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});$('#divSearch input:text').addClass("text ui-widget-content ui-corner-all").focus(function(){kbDefaults.deactivate();}).blur(function(){kbDefaults.activate();});$('#map_search_results fieldset[id^="result-"]').click(function(e){var lon=$(this).find('input[name*="lon"]').val();var lat=$(this).find('input[name*="lat"]').val();var type=$(this).find('input[name*="type"]').val();var pozicia=new OpenLayers.LonLat(lon,lat);pozicia.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));zoom=(type=="polygon")?10:14;map.setCenter(pozicia,zoom);return false;});$('#map_search_results fieldset[id^="result-"]').each(function(i){var type=$(this).find('input[name*="type"]').val();var stylePointer=OpenLayers.Util.applyDefaults({graphicWidth:27,graphicHeight:27,graphicOpacity:1,graphicYOffset:-25,graphicXOffset:-14},OpenLayers.Feature.Vector.style['default']);var stylePolygon=OpenLayers.Util.applyDefaults({fillColor:"#00e13b",strokeColor:"#00e13b",fillOpacity:0,strokeWidth:4,strokeOpacity:0.7},stylePointer);stylePointer.externalGraphic=urlDefault.substr(0,urlDefault.length-1)+$(this).find('img.map-pointer').attr("src");stylePointer.graphicTitle=$(this).find('a[id$="name"]').text();if(type=="polygon"){var polygon=$(this).find('input[name*="polygon"]').val();var pointList=[];var pairs=polygon.trim().split(" ");for(var j=0;j<pairs.length;j++){var pair=pairs[j].split(",");var newPair=new OpenLayers.LonLat(pair[0],pair[1]);newPair.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));var newPoint=new OpenLayers.Geometry.Point(newPair.lon,newPair.lat);pointList.push(newPoint);}
var linearRing=new OpenLayers.Geometry.LinearRing(pointList);var center=linearRing.getCentroid();fSearchPolygon[i]=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([linearRing]),new Object(),stylePolygon);fSearch[i]=new OpenLayers.Feature.Vector(center,new Object(),stylePointer);lFeatures.addFeatures(fSearchPolygon[i]);lFeatures.addFeatures(fSearch[i]);var centerWGS=center.clone();centerWGS.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));$(this).append('<input type="hidden" name="result-lon[]" id="'+i+'-lon" value="'+centerWGS.x+'">');$(this).append('<input type="hidden" name="result-lat[]" id="'+i+'-lat" value="'+centerWGS.y+'">');}else if(type=="point"){var lon=$(this).find('input[name*="lon"]').val();var lat=$(this).find('input[name*="lat"]').val();searchPoint=new OpenLayers.LonLat(lon,lat);searchPoint.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));fSearch[i]=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(searchPoint.lon,searchPoint.lat),new Object(),stylePointer);lFeatures.addFeatures(fSearch[i]);}});results_count=$('#map_search_results fieldset[id^="result-"]').length;if(results_count>0){map.zoomToExtent(lFeatures.getDataExtent());if(map.getZoom()==15)map.zoomOut();}else{var lon=$('#map_search_results input[name*="lon"]').val();var lat=$('#map_search_results input[name*="lat"]').val();zoom=8;pozicia=new OpenLayers.LonLat(lon,lat);pozicia.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));map.setCenter(pozicia,zoom);}}
HikingMaps.Search.goFromResults=function(e){var q=$(this).find('input[name=q]').val();this.st="";var goFromResults=this;$(this).find('input[type=checkbox]:checked').each(function(index){goFromResults.st+=$(this).val()+", ";});this.st=this.st.substr(0,this.st.length-2);$('#searchBox input[name=q]').val(q);HikingMaps.Search.go(q,this.st);return false;}
HikingMaps.Search.resetResults=function(){lFeatures.removeFeatures(fSearch);lFeatures.removeFeatures(fSearchPolygon);fSearch=Array();fSearchPolygon=Array();}
HikingMaps.init=function(){projWGS=new OpenLayers.Projection("EPSG:4326");projGoogle=new OpenLayers.Projection("EPSG:900913");OpenLayers.IMAGE_RELOAD_ATTEMPTS=3;var extent=new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508.34);panZoom=new OpenLayers.Control.PanZoom({slideFactor:192});panZoom.position.y=7;layerSw=new OpenLayers.Control.LayerSwitcher({div:document.getElementById('myLayerSwitcherOL')});layerSw.roundedCorner=false;kbDefaults=new OpenLayers.Control.KeyboardDefaults({slideFactor:192});overview=new OpenLayers.Control.OverviewMap({maximized:false,size:new OpenLayers.Size(250,150),mapOptions:{maxExtent:extent,units:'m',projection:"EPSG:900913",numZoomLevels:10},layers:[new OpenLayers.Layer.Google("overview",{type:google.maps.MapTypeId.TERRAIN,sphericalMercator:true})]});controls=[new OpenLayers.Control.Navigation({zoomBoxEnabled:true,zoomWheelEnabled:true,handleRightClicks:true}),new OpenLayers.Control.Permalink({div:document.getElementById('myPermalink')}),new OpenLayers.Control.Attribution({separator:'<br />'}),kbDefaults,panZoom,layerSw];map=new OpenLayers.Map('map',{controls:controls,numZoomLevels:16,units:'m',projection:"EPSG:900913",maxExtent:extent});map.events.register("addlayer",map,function(){HikingMaps.Layers.forceRefresh(lFoto);});map.events.register("zoomend",map,function(){var zoom=map.getZoomForResolution(map.getResolution());var layerSwitcherTopoLabel=$(".baseLayersDiv span.labelSpan:contains("+uiText['lNameTOPO']+")");var layerSwitcherTopoRadio=layerSwitcherTopoLabel.prev();if($('#myLayerSwitcher span.labelSpan').hasClass('disabled'))$('#myLayerSwitcher span.labelSpan').removeClass('disabled');$('#myLayerSwitcher span.labelSpan[style*="color: gray"]').addClass('disabled');if(zoom>maxZoom)map.zoomOut();if(zoom<=(maxZoom-topoZooms)){layerSwitcherTopoLabel.addClass("disabled");layerSwitcherTopoRadio.attr("disabled",true);if(map.baseLayer==bTOPO)map.setBaseLayer(bGPhy);}else if(zoom>(maxZoom-topoZooms)){if(layerSwitcherTopoLabel.hasClass("disabled")){layerSwitcherTopoLabel.removeClass("disabled");layerSwitcherTopoRadio.attr("disabled",false);}
if(map.baseLayer==bGPhy&&zoom!=lastZoom)map.setBaseLayer(bTOPO);}
lastZoom=zoom
HikingMaps.Layers.forceRefresh(lFoto);});map.events.register("changebaselayer",map,function(){HikingMaps.Layers.onChangeBaseLayer();});$('.baseLbl').text(uiText['cBaseLbl']);$('.dataLbl').text(uiText['cDataLbl']);$('#myPermalink > a').text(uiText['cPermalink']);$('#otherSettingsOverviewMap').click(function(){if($(this).is(":checked")){try{if(overview.map.CLASS_NAME="OpenLayers.Map")overview.maximizeControl();}catch(err){map.addControl(overview);$('#olControlOverviewMapMaximizeButton_innerImage').hide();$('#OpenLayers_Control_minimizeDiv').click(function(){$('#otherSettingsOverviewMap').removeAttr("checked");});overview.maximizeControl();setTimeout("HikingMaps.init.overviewRefresh()",500);}
if(gaEventLogged['overviewmap']!=1){_gaq.push(['_trackEvent','mapa','overviewmap']);gaEventLogged['overviewmap']=1;}}else{overview.minimizeControl();}});HikingMaps.Layers.add();if(top!=self){HikingMaps.init.iframeMode();}else{HikingMaps.UiEvents.register();}
HikingMaps._updateFormats();if((HikingMaps._GETvar('x')!=""&&HikingMaps._GETvar('y')!="")||(HikingMaps._GETvar('lon')==""&&HikingMaps._GETvar('lat')=="")){var pozicia;var mapZoom;if(HikingMaps._GETvar('x')!=""&&HikingMaps._GETvar('y')!=""){pozicia=new OpenLayers.LonLat(HikingMaps._GETvar('x'),HikingMaps._GETvar('y'))
mapZoom=(HikingMaps._GETvar('zoom')!='')?HikingMaps._GETvar('zoom'):14;pozicia.transform(projWGS,projGoogle);map.setCenter(pozicia,mapZoom);lFeatures.removeFeatures(fPos);fPos=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(pozicia.lon,pozicia.lat));lFeatures.addFeatures(fPos);}else if(HikingMaps._GETvar('q').trim()!=""){HikingMaps.Search.go(HikingMaps._GETvar('q'),HikingMaps._GETvar('st'));}else{pozicia=new OpenLayers.LonLat(lon,lat);mapZoom=zoom;pozicia.transform(projWGS,projGoogle);map.setCenter(pozicia,mapZoom);}}
if(HikingMaps._GETvar('trasa')!="")HikingMaps.Hikeplanner.loadDrawn(HikingMaps._GETvar('trasa'));if(HikingMaps._GETvar('hpid')!="")HikingMaps.Hikeplanner.showFromHPid(HikingMaps._GETvar('hpid'));if(HikingMaps._GETvar('gpx')!=""){$('#hpUploadIframe').load(function(){try{gpxFileContent=xml2Str(frames['hpUploadIframe'].document);hpUploadedFeatures=HikingMaps.Hikeplanner.addFeatures(lHPdraw,gpxFileContent,'gpx',10);}catch(err){}
$('#hpUploadIframe').unbind('load');});}
HikingMaps.Hikeplanner.getMyDrawn();HikingMaps.Hikeplanner.getHpRoutes();window.setInterval(function(){$.post('user/map_login.php',{keepAlive:1});},900000);}
HikingMaps.init.iframeMode=function(){$('#map').css("z-index","90");$('div#header > h1 > a').css("z-index",'100');$('#map').css({height:$(document).height(),width:$(document).width()});$('#myMapControl').remove();var cssMap={'z-index':'500','position':'absolute','top':'10px','left':'8px'}
$('div#header > h1 > a').clone().css(cssMap).attr('target','_blank').attr('href',$('#myPermalink a').attr('href')).appendTo('body').find('img').css({'height':'27px','border':'1px solid white'});$('div#header').remove();$('.olControlPanZoom').css('top','40px');}
HikingMaps.init.overviewRefresh=function(){map.zoomOut();map.zoomOut();map.zoomIn();map.zoomIn();}
