/*****************************************************************
 * This is the file for your custom javascript for your web site *
 *****************************************************************/
 
/************************
 * Function Declarations
 */

/**
 * This object will produce a DOMElement for you to emebed in your page.
 * Pass it a node list of elements containing your news items, the 
 * _contents_ of each node will be displayed in side the ticker.
 *
 * There is some CSS required to work with the elements produced by this 
 * object. 
 *
 * To control the animation set the newsTicker.increment, newsTicker.interval 
 * and newsTicker.pause properties (see below); add a node list of news
 * items (such as list items) to newsTicker.messages; call newsTicker.elements
 * and add the returned DOMElement to the DOM (e.g. with .appendChild());
 * Finally, call newsTicker.animate()
 *
 * @todo fix bug with stopping and restarting the animation when the onfocus/onblur
 * events fire.
 */
newsTicker = {
    /**
     * timing object for the animation, returned by setInterval
     *
     * @var object
     * @access private
     */
    animation: null,
    /**
     * the div tag that represents the cursor
     *
     * @var DOMElement
     * @access private
     */
    cursor: null,
    /**
     * this is an event handler for elements inside the ticker, the handler is generated when 
     * the elements are created with newsTicker.elements();
     *
     * @var function
     * @access private
     */
    end: null,
    /**
     * the number of intervals we have been paused for - see this.pause, below
     *
     * @var int
     * @access private
     */
    hold_count: 0,
    /**
     * the number of pixels to increment the width of the ticker by, for each interval.
     *
     * @var int
     * @access public
     */
    increment: 2,
    /**
     * the item index for the list of messages. This is the next index that will be displayed
     * e.g. this.messages.item(this.index);
     *
     * @var int
     * @access private
     */
    index: 0,
    /**
     * the number of milliseconds between each change in the ticker. The width of the ticker will 
     * be incremented once every <interval> milliseconds
     *
     * 1000 / <interval> = ~FPS
     *
     * @var int
     * @access public
     */
    interval: 50,
    /**
     * The element (p.message) which shows the current message
     *
     * @var DOMElement
     * @access private
     */
    message: null,
    /**
     * a node list of messages (or any objec that implements the "item(<index>)" method).
     * the innerHTML of each item will be displayed in the ticker.
     *
     * @var DOMNodeList
     * @access public
     */
    messages: null,
    /**
     * a minimum width of the ticker, or could be thought of as left padding/margin
     *
     * @var int
     * @access public
     */
    offsetLeft: 20,
    /**
     * this is an event handler for elements inside the ticker, the handler is generated when 
     * the elements are created with newsTicker.elements();
     *
     * @var function
     * @access private
     */
    start: null,
    /**
     * once the ticker is fully expanded and the message is visible, pause this many intervals/iterations before
     * starting the animation over with the next message.
     *
     * @var int
     * @access public
     */
    pause: 10,
    /**
     * this is the div.ticker element that will have it's width increased to create the effect of revealing the message.
     *
     * @var DOMElement
     * @access private
     */
    ticker: null,
    
    
    /**
     * get the next message from the list of messages. this method will return the innerHTML 
     * of the message.
     *
     * @access private
     * @return string
     **/
    nextMessage: function () {
        var message = this.messages.item(this.index);
        var children = message.getElementsByTagName('*');
        for (var i = 0; i < children.length; ++i)
        {
            children[i].onfocus = this.end;
        }
        this.index++;
        if (this.index >= this.messages.length)
        {
            this.index = 0;
        }
        return message.innerHTML;
    },
    /**
     * returns a graph of dom nodes ready to be inserted in to your document.
     * The html will look like:
     *   <div class="ticker">
     *       <div class="message-wrapper">
     *           <p class="message"><a href="#">My Message</a></p>
     *       </div>
     *       <div class="cusor"></div>
     *   </div>
     * 
     * @access public
     * @return DOMElement
     **/
    elements: function () {
        myself = this;
        
        this.ticker = document.createElement('div');
        this.ticker.setAttribute('class', 'ticker');
        
        this.ticker.setAttribute('className', 'ticker');
        this.end = function () {
            myself.stop();
            myself.ticker.style['width'] = 'auto';
            myself.ticker.style['width'] = myself.message.clientWidth + myself.offsetLeft + myself.cursor.clientWidth;
            myself.cursor.style['left'] = myself.ticker.offsetLeft + myself.ticker.clientWidth - myself.cursor.clientWidth + 'px';
            myself.cursor.style['display'] = 'none';
        };
        this.start = function () {
            myself.cursor.style['display'] = 'block';
            myself.animate();
        };
        this.ticker.onmouseover = this.end;
        this.ticker.onmouseout = this.start;
        var wrapper = document.createElement('div');
        wrapper.setAttribute('class', 'message-wrapper');
        wrapper.setAttribute('className', 'message-wrapper');
        this.message = document.createElement('p');
        this.message.setAttribute('class', 'message');
        this.message.setAttribute('className', 'message');
        this.message.onfocus = this.end;
        this.ticker.appendChild(wrapper);
        this.cursor = document.createElement('div')
        this.cursor.setAttribute('class', 'cursor');
        this.cursor.setAttribute('className', 'cursor');
        this.ticker.appendChild(this.cursor);
        wrapper.appendChild(this.message);
        if (this.messages.length)
        {
            this.message.innerHTML = this.nextMessage();
        }
        return this.ticker;
    },
    /**
     * Call this to kick off your animation
     *
     * @access public
     * @return void
     **/
    animate: function () {
        myself = this;
        myself.cursor.style['left'] = myself.ticker.offsetLeft + myself.ticker.clientWidth - myself.cursor.clientWidth + 'px';
        myself.cursor.style['display'] = 'block';
        myself.animation = setInterval(function () {
             var tickerWidth = myself.ticker.clientWidth;
             var newTickerWidth = false;
             var messageWidth = myself.message.clientWidth;
             var offsetLeft = myself.message.offsetLeft - myself.ticker.offsetLeft;
             
             if (tickerWidth > (messageWidth + myself.offsetLeft + myself.cursor.clientWidth))
             {
                 // Ticker has expanded enough to display the message fully
                 // Leave the message showing for a while, before replacing it and resetting the 
                 // width of the ticker div.
                 myself.hold_count++
                 if (myself.hold_count > myself.pause)
                 {
                     newTickerWidth = myself.offsetLeft;
                     myself.hold_count = 0;
                     myself.message.innerHTML = myself.nextMessage();
                 }
             }
             else
             {
                 // the ticker hasn't expanded enough to display the message, increase it's width.
                 newTickerWidth = tickerWidth + myself.increment;
             }
             if (newTickerWidth !== false)
             {
                 // poor Webkit
                  if (hum.isWebkit()) myself.cursor.style['display'] = 'none';
                  
                 // a new width for the ticker div has been provided, so change the width
                 myself.ticker.style['width'] = newTickerWidth + 'px';
                 // also move the cursor along by the same amount.
                 myself.cursor.style['left'] = myself.ticker.offsetLeft + myself.ticker.clientWidth - myself.cursor.clientWidth + 1 + 'px';
                 
                 // poor Webkit
                 if (hum.isWebkit()) myself.cursor.style['display'] = 'block';
             }
         }, this.interval);
         
    },
    /**
     * Stop the news ticker animation
     *
     * @access public
     * @return void
     **/
     stop: function () {
         clearInterval(this.animation);
     }
};


