  [Abridged] The spatially averaged global spectrum of the redshifted 21cm line
has generated much experimental interest, for it is potentially a direct probe
of the Epoch of Reionization and the Dark Ages. Since the cosmological signal
here has a purely spectral signature, most proposed experiments have little
angular sensitivity. This is worrisome because with only spectra, the global
21cm signal can be difficult to distinguish from foregrounds such as Galactic
synchrotron radiation, as both are spectrally smooth and the latter is orders
of magnitude brighter. We establish a mathematical framework for global signal
data analysis in a way that removes foregrounds optimally, complementing
spectra with angular information. We explore various experimental design
trade-offs, and find that 1) with spectral-only methods, it is impossible to
mitigate errors that arise from uncertainties in foreground modeling; 2)
foreground contamination can be significantly reduced for experiments with fine
angular resolution; 3) most of the statistical significance in a positive
detection during the Dark Ages comes from a characteristic high-redshift trough
in the 21cm brightness temperature; and 4) Measurement errors decrease more
rapidly with integration time for instruments with fine angular resolution. We
show that if observations and algorithms are optimized based on these findings,
an instrument with a 5 degree beam can achieve highly significant detections
(greater than 5-sigma) of even extended (high Delta-z) reionization scenarios
after integrating for 500 hrs. This is in contrast to instruments without
angular resolution, which cannot detect gradual reionization. Abrupt ionization
histories can be detected at the level of 10-100's of sigma. The expected
errors are also low during the Dark Ages, with a 25-sigma detection of the
expected cosmological signal after only 100 hrs of integration.
