public function onAfterInit() {
		self::$is_mobile = false;
		$config = SiteConfig::current_site_config();
		$request = $this->owner->getRequest();
		
		// If we've accessed the homepage as /home/, then we redirect to / and don't want to double redirect here
		if ($this->owner->redirectedTo()) {
			return;
		}

		// Enforce the site (cookie expires in 1 day)
		$fullSite = $request->getVar('fullSite');

		if(is_numeric($fullSite)) {
			$fullSiteCookie = (int)$fullSite;
			Cookie::set('fullSite', $fullSiteCookie);

			// use the host of the desktop version of the site to set cross-(sub)domain cookie
			$domain = $config->FullSiteDomainNormalized;

			if (!empty($domain)) {
				Cookie::set('fullSite', $fullSite, self::$cookie_expire_time, null, '.' . parse_url($domain, PHP_URL_HOST));
			} else { // otherwise just use a normal cookie with the default domain
				Cookie::set('fullSite', $fullSite, self::$cookie_expire_time);
			}
		}
		else {
			$fullSiteCookie = Cookie::get('fullSite');
		}
		
		if(is_numeric($fullSiteCookie)) {
			// Full site requested
			if($fullSiteCookie) {
				if($this->onMobileDomain() && $config->MobileSiteType == 'RedirectToDomain') {
					return $this->owner->redirect($config->FullSiteDomainNormalized, 301);
				}

				return;
			}
			// Mobile site requested
			else {
				if(!$this->onMobileDomain() && $config->MobileSiteType == 'RedirectToDomain') {
					return $this->owner->redirect($config->MobileDomainNormalized, 301);
				}

				Config::inst()->update('SSViewer', 'theme', $config->MobileTheme);
				self::$is_mobile = true;
				return;
			}
		}

		// If the user requested the mobile domain, set the right theme
		if($this->onMobileDomain()) {
			Config::inst()->update('SSViewer', 'theme', $config->MobileTheme);
			self::$is_mobile = true;
		}

		// User just wants to see a theme, but no redirect occurs
		if(MobileBrowserDetector::is_mobile() && $config->MobileSiteType == 'MobileThemeOnly') {
			Config::inst()->update('SSViewer', 'theme', $config->MobileTheme);
			self::$is_mobile = true;
		}

		// If on a mobile device, but not on the mobile domain and has been setup for redirection
		if(!$this->onMobileDomain() && MobileBrowserDetector::is_mobile() && $config->MobileSiteType == 'RedirectToDomain') {
			return $this->owner->redirect($config->MobileDomainNormalized, 301);
		}
	}