var tabDisplay = {
    /**
     * Produces a tabbed display for your content. A row of tabs runs along a block of content.
     * The first tab is selected and displayed by default. The code is designed to be accessible:
     * it will take a some other wise plain content and convert it in to a tabbed display, so no
     * worries about SEO, page reloads or too many accessibility issues.
     *
     * Place all of your content inside a div with the id "tabBlock", then add the following items
     * in side the div...
     *
     * * An unordered list of links, each link will be a tab button and once clicked
     *   will display the appropriate content under the tab buttons.
     *
     * * Content to be displayed under each tab button. Wrap divs with the class "tab" around each 
     *   chunk of content that should be displayed for each tab button.
     *
     * THINGS TO NOTE: There should be the same number of tab buttons as blocks of content to display
     * and they should be in the same order. This code uses a simple way of deciding what content to 
     * display based on which button has been clicked.
     *
     * There is CSS to accompany this JavaScript.
     *
     * This object depends on the "hum" utility object
     *
     * USAGE: tabDisplay.enable(document.getElementByTagName('tabBlock'));
     *
     * EXAMPLE HTML:
     * 
     * <div id="tabBlock">
     *     <ul class="tabs">
     *         <li class="tab">
     *             <a href="#heading1" class="tab active">Heading 1</a>
     *         </li>
     *         <li class="tab">
     *             <a href="#heading2" class="tab">Heading 2</a>
     *         </li>
     *         <li class="tab">
     *             <a href="#headingN" class="tab">Heading N</a>
     *         </li>
     *     </ul>
     *     <div class="tab">
     *         <h3 class="anchor"><a name="heading1" class="anchor">Heading 1</a></h3>
     *             <!-- Tab 1 Content Here --> 
     *         <div class="clear"></div>
     *     </div>
     *     <div class="clear"></div>
     *     <div class="tab">
     *         <h3 class="anchor"><a name="heading2" class="anchor">Heading 2</a></h3>
     *             <!-- Tab 2 Content Here --> 
     *         <div class="clear"></div>
     *     </div>
     *     <div class="clear"></div>
     *     <div class="tab">
     *         <h3 class="anchor"><a name="headingN" class="anchor">Heading N</a></h3>
     *             <!-- Tab N Content Here -->
     *         <div class="clear"></div>
     *     </div>
     *     <div class="clear"></div>
     * </div>
     **/
    /**
     * each element of the array will hold a reference to a "tab button" - a link
     * @var array
     * @access private
     **/
    buttons : [],
    /**
     * each element of the array will hold a reference "tab panel", a div.tag element that
     * will be displayed when the corresponding tab button is clicked.
     * @var array
     * @access private
     **/
    contentAreas: [],
    /**
     * holds a reference to the entire tab block containing all of the links/buttons and 
     * the content.
     * @var object
     * @access private
     **/
    tabBlock: null,
    /**
     * each element of the array will hold a reference to a "tab button" - a link
     * @return null
     * @param object node the DOM Element that contains all content and buttons - see above.
     * @access public
     **/
    enable: function (node) {
        if (!node || typeof node.getElementsByTagName == 'undefined') return null;
        this.findButtons(node);
        this.findContentAreas(node);
        hum.addClass(node, 'tabBlockActive');
        hum.addClass(node, 'active');
        this.tabBlock = node;
        this.show(0);
    },
    /**
     * searches through all ancestor elements of the tab block to find the "tab buttons"
     * @return null
     * @param object node the DOM Element that contains all content and buttons - see above.
     * @access private
     **/
    findButtons: function (node) {
        if (!node || typeof node.getElementsByTagName == 'undefined') return null;
        var as = node.getElementsByTagName('a');
        if (!as) return null;
        for (var i = 0; i < as.length; ++i)
        {
            if (hum.hasClass(as.item(i), 'tab'))
            {
                as.item(i).buttonIndex = this.buttons.length;
                as.item(i).tabDisplay = this;
                this.buttons[this.buttons.length] = as.item(i);
                myDisplay = this;
                as.item(i).onclick = function () {
                    myDisplay.show(this.buttonIndex);
                    
                    // Technically, should set focus to the div that is displayed upon clicking the tab
                    // button. In reality this can cause an unexpected "jump" in the page by causing the window
                    // to scroll down
                    
                    // var name = this.href.replace(/#/, '');
                    // var anchors = document.getElementsByTagName('a');
                    // if (a.length)
                    // {
                    //     for (var i = 0; i < anchors.length; ++i)
                    //     {
                    //         if (anchors.item(i).getAttribute('name') == name)
                    //         {
                    //             anchors.item(i).focus();
                    //             break;
                    //         }
                    //     }
                    // }
                    return false;
                }
            }
        }
    },
    /**
     * searches through all ancestor elements of the tab block to find the "tab panels"
     * @return null
     * @param object node the DOM Element that contains all content and buttons - see above.
     * @access private
     **/
    findContentAreas: function (node) {
        if (!node || typeof node.getElementsByTagName == 'undefined') return null;
        var divs = node.getElementsByTagName('div');
        if (!divs.length) return null;
        for (var i = 0; i < divs.length; ++i)
        {
            if (hum.hasClass(divs.item(i), 'tab'))
            {
                this.contentAreas[this.contentAreas.length] = divs.item(i);
            }
        }
    },
    /**
     * Sets the appropriate css classes and properies to display the relevent "tab block" or "content area".
     * The each button is indexed from 0 upwards, in the order they appear in the document. The areas of 
     * content to display are indexed in the same way,
     *
     * @return null
     * @param int index the index of the button that was clicked
     * @access private
     **/
    show: function (index) {
        if (index === null || index === false || typeof index == 'undefined') return null;
        for (var i = 0; i < this.contentAreas.length; ++i)
        {
            if (i === index)
            {
                this.contentAreas[i].style['display'] = 'block';
                hum.addClass(this.buttons[i], 'active');
                hum.removeClass(this.buttons[i], 'inactive');
                hum.addClass(this.contentAreas[i], 'active');
                hum.removeClass(this.contentAreas[i], 'inactive');
            }
            else
            {
                this.contentAreas[i].style['display'] = 'none';
                hum.addClass(this.buttons[i], 'inactive');
                hum.removeClass(this.buttons[i], 'active');
                hum.addClass(this.contentAreas[i], 'inactive');
                hum.removeClass(this.contentAreas[i], 'active');
            }
        } 
    }
};



