function accordionMenu() {
 if ($('#mainnavBoxRel').length){
 		
    	$('#mainnavBoxRel #mainnav ul').show();
        $('#mainnavBoxRel #mainnav ul.thisStream').show();
        }
        else
        {
        $('#mainnavBox #mainnav ul').hide();
        $('#mainnavBox #mainnav ul.thisStream').show();
        //Optional
        $('#mainnavBox #mainnav li a').click(function() {
            var checkElement = $(this).next();
            if ((checkElement.is('#mainnavBox #mainnav ul')) && (checkElement.is(':visible'))) {
                return false;
            }
            if ((checkElement.is('#mainnavBox #mainnav ul')) && (!checkElement.is(':visible'))) {
                $('#mainnavBox #mainnav ul:visible').slideUp('normal');
                checkElement.slideDown('normal');
                return false;
            }
        });
        }
    }
    

$('document').ready(
function() {
		$('ul#newsLP').innerfade({
						speed: 1000,
						timeout: 8000,
						type: 'random'
					});	
		$('ul#newsStream').innerfade({
						speed: 1000,
						timeout: 8000,
						type: 'sequence'
					});	
		$('ul#newsHome').innerfade({
						speed: 1000,
						timeout: 8000,
						type: 'sequence'
					});	
	
// 1
//Create Absolutely Positioned Main Navigation box.
// These wrap code around the main navigation, so it can be absolutely postioned for the standard style. Also correct ie6 rendering of that AP div.
 if ($('#mainnav')){   
    $('#mainnav').wrap('<div id="mainnavBox" />');
}
    if ($.browser.msie) {
        if ($.browser.version == 6.0) {
            $('#mainnavBox').before('<div></div>');
            //$('#styling_widget').html('<a class="a-indicator smalltxt" href="?theme=norm" title="Normal Text">a</a> <a class="a-indicator XLtxt" href="?theme=XL" title="Large Text">a</a> | <a href="/display.php" rel="internal" accesskey="0">Alternative options</a>');
			//$('#styling_widget').attr('style', 'display: none;');
        };
    }

// 3
// This is the alternative stylesheet switcher code. If the styling widget is there, start assigning stylesheets to cookies, and ensuring the navigation is either AP or RP as required.
    if ($('#styling_widget').length){
    if ($.cookie("styleBiscuit")) {
    
	if (($.cookie("styleBiscuit") == 'medium') || ($.cookie("styleBiscuit") == 'large') || ($.cookie("styleBiscuit") == 'XLtext')) {
                $('#mainnavBox').attr('id', 'mainnavBoxRel');
            }
            if ($.cookie("styleBiscuit") == 'small') {
                $('#mainnavBoxRel').attr('id', 'mainnavBox');
                $('#mainnavBox #mainnav ul').show();
            }
      $("link").attr("href", "/system/" + $.cookie("styleBiscuit") + ".css");
    }
        // Style changer
        $(".smalltxt").click(function() {
         if ($('#mainnavBox')) { $('#mainnavBoxRel').attr('id', 'mainnavBox');
        $('#mainnavBox #mainnav ul').hide();
        $('#mainnavBox #mainnav ul.thisStream').show();}
		
        $("link").attr("href", "/system/small.css");
            $.cookie("styleBiscuit", "small", { path: '/'});
            return false;
        });

        $(".mediumtxt").click(function() {
           if ($('#mainnavBox')) {$('#mainnavBox').attr('id', 'mainnavBoxRel');
             $('#mainnavBoxRel #mainnav ul').show();}
            $("link").attr("href", "/system/medium.css");
            $.cookie("styleBiscuit", "medium", { path: '/'});  
            return false;
        });

        $(".largetxt").click(function() {
           if ($('#mainnavBox')) {$('#mainnavBox').attr('id', 'mainnavBoxRel');
           $('#mainnavBoxRel #mainnav ul').show();}
		   
            $("link").attr("href", "/system/large.css");
            $.cookie("styleBiscuit", "large", { path: '/'});
            return false;
        });
 }
    
  // This is the alternative code for the home page news right-to-left simple 'ticker'.
  if ($("ul#ticker01").length) {
  $("ul#ticker01").liScroll();
  }
  
  accordionMenu();
  
 //$('body').prepend('<script type="text/javascript" src="scripts/oomph2/oomph.js"><\/script>');
  
});
