/** jQuery cssSwitcher
 * Written on jquery v1.3.2, but should be backward compatible.
 * Instructions
 * 1. Upload this script and the jQuery Library to CommonScripts
 * 2. Add to top of any Page Layout code file (ascx) that you need to 
 *    dynamically switch, a <cms:displaynavigation> control to render 
 *    SectionCssSwitcher.xsl
 * 3. Add to the Post-Titan Metatags/Snippets the following:
 *
 *    <link id="additionalStyle" type="text/css" rel="stylesheet" href=""></link>
 *    <SCRIPT src="/CommonScripts/jquery-1.3.2.min.js" type="text/javascript"></SCRIPT>
 *    <SCRIPT src="/CommonScripts/cssSwitcher.js" type="text/javascript"></SCRIPT>
 *
 * 4. Change the CustomPropertiesXml global parameter so that the Source='ClientCssRoot' 
 *    instead of 'FilePiles' for CustomNavFlag1
 * 5. Save and Refresh
 * 6. On the parent pages for each section, specify in CustomNavFlag1 the path the the
 *    CSS file to dynamically add as the "additionalStyles" link tag.
 */
$(document).ready(function() {
	switchCss($("input#sectionCss"));
});

switchCss = function(cssInput) {
	var $link = $("link[id='additionalStyle']");
	if ($link == null || cssInput == null || cssInput.attr("value") == "")
		return;
	// The primary CSS ref has an ID="documentStyle"
	$link.attr("href", cssInput.attr("value"));
};