function CreatePopupMenu(map, popup) {
  var max       = map.ZoomLevels[0];
  var current   = map.ZoomLevels[map.ZoomLevel];
  
  var html = '<a href="" onclick="map.LocatePopupIcon(\'PL\'); return false;">'+MsgCenter+'</a><br />';
  
  if (max != current)
    html += '<a href="" onclick="map.LocatePopupIcon(\'PL\', \'max\'); return false;">'+MsgMaxDetail+'</a><br />';
  
  if (max!='200000' && current!='200000')
    html += '<a href="" onclick="map.LocatePopupIcon(\'PL\', 200000); return false;">'+MsgMap200+'</a><br />';
  
  return map.CreatePopupHTML(popup.descr,html);
}

function MapLocatePlace(iconPos, iconDesc) {
  var iconUrl  = ngMapAPIURL+'/locate.png';
  var iconHS   = new ScreenPt(15,15);
  var scale    = 'max';
  var icon     = null;
  
  icon = map.AddPopupIcon('PL', iconUrl, iconPos, iconDesc, iconHS);  
  icon.onpopup = CreatePopupMenu;
  map.LocatePopupIcon('PL', 'max');
}

function SwitchPlace(type_map) {
  
  if(map.TypeMap==type_map) return;
  if((map.TypeMap>=0)&&(map.TypeMap<LocatePlaces.length))
  {
    LocatePlaces[map.TypeMap].tagobject.className = '';
  }
  map.TypeMap=type_map;
  if((map.TypeMap>=0)&&(map.TypeMap<LocatePlaces.length))
  {
    LocatePlaces[map.TypeMap].tagobject.className = 'act';
    MapLocatePlace(LocatePlaces[map.TypeMap].pos, LocatePlaces[map.TypeMap].descr);     
  }
}

function MapInitialize(map)
{
  map.PanMode();
}

function init() {  
  map = new ngMap('Map');
  map.OnInitialize = MapInitialize;
  
  if((typeof LocatePlaces != 'undefined')&&(LocatePlaces.length>0))
  {
    map.TypeMap = -1;
    SwitchPlace(0);
  }
  else map.Home();
}

window.onload = init;
