function ResetVehicleConfig()
{
   config_upgradepoints.text = "Upgrade Points   " @ $UpgradePoints;
   vc_acceleration.Visible = false;
   vc_armor.Visible = false;
   vc_brakes.Visible = false;
   vc_capacity.Visible = false;
   vc_crossbow.Visible = false;
   vc_flamethrower.Visible = false;
   vc_gastankarmor.Visible = false;
   vc_machinegun.Visible = false;
   vc_ram.Visible = false;
   vc_rpg.Visible = false;
   vc_steering.Visible = false;
   vc_tirearmor.Visible = false;
   vc_tires.Visible = false;
   vc_topspeed.Visible = false;
   vc_windowarmor.Visible = false;
   DisplayTutorial(upgrade);
   
}

function ShowUpgradeLevel()
{
   // make all the upper levels grey

   level2_1.SetBitmap(expandfilename("~/data/images/gui/grey.png"));
   level2_2.SetBitmap(expandfilename("~/data/images/gui/grey.png"));
   level2_3.SetBitmap(expandfilename("~/data/images/gui/grey.png"));
   level2_4.SetBitmap(expandfilename("~/data/images/gui/grey.png"));

   level3_1.SetBitmap(expandfilename("~/data/images/gui/grey.png"));
   level3_2.SetBitmap(expandfilename("~/data/images/gui/grey.png"));
   level3_3.SetBitmap(expandfilename("~/data/images/gui/grey.png"));

   level4_1.SetBitmap(expandfilename("~/data/images/gui/grey.png"));
   level4_2.SetBitmap(expandfilename("~/data/images/gui/grey.png"));
   level4_3.SetBitmap(expandfilename("~/data/images/gui/grey.png"));

   if($CapturedCities >= 10)
   {
      level2_1.SetBitmap(expandfilename("~/data/images/screens/tire_armor.png"));
      level2_1.Command = "UpgradePart(tirearmor);";      
      level2_2.SetBitmap(expandfilename("~/data/images/screens/brake.png"));
      level2_2.Command = "UpgradePart(brakes);";
      level2_3.SetBitmap(expandfilename("~/data/images/screens/capacity.png"));
      level2_3.Command = "UpgradePart(capacity);";
      level2_4.SetBitmap(expandfilename("~/data/images/screens/flamethrower.png"));
      level2_4.Command ="UpgradePart(flamethrower);";
   }
   
   if($CapturedCities >= 20)
   {
      level3_1.SetBitmap(expandfilename("~/data/images/screens/window_armor.png"));
      level3_1.Command = "UpgradePart(windowarmor);";
      level3_2.SetBitmap(expandfilename("~/data/images/screens/top_speed.png"));
      level3_2.Command = "UpgradePart(topspeed);";
      level3_3.SetBitmap(expandfilename("~/data/images/screens/machinegun.png"));
      level3_3.Command = "UpgradePart(machinegun);";
   }

   if($CapturedCities >= 35)
   {
      level4_1.SetBitmap(expandfilename("~/data/images/screens/gas_tank_armor.png"));
      level4_1.Command = "UpgradePart(gastankarmor);";
      level4_2.SetBitmap(expandfilename("~/data/images/screens/turning.png"));
      level4_2.Command = "UpgradePart(steering);";
      level4_3.SetBitmap(expandfilename("~/data/images/screens/rpg.png"));
      level4_3.Command = "UpgradePart(rpg);";
   }
}

// direction is back or forward in the vehicle array

