function worldmap::OnWake()
{
   $MarkerList = "";
   $MapZoomLevel = 0;
   
   %position = map.GetPosition();
   
   mapwindow.SetSceneGraph(sg);
   
   %x = getWord(%position, 0);
   %y = getWord(%position, 1);

   mapwindow.setCurrentCameraPosition(%x SPC %y);
   mapwindow.setCurrentCameraArea(%x-1000 SPC %y-500 SPC %x+1000 SPC %y+500);      

   playermarker.visible = true;   
   playermarker.SetPosition(player.getPosition());
   
   for(%i=1;%i<=30;%i++)
   {
      %word = "silo" @ %i;
      
      if($silos[%word] $= 1 && %word.captured !$= 1)
      {
         %marker = new t2dStaticSprite() {
            imageMap = "nukemarker";
            frame = "0";
            canSaveDynamicFields = "1";
            size = "10.000 10.000";
            scenegraph = "sg";
            Layer = "2";
         };
         
         %pos = %word.GetPosition();
         %x = getWord(%pos, 0);
         %y = getWord(%pos, 1);
         
         %marker.SetPosition(%x, %y);
         
         if($MarkerList $= "")
            $MarkerList = %marker;
         else
            $MarkerList = $MarkerList SPC %marker;
      }
   }
}

function worldMap::OnSleep()
{
   playermarker.visible = false;   
   $screenActive = false;
   
   %count = getWordCount($MarkerList);
   
   for(%i=0;%i<%count;%i++)
   {
      %obj = getWord($MarkerList, %i);
         
      if(isObject(%obj) $= true)
         %obj.Safedelete();      
   }
}

function MapZoomIn()
{
   %position = player.GetPosition();
   %x = getWord(%position, 0);
   %y = getWord(%position, 1);
   
   $MapZoomLevel++;
      
   switch$ ($MapZoomLevel)
   {
      case 1:
         mapwindow.setCurrentCameraPosition(%x SPC %y);
         mapwindow.setCurrentCameraArea(%x-500 SPC %y-250 SPC %x+500 SPC %y+250);   
         playermarker.SetSize(30 SPC 30); 
         alxPlay(goodbeep);  
      case 2:
         mapwindow.setCurrentCameraPosition(%x SPC %y);
         mapwindow.setCurrentCameraArea(%x-250 SPC %y-125 SPC %x+250 SPC %y+125);         
         playermarker.SetSize(20 SPC 20); 
         alxPlay(goodbeep);  
      case 3:
         mapwindow.setCurrentCameraPosition(%x SPC %y);
         mapwindow.setCurrentCameraArea(%x-125 SPC %y-75 SPC %x+125 SPC %y+125);         
         playermarker.SetSize(10 SPC 10); 
         alxPlay(goodbeep);  
   }
   
   if($MapZoomLevel > 3)
      $MapZoomLevel = 3;
}

function MapZoomOut()
{
   $MapZoomLevel--;
   
   switch$ ($MapZoomLevel)
   {
      case 0:
         %position = map.GetPosition();
         
         %x = getWord(%position, 0);
         %y = getWord(%position, 1);

         mapwindow.setCurrentCameraPosition(%x SPC %y);
         mapwindow.setCurrentCameraArea(%x-1000 SPC %y-500 SPC %x+1000 SPC %y+500);      
         playermarker.SetSize(40 SPC 40); 
         alxPlay(goodbeep);  
      
      case 1:
         %position = player.GetPosition();
         %x = getWord(%position, 0);
         %y = getWord(%position, 1);
         playermarker.SetSize(30 SPC 30); 
         mapwindow.setCurrentCameraPosition(%x SPC %y);
         mapwindow.setCurrentCameraArea(%x-500 SPC %y-250 SPC %x+500 SPC %y+250);      
         alxPlay(goodbeep);  
      case 2:
         %position = player.GetPosition();
         %x = getWord(%position, 0);
         %y = getWord(%position, 1);
         playermarker.SetSize(20 SPC 20); 
         mapwindow.setCurrentCameraPosition(%x SPC %y);
         mapwindow.setCurrentCameraArea(%x-250 SPC %y-125 SPC %x+250 SPC %y+125);         
         alxPlay(goodbeep);  
   }
   
   if($MapZoomLevel < 0)
      $MapZoomLevel = 0;
}