function SpecialSearchReturn()
{
   // go through each potential found item   
   
   if($SpecialSearchIndex $= 1 && $FoodFound !$= "" && $StopSearchFlag $= "")   
      %text = "You have found " @ $foodFound @ " Food. Do you want to take it? \n\n Current food supply is " @ $food;
   if($SpecialSearchIndex $= 2 && $gunsFound !$= "" && $StopSearchFlag $= "")
      %text = "You have found " @ $gunsFound @ " Guns. Do you want to take it? \n\n Current gun supply is " @ $guns;
   if($SpecialSearchIndex $= 3 && $ammoFound !$= "" && $StopSearchFlag $= "")
      %text = "You have found " @ $ammoFound @ " Ammo. Do you want to take it? \n\n Current ammo supply is " @ $ammo;
   if($SpecialSearchIndex $= 4 && $medicineFound !$= "" && $StopSearchFlag $= "")
      %text = "You have found " @ $medicineFound @ " Medicine. Do you want to take it? \n\n Current medicine supply is " @ $medicine;
   if($SpecialSearchIndex $= 5 && $tiresFound !$= "" && $StopSearchFlag $= "")
      %text = "You have found " @ $tiresFound @ " Tires. Do you want to take it? \n\n Current tire supply is " @ $tires;
   if($SpecialSearchIndex $= 6 && $sparepartsFound !$= "" && $StopSearchFlag $= "")   
      %text = "You have found " @ $sparepartsFound @ " Spare Parts. Do you want to take it? \n\n Current spare parts supply is " @ $spareparts;
   if($SpecialSearchIndex $= 7 && $fuelFound !$= "" && $StopSearchFlag $= "")
      %text = "You have found " @ $fuelFound @ " Fuel. Do you want to take it? \n\n Current fuel supply " @ $fuel;
   
   if(%text !$= "")
   {
      InfoWindow.Visible = true;
      InfoText.setText(%text @ "\n\n Spare Capacity is " @ GetTotalSupplyCapacity() - GetCurrentSupplyCount());
      Infocontinuebutton.Visible = false;
      InfoYesbutton.Visible = true;
      InfoNobutton.Visible = true;
      InfoYesbutton.command = "YesSpecialSearch();";
      InfoNobutton.command = "NoSpecialSearch();";      
   }
   else
   {
      $SpecialSearchIndex++;
      
      if($SpecialSearchIndex <= 7)
         SpecialSearchReturn();      
      else
         CheckBadEvent();     
   }
}

// if they take the current item, take it and return to SearchReturn to see if there 
// are any more items

function YesSpecialSearch()
{
   if(Infowindow.Visible $= false)
      return;
      
   %room = GetTotalSupplyCapacity() - GetCurrentSupplyCount();
      
   // if they don't have enough room just take what they can
   
   if($SpecialSearchIndex $= 1)   
   {
      if($foodFound > %room)
      {
         IncreaseFood(%room);
         %filled = true;
         $specialEncounterObject.food = $specialEncounterObject.food-%room;
      }
      else
      {
         $specialEncounterObject.food = $specialEncounterObject.food-$foodFound;
         IncreaseFood($foodFound);
      }
   }
   
   if($SpecialSearchIndex $= 2)
   {
      if($GunsFound > %room)
      {
         IncreaseGuns(%room);
         %filled = true;
         $specialEncounterObject.guns = $specialEncounterObject.guns-%room;
      }
      else
      {
         IncreaseGuns($gunsFound);
         $specialEncounterObject.guns = $specialEncounterObject.guns-$gunsFound;
      }
   }
   
   // 20 rounds of ammo will be 1 storage unit
   
   if($SpecialSearchIndex $= 3)
   {
      %ammostorage = $ammoFound/20;
      %ammostorage = mCeil(%ammostorage);
      
      if(%ammostorage > %room)
      {
         IncreaseAmmo(%room*20);
         %filled = true;
         $specialEncounterObject.ammo = $specialEncounterObject.ammo-%room*20;
      }
      else
      {
         $specialEncounterObject.ammo = $specialEncounterObject.ammo-$ammoFound;
         IncreaseAmmo($ammoFound);
         
         if($ammo > 9999)
            $ammo = 9999;
      }
   }

   if($SpecialSearchIndex $= 4)
   {
      if($MedicineFound > %room)
      {
         IncreaseMedicine(%room);
         %filled = true;
         $specialEncounterObject.medicine = $specialEncounterObject.medicine-%room;
      }
      else
      {
         $specialEncounterObject.medicine = $specialEncounterObject.medicine-$medicineFound;
         IncreaseMedicine($medicineFound);
      }
   }

   if($SpecialSearchIndex $= 5)
   {
      if($TiresFound > %room)
      {
         IncreaseTires(%room);
         %filled = true;
         $specialEncounterObject.tires = $specialEncounterObject.tires-%room;
      }
      else
      {
         IncreaseTires($tiresFound);
         $specialEncounterObject.tires = $specialEncounterObject.tires-$tiresFound;
      }
   }

   if($SpecialSearchIndex $= 6)
   {
      if($sparepartsFound > %room)
      {
         IncreaseSpareParts(%room);
         %filled = true;
         $specialEncounterObject.spareparts = $specialEncounterObject.spareparts-%room;
      }
      else
      {
         $specialEncounterObject.spareparts = $specialEncounterObject.spareparts-$spareparts;
         IncreaseSpareParts($sparepartsFound);
      }
   }

   if($SpecialSearchIndex $= 7)
   {
      if($FuelFound > %room)
      {
         IncreaseFuel(%room);
         %filled = true;
         $specialEncounterObject.spareparts = $specialEncounterObject.spareparts-%room;
      }
      else
      {
         $specialEncounterObject.spareparts = $specialEncounterObject.spareparts-$fuelFound;
         IncreaseFuel($fuelFound);
      }
   }

   // if they are filled to capacity then set this flag so no other items may be taken for this search
   
   if(%filled $= true)
      $StopSearchFlag = true;
   
   UpdateStatsBar();
   
   $SpecialSearchIndex++;
   
   SpecialSearchReturn();   
}

// if they say no to taking an item return to SearchReturn to see if there are more items

function NoSpecialSearch()
{
   $SpecialSearchIndex++;
   
   SpecialSearchReturn();   
}