function audioPlayer()
{
    /* 
     * The embedded audio player in web pages is controlled with a jQuery plugin, JPlayer,
     * and a small flash applet that comes with it.
     * We are going to build up all of the elements which will be the interface for the player,
     * then we'll drop these in to the page and initiliase the JPlayer plugin.
     *
     */
     
     // Look to see if there are any audio files being linked to on the page.
     audioFiles = jQuery('div.attribute-audio_file').get();
       if (audioFiles.length > 0)
       {
           // Looks like we can only really have one of these in a page (probably what we want anyway)
           
           links = audioFiles[0].getElementsByTagName('a');
           link = links.length ? links.item(0) : null;
           
           // Links must have special css classes set.
           if (hum.hasClass(link, 'audio') && hum.hasClass(link, 'mpeg'))
           {
               /*
                * Build up interface for the player.
                */
               // Main container
               jPlayerInterface = document.createElement('div');
               jPlayerInterface.id = 'jPlayer_interface';
               audioFiles[0].appendChild(jPlayerInterface);
               // Controls - this object has the id used by JPlayer and the
               // friendly (human readable) label for each control in the player's
               // interface. We'll loop through each property and use the details
               /// to create the individual controls as html elements.
               jplayer = {
                    controls: {
                        play: {
                            id: 'jPlayer_play',
                            label: 'Play'
                        },
                        pause: {
                            id: 'jPlayer_pause',
                            label: 'Pause'
                        },
                        stop: {
                            id: 'jPlayer_stop',
                            label: 'Stop'
                        },
                        minvol: {
                            id: 'jPlayer_volume_min',
                            label: 'Mute Volume'
                        },
                        maxvol: {
                            id: 'jPlayer_volume_max',
                            label: 'Maximum Volume'
                        }
                    }
               };
               controlBar = document.createElement('ul');
               controlBar.id = 'jPlayer_controls';
               jPlayerInterface.appendChild(controlBar);
               for (control in jplayer.controls)
               {
                   buttonContainer = document.createElement('li');
                   controlBar.appendChild(buttonContainer);
                   buttonContainer.id = jplayer.controls[control].id;
                   button = document.createElement('a');
                   buttonContainer.appendChild(button);
                   button.href = '#';
                   button.onclick = function () {return false;};
                   label = document.createElement('span');
                   labelText = document.createTextNode(jplayer.controls[control].label);
                   label.appendChild(labelText);
                   button.appendChild(label);
                   control.button = button;
               }
               // Progress Bar
               progress = document.createElement('div');
               progress.id = 'jPlayer_progress';
               jPlayerInterface.appendChild(progress);
               progressLoad = document.createElement('div');
               progressLoad.id = 'jPlayer_progress_load_bar';
               progress.appendChild(progressLoad);
               progressPlay = document.createElement('div');
               progressPlay.id = 'jPlayer_progress_play_bar';
               // Accessibility for Rich Internet Applications
               progressPlay.setAttribute('role', 'slider');
               progressPlay.setAttribute('aria-valuemin', 0);
               progressPlay.setAttribute('aria-valuemax', 100);
               progressPlay.setAttribute('aria-valuetext', '0 percent');
               progressPlay.setAttribute('tabindex', -1);
               progressLabel = document.createElement('span');
               progressLabel.id = 'jPlayer_progress_play_bar_label';
               progressLabelText = document.createTextNode('Track Progress');
               progressLabel.appendChild(progressLabelText);
               progress.appendChild(progressPlay);
               progressPlay.setAttribute('aria-labelledby', 'jPlayer_progress_play_bar_label');
               
               // Volume Bar
               volumebar = document.createElement('div');
               volumebar.id = 'jPlayer_volume_bar';
               // Accessibility for Rich Internet Applications
               volumebar.setAttribute('aria-valuemin', 0);
               volumebar.setAttribute('aria-valuemax', 100);
               volumebar.setAttribute('role', 'slider');
               volumebar.setAttribute('tabindex', -1);
               
               jPlayerInterface.appendChild(volumebar);
               volumebarValue = document.createElement('div');
               volumebarValue.id = 'jPlayer_volume_bar_value';
               volumebar.appendChild(volumebarValue);
               // Track Information
               trackinfo = document.createElement('div');
               trackinfo.id = 'jPlayer_track_information';
               jPlayerInterface.appendChild(trackinfo);
               trackTitle = document.createElement('div');
               trackTitle.id = 'jPlayer_track_title';
               trackinfo.appendChild(trackTitle);
               trackPlaytime = document.createElement('div');
               trackPlaytime.id = 'jPlayer_play_time';
               trackinfo.appendChild(trackPlaytime);
               trackTotaltime = document.createElement('div');
               trackTotaltime.id = 'jPlayer_total_time';
               trackinfo.appendChild(trackTotaltime);
               audioHeading = jQuery('div.attribute-short_title').get();
               audioHeading = audioHeading[0] ? audioHeading[0] : null;
               audioHeading = audioHeading ? audioHeading.innerHTML : null;
               if (audioHeading)
               {
                   trackTitleText = document.createTextNode(audioHeading);
                   trackTitle.appendChild(trackTitleText);
               }

                /*
                 * Initialise the jPlayer and add it to the page.
                 */
               jPlayerContainer = document.createElement('div');
               jPlayerContainer.id = 'jPlayer_container';
               audioFiles[0].appendChild(jPlayerContainer);
               jQuery(jPlayerContainer).jPlayer({
                   swfPath: '/design/orion_public/javascript/jquery/',
                   ready: function () {
			    jQuery(jPlayerContainer).setFile(link.href).play();
                    },
                    cssPrefix: 'jplayer'
               });
               // let jPlayer attach it's functions to the controls of the interface.
               jQuery(jPlayerContainer).jPlayerId("play", jplayer.controls.play.id);
               jQuery(jPlayerContainer).jPlayerId("pause", jplayer.controls.pause.id);
               jQuery(jPlayerContainer).jPlayerId("stop", jplayer.controls.stop.id);
               jQuery(jPlayerContainer).jPlayerId("loadBar", "jPlayer_progress_load_bar");
               jQuery(jPlayerContainer).jPlayerId("playBar", "jPlayer_progress_play_bar");
               jQuery(jPlayerContainer).jPlayerId("volumeMin", jplayer.controls.minvol.id);
               jQuery(jPlayerContainer).jPlayerId("volumeMax", jplayer.controls.maxvol.id);
               jQuery(jPlayerContainer).jPlayerId("volumeBar", "jPlayer_volume_bar");
               jQuery(jPlayerContainer).jPlayerId("volumeBarValue", "jPlayer_volume_bar_value");
               jQuery(jPlayerContainer).onProgressChange( 
                   function (loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {   
                        var myPlayedTime = new Date(playedTime);
                        var ptMin = (myPlayedTime.getMinutes() < 10) ? "0" + myPlayedTime.getMinutes() : myPlayedTime.getMinutes();
                        var ptSec = (myPlayedTime.getSeconds() < 10) ? "0" + myPlayedTime.getSeconds() : myPlayedTime.getSeconds();
                        jQuery("#jPlayer_play_time").text(ptMin+":"+ptSec);

                        var myTotalTime = new Date(totalTime);
                        var ttMin = (myTotalTime.getMinutes() < 10) ? "0" + myTotalTime.getMinutes() : myTotalTime.getMinutes();
                        var ttSec = (myTotalTime.getSeconds() < 10) ? "0" + myTotalTime.getSeconds() : myTotalTime.getSeconds();
                        jQuery("#jPlayer_total_time").text(ttMin+":"+ttSec);
                    }
                );
           }
    }
                
    
}

/*
 * End Function Declarations
 ****************************/
/*******************
 * Global Variables
 */



/*
 * End Global Variables
 ***********************/
/***************************************************************************************
 * Initialisation Code - code in this area will run as soon as the document has loaded
 *
 * Place here the javascript code and function calls you would like to run when the page loads
 * Note: If you use sifr text you should put your sifr code at the very bottom of this file.
 */
DomLoaded.load(
    function() {
        // Place your initialisation code here (this is like window.onload)

                    //////////////////////////////////////////////////////////////////////////
                    // Audio Player
                    audioPlayer();
                    
                    //////////////////////////////////////////////////////////////////////////
                    // Table of Contents
                    var tocButton = document.getElementById('toc-button');
                    if (tocButton)
                    {
                        var a = tocButton.getElementsByTagName('a').item(0);
                        a.onclick = function () { return false;};
                        a.href = '#';
                        tocButton.onclick = function () {
                            var toc = document.getElementById("tocmenu-design");        
                            if (jQuery(toc).css('display') != 'none')
                            {
                                jQuery(toc).hide(300, function () { document.getElementById('orion_wrapper').style['display'] = 'none'; document.getElementById('orion_wrapper').style['display'] = 'block'; });
                            }
                            else
                            {
                                jQuery(toc).show(300, function () { document.getElementById('orion_wrapper').style['display'] = 'none'; document.getElementById('orion_wrapper').style['display'] = 'block'; });
                            }
                            return false;
                        };
                    }
                    
                    //////////////////////////////////////////////////////////////////////////
                    // Genre Scoller / Slider Gallery
                    if (!hum.isFirefox2() && !hum.isOpera())
                    {
                        //console.log("initialising slider");
                        var container = jQuery('div.sliderGallery');
                        container.scrollLeft = 0;
                        container.scrollTop = 0;
                        var ul = jQuery('ul', container);
                        var handle = jQuery('.handle', container);
                        var itemsWidth = ul.innerWidth() - container.outerWidth();
                        //HACK
                        // Width is sometimes 0!? Need to debug. In the meantime have a hack.
                        itemsWidth = 1434;
                        jQuery('#genre-bar').addClass('sliderGalleryActive');
                        jQuery('div.sliderGallery').addClass('sliderGalleryActive');
                        //console.log("width = " + itemsWidth);
                        jQuery('.slider', container).slider({
                            min: 0,
                            max: itemsWidth,
                            stop: function (event, ui) {
                                //console.log("stop");
                                ul.animate({'left' : ui.value * -1}, 930);
                            },
                            slide: function (event, ui) {
                                //console.log("ui.value = " + ul.value +"; ui.style['left'] = " + ul.css('left'));
                                ul.css('left', ui.value * -1);
                            },
                            animate: false,
                            orientation: 'horizontal',
                            value: 0
                        });
                        //console.log("slider loaded");
                    }
                    //////////////////////////////////////////////////////////////////////////
                    // News Ticker
                    if (!newsTicker.messages && !hum.isFirefox2())
                    {
                        var latest_news_block = document.getElementById('latest_news');
                        if (latest_news_block)
                        {
                            if (hum.isIE6())
                            {
                                newsTicker.interval = 200;
                                newsTicker.increment = 5;
                            }
                            var newsTickerWrapper = document.getElementById('news_ticker_wrapper');
                            newsTicker.messages = latest_news_block.getElementsByTagName('li');
                            elements = newsTicker.elements();
                            newsTickerWrapper.appendChild(elements);
                            newsTickerWrapper.style['display'] = 'block';
                            newsTicker.animate();
                        }
                    }
                    //////////////////////////////////////////////////////////////////////////
                    // Banner Gallery
                    var bannerGallery = document.getElementById('banner-gallery');
                    if (bannerGallery && !bannerGallery.banners)
                    {
                        var banners = bannerGallery.getElementsByTagName('li');
                        if (banners.length >= 2)
                        {
                            for (var i = 1; i < banners.length; ++i)
                            {
                                banners.item(i).style['display'] = 'none';
                            }
                            bannerGallery.banners = banners;
                            bannerGallery.bannerIndex = 0;
                            var bannerAnimation = setInterval(function (){
                                var banners = bannerGallery.banners;
                                var index = bannerGallery.bannerIndex;
                                if (index >= banners.length)
                                {
                                    index = 0;
                                }
                                var nextIndex = index + 1;
                                if (nextIndex >= banners.length)
                                {
                                    nextIndex = 0;
                                }
                                var currentBanner = banners.item(index);
                                var nextBanner = banners.item(nextIndex);
                                bannerGallery.bannerIndex = nextIndex;
                                jQuery(currentBanner).fadeOut('slow');
                                setTimeout(function (){
                                    jQuery(nextBanner).fadeIn('slow');
                                }, 250);
                            }, 5000);
                        }
                    }
                    
                    //////////////////////////////////////////////////////////////////////////
                    // Tabbed Content Panel
                    tabDisplay.enable(document.getElementById('tabBlock'));
                    
                    
                    
            // Call Google Analytics Last of all
            //hum.analytics();
            
        // --------------------------------------------------------------
    }
);
/*
 * End Initialisation Code
 **************************/
/************
 * Sifr Code
 ** sIFR.relace(Font, {
  *   selector: '',
  *   elements: [],
  *   css: '.sIFR-root {foo:bar}',
  *   wmode: 'transparent',
  *   tuneHeight: 0,
  *   tuneWidth: 0,
  *   offsetTop: 0,
  *   forceWidth: true|false,
  *   offsetLeft: 0,
  *   peventWrap: true|false,
  *   forceSingleLine: true|false
  * });
  */
if (typeof sIFR != "undefined")
{   

    // Your code for loading Sifr should go here (if applicable)
    
    var myriadProCondensedItalic = {src: '/design/orion_public/flash/myriad-pro-bold-condensed-italic.swf'};
    var myriadProBoldCondensed = {src: '/design/orion_public/flash/myriad-pro-bold-condensed.swf'};
    var myriadProBoldItalic = {src: '/design/orion_public/flash/myriad-pro-bold-italic.swf'};
    var myriadProBold = {src: '/design/orion_public/flash/myriad-pro-bold.swf'};
    var myriadProCondensedItalic = {src: '/design/orion_public/flash/myriad-pro-condensed-italic.swf'};
    var myriadProCondensed = {src: '/design/orion_public/flash/myriad-pro-condensed.swf'};
    var myriadProItalic = {src: '/design/orion_public/flash/myriad-pro-italic.swf'};
    var myriadProRegular = {src: '/design/orion_public/flash/myriad-pro-regular.swf'};
    var myriadProSemiboldItalic = {src: '/design/orion_public/flash/myriad-pro-semibold-italic.swf'};
    var myriadProSemibold = {src: '/design/orion_public/flash/myriad-pro-semibold.swf'};
    
    sIFR.useStyleCheck = true;
    sIFR.activate(myriadProRegular);
    sIFR.replace(myriadProRegular, {
        selector: "#welcome-text",
        css: '.sIFR-root {color:#666666;font-size:20px;text-decoration:none}',
        wmode: 'transparent',
        tuneHeight:0
    });
    sIFR.replace(myriadProRegular, {
        selector: "div.wide-box h3, .bucket h3, div.narrow-box h3",
        css: '.sIFR-root {color:#3b7086;font-size:18px;text-decoration:none}',
        wmode: 'transparent',
        tuneHeight:-2
    });
    sIFR.replace(myriadProRegular, {
        selector: "div.bucket h4",
        css: '.sIFR-root {color:#ffffff;font-size:18px;text-decoration:none}',
        wmode: 'transparent',
        tuneHeight:-2
    });
    sIFR.replace(myriadProRegular, {
        selector: "div.bucket p.description",
        css: '.sIFR-root {color:#ffffff;font-size:13px;text-decoration:none}',
        wmode: 'transparent',
        tuneHeight:-2
    });
    sIFR.replace(myriadProRegular, {
        selector: "#latest_news p.recent",
        css: '.sIFR-root {color:#666666;font-size:16px;text-decoration:none}',
        wmode: 'transparent',
        tuneHeight:0
    });
    sIFR.replace(myriadProRegular, {
        selector: "div.skinny-box h2, div.skinny-box h3",
        css: '.sIFR-root {color:#ffffff;font-size:16px;text-decoration:none;}',
        wmode: 'transparent',
        tuneHeight:-2
    });
    sIFR.replace(myriadProBold, {
        selector: "div#featured_pages div.skinny-box span.title",
        css: '.sIFR-root {color:#3b7086;font-size:14px;text-decoration:none;font-weight:normal}',
        wmode: 'transparent',
        tuneHeight:-2
    });
    /*
    sIFR.replace(myriadProRegular, {
            selector: "#orion_footer ul li",
            css: '.sIFR-root {color:#ffffff;font-size:11px;text-decoration:none} .sIRF-root a {color:#ffffff;text-decoration:none} a:hover {color:#ffffff;text-decoration:underline}',
            wmode: 'transparent',
            tuneHeight: -3,
            offsetTop:2,
            tuneWidth:3
        });
        sIFR.replace(myriadProRegular, {
            selector: "#orion_footer #footer_address",
            css: '.sIFR-root {color:#ffffff;font-size:11px} address {display:inline;margin:0;padding:0}',
            wmode: 'transparent'
        });*/
    
    
   // ----------------------------------------------------------
}
/*
 * End Sifr Code
 ****************/