/// <summary>
        /// Sets the next media node. Should be used either from a mediaComplete event, or an options reset from
        /// the parent.
        /// </summary>
        private bool SetNextMediaNodeInOptions()
        {
            // What if there are no media nodes?
            if (_options.mediaNodes.Count == 0)
            {
                Trace.WriteLine(new LogMessage("Region - SetNextMediaNode", "No media nodes to display"), LogType.Audit.ToString());

                return(false);
            }

            // Zero out the options that are persisted
            _options.text             = "";
            _options.documentTemplate = "";
            _options.copyrightNotice  = "";
            _options.scrollSpeed      = 30;
            _options.updateInterval   = 6;
            _options.uri        = "";
            _options.direction  = "none";
            _options.javaScript = "";
            _options.FromDt     = DateTime.MinValue;
            _options.ToDt       = DateTime.MaxValue;
            _options.Dictionary = new MediaDictionary();

            // Tidy up old audio if necessary
            foreach (Media audio in _options.Audio)
            {
                try
                {
                    // Unbind any events and dispose
                    audio.DurationElapsedEvent -= audio_DurationElapsedEvent;
                    audio.Dispose();
                }
                catch
                {
                    Trace.WriteLine(new LogMessage("Region - SetNextMediaNodeInOptions", "Unable to dispose of audio item"), LogType.Audit.ToString());
                }
            }

            // Empty the options node
            _options.Audio.Clear();

            // Get a media node
            bool validNode   = false;
            int  numAttempts = 0;

            // Loop through all the nodes in order
            while (numAttempts < _options.mediaNodes.Count)
            {
                // Move the sequence on
                _currentSequence++;

                if (_currentSequence >= _options.mediaNodes.Count)
                {
                    // Start from the beginning
                    _currentSequence = 0;

                    // We have expired (want to raise an expired event to the parent)
                    _hasExpired = true;

                    Trace.WriteLine(new LogMessage("Region - SetNextMediaNode", "Media Expired:" + _options.ToString() + " . Reached the end of the sequence. Starting from the beginning."), LogType.Audit.ToString());

                    // Region Expired
                    if (DurationElapsedEvent != null)
                    {
                        DurationElapsedEvent();
                    }

                    // We want to continue on to show the next media (unless the duration elapsed event triggers a region change)
                    if (_layoutExpired)
                    {
                        return(true);
                    }
                }

                // Get the media node for this sequence
                XmlNode mediaNode = _options.mediaNodes[_currentSequence];
                XmlAttributeCollection nodeAttributes = mediaNode.Attributes;

                // Set the media id
                if (nodeAttributes["id"].Value != null)
                {
                    _options.mediaid = nodeAttributes["id"].Value;
                }

                // Set the file id
                if (nodeAttributes["fileId"] != null)
                {
                    _options.FileId = int.Parse(nodeAttributes["fileId"].Value);
                }

                // Check isnt blacklisted
                if (_blackList.BlackListed(_options.mediaid))
                {
                    Trace.WriteLine(new LogMessage("Region - SetNextMediaNode", string.Format("MediaID [{0}] has been blacklisted.", _options.mediaid)), LogType.Error.ToString());

                    // Increment the number of attempts and try again
                    numAttempts++;

                    // Carry on
                    continue;
                }

                // Assume we have a valid node at this point
                validNode = true;

                // Parse the options for this media node
                ParseOptionsForMediaNode(mediaNode, nodeAttributes);

                // Is this widget inside the from/to date?
                if (!(_options.FromDt <= DateTime.Now && _options.ToDt > DateTime.Now))
                {
                    Trace.WriteLine(new LogMessage("Region", "SetNextMediaNode: Widget outside from/to date."), LogType.Audit.ToString());

                    // Increment the number of attempts and try again
                    numAttempts++;

                    // Carry on
                    continue;
                }

                // Is this a file based media node?
                if (_options.type == "video" || _options.type == "flash" || _options.type == "image" || _options.type == "powerpoint" || _options.type == "audio" || _options.type == "htmlpackage")
                {
                    // Use the cache manager to determine if the file is valid
                    validNode = _cacheManager.IsValidPath(_options.uri);
                }

                // If we have a valid node, break out of the loop
                if (validNode)
                {
                    break;
                }

                // Increment the number of attempts and try again
                numAttempts++;
            }

            // If we dont have a valid node out of all the nodes in the region, then return false.
            if (!validNode)
            {
                return(false);
            }

            Trace.WriteLine(new LogMessage("Region - SetNextMediaNode", "New media detected " + _options.type), LogType.Audit.ToString());

            return(true);
        }