function ShowVehicle(%direction)
{
   alxPlay(click);

   if(%direction $= "")
   {
      $ShowListSlot = 1;

      // find the first vehicle in the array
      
      for(%i=1;%i<=10;%i++)
      {
         if($vehicles[%i, vehicle] !$= "")
         {
            $Configslot = %i;
            $ShowListSlot = %i;
            ResetVehicleConfig();
            break;   
         }
      }      
   }
   else
   {
      // get the next car
      
      if(%direction $= "forward")
      {
         $ShowListSlot++;
         
         for(%i=$ShowListSlot;%i<=10;%i++)
         {
            if($vehicles[%i, vehicle] !$= "")
            {
               $Configslot = %i;
               $ShowListSlot = %i;
               %match = true;
               ResetVehicleConfig();
               break;   
            }
         }               
         
         // if there isn't a match put showlistslot back to where it was
         
         if(%match $= "")
            $ShowListSlot--;
      }
      
      if(%direction $= "backward")
      {
         $ShowListSlot--;
         
         // messed up the loop if it's less then 1
         
         if($ShowListSlot < 1)
            $ShowListSlot = 1;
         
         for(%i=$ShowListSlot;%i>=1;%i--)
         {
            if($vehicles[%i, vehicle] !$= "")
            {
               $Configslot = %i;
               $ShowListSlot = %i;
               %match = true;
               ResetVehicleConfig();
               break;   
            }
         }      

         // if there isn't a match put showlistslot back to where it was
         
         if(%match $= "")
            $ShowListSlot++;
      }
   }
   
   // update icon
   
   vehicleicon.SetBitmap(expandfilename("~/data/images/icons/" @ $vehicles[$Configslot, vehicle] @ ".png"));
   vehicleicon.ToolTip = GetVehicleDisplayName($vehicles[$Configslot, vehicle]);
   
   if($vehicles[$Configslot, stocktirearmor] > 0)
   {
      vc_tirearmor.Visible = true;
      %num = GetUpgradeTireArmorPoints($vehicles[$Configslot, vehicle]);
      %level = $vehicles[$Configslot, stocktirearmor] / %num;
      vc_tirearmor.setExtent(%level*10, 10);            
   }

   if($vehicles[$Configslot, stockarmor] > 0)
   {
      vc_armor.Visible = true;
      %num = GetUpgradeArmorPoints($vehicles[$Configslot, vehicle]);
      %level = $vehicles[$Configslot, stockarmor] / %num;
      vc_armor.setExtent(%level*10, 10);            
   }

   if($vehicles[$Configslot, acceleration] > 0)
   {
      vc_acceleration.Visible = true;
      vc_acceleration.setExtent($vehicles[$Configslot, acceleration]*10, 10);
   }

   if($vehicles[$Configslot, brakes] > 0)
   {
      vc_brakes.Visible = true;
      vc_brakes.setExtent($vehicles[$Configslot, brakes]*10, 10);
   }
      
   if($vehicles[$Configslot, steering] > 0)
   {
      vc_steering.Visible = true;
      vc_steering.setExtent($vehicles[$Configslot, steering]*10, 10);
   }
   
   if($vehicles[$Configslot, stockwindowarmor] > 0)
   {
      vc_windowarmor.Visible = true;
      %num = GetUpgradewindowArmorPoints($vehicles[$Configslot, vehicle]);
      %level = $vehicles[$Configslot, stockwindowarmor] / %num;
      vc_windowarmor.setExtent(%level*10, 10);            
   }
   
   if($vehicles[$Configslot, stockgastankarmor] > 0)
   {
      vc_gastankarmor.Visible = true;
      %num = GetUpgradeGasTankArmorPoints($vehicles[$Configslot, vehicle]);
      %level = $vehicles[$Configslot, stockgastankarmor] / %num;
      vc_gastankarmor.setExtent(%level*10, 10);      
   }
   
   if($vehicles[$Configslot, tireupgrade] > 0)
   {
      vc_tires.Visible = true;
      %num = $vehicles[$Configslot, tireupgrade]*16.6;
      
      if(%num >= 49)  
         %num = 50;
         
      vc_tires.setExtent(%num, 10);
   }
   

   if($vehicles[$Configslot, topspeed] > GetVehicleTopSpeed($vehicles[$Configslot, vehicle]))
   {
      vc_topspeed.Visible = true;
      vc_topspeed.setExtent($vehicles[$Configslot, topspeedlevel] * 10, 10);    
   }

   if($vehicles[$Configslot, mountedweapon] !$= "")
   {
      %num = GetUpgradeSpecialWeaponHitPoints($vehicles[$Configslot, mountedweapon]);
      %level = $vehicles[$Configslot, stockmountedweaponhp] / %num;
      
      switch$($vehicles[$Configslot, mountedweapon])
      {
         case "crossbow":
            vc_crossbow.Visible = true;
            vc_crossbow.setExtent(%level*10, 10);         
         case "flamethrower":
            vc_flamethrower.Visible = true;
            vc_flamethrower.setExtent(%level*10, 10);
         case "machinegun":
            vc_machinegun.Visible = true;
            vc_machinegun.setExtent(%level*10, 10);
         case "rpg":
            vc_rpg.Visible = true;
            vc_rpg.setExtent(%level*10, 10);
      }
   }

   if($vehicles[$Configslot, stockramhp] > 0)
   {
      vc_ram.Visible = true;
      %num = GetUpgradeRamPoints($vehicles[$Configslot, vehicle]);
      %level = $vehicles[$Configslot, stockramhp] / %num;
      vc_ram.setExtent(%level*10, 10);      
   }

   if($vehicles[$Configslot, supplycapacity] > GetVehicleSupplyCapacity($vehicles[$Configslot, vehicle]))
   {
      vc_capacity.Visible = true;
      %num = GetSupplyCapacityUpgrade($vehicles[$Configslot, vehicle]);
      %stockcapacity = GetVehicleSupplyCapacity($vehicles[$Configslot, vehicle]);
      %extracapacity = $vehicles[$Configslot, SupplyCapacity] - %stockcapacity;
      %level = %extracapacity / %num;
      vc_capacity.setExtent(%level*10, 10);
   }
   
   DisplayPointCost();
}

