// Copyright (c) Position s.r.o.
// All rights reserved.

ID_ZEBRASCALE_SPAN="idControlScale";ID_SEARCH_COUNTER="idResultCounter";ID_INFODIV_CONTENT="idInformation";ID_INFODIV_TITLE="idInfoDivTitle";ID_INFODIV_BODY="idInfoDivBody";ID_INFODIV_FOOTER="idInfoDivFooter";ID_POIDIV="idPOIDiv";ID_POIDIV_TITLE_L="idPOIDivTitleL";ID_POIDIV_TITLE_R="idPOIDivTitleR";ID_POIDIV_BODY_L="idPOIDivBodyL";ID_POIDIV_BODY_R="idPOIDivBodyR";DEFAULT_SEARCH_FORM="basic";MAPCOUNTRY="CR";var AntennaIconID="idPOIantenna",locate_cov=false,showMapMenu=true,FormValues=[];
function preloadImages(a){for(var b=0;b<a.length;b++){var c=new Image;if(ngIExplorer){c.src="img/empty.gif";c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a[b]+"')"}else c.src=a[b]}}function preloadCursor(a){document.createElement("img").src=a}function openOrderForm(a){(a=window.open(a,"_blank","toolbar=no,menubar=no,scrollbar=no,status=no,directories=no,location=no,width=248,height=303"))&&a.focus&&a.focus();return!a}
function formatScaleNumber(a){result="";a=Math.floor(a).toString();for(var b=a.length-3;b>=0;b-=3)result=" "+a.substr(b,3)+result;return result=a.substr(0,a.length-3*Math.floor(a.length/3))+result}
function getElementTopLeft(a){docObj=typeof a!="object"?document.getElementById(a):a;var b=new Array(2);if(document.defaultView){a=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("top");tmphght=a.split("px");b[0]=parseInt(tmphght[0]);a=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("left");tmphght=a.split("px");b[1]=parseInt(tmphght[0])}else{b[0]=document.getElementById(a).offsetTop;b[1]=document.getElementById(a).offsetLeft}return b}
function getElementHeight(a){docObj=document.getElementById(a);if(document.defaultView){tmphght=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("height").split("px");tmphght=tmphght[0]}else tmphght=document.getElementById(a).offsetHeight;return tmphght}
function getElementWidth(a){docObj=document.getElementById(a);if(document.defaultView){tmphght=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("width").split("px");tmphght=tmphght[0]}else tmphght=document.getElementById(a).offsetWidth;return tmphght}
function getElementMarginH(a){docObj=document.getElementById(a);if(document.defaultView){var b=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("margin-left");a=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("margin-right")}else{b=docObj.currentStyle.marginLeft;a=docObj.currentStyle.marginRight}b=b.split("px");a=a.split("px");return tmphght=parseInt(b[0],10)+parseInt(a[0],10)}
function getElementMarginV(a){docObj=document.getElementById(a);if(document.defaultView){var b=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("margin-top");a=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("margin-bottom")}else{b=docObj.currentStyle.marginTop;a=docObj.currentStyle.marginBottom}b=b.split("px");if(b[0]=="auto")b[0]=0;a=a.split("px");if(a[0]=="auto")a[0]=0;return tmphght=parseInt(b[0],10)+parseInt(a[0],10)}
function renderScaleText(a){return"1 : "+a}
function renderScales(){if(map.ZoomLevels&&map.ZoomLevel>=0){var a=document.getElementById("idScaleHolder");if(a){var b="";b+='<img src="img/zoom_out.gif?2" onclick="map.ZoomOut();" title="'+lngIconTitleZoomOut+'" alt="'+lngIconAltZoomOut+'" class="HandCursor" width="30px" height="22px" style="border: none;"/></a>';var c,d,e,f;d=1;for(c=map.ZoomLevels.length-1;c>=0;c--,d++){e=String(Math.round(d*8/map.ZoomLevels.length));if(e==0)e=1;if(c==map.ZoomLevel)e="_green";f="1 : "+FormatScale(map.ZoomLevels[c]);
b+='<a href="javascript:map.SetScale('+map.ZoomLevels[c]+')" hidefocus="true" ><img src="/img/zoom'+e+'.gif?2" alt="'+f+'" title="'+f+'" width="9" height="22" style="border: none;" /></a>'}b+='<img src="img/zoom_in.gif?2" onclick="map.ZoomIn();" title="'+lngIconTitleZoomIn+'" alt="'+lngIconAltZoomIn+'" class="HandCursor" width="30px" height="22px" style="border: none;" />';a.innerHTML=b}}}
function getElementTopBottom(a,b){docObj=document.getElementById(a);if(document.defaultView){a=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("top");var c=document.defaultView.getComputedStyle(docObj,"").getPropertyValue("height");top_=a.split("px");bottom_=c.split("px");b[0]=parseInt(top_[0]);b[1]=parseInt(b[0])+parseInt(bottom_[0])}else{b[0]=docObj.offsetTop;b[1]=docObj.offsetHeight+b[0]}}
function HiliteImg(a,b){if(a&&b!="")if(ngIExplorer)a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/"+b+".png')";else a.src="img/"+b+".png"}function DimImg(a,b){if(a&&b!="")if(ngIExplorer)a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/"+b+".png')";else a.src="img/"+b+".png"}
function HiliteImg2(a,b){var c=document.getElementById(a+"1");if(c){c.src="images/"+b+"1.png";c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"')"}if(c=document.getElementById(a+"2")){c.src="images/"+b+"2.png";c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"')"}}
function DimImg2(a,b){var c=document.getElementById(a+"1");if(c){c.src="images/"+b+"1.png";c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"')"}if(c=document.getElementById(a+"2")){c.src="images/"+b+"2.png";c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"')"}}
function ImgChange(a,b){if(b=="undefined")b=false;img1=document.getElementById(a);img2=document.getElementById(a+"_");if(img1&&img2){img1.className=b?"hidden":"HandCursor";img2.className=b?"HandCursor":"hidden"}}
function changeSearch(a){var b=document.getElementById("idSearchForm1"),c=document.getElementById("idSearchForm2");if(b&&c)switch(a){case "basic":b.className="hidden";c.className="blockvisible";SelectedSearchFormType=formid=1;break;case "extended":b.className="blockvisible";c.className="hidden";formid=2;SelectedSearchFormType=0;break;default:break}RenderSearchMenu()}
function SaveFormValue(a,b,c){if(a>=0&&a<SearchForms.length/4){var d=SearchForms[a*4+1],e=SearchForms[a*4+3];if(a=document.getElementById(SearchForms[a*4+2][b]))a.value=c!=""||c=="- "+d[j]+" -"?c:"- "+d[b]+" -"}}
function RedrawFormValue(a,b){for(var c="",d=0;d<SearchForms.length/4;d++)if(a>=0&&a<SearchForms.length/4){c=SearchForms[d*4+2];for(var e=SearchForms[d*4+3],f=SearchForms[d*4+1],g="",h=0;h<e.length;h++){g=c[h];if(e[h]==b)break}if(e=document.getElementById(g)){c=e.value;if(c=="")c="- "+f[h]+" -";e.value=c}}}function RenderSearchMenu(){var a=SearchForms.length/4;for(j=0;j<a;j++)for(var b=SearchForms[j*4+3],c=0;c<b.length;c++)RedrawFormValue(j,b[c])}
function GetFormValue(a,b){var c="";if(a>=0&&a<SearchForms.length/4){var d=SearchForms[a*4+1],e=SearchForms[a*4+2];a=SearchForms[a*4+3];for(var f="",g=0;g<a.length;g++){f=e[g];if(a[g]==b)break}if(b=document.getElementById(f))c=b.value}if(c=="- "+d[g]+" -")c="";return c}
function SearchBoxEnter(a){var b=document.getElementById(a);if(b){var c=SelectedSearchFormType,d=SearchForms.length/4;if(c>=0&&c<d){d=SearchForms[c*4+2];c=SearchForms[c*4+1];for(var e=0;e<d.length;e++)if(d[e]==a)break;if(b.value=="- "+c[e]+" -")b.value=""}}}
function SearchBoxLeave(a){var b=document.getElementById(a);if(b)if(b.value==""){var c=SelectedSearchFormType,d=SearchForms.length/4;if(c>=0&&c<d){d=SearchForms[c*4+2];c=SearchForms[c*4+1];for(var e=0;e<d.length;e++)if(d[e]==a)break;b.value="- "+c[e]+" -"}}}function SearchKeyPress(a){if(!a)a=window.event;if((a.which?a.which:a.keyCode)==13){Search();return false}return true}
function HideSearch(){var a=document.getElementById("idSearchResults");if(a)a.style.visibility="hidden";window.places&&places.ClearDisplayedItems()}function gotoSearchExample(a){if(SelectedSearchFormType==1){var b=document.getElementById(SearchForms[6][0]);if(b)b.value=a;Search()}}
function clickFullScreen(a){if(a)window.close();else{a=window.screen.width;var b=window.screen.height,c="";if(document.all&&navigator.userAgent.indexOf("Opera")==-1)c="1";c="index.php?x="+a+"&y="+b+"&f=1&ie="+c;if(map){if(map.ZoomLevel!=map.ZoomLevels.length-1)c+="&SESS="+map.MapSession+"&SESSX="+map.X+"&SESSY="+map.Y;c+="&lang="+Lang;if(map.Mode){c+="&MAPMODE=";if(map.Mode!="")c+=ng_URLEncode(map.Mode)}if(map.Coverage){c+="&ACTIVECOV=";if(map.Coverage&&map.Coverage>=0)c+=map.Coverage}if(map.LayerStates){c+=
"&ACTIVELAY=";for(var d=0;d<map.LayerStates.length;d++){if(d>0)c+=";";c+=map.LayerStates[d]?"1":"0"}}}var e=SelectedSearchFormType;d=0;d=SearchForms[e*4+1];d=SearchForms[e*4+2];var f=SearchForms[e*4+3],g="";for(d=0;d<f.length;d++){g=GetFormValue(e,f[d]);if(g!="")c+="&SEARCH"+d+"="+g}c+="&SEARCHFIELDS="+f.length;if(SelectedSearchForm>=0)c+="&SEARCHFORM="+SelectedSearchFormType;window.open(c,"","fullscreen=yes, scrollbars=yes, width="+a+", height="+b+", top=0, left=0")}}
function clickPrint(){if(map){var a=722,b=600;if(a>screen.width)a=screen.width;if(b>screen.height)b=screen.height;var c=(screen.width-a)/2,d=(screen.heigh-b)/2;if(c<0)c=0;if(d<0)d=0;var e="";if(map.Coverage>=0)e+=map.Coverage;e="../src/print.php?ACOV="+e+"&"+map.URLStateParams();if(window.Lang)e+="&lang="+Lang;(a=window.open(e,"print","width="+a+",height="+b+",scrollbars=yes,menubar=yes,resizable=yes,left="+c+",top="+d))&&a.focus()}}
function clickHome(){map.ZoomMode();map.Home&&map.Home();HideInfo();places&&places.ClearDisplayedItems()}function CheckLayer(a){if(map&&map.LayerStates){ActiveNearestResults==a&&map.LayerStates[a]&&HideInfo();map.LayerStates[a]=!map.LayerStates[a];setCheckImage("idLayer"+a,3,map.LayerStates[a]);map.MapCommand(map.LayerStates[a]?"EL":"DL",a)}}var LastCheckedLayer3=-1;
function CheckLayer3(a){if(map&&map.LayerStates){ActiveNearestResults==a&&map.LayerStates[a]&&HideInfo();if(LastCheckedLayer3==a||!map.LayerStates[a])map.LayerStates[a]=!map.LayerStates[a];map.MapCommand(map.LayerStates[a]?"EL3":"DL3",a);LastCheckedLayer3=a}}function CheckCoverage(a){if(map){for(var b=0;b<Coverage.length;b++)b!=a&&setCheckImage("idCoverage"+b,2,false);switchCheckImage("idCoverage"+a,2);map.MapCommand("CE",a)}}
function ShowInfo(){ClearInfoDiv();document.getElementById("idInfoDiv").style.visibility="visible"}function HideInfo(){document.getElementById("idInfoDiv").style.visibility="hidden";map.HideMapMenu();places&&places.ClearDisplayedItems();ClearInfoDiv()}function closeInfo(){HideInfo()}function isWGScoords(a){sep_pos=a.indexOf(";");if(sep_pos>0&&sep_pos<a.length-1)return true;return false}
function Search(){for(var a=false,b=SelectedSearchFormType,c=SearchForms[4*b+1],d=SearchForms[4*b+2],e=SearchForms[4*b+3],f="",g="",h=0;h<c.length;h++)if(document.getElementById(d[h]))switch(e[h]){case "city":f=GetFormValue(b,e[h]);if(f!="")a=true;break;case "street":g=GetFormValue(b,e[h]);if(g!="")a=true;break;case "cp":cp=GetFormValue(b,e[h]);if(cp!="")a=true;break;case "co":co=GetFormValue(b,e[h]);if(co!="")a=true;break}if(a){ActiveNearestResults=-1;GotoInfoDivElement();SetInfoBody(lngMessageWaitSearching);
ResetPOILocation();SwitchInfoPanel(0);switch(b){case 0:places.SearchAddress(f,g,cp,co);break;case 1:isWGScoords(f)?places.SearchCoords(f):places.Search(f);break;default:ClearInfoFooter()}}}function ClearSearchCounter(){var a=document.getElementById(ID_SEARCH_COUNTER);if(a)a.innerHTML=""}function StartSearch(){ShowInfo();ClearInfoFooter();SetInfoTitle(lngSearchResults);SetInfoBody(lngMessageWaitSearching);return true}function StopSearch(){SetInfoBody("");ClearInfoFooter()}
function NextPage(){SetInfoBody(lngMessageWaitSearching);searchresults&&searchresults.NextPage()}function PrevPage(){SetInfoBody(lngMessageWaitSearching);searchresults&&searchresults.PrevPage()}function ngSearchFnc_getStatusText(a){return lngCityStatus[a]}
function ngSearchFnc_setResultDescription(a){var b="";if(typeof a=="object"&&a!=null){if(typeof a.street=="string"&&a.street!="")b=a.street;if(typeof a.city=="string"&&a.city!=""){if(b!="")b+=", ";b+=a.city;if(typeof a.statusKod=="string"&&a.statusKod!=""){var c=ngSearchFnc_getStatusText(a.statusKod);if(c!="")b+=", "+c}}if(typeof a.psc=="string"&&a.psc!=""){if(b!="")b+=", ";b+=a.psc}}if(b=="")b=a.descr;else a.descr=b;return b}
function IsPrevPlaceVisible(a){if(typeof a.PrevVisible!="undefined"&&a.PrevVisible||typeof a.Params!="undefined"&&a.Params.PrevVisible)return true;return false}function IsNextPlaceVisible(a){if(typeof a.NextVisible!="undefined"&&a.NextVisible||typeof a.Params!="undefined"&&a.Params.NextVisible)return true;return false}
function DisplaySearchResults(a){map.PanMode();if(a.Results.length>0){searchresults=a;var b="";classname=' class="SearchResults';classname+='" ';b+="<div "+classname+' style="position:relative;height:auto;/*background-color:#33cc33;*/">';for(var c=0;c<a.Results.length;c++){b+="<div>";b+='<span style="margin-right: 5px">';b+="</span><span>";if(typeof a.Results[c].dist!="undefined")b+=a.Results[c].dist+"&nbsp;&nbsp;";b+='<a href="javascript:LocateItem('+c+');" hidefocus="true">'+ngSearchFnc_setResultDescription(a.Results[c])+
"</a>";b+="</span>";b+="</div>"}b+="</div>";SetInfoBody(b);b="";if(IsPrevPlaceVisible(a)){b+=typeof a.Params=="undefined"||typeof a.Params.PageFrom=="undefined"||typeof a.Params.PageTo=="undefined"?lngResults+" "+a.PageFrom+".."+a.PageTo+"&nbsp|&nbsp":lngResults+" "+a.Params.PageFrom+".."+a.Params.PageTo+"&nbsp|&nbsp";b+='&laquo;&nbsp;<a href="javascript:PrevPage();">';b+=lngPrevious;b+="</a>"}if(IsNextPlaceVisible(a)){if(IsPrevPlaceVisible(a))b+="&nbsp;|&nbsp;";b+='<a href="javascript:NextPage();">';
b+=lngNext;b+="</a>";b+="&nbsp;&raquo;"}SetInfoFooter(b);GotoInfoDivElement();a.Results.length==1&&LocateItem(0)}}function DisplaySearchError(a){var b="";switch(a){case -3:b=lngErrorInvalidID;break;case -2:b=lngErrorInvalidLayer;break;case -1:default:b=lngErrorNoResults;break}SwitchInfoPanel(0);SetInfoBody(b);ClearInfoFooter();GotoInfoDivElement()}function EnableLayer(a){if(map.LayerStates&&!map.LayerStates[a]){map.LayerStates[a]=!map.LayerStates[a];map.MapCommand("EL",parseInt(a))}}
function FindNearest(a){if(map){if(proj){GotoInfoDivElement();proj.NearestLayer=a;proj.OnCalculate=function(c,d){d&&nearest.NearestToPos("Ufon"+c.NearestLayer,d,MAPCOUNTRY)};var b=new ScreenPt(map.PopupX,map.PopupY);proj.Pixels2Proj(b)}ActiveNearestResults=a;map.HideMapMenu();EnableLayer(a)}}
function FindNearestToPos(a){if(POI_Location!="")if(map){if(proj){GotoInfoDivElement();nearest&&nearest.OnSearch();SwitchInfoPanel(0);proj.NearestLayer=a;proj.OnCalculate=function(c,d){d&&nearest.NearestToPos("Ufon"+c.NearestLayer,d,MAPCOUNTRY)};var b=new ScreenPt(POI_Location.x,POI_Location.y);RedirectCmdFinished();proj.Pixels2Proj(b)}ActiveNearestResults=a;map.HideMapMenu();EnableLayer(a)}}
function SwitchInfoPanel(a){var b=document.getElementById(ID_INFODIV_CONTENT),c=document.getElementById(ID_POIDIV);switch(parseInt(a)){case 0:if(b)b.className="InfoDivContent";if(c)c.className="hidden";break;case 1:if(b)b.className="hidden";if(c)c.className="InfoDivContent";break;default:break}}function SetInnerHTML(a,b){if(a=document.getElementById(a))a.innerHTML=b}function GetInnerHTML(a){if(a=document.getElementById(a))return a.innerHTML;return""}
function AppendInnerHTML(a,b){if(a=document.getElementById(a))a.innerHTML+=b}function SetInfoTitle(a){SetInnerHTML(ID_INFODIV_TITLE,a)}function SetInfoBody(a){SetInnerHTML(ID_INFODIV_BODY,a);hideFocusOutlineOnLinks(ID_INFODIV_BODY)}function AppendInfoBody(a){AppendInnerHTML(ID_INFODIV_BODY,a);hideFocusOutlineOnLinks(ID_INFODIV_BODY)}function ElementAddClassTo(a,b){if(a=document.getElementById(a)){var c=a.className.split(" ",2);if(b!="")b=" "+b;a.className=c[0]+b}}
function SetInfoFooter(a){SetInnerHTML(ID_INFODIV_FOOTER,a);var b="",c="";if(a==""||typeof a=="undefined"){b="fontSize0";c="higherInfoBody"}ElementAddClassTo(ID_INFODIV_FOOTER,b);ElementAddClassTo(ID_INFODIV_BODY,c);hideFocusOutlineOnLinks(ID_INFODIV_FOOTER)}function ClearInfoDiv(){locate_cov=false;ClearInfoFooter();SetInfoBody("");SetInfoTitle("")}function ClearInfoFooter(){SetInfoFooter("")}function GotoInfoDivElement(){document.location.href="#"+ID_INFODIV_CONTENT}
function GotoTopElement(){document.location.href="#idArrowUp"}function SetPOITitles(a,b){a!=-1&&SetInnerHTML(ID_POIDIV_TITLE_L,a);b!=-1&&SetInnerHTML(ID_POIDIV_TITLE_R,b)}function SetPOIBodies(a,b){a!=-1&&SetInnerHTML(ID_POIDIV_BODY_L,a);b!=-1&&SetInnerHTML(ID_POIDIV_BODY_R,b);hideFocusOutlineOnLinks(ID_POIDIV)}
function RenderPOImenu(){SetPOITitles(lngAvailableSignals,lngNearestObjects);var a="";if(LayerNearestTitles.length>0)for(b=0;b<LayerNearestTitles.length;b++){a+='<img style="border:none;margin-right:5px;" src="../img/point.gif?2" />&nbsp;<a href="javascript:FindNearestToPos('+b+')">';a+=LayerObjectNames[b].toLowerCase()+"</a><br />"}a="";if(typeof AvailCoverage!="undefined")for(var b=0;b<AvailCoverage.length;b++)a+='<a href="javascript:CheckCoveragePOI('+AvailCoverage[b][1]+')">'+AvailCoverage[b][0]+
"</a><br />";return true}function SetPromoBody(a){alert(a)}function CheckCoveragePOI(a){POIdontReset=true;CheckCoverage(a)}function RestoreCmdFinished(){map.OnCommandFinished=cmdFinishedBackupForPOI}function RedirectCmdFinished(a){cmdFinishedBackupForPOI=map.OnCommandFinished;map.OnCommandFinished=typeof a!="undefined"&&a=="dataloaded"?POIloaded2:POIloaded}function POIloaded(){map.OnCommandFinished=cmdFinishedBackupForPOI}
function POIloaded2(a){map.OnCommandFinished=cmdFinishedBackupForPOI;RenderPOImenu(a)}function UpdatePOImenu(){if(map)if(proj){proj.OnCalculate=function(b,c){if(c)map.PopupIcons[AntennaIconID].pos=c;RedirectCmdFinished("dataloaded");map.MapCommand("AVAILCOV","&pos="+c+"&cnt="+AvailCovCmdRunning+"&coords="+AvailCovCoords)};var a=new ScreenPt(POI_Location.x,POI_Location.y);RenderPOImenu();proj.Pixels2Proj(a)}}
function PlaceAntenna(a){var b=new ScreenPt(a.MouseX,a.MouseY);if(ngIExplorer){b.x-=2;b.y-=2}var c=a.PopupIcons[AntennaIconID];a.RemovePopupIconByID(AntennaIconID);a.PopupIcons[AntennaIconID]=c;a.DrawPopupIcon(AntennaIconID,b);return b}function DrawAntenna(a,b){var c=map;a=new ScreenPt(a,b);b=c.PopupIcons[AntennaIconID];c.RemovePopupIconByID(AntennaIconID);c.PopupIcons[AntennaIconID]=b;c.DrawPopupIcon(AntennaIconID,a)}
function HideIcon(){if(map){var a=map.PopupIcons[AntennaIconID];map.RemovePopupIconByID(AntennaIconID);map.PopupIcons[AntennaIconID]=a}}function LeftMouseButton(a){if(typeof ngIExplorer!="undefined"&&ngIExplorer&&a.button==1)return true;if(typeof ngOpera!="undefined"&&a.button==0)return true;if(typeof window.event=="undefined"&&a.button==0)return true;return false}
function POIMouseDown(a,b){if(!LeftMouseButton(b))return true;POIbeingLocated=true;POI_Location=new ScreenPt(a.MouseX,a.MouseY);if(ngIExplorer){POI_Location.x-=2;POI_Location.y-=2}POILocated=true;DrawAntenna(POI_Location.x,POI_Location.y);POIclicked||SwitchInfoPanel(1);UpdatePOImenu();return POIclicked=true}function StopMoveAntenna(){DrawAntenna(POI_Location.x,POI_Location.y)}
function POIMouseMove(a){if(typeof POIbeingLocated=="undefined"||!POIbeingLocated)return true;typeof IDAntennaTimer!="undefined"&&window.clearTimeout(IDAntennaTimer);IDAntennaTimer=window.setTimeout(UpdatePOImenu,500);if(ngIExplorer){typeof IDAntennaMOVEtimer!="undefined"&&window.clearTimeout(IDAntennaMOVEtimer);IDAntennaMOVEtimer=window.setTimeout(StopMoveAntenna,50)}POI_Location=new ScreenPt(a.MouseX,a.MouseY);if(ngIExplorer){POI_Location.x-=2;POI_Location.y-=2}HideIcon();return true}
function POIMouseUp(a,b){if(!LeftMouseButton(b))return true;POIbeingLocated=false;lastposX=a.PopupIcons[AntennaIconID].screenpos.x;lastposY=a.PopupIcons[AntennaIconID].screenpos.y;pos=PlaceAntenna(a,b);typeof IDAntennaTimer!="undefined"&&window.clearTimeout(IDAntennaTimer);if(typeof POI_Location!="undefined")if(POI_Location.x!=lastposX||POI_Location.y!=lastposY){POI_Location=new ScreenPt(pos.x,pos.y);if(ngIExplorer){POI_Location.x-=2;POI_Location.y-=2}POILocated=true;UpdatePOImenu()}return true}
function ResetPOILocation(){if(window.POILocated){if(typeof POIdontReset=="undefined"||!POIdontReset){HideIcon();POILocated=false;POI_Location="";POIclicked=false;SwitchInfoPanel(0)}UpdatePOImenu()}POIdontReset=false;return true}
function GetActiveObjPosByID(a,b,c){if(typeof c=="undefiend")c=map;var d,e=-1;if(typeof a=="string"){d=c.ActiveLayers.length;for(var f=0;f<d;f++)if(c.ActiveLayers[f].objid==a){e=f;break}}else e=a;if(e>=0&&e<c.ActiveLayers.length){a=c.ActiveLayers[e].objs;d=a.length;for(f=0;f<d;f++)if(a[f].objid==b)return a[f].pos}return false}function PopupCenter(){map.Center(map.PopupX,map.PopupY)}
function PopupMaxDetail(a){typeof a!="undefined"&&!a?map.LocateScaleXY("max",a):map.MaxDetail(map.PopupX,map.PopupY)}function PopupScale200(){map.SetScale(2E5,map.PopupX,map.PopupY)}function OpenURLInNewWin(a){return!window.open(a)}function OpenURLTF(a){try{var b=parent;if(b!=window){for(;b;){if(b.parent==b)break;b=b.parent}b.location.href=a}else document.location.href=a;return true}catch(c){return false}}
function PromoCreatePopupHTML(a,b,c){var d="";if(a!="")d+='<div class="'+this.PopupTextStyle+'">'+a+"</div>";if(typeof c!="undefined"&&c!="")d+='<div class="'+this.PopupMenuStyle+'Promo">'+c+"</div>";d+=typeof b!="undefined"&&b!=""?'<div class="'+this.PopupMenuStyle+'">'+b+"</div>":'<div class="'+this.PopupMenuStyle+'"></div>';return d}
function BuildPromoHtml(a){var b="";if(a.length==0)b+=lngNoCoverage;for(var c=0;c<a.length;c++)switch(a[c][0]){case "V":b+=lngOrderPopupV1;break;case "D":b+=lngOrderPopupD1;break}if(b.length==0)b=lngNothingAtThisPlace;return b}
function RenderNearestPopUpMenu(a,b,c,d,e){if(typeof c=="undefined")c="";c=c==""?lngMessageWaitLoading:typeof AvailCoverage!="undefined"?AvailCoverage.length==0?lngNoCoverage:BuildPromoHtml(AvailCoverage):"";d="";if(LayerNearestTitles.length>0)if(LayerNearestTitles.length>1){d+=lngFindNearest+" <br />";for(var f in LayerNearestTitles){d+='&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:FindNearest('+f+')">';d+=LayerNearestTitles[f].toLowerCase()+"</a><br />"}}else{f=0;d+='<a href="javascript:FindNearest('+
f+')">'+lngFindNearest+"&nbsp;";d+=LayerNearestTitles[f].toLowerCase()+"</a><br />"}d+='<a href="javascript:PopupCenter();">'+lngCenterMap+"</a>&nbsp;&raquo;<br />";d+=typeof e!="undefined"?"<a href=\"javascript:PopupMaxDetail('"+e+"');\">"+lngMaximalDetail+"</a>&nbsp;&raquo;<br />":'<a href="javascript:PopupMaxDetail();">'+lngMaximalDetail+"</a>&nbsp;&raquo;<br />";if(c=="")if(typeof AvailCoverage=="undefined"){c="";return a.CreatePopupHTML(b,d,c)}else{if(AvailCoverage.length==0){c=lngNoCoverage;
return a.CreatePopupHTML(b,d,c)}}else{if(typeof AvailCoverage=="undefined")c="";return a.CreatePopupHTML(b,d,c)}}
function RenderDefaultPopUpMenu(a,b,c,d,e){c="";c+='<a href="javascript:PopupCenter();">'+lngCenterMap+"</a>&nbsp;&raquo;<br />";c+=typeof e!="undefined"?"<a href=\"javascript:PopupMaxDetail('"+e+"');\">"+lngMaximalDetail+"</a>&nbsp;&raquo;<br />":'<a href="javascript:PopupMaxDetail();">'+lngMaximalDetail+"</a>&nbsp;&raquo;<br />";if(d!="undefined"&&d!="")c+=d;if(typeof AvailCoverage!="undefined"){d=new RegExp(/^.+(\|.+\|)$/i);d=d.exec(b);if(d!=null&&d[1]!=""){d=d[1];if(b.match(d))b=b.replace(/\|.+\|$/g,
"");d=d.replace(/\|/g,"");d=d.replace(/[\;\|]/g,"");AvailCoverage=eval("{"+d.replace(/^.+=/g,"")+"};")}else promo=""}else{d=new RegExp(/^.+(\|.+\|)$/i);d=d.exec(b);if(d!=null){d=d[1];if(b.match(d))b=b.replace(/\|.+\|$/g,"");d=d.replace(/\|/g,"");d=d.replace(/[\;\|]/g,"");AvailCoverage=eval("{"+d.replace(/^.+=/g,"")+"};")}promo=""}return typeof AvailCoverage!="undefined"?a.CreatePopupHTML(b,c,BuildPromoHtml(AvailCoverage)):a.CreatePopupHTML(b,c,promo)}
function CreatePopup(a,b,c,d,e,f){if(a){a.innerHTML='<div class="'+this.PopupFrameStyle+'">'+d+"</div>";var g=false,h=false;if(b+a.offsetWidth-28>this.MapWidth+e){g=true;b+=-a.offsetWidth+28}else b-=28;if(c-a.offsetHeight-12>f){h=true;c+=-a.offsetHeight-12}d=h?'<div class="'+this.PopupFrameStyle+'">'+d+'</div><div style="z-index: 503; position: relative; top:-1px; text-align:'+(g?"right":"left")+'"><img src="img/popupArrDown.gif?2" width="55" height="13" alt="" border="0" /></div>':'<div style="position: relative; z-index: 503; text-align:'+
(g?"right":"left")+'"><img src="img/popupArrUp.gif?2" width="55" height="13" alt="" border="0" /></div><div class="'+this.PopupFrameStyle+'" style="position: relative; top: -1px;">'+d+"</div>";a.innerHTML=d;h?ng_setLeftTop(a,b,c+2):ng_setLeftTop(a,b,c-2);a.style.visibility="visible"}}function ClosePopup(){map.HidePopup();map.HideMapMenu()}
function SearchMenu(a,b){var c=b.descr;locate_cov=true;if(typeof a.PopupIcons.Plc1_Search!="undefined"&&typeof a.PopupIcons.Plc1_Search.cov!="undefined"&&typeof AvailCoverage!="undefined")AvailCoverage=a.PopupIcons.Plc1_Search.cov;return RenderNearestPopUpMenu(a,c,"&nbsp",false,b.pos)}function ItemPopupMenu(a,b){return RenderDefaultPopUpMenu(a,b.descr,ngOpera)}
function MapMenuPos(a){if(a){locate_cov=false;if(typeof a.PopupIcons.Plc1_Search!="undefined"&&typeof a.PopupIcons.Plc1_Search.cov=="undefined"&&typeof AvailCoverage!="undefined")a.PopupIcons.Plc1_Search.cov=AvailCoverage;ClosePopup();var b=a.MouseX,c=a.MouseY;a.PopupX=a.MouseX;a.PopupY=a.MouseY;a.MapCommand("AVAILCOV","&pos_x="+b+"&pos_y="+c)}return RenderNearestPopUpMenu(a,lngAtThisPlace,"",false,ngOpera,"")}
function ActiveObjectMenu(a,b,c){a.HideMapMenu();var d=c.descr,e='<a href="#idInfoDiv" onclick="Detail(\''+c.objid+"','"+b.objid+"');\">"+lngMoreInformation+"</a>&nbsp;&raquo;<br />";if(b.objid.substring(0,8)=="ufon:BTS")for(b=0;b<Layers.length;b++)if(Layers[b]=="ufon:outages"){e+='<a href="#idInfoDiv" onclick="Detail(\''+c.objid+"','ufon:outage_history');\">"+lngOutagesHistory+"</a>&nbsp;&raquo;<br />";break}locate_cov=true;return RenderDefaultPopUpMenu(a,d,false,e,c.pos)}
function Detail(a,b,c){if(b.substring(0,8)=="ufon:BTS")b="ufon:BTS";switch(b){case "Ufon:Shops":phpscript="src/detail_shop.php";infoTitle=lngActiveObjects[0];break;case "ufon:BTS":phpscript="src/detail_bts.php";infoTitle=lngActiveObjects[1];break;case "ufon:outage_history":phpscript="src/detail_outage_history.php";infoTitle=lngActiveObjects[1];break;case "ufon:outages":phpscript="src/detail_outage.php";infoTitle=lngActiveObjects[2];break;default:return}ShowInfo();SetInfoTitle(infoTitle);SetInfoBody(lngMessageWaitLoading);
ClearInfoFooter();GotoInfoDivElement();if(!c||c=="undefined")c="";phpscript!=""&&places.ProcessUrl("../"+phpscript+"?id="+a+c+"&lang="+Lang)}
function LocateItem(a){if(searchresults){var b=Array("H","P","D");if(ActiveNearestResults>=0&&ActiveNearestResults<b.length)searchresults.SearchType=b[ActiveNearestResults];window.places&&places.ClearDisplayedItems();GotoTopElement();switch(searchresults.SearchType){case "H":case "P":case "D":LocateNearest(searchresults,a);return;default:searchresults.LocateItem(a,5E4);return}}}
function LocateMapXY(a,b,c){if(map){NearestPopupLay=Layers[a];NearestPopupObjID=c;map.ActiveCommandCallback=ShowNearestPopup;GotoTopElement();map.LocateScaleXY("max",b)}}function LocateAfterLayerOn(a){map.ActiveCommandCallback=ShowNearestPopup;if(map.PositionToLocateTo){GotoTopElement();map.LocateScaleXY("max",map.PositionToLocateTo)}return true}
function LocateMapGC(a,b,c){if(map){NearestPopupLay=Layers[a];NearestPopupObjID=c;map.PositionToLocateTo=b;map.ActiveCommandCallback=LocateAfterLayerOn;EnableLayer(a)}}function LocateLayerObjectRPC(a){LocateLayerObject(a.LocateLayerObject_Layer,a.LocateLayerObject_Geocode,a.LocateLayerObject_ObjID)}
function LocateLayerObject(a,b,c){if(map){OnTilesLoadedBak=map.OnTilesLoaded;map.OnTilesLoaded=ShowLayerObjectPopup;if(parseInt(a)!="NaN")a=parseInt(a);NearestPopupLay=a;NearestPopupObjID=c;map.MapCommand("LOCATELAYEROBJ","&layer="+a+"&position="+ng_URLEncode(b)+"&scale=max")}}function ShowLayerObjectPopup(a){if(OnTilesLoadedBak)a.OnTilesLoaded=OnTilesLoadedBak;a.ShowActiveObjPopupByID(NearestPopupLay,NearestPopupObjID);a.OnTilesLoaded(this);return true}
function ShowNearestPopup(a){a.ShowActiveObjPopupByID(NearestPopupLay,NearestPopupObjID)}function LocateNearest(a,b){var c=a.Results[b].id.split("_");if(c.length>=2){NearestPopupLay=c[0];NearestPopupObjID=c[1];map.ActiveCommandCallback=ShowNearestPopup}map.LocateScaleXY("max",a.Results[b].pos)}
function SetMapMode(a){a.OnMouseDown="";a.OnMouseUp="";a.OnMouseMove="";a.Mode=="P"?ImgChange("idControlPan",true):ImgChange("idControlPan",false);a.Mode=="Z+"?ImgChange("idControlZoom",true):ImgChange("idControlZoom",false);a.Mode=="L"?ImgChange("idControlAntenna",true):ImgChange("idControlAntenna",false);if(a.Mode=="L"){POIclicked=false;RenderPOImenu(true);a.MouseMode="LP";a.SetCursor(a.CursorLocatePt);if(window.POIMouseDown)a.OnMouseDown=POIMouseDown;if(window.POIMouseMove)a.OnMouseMove=POIMouseMove;
if(window.POIMouseUp)a.OnMouseUp=POIMouseUp}else{SwitchInfoPanel(0);ResetPOILocation()}}function setCheckImage(a,b,c){if(a=document.getElementById(a))a.src=c?"img/box_point"+b+"_.gif?2":"img/box_point"+b+".gif?2"}function switchCheckImage(a,b){if(a=document.getElementById(a))a.src=a.src=="img/box_point"+b+"_.gif?2"?"img/box_point"+b+".gif?2":"img/box_point"+b+"_.gif?2"}
function UpdateLayerStates(){if(map&&map.LayerStates)for(var a=0;a<map.LayerStates.length;a++)setCheckImage("idLayer"+a,3,map.LayerStates[a])}function UpdateCoverageStates(){if(map&&map.Coverage>=0&&Coverage)for(var a=0;a<Coverage.length;a++)setCheckImage("idCoverage"+a,2,a==map.Coverage?true:false)}
function DrawMapControls(a){renderScales();a.ZoomLevel==0&&a.Mode!="L"&&a.PanMode();if(a.ActiveCommand=="AVAILCOV"||a.ActiveCommand=="LI")if(typeof AvailCoverage!="undefined"){var b="";if(LayerNearestTitles.length>0)if(LayerNearestTitles.length>1){b+=lngFindNearest+" <br />";for(var c in LayerNearestTitles){b+='&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:FindNearest('+c+')">';b+=LayerNearestTitles[c].toLowerCase()+"</a><br />"}}else{c=0;b+='<a href="javascript:FindNearest('+c+')">'+lngFindNearest+
"&nbsp;";b+=LayerNearestTitles[c].toLowerCase()+"</a><br />"}b+='<a href="javascript:PopupCenter();">'+lngCenterMap+"</a>&nbsp;&raquo;<br />";b+=typeof position!="undefined"?"<a href=\"javascript:PopupMaxDetail('"+position+"');\">"+lngMaximalDetail+"</a>&nbsp;&raquo;<br />":'<a href="javascript:PopupMaxDetail();">'+lngMaximalDetail+"</a>&nbsp;&raquo;<br />";promo=AvailCoverage.length!=0?BuildPromoHtml(AvailCoverage):map.ActiveCommand=="LI"?lngNoCoverage:lngNothingAtThisPlace;b=map.CreatePopupHTML(typeof map.PopupIcons.Plc1_Search!=
"undefined"&&map.ActiveCommand!="AVAILCOV"?map.PopupIcons.Plc1_Search.descr:lngAtThisPlace,b,promo);if(locate_cov){c=map.PopupIcons.Plc1_Search.popupx;d=map.PopupIcons.Plc1_Search.popupy}else{c=map.MouseX;var d=map.MouseY}map.ActiveCommand=="AVAILCOV"&&map.CreatePopup(map.ObjMenu,c,d,b,0,0)}if(window.InitMapMode&&InitMapMode!=false){a.SetMode(InitMapMode);InitMapMode=false}UpdateLayerStates();UpdateCoverageStates();return true}
function hideFocusOutlineOnLinks(a){if(typeof a=="undefined"||a==""||!a)for(a=0;a<document.links.length;a++){if(ngIExplorer)document.links[a].hideFocus="true";document.links[a].style.outline="none"}else{if(typeof a!="object")a=document.getElementById(a);if(a){DBGlinksLevel=0;ProcessLinks(a)}}}
function ProcessLinks(a){tag_name=a.tagName;if(typeof tag_name!="undefined")tag_name=tag_name.toLowerCase();if(tag_name=="a"){if(ngIExplorer)a.hideFocus="true";a.style.outline="none"}for(var b=0;b<a.childNodes.length;b++)ProcessLinks(a.childNodes[b])}
function setArrowImages(){for(var a=new Array("imgLeftUp","imgLeftDown","imgRightUp","imgRightDown"),b=new Array("img/arr_leftup.png","img/arr_leftdown.png","img/arr_rightup.png","img/arr_rightdown.png"),c=0;c<b.length;c++){var d=document.getElementById(a[c]);if(d)if(ngIExplorer){d.src="img/empty.gif";d.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b[c]+"')"}else d.src=b[c]}}
function Init(){preloadImages(new Array("img/cross.png","img/zoom_in.gif?2","img/zoom_out.gif?2","img/zoom_green.gif?2","img/zoom1.gif?2","img/zoom2.gif?2","img/zoom3.gif?2","img/zoom4.gif?2","img/zoom5.gif?2","img/zoom6.gif?2","img/zoom7.gif?2","img/zoom8.gif?2","img/arr_leftup.png","img/arr_leftdown.png","img/arr_rightup.png","img/arr_rightdown.png","img/arr_up.png","img/arr_down.png","img/arr_left.png","img/arr_right.png","img/tb_zoom.gif?2","img/tb_pan.gif?2","img/tb_print.gif?2","img/tb_maximum.gif?2",
"img/tb_home.gif?2","img/zoom_out.gif?2","img/zoom_in.gif?2","img/point_green.gif"));hideFocusOutlineOnLinks();RenderSearchMenu();mapCommandRunning=false;LastActionParams=LastUserAction="";map=new ngMap("idMainMap","map.php?lang="+Lang);map.CreatePopupHTML=PromoCreatePopupHTML;map.CreatePopup=CreatePopup;map.OnModeChanged=SetMapMode;map.OnCommandFinished=DrawMapControls;map.OnItemPopupMenu=ItemPopupMenu;map.OnMapMenu=MapMenuPos;map.OnActiveObjectMenu=ActiveObjectMenu;document.oncontextmenu=function(){return false};
previewmap=new ngMap("idPreviewMap","map.php?lang="+Lang);previewmap.Preview(map,"csPreviewBox");map.LayerStates=[];proj=new ngProj(map);places=new ngPlaces(map);places.PageSize=10;places.OnSearch=StartSearch;places.OnSearchResults=DisplaySearchResults;places.OnSearchCancel=StopSearch;places.OnSearchError=DisplaySearchError;places.OnItemPopupMenu=SearchMenu;places.LocateIcon="img/cross.png";places.LocateIconHotSpot=new ScreenPt(12,12);nearest=new ngNearest(map);nearest.NearestURL="http://"+document.domain+
"/src/nearest.php";nearest.PageSize=10;nearest.OnSearch=StartSearch;nearest.OnSearchResults=DisplaySearchResults;nearest.OnSearchCancel=StopSearch;nearest.OnSearchError=DisplaySearchError;nearest.OnLocateItem=LocateNearest;setArrowImages();if(ShopID!=""&&ShopID!="undefined")Detail(ShopID,"Ufon:Shops","&uid="+ShopID+"&locate=true");else{if(InitSession!=""){map.MapSession=InitSession;map.X=InitX;map.Y=InitY;map.Update()}if(LocatePoint.length>0)map.MapCommand("LOCATEPT","&ACTIVELAY="+ActiveLayers+"&ACTIVECOV="+
ActiveCoverage+"&BW="+BWmap+("&SCALEPROJPOS="+LocatePoint));else{window.InitSearch&&InitSearch&&Search();map.MapCommand("IT","&ACTIVELAY="+ActiveLayers+"&ACTIVECOV="+ActiveCoverage+"&BW="+BWmap)}}ActiveNearestResults=-1}window.onload=Init;
