added page switching code and some programmatic display/hide of the
other pages. Optimized performance a lil.