function GoodEndGame()
{  
   canvas.cursoroff();   
   canvas.SetContent(EndGameScreen);
   alxPlay(Burning);
   schedule(5000, 0, "GoodEndGameDialog");
}

function GoodEndGameDialog()
{
   canvas.cursoron();

   canvas.PushDialog(EndDialog);
   
   %text = "Congratulations! Your gang has successfully secured all of the nuclear silos and prevented the " @
   "destruction of the human race. With the Children of Tomorrow defeated and the threat of a nuclear holocaust " @
   "neutralized, the battered remains of the United States can hopefully start to rebuild."; 
   
   EndGameText.setText(%text);
}

function BadEndGame()
{
   InfoYesbutton.Visible = false;
   InfoNobutton.Visible = false;
   Infocontinuebutton.Visible = true;
   
   infocontinuebutton.command = "PushMain();";
   
   InfoWindow.Visible = true;
   
   %text = "Unfortunately your gang has run out of time. The Children of Tomorrow has managed to arm and launch " @
   "enough nuclear missiles to destroy the rest of the planet and end the continuation of the human race.";

   InfoText.setText(%text);
}

function PushMain()
{
   Infowindow.Visible = false;
   canvas.SetContent(RoadGangsMain);   
   $GameStarted = "";
}

function EndGameMenu::OnWake()
{
   // test for a save file, if there is no previous save go back to main menu
   
   if($VerifySaveGame $= true)
   {
      endgameyes.Visible = true;
      endgameno.Visible = true;
      endgamecontinue.Visible = false;
      endgamedesc.setText("Game over! Would you like to load your last save game?");      
   }

   if($VerifySaveGame $= "")
   {
      endgameyes.Visible = false;
      endgameno.Visible = false;
      endgamecontinue.Visible = true;
      endgamedesc.setText("Game over!");      
   }
   
}
