moveMap.bindcmd( keyboard, $keys_Map, "LaunchMap();", "" );
moveMap.bindcmd( keyboard, $keys_QuickSave, "SaveGame();", "" );
moveMap.bindcmd( keyboard, $keys_QuickLoad, "QuickLoad();", "" );
moveMap.bindcmd( keyboard, $keys_GangStats, "LaunchGangStats();", "" );
moveMap.bindcmd( keyboard, $keys_SupplySearch, "LaunchSearchSupplies();", "" );
moveMap.bindcmd( keyboard, $keys_VehicleSearch, "LaunchSearchVehicles();", "" );
moveMap.bindcmd( keyboard, $keys_VehicleStats, "LaunchVehicleStats();", "" );
moveMap.bindcmd( keyboard, $keys_PeopleSearch, "LaunchSearchPeople();", "" );
moveMap.bindcmd( keyboard, $keys_HealGang, "LaunchHealGang();", "" );
moveMap.bindcmd( keyboard, $keys_VehicleUpgrades, "LaunchVehicleConfig();", "" );
moveMap.bindcmd( keyboard, $Keys_CaptureCity, "LaunchCaptureCity();", "" );
moveMap.bindcmd( keyboard, $keys_RotateCamera, "LaunchRotateCamera();", "" );
moveMap.bindcmd( keyboard, escape, "LaunchOptions();", "" );
moveMap.bindcmd( keyboard, $keys_Pause, "PauseGame();", "" );

moveMap.bindcmd( keyboard, $Keys_AttackCrew, "CustomAttackOrder(attackcrew);", "" );
moveMap.bindcmd( keyboard, $keys_AttackEngine, "CustomAttackOrder(attackengine);", "" );
moveMap.bindcmd( keyboard, $Keys_AttackGasTank, "CustomAttackOrder(attackgastank);", "" );
moveMap.bindcmd( keyboard, $Keys_AttackTires, "CustomAttackOrder(attacktires);", "" );
moveMap.bindcmd( keyboard, $Keys_AttackWeapon, "CustomAttackOrder(attackweapon);", "" );
moveMap.bindcmd( keyboard, $Keys_SelectTarget, "CustomAttackOrder(attackvehicle);", "" );
moveMap.bindcmd( keyboard, $Keys_BoardVehicle, "CustomAttackOrder(BoardVehicle);", "" );
moveMap.bindcmd( keyboard, $keys_RamVehicle, "CustomAttackOrder(RamVehicle);", "" );
moveMap.bindcmd( keyboard, $keys_Brake, "DecreasePlayerSpeed();", "" );
moveMap.bindcmd( keyboard, $keys_Accelerate, "IncreasePlayerSpeed();", "" );

// turn based

moveMap.bindcmd( keyboard, $keys_TurnLeft, "TurnPlayerLeft();", "" );
moveMap.bindcmd( keyboard, $Keys_TurnRight, "TurnPlayerRight();", "" );
moveMap.bindcmd( keyboard, $keys_Move, "PlayerMove();", "" );
moveMap.bindcmd( keyboard, $keys_Attack, "PlayerAttack();", "" );

//if($turnbased $= true)
//   QuickBattleMap.bind(mouse, "zaxis", "MouseWheelTB");
//else
   moveMap.bind(mouse, "zaxis", "MouseWheel");

function PauseGame()
{
   if($combat $= true)
   {
      $pause = sg.getScenePause();
      
      if($pause $= 1)
      {
         sg.setScenePause(false);
         $pause = "";         
         pausetext.visible = false;
      }
      else
      {
         sg.setScenePause(true);
         $pause = 1;
         
         // place the pause text on screen
         
         %pos = Screen2D.getCurrentCameraPosition();
         
         pausetext.visible = true;
         pausetext.SetPosition(%pos);
      }
   }
}

function LaunchRotateCamera()
{
   if($combat $= true && $peoplebattle $= "")
      RotateCamera();   
   
   if($peoplebattle $= true)
      RotateInfantrySquad();
}

function LaunchOptions()
{
   if($GameStarted !$= true  || $screenActive $= true)
      return;
   
   if(CheckSearchWindows() $= true)
      return;
   
   if($combat $= true)
   {
      if(QuitGame.isActive() $= true)
         canvas.PopDialog(QuitGame);
      else
         canvas.PushDialog(QuitGame);
   }
   else
   {
      if(Options.isActive() $= true)
         canvas.popdialog(Options);   
      else
         canvas.pushdialog(Options);   
   }
}

function LaunchCaptureCity()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;
   
   if(CheckSearchWindows() $= true)
      return;
      
   CaptureCity();
}

function LaunchSearchSupplies()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;

   SearchSupplies();
}

function LaunchSearchVehicles()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;

   SearchVehicles();
}

function LaunchSearchPeople()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;

   PeopleSearch();   
}

function LaunchHealGang()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;

   HealGang();
}

function LaunchVehicleConfig()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;
   
   canvas.pushdialog(VehicleConfig);   
}

function LaunchMap()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   alxPlay(click);

   if(CheckSearchWindows() $= true)
      return;

   canvas.PushDialog(worldmap);   
   
}

function LaunchGangStats()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;

   canvas.PushDialog(gangstats);      
}

function LaunchVehicleStats()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;

   canvas.PushDialog(vehiclestats);      
}

function LaunchVehicleUpgrades()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;

   if(CheckSearchWindows() $= true)
      return;

   canvas.PushDialog(vehicleconfig);   
}

function QuickLoad()
{
   if($GameStarted !$= true || $combat $= true || $screenActive $= true)
      return;
   
   // if there isn't a saved game don't load
   
   %fo = new fileobject();
  
   %file = "~/save" @ $saveid @ ".sav";

   %ret = %fo.OpenForRead(%file);
   
   if(%ret == 0)
      return;
   
   PreLoadGame();  
}

function CheckSearchWindows()
{
   if(Infowindow.Visible $= true)
      return true;
}

///////////////// turn based ///////////////////////////