I'd like to create a module that detects some properties of my web site visitors and use those to select a theme. Just as an example, to clarify my needs: suppose I have two themes set up called 'extern' in /sites/all/themes/extern and one called 'intern' in /sites/all/themes/intern. So one for external users and one for internal users. I know the IP addresses of my internal users (note that they might not be on my intranet alone). Depending if the IP address is in a predefined list, I would like my site to use the 'intern' theme and otherwise use the 'extern' theme.
In my module, what functions/hooks to I need to override, what do I need to change in the passed parameters or is there another way to go about this, like call module-based functions from template.php? Each of the theme's might have a different set over overriding template files, so my 'intern' theme might have a page.tpl.php only and my 'extern' theme might have both a page.tpl.php and a block.tpl.php or even another set of template files.
I'd like to implement this using the standard PHPtemplate engine and I do not like to fork any existing modules please.