ngNearestVer=1;ngNearestSubVer=0;ngNearestAPIVersion=ngNearestVer+"."+ngNearestSubVer;ngNearestByID=new Array();ngNearestLastID=0;errNearestNotFound=-1;errNearestNotAvailable=-2;function nr_ProcessUrl(a){this.rpc.sendRequest(a)}function nr_NearestToPos(d,c,b,a){if((d=="")||(c=="")){return}this.Reset();this.SearchType="P";this.NearestParams="&C=P&L="+ng_URLEncode(d)+"&POS="+c;if((typeof b!="undefined")&&(b!="")){this.NearestParams+="&COUNTRY="+ng_URLEncode(b)}if(typeof a!="undefined"){this.NearestParams+="&"+a}this.DoSearch()}function nr_NearestTo(b,e,d,c,a){if((b=="")||(e=="")||(d=="")){return}this.Reset();this.SearchType=b;this.NearestParams="&C="+b+"&L="+ng_URLEncode(e)+"&POS="+ng_URLEncode(d);if((typeof c!="undefined")&&(c!="")){this.NearestParams+="&COUNTRY="+ng_URLEncode(c)}if(typeof a!="undefined"){this.NearestParams+="&"+a}this.DoSearch()}function nr_LoadLayers(c){if((!this.OnLoadLayers)||(this.OnLoadLayers(this))){this.CmdID++;if(this.CmdID>99){this.CmdID=0}var b="NE="+this.NearestID+"&C=L&CI="+this.CmdID;if(this.APIKey!=""){b+="&KEY="+this.APIKey}if((typeof c!="undefined")&&(c!="")){b+="&COUNTRY="+ng_URLEncode(c)}var a=ng_AddURLParam(this.NearestURL,b);this.ProcessUrl(a)}}function nr_LayersLoaded(){if(this.OnLayersLoaded){this.OnLayersLoaded(this)}}function nr_URLStateParams(){var a="";if(this.NearestParams!=""){a+="NE="+this.NearestID+"&P="+this.Page+"&CI="+this.CmdID;if(this.DistEps>0){a+="&EP="+this.DistEps}if(this.PageSize>0){a+="&PS="+this.PageSize}if(this.APIKey!=""){a+="&KEY="+this.APIKey}a+=this.NearestParams}return a}function nr_DoSearch(){if(this.NearestParams!=""){if((!this.OnSearch)||(this.OnSearch(this))){this.CmdID++;if(this.CmdID>99){this.CmdID=0}var a=ng_AddURLParam(this.NearestURL,this.URLStateParams());this.ProcessUrl(a)}}}function nr_CancelSearch(){this.CmdID++;if(this.CmdID>99){this.CmdID=0}}function nr_SearchFinished(){if(this.OnSearchResults){this.OnSearchResults(this)}}function nr_Error(a){if(this.OnSearchError){this.OnSearchError(this,a)}}function nr_FirstPage(){if(this.Page>0){this.Page=0;this.DoSearch()}}function nr_NextPage(){if(this.NextVisible){this.Page++;this.DoSearch()}}function nr_PrevPage(){if(this.Page>0){this.Page--;this.DoSearch()}}function nr_FindItemByID(c){var b=Results.length;for(var a=0;a<b;a++){if((Results[a])&&(Results[a].id==c)){return a}}return -1}function nr_DefaultItemPopupMenu(b,a){return b.CreatePopupHTML(a.descr)}function nr_DisplayItem(b){if((!this.Map)||(b<0)||(b>=this.Results.length)){return false}var a=null;if(this.OnDisplayItem){a=this.OnDisplayItem(this,b)}if(!a){var e,d;var g=this.Results[b];if((typeof g.pos=="undefined")||(g.pos=="")){return null}var f=this.DisplayIcon.length;if(f>0){var c=((this.Page*this.PageSize)+b)%f;e=this.DisplayIcon[c];d=this.DisplayIconHotSpot[c]}else{e=this.LocateIcon;d=this.LocateIconHotSpot}a=this.Map.AddPopupIcon(this.LocateIconId+"_"+g.id,e,g.pos,g.descr,d);a.onpopup=this.OnItemPopupMenu}return a}function nr_DisplayItemByID(a){if(this.Map){return this.DisplayItem(this.FindItemByID(a))}return false}function nr_LocateItem(b,e,c){if((!this.Map)||(b<0)||(b>=this.Results.length)){return false}if((this.OnLocateItem)&&(!this.OnLocateItem(this,b))){return false}var d=this.Results[b];var f=this.LocateIconId+"_"+d.id;if(!this.Map.PopupIconExists(f)){f=this.LocateIconId+"_Search";this.Map.RemovePopupIconByID(f);var a=null;if(this.OnDisplayItem){a=this.OnDisplayItem(this,b)}if(!a){if((typeof d.pos=="undefined")||(d.pos=="")){return false}a=this.Map.AddPopupIcon(f,this.LocateIcon,d.pos,d.descr,this.LocateIconHotSpot);a.onpopup=this.OnItemPopupMenu}}if(typeof e=="undefined"){e=d.scale}return this.Map.LocatePopupIcon(f,e,c)}function nr_LocateItemByID(b,a){if(this.Map){return this.LocateItem(this.FindItemByID(b),undefined,a)}return false}function nr_LocateItems(a){if(this.Map){this.Map.LocatePopupIcons(this.LocateIconId+"_*",a)}}function nr_RemoveItem(a){if((!this.Map)||(a<0)||(a>=this.Results.length)){return false}var b=this.Results[a];if(b){this.Map.RemovePopupIconByID(this.LocateIconId+"_"+b.id);return true}return false}function nr_RemoveItemByID(a){if(this.Map){return this.RemoveItem(this.FindItemByID(a))}return false}function nr_DisplayAllItems(){var b=this.Results.length;for(var a=0;a<b;a++){this.DisplayItem(a)}}function nr_ClearDisplayedItems(){if(this.Map){this.Map.RemovePopupIconsByID(this.LocateIconId+"_")}}function getNearestByID(a){if(ngNearestByID){return ngNearestByID[a]}return null}function nr_Reset(){this.NearestParams="";this.Results=new Array();this.SearchType="";this.DistEps=0;this.Page=0;this.PageFrom=0;this.PageTo=0;this.NextVisible=false;this.PrevVisible=false;this.ClearDisplayedItems()}function ngNearest(b){ngNearestLastID++;this.NearestID="ngNear"+ngNearestLastID;this.rpc=new ngRPC(this.NearestID);ngNearestByID[this.NearestID]=this;if(typeof ngMapAPIKey=="undefined"){this.APIKey=""}else{this.APIKey=ngMapAPIKey}if(typeof b!="undefined"){this.Map=b}else{this.Map=null}this.NearestURL=ngMapAPIURL+"/nearest.php";this.NearestParams="";this.LocateIcon=ngMapAPIURL+"/locate.png";this.LocateIconHotSpot=new ScreenPt(15,15);this.LocateIconId="Near"+ngNearestLastID;ng_PreloadImage(this.LocateIcon);this.DisplayIcon=new Array();this.DisplayIconHotSpot=new Array();for(var a=0;a<10;a++){this.DisplayIcon[a]=ngMapAPIURL+"/n"+(a+1)+".png";this.DisplayIconHotSpot[a]=new ScreenPt(9,9);ng_PreloadImage(this.DisplayIcon[a])}this.Results=new Array();this.Layers=new Array();this.CmdID=0;this.SearchType="";this.DistEps=0;this.Page=0;this.PageFrom=0;this.PageTo=0;this.PageSize=0;this.NextVisible=false;this.PrevVisible=false;this.ProcessUrl=nr_ProcessUrl;this.DoSearch=nr_DoSearch;this.URLStateParams=nr_URLStateParams;this.SearchFinished=nr_SearchFinished;this.LayersLoaded=nr_LayersLoaded;this.Error=nr_Error;this.DefaultItemPopupMenu=nr_DefaultItemPopupMenu;this.Reset=nr_Reset;this.NearestToPos=nr_NearestToPos;this.NearestTo=nr_NearestTo;this.LoadLayers=nr_LoadLayers;this.FirstPage=nr_FirstPage;this.NextPage=nr_NextPage;this.PrevPage=nr_PrevPage;this.FindItemByID=nr_FindItemByID;this.DisplayItem=nr_DisplayItem;this.DisplayItemByID=nr_DisplayItemByID;this.LocateItem=nr_LocateItem;this.LocateItemByID=nr_LocateItemByID;this.LocateItems=nr_LocateItems;this.RemoveItem=nr_RemoveItem;this.RemoveItemByID=nr_RemoveItemByID;this.DisplayAllItems=nr_DisplayAllItems;this.ClearDisplayedItems=nr_ClearDisplayedItems;this.OnLoadLayers=null;this.OnLayersLoaded=null;this.OnSearch=null;this.OnSearchResults=null;this.OnSearchCancel=null;this.OnSearchError=null;this.OnItemPopupMenu=this.DefaultItemPopupMenu;this.OnDisplayItem=null;this.OnLocateItem=null};