Path to theme within a module / jQuery context? I've written a custom D7 module as a companion to a theme I've contributed to drupal.org and in the module, I effect output of the logo image with some basic jQuery as such:

$("li.purple").click(function () {
$('#logo-img').attr('src', '/sites/all/themes/mytheme/images/logo-purple.png');
});

$("li.green").click(function () {
$('#logo-img').attr('src', '/sites/all/themes/mytheme/images/logo-green.png');
});


etc...

Now this works fine but ideally I'd like not to have to hard code the theme path as above, it would be great to have a variable instead. 

I did some searching and found a drupal docs page, "Pass the theme path to javascript", but I can't really make heads or tails of it within the context of what I'm trying to do. There's a preprocess function on the aforementioned docs page that supposedly can tell jQuery what the path to the theme is but I don't quiet understand the usage in terms of actually creating a theme path variable.  So from this:

function my_module_preprocess_page(&amp;$vars) {
  drupal_add_js('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline');
}


I need to extract the path variable and put into this:

$("li.green").click(function () {
$('#logo-img').attr('src', pathToTheme + '/images/logo-purple.png');
});


... However, I get this error:

Uncaught ReferenceError: pathToTheme is not defined 


... so I'm just struggling how to get this to work or if it's even possible.
Use Drupal.settings.pathToTheme.

$("li.green").click(function () {
 $('#logo-img').attr('src', Drupal.settings.pathToTheme + '/images/logo-purple.png');
});


Also, theme_preprocess_page(&amp;$vars) should be in template.php as your_theme_preprocess_page(&amp;$vars);

Good idea to not hard code the theme path, that path structure wouldn't work for all set-ups.