function UpgradePart(%item)
{
   %points = GetPointCost($vehicles[$Configslot, vehicle], %item);

   if(%points > $UpgradePoints)
   {
      alxPlay(buzzer);
      return;
   }
   
   switch$ (%item)
   {
      case "acceleration":
         if($vehicles[$Configslot, acceleration] == 5)
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, acceleration]++;
         
         vc_acceleration.Visible = true;
         vc_acceleration.setExtent($vehicles[$Configslot, acceleration]*10, 10);

      case "armor":
         %armor = GetUpgradeArmorPoints($vehicles[$Configslot, vehicle]);
         %max = %armor*5;
         
         if($vehicles[$Configslot, stockarmor] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         // can't mount to certain vehicles
         
         if($vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }
         
         $vehicles[$Configslot, stockarmor] = $vehicles[$Configslot, stockarmor]+%armor;
         $vehicles[$Configslot, currentarmor] = $vehicles[$Configslot, currentarmor]+%armor;

         vc_armor.Visible = true;
         %num = GetUpgradeArmorPoints($vehicles[$Configslot, vehicle]);
         %level = $vehicles[$Configslot, stockarmor] / %num;
         vc_armor.setExtent(%level*10, 10);            
      
      case "brakes":
         if($vehicles[$Configslot, brakes] == 5)
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, brakes]++;

         vc_brakes.Visible = true;
         vc_brakes.setExtent($vehicles[$Configslot, brakes]*10, 10);
      
      case "capacity":
         %capacity = GetSupplyCapacityUpgrade($vehicles[$Configslot, vehicle]);
         %max = %capacity*5;
         %max = %max+GetVehicleSupplyCapacity($vehicles[$Configslot, vehicle]);
                  
         if($vehicles[$Configslot, supplycapacity] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, SupplyCapacity] = $vehicles[$Configslot, SupplyCapacity]+GetSupplyCapacityUpgrade($vehicles[$Configslot, vehicle]);         

         vc_capacity.Visible = true;
         %num = GetSupplyCapacityUpgrade($vehicles[$Configslot, vehicle]);
         %stockcapacity = GetVehicleSupplyCapacity($vehicles[$Configslot, vehicle]);
         %extracapacity = $vehicles[$Configslot, SupplyCapacity] - %stockcapacity;
         %level = %extracapacity / %num;
         vc_capacity.setExtent(%level*10, 10);
            
      case "tireupgrade":
         if($vehicles[$Configslot, tireupgrade] == 3)
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, tireupgrade]++;

         vc_tires.Visible = true;
         %num = $vehicles[$Configslot, tireupgrade]*16.6;
         
         if(%num >= 49)  
            %num = 50;
            
         vc_tires.setExtent(%num, 10);
            
      case "gastankarmor":
         %armor = GetUpgradeGasTankArmorPoints($vehicles[$Configslot, vehicle]);
         %max = %armor*5;
         
         if($vehicles[$Configslot, stockgastankarmor] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, stockgastankarmor] = $vehicles[$Configslot, stockgastankarmor]+%armor;
         $vehicles[$Configslot, currentgastankarmor] = $vehicles[$Configslot, currentgastankarmor]+%armor; 

         vc_gastankarmor.Visible = true;
         %num = GetUpgradeGasTankArmorPoints($vehicles[$Configslot, vehicle]);
         %level = $vehicles[$Configslot, stockgastankarmor] / %num;
         vc_gastankarmor.setExtent(%level*10, 10);      
      
      case "tirearmor":
         %armor = GetUpgradeTireArmorPoints($vehicles[$Configslot, vehicle]);
         %max = %armor*5;

         if($vehicles[$Configslot, stocktirearmor] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         if($vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, stocktirearmor] = $vehicles[$Configslot, stocktirearmor]+%armor;
         $vehicles[$Configslot, currenttirearmor] = $vehicles[$Configslot, currenttirearmor]+%armor;

         vc_tirearmor.Visible = true;
         %num = GetUpgradeTireArmorPoints($vehicles[$Configslot, vehicle]);
         %level = $vehicles[$Configslot, stocktirearmor] / %num;
         vc_tirearmor.setExtent(%level*10, 10);            
      
      case "windowarmor":
         %armor = GetUpgradewindowArmorPoints($vehicles[$Configslot, vehicle]);
         %max = %armor*5;
         
         if($vehicles[$Configslot, stockwindowarmor] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         if($vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, stockwindowarmor] = $vehicles[$Configslot, stockwindowarmor]+%armor;
         $vehicles[$Configslot, currentwindowarmor] = $vehicles[$Configslot, currentwindowarmor]+%armor;

         vc_windowarmor.Visible = true;
         %num = GetUpgradewindowArmorPoints($vehicles[$Configslot, vehicle]);
         %level = $vehicles[$Configslot, stockwindowarmor] / %num;
         vc_windowarmor.setExtent(%level*10, 10);            
      
      case "ram":
         %ram = GetUpgradeRamPoints($vehicles[$Configslot, vehicle]);
         %max = %ram*5;
         
         if($vehicles[$Configslot, stockramhp] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         // can't mount to certain vehicles
         
         if($vehicles[$Configslot, vehicle] $= "compact" || $vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "jeep" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, stockramhp] = $vehicles[$Configslot, stockramhp]+%ram;
         $vehicles[$Configslot, currentramhp] = $vehicles[$Configslot, currentramhp]+%ram;

         vc_ram.Visible = true;
         %num = GetUpgradeRamPoints($vehicles[$Configslot, vehicle]);
         %level = $vehicles[$Configslot, stockramhp] / %num;
         vc_ram.setExtent(%level*10, 10);      

      case "crossbow":
         %weapon = GetUpgradeSpecialWeaponHitPoints("crossbow");
         %max = %weapon*5;
         
         if($vehicles[$Configslot, stockmountedweaponhp] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         // can't mount to certain vehicles
         
         if($vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "jeep" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }
         
         // if they are upgrading from another weapon
                  
         if($vehicles[$Configslot, mountedweapon] !$= "crossbow")
         {
            $vehicles[$Configslot, mountedweapon] = "";
            $vehicles[$Configslot, stockmountedweaponhp] = "";
            $vehicles[$Configslot, currentmountedweaponhp] = "";
            vc_rpg.Visible = false;
            vc_flamethrower.Visible = false;
            vc_machinegun.Visible = false;
         }

         $vehicles[$Configslot, mountedweapon] = "crossbow";
         $vehicles[$Configslot, stockmountedweaponhp] = $vehicles[$Configslot, stockmountedweaponhp]+%weapon;
         $vehicles[$Configslot, currentmountedweaponhp] = $vehicles[$Configslot, currentmountedweaponhp]+%weapon;

         %num = GetUpgradeSpecialWeaponHitPoints($vehicles[$Configslot, mountedweapon]);
         %level = $vehicles[$Configslot, stockmountedweaponhp] / %num;
         vc_crossbow.Visible = true;
         vc_crossbow.setExtent(%level*10, 10);         

      case "flamethrower":
         %weapon = GetUpgradeSpecialWeaponHitPoints("flamethrower");
         %max = %weapon*5;

         if($vehicles[$Configslot, stockmountedweaponhp] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         // can't mount to certain vehicles
         
         if($vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "jeep" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }

         // if they are upgrading from another weapon
                  
         if($vehicles[$Configslot, mountedweapon] !$= "flamethrower")
         {
            $vehicles[$Configslot, mountedweapon] = "";
            $vehicles[$Configslot, stockmountedweaponhp] = "";
            $vehicles[$Configslot, currentmountedweaponhp] = "";
            vc_crossbow.Visible = false;
            vc_rpg.Visible = false;
            vc_machinegun.Visible = false;
         }

         $vehicles[$Configslot, mountedweapon] = "flamethrower";
         $vehicles[$Configslot, stockmountedweaponhp] = $vehicles[$Configslot, stockmountedweaponhp]+%weapon;
         $vehicles[$Configslot, currentmountedweaponhp] = $vehicles[$Configslot, currentmountedweaponhp]+%weapon;

         %num = GetUpgradeSpecialWeaponHitPoints($vehicles[$Configslot, mountedweapon]);
         %level = $vehicles[$Configslot, stockmountedweaponhp] / %num;
         vc_flamethrower.Visible = true;
         vc_flamethrower.setExtent(%level*10, 10);

      case "machinegun":
         %weapon = GetUpgradeSpecialWeaponHitPoints("machinegun");
         %max = %weapon*5;

         if($vehicles[$Configslot, stockmountedweaponhp] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         // if they are upgrading from another weapon
                  
         if($vehicles[$Configslot, mountedweapon] !$= "machinegun")
         {
            $vehicles[$Configslot, mountedweapon] = "";
            $vehicles[$Configslot, stockmountedweaponhp] = "";
            $vehicles[$Configslot, currentmountedweaponhp] = "";
            vc_crossbow.Visible = false;
            vc_flamethrower.Visible = false;
            vc_rpg.Visible = false;
         }

         // can't mount to certain vehicles
         
         if($vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "jeep" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, mountedweapon] = "machinegun";
         $vehicles[$Configslot, stockmountedweaponhp] = $vehicles[$Configslot, stockmountedweaponhp]+%weapon;
         $vehicles[$Configslot, currentmountedweaponhp] = $vehicles[$Configslot, currentmountedweaponhp]+%weapon;

         %num = GetUpgradeSpecialWeaponHitPoints($vehicles[$Configslot, mountedweapon]);
         %level = $vehicles[$Configslot, stockmountedweaponhp] / %num;      
         vc_machinegun.Visible = true;
         vc_machinegun.setExtent(%level*10, 10);
      
      case "rpg":
         %weapon = GetUpgradeSpecialWeaponHitPoints("rpg");
         %max = %weapon*5;

         if($vehicles[$Configslot, stockmountedweaponhp] == %max)
         {
            alxPlay(buzzer);
            return;            
         }

         // if they are upgrading from another weapon
                  
         if($vehicles[$Configslot, mountedweapon] !$= "rpg")
         {
            $vehicles[$Configslot, mountedweapon] = "";
            $vehicles[$Configslot, stockmountedweaponhp] = "";
            $vehicles[$Configslot, currentmountedweaponhp] = "";
            vc_crossbow.Visible = false;
            vc_flamethrower.Visible = false;
            vc_machinegun.Visible = false;
         }
         
         // can't mount to certain vehicles
         
         if($vehicles[$Configslot, vehicle] $= "bike" || $vehicles[$Configslot, vehicle] $= "jeep" || $vehicles[$Configslot, vehicle] $= "dunebuggy")
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, mountedweapon] = "rpg";
         $vehicles[$Configslot, stockmountedweaponhp] = $vehicles[$Configslot, stockmountedweaponhp]+%weapon;
         $vehicles[$Configslot, currentmountedweaponhp] = $vehicles[$Configslot, currentmountedweaponhp]+%weapon;

         %num = GetUpgradeSpecialWeaponHitPoints($vehicles[$Configslot, mountedweapon]);
         %level = $vehicles[$Configslot, stockmountedweaponhp] / %num;
         vc_rpg.Visible = true;
         vc_rpg.setExtent(%level*10, 10);
      
      case "topspeed":
         if($vehicles[$Configslot, topspeedlevel] == 5)
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, topspeed] = $vehicles[$Configslot, topspeed]+10;
         $vehicles[$Configslot, topspeedlevel]++;

         vc_topspeed.Visible = true;
         vc_topspeed.setExtent($vehicles[$Configslot, topspeedlevel] * 10, 10);    
               
      case "steering":
         if($vehicles[$Configslot, steering] == 5)
         {
            alxPlay(buzzer);
            return;            
         }

         $vehicles[$Configslot, steering]++;

         vc_steering.Visible = true;
         vc_steering.setExtent($vehicles[$Configslot, steering]*10, 10);
   }

   $UpgradePoints = $UpgradePoints-%points;   
   alxPlay(upgrade);
   config_upgradepoints.text = "Upgrade Points   " @ $UpgradePoints;
}


function DisplayPointCost()
{
   for(%i=1;%i<=5;%i++)
   {
      %control = "level1_" @ %i;
      
      switch$ (%control.text)
      {      
         case "acceleration":
            %desc = "Acceleration";         
         case "armor":
            %desc = "Armor";
         case "tireupgrade":
            %desc = "Tires";
         case "ram":
            %desc = "Ram";
         case "crossbow":
            %desc = "Crossbow";
      }

      %string = %desc SPC "point cost Is " @ GetPointCost($vehicles[$Configslot, vehicle], %control.text);      
      %control.ToolTip = %string;      
   }

   if($CapturedCities >= 10)
   {
      for(%i=1;%i<=4;%i++)
      {
         %control = "level2_" @ %i;
         
         switch$ (%control.text)
         {      
            case "tirearmor":
               %desc = "Tire Armor";
            case "brakes":
               %desc = "Brakes";
            case "capacity":
               %desc = "Supply Capacity";
            case "flamethrower":
               %desc = "Flame Thrower";
         }
         
         %string = %desc SPC "point cost Is " @ GetPointCost($vehicles[$Configslot, vehicle], %control.text);      
         %control.ToolTip = %string;      
      }
   }

   if($CapturedCities >= 20)
   {
      for(%i=1;%i<=3;%i++)
      {
         %control = "level3_" @ %i;
         
         switch$ (%control.text)
         {      
            case "machinegun":
               %desc = "Machine Gun";
            case "windowarmor":
               %desc = "Window Armor";
            case "topspeed":
               %desc = "Topspeed";
         }

         %string = %desc SPC "point cost Is " @ GetPointCost($vehicles[$Configslot, vehicle], %control.text);      
         %control.ToolTip = %string;      
      }
   }
   
   if($CapturedCities >= 35)
   {
      for(%i=1;%i<=3;%i++)
      {
         %control = "level4_" @ %i;
         
         switch$ (%control.text)
         {      
            case "gastankarmor":
               %desc = "Gas Tank Armor";
            case "rpg":
               %desc = "RPG";
            case "steering":
               %desc = "Steering";
         }

         %string = %desc SPC "point cost Is " @ GetPointCost($vehicles[$Configslot, vehicle], %control.text);      
         %control.ToolTip = %string;      
      }
   }
      
}



// depending on the size of the vehicle this will be a per level upgrade of supply capacity for 1 vehicle

function GetSupplyCapacityUpgrade(%vehicle)
{
   switch$ (%vehicle)
   {
      case "dunebuggy":
         return 10;           
      case "bike":
         return 5;           
      case "jeep":
         return 10;           
      case "compact":
         return 15;           
      case "minivan":
         return 15;           
      case "towtruck":
         return 15;           
      case "van":
         return 20;           
      case "limo":
         return 20;           
      case "sedan":
         return 15;           
      case "sportscar":
         return 10;           
      case "pickuptruck":
         return 15;           
      case "musclecar":
         return 15;           
      case "stationwagon":
         return 20;           
      case "humvee":
         return 25;           
      case "suv":
         return 25;           
      case "flatbedtruck":
         return 30;           
      case "trailertruck":
         return 30;           
      case "fireengine":
         return 20;           
      case "garbagetruck":
         return 20;           
      case "bus":
         return 30;           
      case "boxtruck":
         return 20;           
      case "cargovan":
         return 20;           
      case "ambulance":
         return 15;           
      case "construction":
         return 10;                 
   }
}

function vehicleconfig::OnSleep()
{
   $screenActive = false;
   UpdateStatsBar();
}

// the point cost for items - the points need to stay in 1 function for easy changing

function GetPointCost(%vehicle, %item)
{   
   switch$ (%item)
   {
      case "acceleration":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 2;
            case "minivan":
               return 2;
            case "towtruck":
               return 2;
            case "van":
               return 2;
            case "limo":
               return 2;
            case "sedan":
               return 2;
            case "sportscar":
               return 1;
            case "pickuptruck":
               return 2;
            case "musclecar":
               return 2;
            case "stationwagon":
               return 2;
            case "humvee":
               return 2;
            case "suv":
               return 2;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 3;
            case "boxtruck":
               return 3;
            case "cargovan":
               return 2;
            case "ambulance":
               return 2;
            case "construction":
               return 1;
         }
      case "armor":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 1;
            case "minivan":
               return 2;
            case "towtruck":
               return 3;
            case "van":
               return 3;
            case "limo":
               return 3;
            case "sedan":
               return 3;
            case "sportscar":
               return 2;
            case "pickuptruck":
               return 3;
            case "musclecar":
               return 3;
            case "stationwagon":
               return 3;
            case "humvee":
               return 3;
            case "suv":
               return 3;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 4;
            case "garbagetruck":
               return 4;
            case "bus":
               return 4;
            case "boxtruck":
               return 4;
            case "cargovan":
               return 3;
            case "ambulance":
               return 3;
            case "construction":
               return 3;
         }
      case "brakes":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 2;
            case "minivan":
               return 2;
            case "towtruck":
               return 2;
            case "van":
               return 2;
            case "limo":
               return 2;
            case "sedan":
               return 2;
            case "sportscar":
               return 1;
            case "pickuptruck":
               return 2;
            case "musclecar":
               return 2;
            case "stationwagon":
               return 2;
            case "humvee":
               return 2;
            case "suv":
               return 2;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 3;
            case "boxtruck":
               return 3;
            case "cargovan":
               return 2;
            case "ambulance":
               return 2;
            case "construction":
               return 3;
         }
      case "capacity":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 1;
            case "minivan":
               return 1;
            case "towtruck":
               return 2;
            case "van":
               return 2;
            case "limo":
               return 2;
            case "sedan":
               return 2;
            case "sportscar":
               return 2;
            case "pickuptruck":
               return 3;
            case "musclecar":
               return 3;
            case "stationwagon":
               return 1;
            case "humvee":
               return 3;
            case "suv":
               return 3;
            case "flatbedtruck":
               return 5;
            case "traiertruck":
               return 5;
            case "fireengine":
               return 4;
            case "garbagetruck":
               return 4;
            case "bus":
               return 4;
            case "boxtruck":
               return 4;
            case "cargovan":
               return 3;
            case "ambulance":
               return 3;
            case "construction":
               return 3;
         }
      case "crossbow":
         return 5;
      case "tireupgrade":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 1;
            case "minivan":
               return 2;
            case "towtruck":
               return 3;
            case "van":
               return 3;
            case "limo":
               return 3;
            case "sedan":
               return 3;
            case "sportscar":
               return 2;
            case "pickuptruck":
               return 3;
            case "musclecar":
               return 3;
            case "stationwagon":
               return 3;
            case "humvee":
               return 3;
            case "suv":
               return 3;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 3;
            case "boxtruck":
               return 3;
            case "cargovan":
               return 3;
            case "ambulance":
               return 3;
            case "construction":
               return 2;
         }
      case "flamethrower":
         return 7;
      case "gastankarmor":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 1;
            case "minivan":
               return 2;
            case "towtruck":
               return 3;
            case "van":
               return 3;
            case "limo":
               return 3;
            case "sedan":
               return 3;
            case "sportscar":
               return 2;
            case "pickuptruck":
               return 3;
            case "musclecar":
               return 3;
            case "stationwagon":
               return 3;
            case "humvee":
               return 3;
            case "suv":
               return 3;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 4;
            case "boxtruck":
               return 4;
            case "cargovan":
               return 3;
            case "ambulance":
               return 3;
            case "construction":
               return 2;
         }
      case "machinegun":
         return 10;
      case "windowarmor":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 1;
            case "minivan":
               return 2;
            case "towtruck":
               return 2;
            case "van":
               return 2;
            case "limo":
               return 2;
            case "sedan":
               return 2;
            case "sportscar":
               return 1;
            case "pickuptruck":
               return 2;
            case "musclecar":
               return 2;
            case "stationwagon":
               return 3;
            case "humvee":
               return 2;
            case "suv":
               return 2;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 3;
            case "boxtruck":
               return 3;
            case "cargovan":
               return 2;
            case "ambulance":
               return 2;
            case "construction":
               return 2;
         }
      case "ram":      
         switch$ (%vehicle)
         {
            case "jeep":
               return 2;
            case "compact":
               return 2;
            case "minivan":
               return 2;
            case "towtruck":
               return 3;
            case "van":
               return 3;
            case "limo":
               return 4;
            case "sedan":
               return 3;
            case "sportscar":
               return 2;
            case "pickuptruck":
               return 3;
            case "musclecar":
               return 3;
            case "stationwagon":
               return 3;
            case "humvee":
               return 4;
            case "suv":
               return 4;
            case "flatbedtruck":
               return 5;
            case "trailertruck":
               return 5;
            case "fireengine":
               return 4;
            case "garbagetruck":
               return 4;
            case "bus":
               return 4;
            case "boxtruck":
               return 4;
            case "cargovan":
               return 4;
            case "ambulance":
               return 4;
            case "construction":
               return 4;
         }
      case "rpg":
         return 12;
      case "steering":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 2;
            case "minivan":
               return 2;
            case "towtruck":
               return 2;
            case "van":
               return 2;
            case "limo":
               return 2;
            case "sedan":
               return 2;
            case "sportscar":
               return 1;
            case "pickuptruck":
               return 2;
            case "musclecar":
               return 2;
            case "stationwagon":
               return 2;
            case "humvee":
               return 2;
            case "suv":
               return 2;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 3;
            case "boxtruck":
               return 3;
            case "cargovan":
               return 2;
            case "ambulance":
               return 2;
            case "construction":
               return 2;
         }
      case "tirearmor":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 1;
            case "minivan":
               return 2;
            case "towtruck":
               return 3;
            case "van":
               return 3;
            case "limo":
               return 3;
            case "sedan":
               return 3;
            case "sportscar":
               return 2;
            case "pickuptruck":
               return 3;
            case "musclecar":
               return 3;
            case "stationwagon":
               return 3;
            case "humvee":
               return 3;
            case "suv":
               return 3;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 3;
            case "boxtruck":
               return 4;
            case "cargovan":
               return 3;
            case "ambulance":
               return 3;
            case "construction":
               return 2;
         }
      case "topspeed":
         switch$ (%vehicle)
         {
            case "dunebuggy":
               return 1;
            case "bike":
               return 1;
            case "jeep":
               return 1;
            case "compact":
               return 2;
            case "minivan":
               return 2;
            case "towtruck":
               return 2;
            case "van":
               return 2;
            case "limo":
               return 2;
            case "sedan":
               return 2;
            case "sportscar":
               return 1;
            case "pickuptruck":
               return 2;
            case "musclecar":
               return 2;
            case "stationwagon":
               return 2;
            case "humvee":
               return 2;
            case "suv":
               return 2;
            case "flatbedtruck":
               return 4;
            case "trailertruck":
               return 4;
            case "fireengine":
               return 3;
            case "garbagetruck":
               return 3;
            case "bus":
               return 3;
            case "boxtruck":
               return 3;
            case "cargovan":
               return 2;
            case "ambulance":
               return 2;
            case "construction":
               return 2;
         }
   }
}

function VehicleConfig::OnWake()
{
   ShowUpgradeLevel();
   ShowVehicle();  
   DisplayPointCost();
   $screenActive = true;
}

