Menus - hard coded primary nav with per-page sub nav
I am not sure which part you need hardcoded, but if it is everything but the a tag, then then l() helper function comes to the rescue: 

&lt;li class="menu-item" id="foo"&gt;
  &lt;span&gt;
    &lt;img src="menu_foo.png" alt="icon showing foo"/&gt;
    &lt;?php print l("Foo", "original/path/to/foo") ?&gt;
  &lt;/span&gt;
&lt;/li&gt;


Now, if you access "/original/path/to/foo" or (on of its) alias(es), the l() helper will automatically add a class "active" to the a tag, generated by l().

If, for some reason you need the l() outside of the a, or if you want to customize the a itself (e.g. by adding markup to it), you can use the code seen in the l() to determine activeness  of the current item. Place this as helper in template.php of your theme:

function _my_theme_is_active($path) {
  $active = FALSE;
  if (($path == $_GET['q'] || ($path == '&lt;front&gt;' &amp;&amp; drupal_is_front_page())) &amp;&amp; 
      (empty($options['language']) || $options['language']-&gt;language == $language-&gt;language)) {
    $active = TRUE;
  }
  return $active;
}


Obviously my_theme is the name of your theme.

Then in the tpl.php files, or anywhere in the scope of your theme, you can use the function:

&lt;li&gt;
  &lt;a href="&lt;?php print url("original/path/to/foo") ?&gt;" &lt;?php print (_my_theme_is_active("original/path/to/foo") ? 'class="active"' : ' ') ?&gt; id="foo-1"&gt;
    Foo
  &lt;/a&gt;
&lt;/li&gt;


Beware that you use url() to catch aliasing for the oringial path, but that you /do/ pass in the original (system) path into the _my_theme_is_active helper.