Access the variant id of a template


I am trying to dynamically list in the global template the CSS and JS resources required by the inner templates.

For example:

## $vid is the sys_variantid
#if($vid == "569")
<script src="$rxs_navbase/js/somejs.js"></script>
<link href="$rxs_navbase/css/somecss.css" />
<script src="$rxs_navbase/css/someothercss.css" />

However if a dispatch template is being used, the sys_variantid returned will be that of the dispatch template and not the template selected by the dispatch template.

How do I pass the selected templates variantid up to the global template?