	var rbs = 
{
	flash: function()
	{
		if (swfobject.hasFlashPlayerVersion("9.0.16"))
		{
  			$$('body').addClass("flash-enabled");
		}
  	},


	//*------------------------------------------------------------------//
	ieZIndexFix: function()
	{
		var relativelyPositionedElements = $$('#navigation .sub-wrapper, #navigation dt, #navigation .join, #navigation dd');
		var zIndex = 1000;
		relativelyPositionedElements.each
		(
			function(el)
			{
				el.setStyle('z-index', zIndex--);
			}
		)
  	},


	//*------------------------------------------------------------------//
	navigation: function()
	{	
		//CHECK FOR FALLBACK CURRENT SECTION AND INJECT INTO NAVIGATION STRUCTURE
		if($('current-section'))
		{
			$('current-section').getChildren().inject($('current-section-placeholder'));
			$('current-section').dispose();
		}
		
		//GO IN ADD PRESENTATIONAL MARKUP FUNCTION
		var subSections = $('navigation').getElements('dt');
		if(subSections[0].getNext().get('tag')=='dd')
		{
			subSections[0].getNext().addClass('first-sub-section');
		}
		if(subSections.getLast().getNext().get('tag')=='dd')
		{
			subSections.getLast().getNext().addClass('last-sub-section');
		}
		
		//ADD PRESENTATIONAL MARKUP TO ACHIEVE ROUNDED CORNERS AND JOIN
		function addPresentationalMarkup()
		{
			var subSectionBorders = $$('.primary-navigation .sub-section .h, .primary-navigation .sub-section .f');
			subSectionBorders.each
			(
				function(subSectionBorder)
				{
					var left   = new Element('div',{'class': 'left'});
					var center = new Element('div',{'class': 'center'});
					var right  = new Element('div',{'class': 'right'});
					left.inject(subSectionBorder);
					center.inject(subSectionBorder);
					right.inject(subSectionBorder);
				}
			);

			var sectionLinks = $$('.primary-navigation dt a');
			sectionLinks.each
			(
				function(sectionLink)
				{
					var join   = new Element('div',{'class': 'join'});
					join.inject(sectionLink);
				}
			);
		}

		//CREATE MASK
		function createMask()
		{
			mask = new Element('div',{'class': 'mask'});
			mask.setStyles({height:0, left:0, opacity: 0, position:'absolute', top:0, width:0});
			mask.inject($('wrapper'), 'bottom');
			maskFX = new Fx.Tween(mask, {duration:500, link:'cancel', transition: Fx.Transitions.Sine.easeInOut});
		}

		//SHOW MASK
		function showMask()
		{
			if((Browser.Engine.trident && Browser.Engine.version < 6) || (Browser.Engine.gecko && Browser.Engine.version < 19))
  			{
				$$('.flash, select').setStyle('display', 'none');
			}
			var windowCoords     = window.getCoordinates();
			var headerCoords     = $('header').getCoordinates();
			var navigationCoords = $('navigation').getCoordinates();
			var contentCoords    = $('content').getCoordinates();
			var footerCoords     = $('footer').getCoordinates();
			var scrollSize       = $('content').getElement('.sub-wrapper').getSize().x;
			var scrolled = window.getScroll();

			if((contentCoords.height + footerCoords.height) < windowCoords.height)
			{
				calculatedHeight = windowCoords.height.toInt() - headerCoords.height - navigationCoords.height + scrolled.y;
			}
			else
			{
				calculatedHeight = contentCoords.height + footerCoords.height;
			}

			if(scrollSize > windowCoords.width)
			{
				calculatedWidth = scrollSize;
			}
			else
			{
				calculatedWidth = "100%";
			}
			
			mask.setStyles({height:calculatedHeight, left:0, top:contentCoords.top, width:calculatedWidth});
		        maskFX.start('opacity', .6);
		}

		//HIDE MASK
		function hideMask()
		{
			maskFX.start('opacity', 0);
			if((Browser.Engine.trident && Browser.Engine.version < 6) || (Browser.Engine.gecko && Browser.Engine.version < 19))
  			{
				var delayFunc  = function()
				{
					$$('.flash, select').setStyle('display', 'block');
				}
				delayFunc.delay(750);
			}
		}

		//CALCULATES THE WIDTHS OF EACH SUBSECTION
		function setSubsectionWidths()
		{
			var subSections = $$('.primary-navigation .sub-section');
			subSections.each
			(
				function(subSection)
				{
					var groups = subSection.getElement('.c').getChildren('.group');
					var proposedWidth = groups.length*151+2;
					if (proposedWidth == 0)
					{
						subSection.setStyle('display', 'none');
						return;
					}
					else if (proposedWidth == 153)
					{
						subSection.setStyle('width', 275 + 11);
					}
					else if(proposedWidth > 924)
					{
						subSection.setStyle('width', 924);
					}
					else
					{
						subSection.setStyle('width', proposedWidth + 11);
					}

					var centerDiv = subSection.getElements('.center');
					centerDiv.setStyle('width', subSection.getStyle('width').toInt() - 6);
				}	
			);
		}

		//SHOW SUBSECTION
		function showSubsection(sectionLink)
		{
			if(sectionLink.getParent().getNext().get('tag')=='dd')
			{
				var position = sectionLink.getCoordinates($('navigation').getElement('.sub-wrapper'));
				var currentSection = sectionLink.getParent().getNext();
		        	var proposedPosition = (position.left + 90) - (currentSection.getCoordinates().width/2);		                		
		        	if(proposedPosition < 0)
				{
		        		currentSection.setStyle('left', 0);
		        	}
		        	else if ((proposedPosition + currentSection.getCoordinates().width) > 924)
		        	{
					currentSection.setStyle('left', 924-currentSection.getCoordinates().width);
		        	}
		        	else
				{
					currentSection.setStyle('left', proposedPosition);
		        	}
		        	currentSection.setStyle('top', position.bottom);
		        	sectionLink.getElement('.join').setStyle('display', 'block');
		        	if (!(Browser.Platform.mac && Browser.Engine.gecko && Browser.Engine.version < 19 && $$('.flash').length>0))
		        	{
		        		showMask();
		        	}
			}
		}

		//HIDE SUBSECTION
		function hideSubsection(sectionLink)
		{
			if(sectionLink.getParent().getNext().get('tag')=='dd')
			{
				currentSection = sectionLink.getParent().getNext();
				currentSection.setStyle('left', -5000);
				sectionLink.getElement('.join').setStyle('display', 'none');
				hideMask();
			}
		}
		
		//SECTION LINK FUNCTIONALITY
                var sectionLinks = $$('.primary-navigation dt a');
                sectionLinks.each
                (
                	function(sectionLink)
                	{
                		sectionLink
				.addEvent
				(
					'focus',
					function()
					{
						showSubsection(sectionLink);
					}
				)
				.addEvent
				(
					'blur',
					function()
					{
						hideSubsection(sectionLink);
					}
				)
				.addEvent
				(
					'mouseenter',
					function()
					{
						showSubsection(sectionLink);
					}
				)
				.addEvent
				(
					'mouseleave',
					function()
					{
						hideSubsection(sectionLink);
					}
				)
			}
		);

		//SUBSECTION LINK (KEYBOARD EVENTS)
		var subSectionLinks = $$('.primary-navigation dd a');
                subSectionLinks.each
                (
                	function(subSectionLink)
                	{
                		subSectionLink.removeProperty('tabindex');
                		subSectionLink
				.addEvent
				(
					'focus',
		                	function()
		                	{	
						showSubsection(subSectionLink.getParent('.sub-section').getPrevious('dt').getElement('a'));
						subSectionLink.getParent('.sub-section').getPrevious('dt').getElement('a').addClass('focus');
						showMask();
		                	}
		                )
		                .addEvent
				(
					'blur',
		                	function()
		                	{
						hideSubsection(subSectionLink.getParent('.sub-section').getPrevious('dt').getElement('a'));
						subSectionLink.getParent('.sub-section').getPrevious('dt').getElement('a').removeClass('focus');
						hideMask();
					}
				)
			}
		);

		//SECONDARY SECTION LINK FUNCTIONALITY (KEYBAORD EVENTS)
		$$('.sub-section')
		.addEvent
		(
			'mouseenter',
		        function()
		        { 		
	            		showSubsection(this.getPrevious('dt').getElement('a'));
	         		this.getPrevious('dt').getElement('a').addClass('focus');
	              	}
		)
		.addEvent
		(
			'mouseleave',
		        function()
		        {
	            		hideSubsection(this.getPrevious().getElement('a'));
	            		this.getPrevious('dt').getElement('a').removeClass('focus');
	               	}
		);


		addPresentationalMarkup();
		createMask();
		setSubsectionWidths();
	},


	//*------------------------------------------------------------------//
	smoothScrollLinks: function()
	{
		var smoothScroll = new SmoothScroll({links:'a[rel=internal]'});
	},


	//*------------------------------------------------------------------//
	screenReaderLinks: function()
	{
		var screenReaderLinks = $$('.screen-reader-links a');
		screenReaderLinks.each
		(
			function(link)
			{
				link
				.setStyle('opacity', '.9')
				.addEvent
				(
					'focus',
					function()
					{
						link.getParent().setStyle('left', '0px');
					}
				)
				.addEvent
				(
					'blur',
					function()
					{
						link.getParent().setStyle('left', '-5000px');
					}
				)
			}
		);
	},


	//*------------------------------------------------------------------//
	externalLinks: function()
	{
		var anchors = $$('a[rel="external"]');
		anchors.each
		(
			function(anchor)
			{
				anchor.addEvent
				(
					'click',
					function(e)
					{
						e.preventDefault();
						window.open(anchor.href);
					}
				)
			}
		)
	},
	
	//*------------------------------------------------------------------//
	popupLinks: function()
	{
		var anchors = $$('a[rel="popup"]');
		anchors.each
		(
			function(anchor)
			{
				anchor.addEvent
				(
					'click',
					function(e)
					{
						var left = (screen.width/2  - 300);
						var top  = (screen.height/2 - 260);
						e.preventDefault();
						window.open(anchor.href, "RBS", 'width=600,height=520,scrollbars=1,toolbar=0,resizable=0,top='+top+',left=' +left+"'");
					}
				)
			}
		)
	},
	flashHasJS: function()
	{
		return true;
	},
	flashPopupLinks: function(location)
	{
		
			var left = (screen.width/2  - 300);
			var top  = (screen.height/2 - 260);
			window.open(location, "RBS", 'width=600,height=520,scrollbars=1,toolbar=0,resizable=0,top='+top+',left=' +left+"'");
		
	},


	//*------------------------------------------------------------------//
	tools: function()
	{
		if($$('.tools').length>0)
		{
			new Asset.images(['/images/interface/tools/icon_share_hover.gif', '/images/interface/tools/icon_bookmark_hover.gif', '/images/interface/tools/icon_email_hover.gif', '/images/interface/tools/icon_print_hover.gif'])
			$$('.tools img').each
			(
				function(el)
				{		
					el.addEvent
					(
						'mouseover',
						function()
						{
							this.setAttribute('src',this.src.replace('.gif', '_hover.gif'));
						}
					)
					.addEvent
					(
						'mouseout',
						function()
						{
							this.setAttribute('src',this.src.replace('_hover.gif', '.gif'));
						}
					);
				}
			)

			$$('.print').addEvent
			(
				'click',
				function(e)
				{
					e.stop();
					window.print();
				}
			)


			function bookmarksite(title,url)
			{
				if (window.sidebar)
				{
					window.sidebar.addPanel(title, url, "");
				}
				else if(window.opera && window.print)
				{
					var elem = document.createElement('a');
					elem.setAttribute('href',url);
					elem.setAttribute('title',title);
					elem.setAttribute('rel','sidebar');
					elem.click();
				} 
				else if(document.all)
				{
					window.external.AddFavorite(url, title);
				}
			}

			if(Browser.Engine.trident || Browser.Engine.gecko)
			{
				$$('.bookmark').addEvent
				(
					'click',
					function(e)
					{
						e.stop();
						bookmarksite(document.title, document.location.href);
					}
				)
			}
		}
	},


	//*------------------------------------------------------------------//
	errorMessages: function()
	{
		var errorMessages = $$('.error-msg');
		var delayFunc = function()
		{
			var myFx = new Fx.Scroll(window, {duration:2000}).toElement(errorMessages[0]);
			myFx.onComplete = function(){errorMessages[0].highlight('#ff0000');}
		}
		if($$('.error-msg').length > 0)
		{
			delayFunc.delay(500);
		}
	},


	//*------------------------------------------------------------------//
	accordions: function()
	{	
		var accordions = $$('.accordion');
		accordions.each
		(
			function(accordion)
			{
				var style = "1px solid " + accordion.getFirst('.element').getStyle('border-color').split(" ")[0];
				accordion.getElements('.toggler').setStyle('border-bottom', style);
				accordion.getElements('.toggler').addClass('closed');
				
				if(accordion.getElements('.error-msg').length > 0)
				{
					error = accordion.getElements('.element').length - 1;
				}
				else
				{
					error = -1;
				}

				var accordion = new Accordion
				(
					accordion.getElements('.toggler'), accordion.getElements('.element'),
					{
						alwaysHide:true,
						show:error,
						onActive: function(toggler, element)
						{
							var togglerEffect = new Fx.Morph(toggler, {duration: 500, transition: Fx.Transitions.Sine.easeOut});
							var elementEffect = new Fx.Morph(element, {duration: 500, transition: Fx.Transitions.Sine.easeOut});
							toggler.removeClass('closed').addClass('open');
							togglerEffect.start({'background-color': '#fff'});
							elementEffect.start({'background-color': '#fff'});
							toggler.setStyle('border-bottom', '1px solid #fff');
							if(!Browser.Engine.trident)
							{
								element.setStyle('padding-bottom', '12px');
							}
						},
						onBackground: function(toggler, element)
						{
							var togglerEffect = new Fx.Morph(toggler, {duration: 500, transition: Fx.Transitions.Sine.easeOut});
							var elementEffect = new Fx.Morph(element, {duration: 500, transition: Fx.Transitions.Sine.easeOut});
							toggler.removeClass('open').addClass('closed');
							togglerEffect.start({'background-color': toggler.getParent().getParent().getStyle('background-color')});
							elementEffect.start({'background-color': toggler.getParent().getParent().getStyle('background-color')});
							toggler.setStyle('border-bottom', style);
							element.setStyle('padding-bottom', '0');
						}
					}
				);
			}
		)
		$$('.toggler').setStyle('cursor', 'pointer');
		$$('.toggler').addEvent('click', function(event) {event.stop();})
	},


	//*------------------------------------------------------------------//
	expandableModules: function()
	{
		function module(domElement)
		{
			this.domElement   = domElement;
			this.expand       = new Element('a',{'href':'#', 'class': 'control expand expand-disable', 'title':'Follow link to expand module content.'});
			this.contract     = new Element('a',{'href':'#', 'class': 'control collapse', 'title':'Follow link to collapse module content.'});
			this.slider       = new Fx.Slide(domElement.getElement('.feed'), {duration: 400,transition: Fx.Transitions.Circ.easeOut});

			this.generateControls = function(expand, contract)
			{
				expand.inject(domElement, 'top');
				contract.inject(domElement, 'top');
			}

			this.attachEvents = function(expand, contract, slider)
			{
				this.expand = expand;
				this.expand.addEvent
				(
					'click', function(e)
					{
						e.stop();
						slider.slideIn();
					}
				);

				this.contract.addEvent
				(
					'click', function(e)
					{
						e.stop();
						slider.slideOut();
					}
				);

				this.slider.addEvent
				(
					'complete', function()
					{
						if(slider.open)
						{
							expand.addClass('expand-disable');
							contract.removeClass('collapse-disable');
						}
						else
						{
							contract.addClass('collapse-disable');
							expand.removeClass('expand-disable');
						}
					}
				);
			}
			this.generateControls(this.expand, this.contract);
			this.attachEvents(this.expand, this.contract, this.slider);
			return true;
		}

		var modules = $$('.expander');
		for (i=0; i<modules.length; i++)
		{
			var mod = new module(modules[i]);
		}
	},


	//*------------------------------------------------------------------//
	sortableModules: function()
	{
		var handles = $$('.functional-modules .title');
		handles.setStyle('cursor', 'move');
		var mySortables = new Sortables
		(
			'.functional-modules',
			{
				handle:'.title',
    				constrain: true,
    				clone: true,
    				revert: true,
    				opacity: .6
			}
		);
	},


	//*------------------------------------------------------------------//
	subPageUpdater: function()
	{
		function subPage(domElement)
		{
			this.domElement   = domElement;
			this.anchors      = domElement.getElements('.tertiary-navigation a');
			this.contentZone  = domElement.getElement('.c');
			this.updateContainer;

			this.prepareElements = function()
			{
				elements = this.contentZone.getChildren();
				this.updateContainer   = new Element('div',{'class': 'updateContainer'});
				this.updateContainer.inject(this.contentZone, 'top');
				elements.inject(this.updateContainer);
			}
			this.prepareElements();

			this.makeRequest = function(href, updateContainer, contentZone)
			{
				var req = new Request.HTML
				(
					{
						url:href + '?ajax=true',
						onSuccess: function(html)
						{
							updateContainer.set('text', '');
							updateContainer.adopt(html);
							
							var delayFunc = function()
							{
								contentZone.removeClass('preloader');
								resultFX = new Fx.Tween(contentZone, {duration:750, transition: Fx.Transitions.Circ.easeInOut});
								resultFX.start('height', updateContainer.getStyle('height'));
								updateContainer.fade("in");
								resultFX.onComplete = function()
								{
									contentZone.setStyle('height', 'auto');
									contentZone.setStyle('overflow', 'auto');
								}
							}
							delayFunc.delay(750);
						}
					}
				);
				req.send();
			}
			
			this.attachEvents = function(contentZone, updateContainer, anchors)
			{
				doStuff = function(href, updateContainer, contentZone)
				{
					this.makeRequest(href, updateContainer, contentZone);
				}.bind(this)

				this.anchors.each
				(
					function(anchor)
					{
						anchor.addEvent
						(
							'click',
							function(e)
							{
								anchor.getParent().getParent().getElements('a').removeClass('current');
								anchor.addClass('current');
								e.stop();
								contentZone.setStyle('overflow', 'hidden');
								updateContainer.fade("out");
								contentZoneFX = new Fx.Tween(contentZone, {duration:750, transition: Fx.Transitions.Circ.easeInOut});
								contentZoneFX.start('height', 100);
								contentZone.addClass('preloader');
								var delayFunc = function()
								{
									this.doStuff(anchor.href, updateContainer, contentZone);
								}
								delayFunc.delay(750);
							}.bind(this)
						)
					}
				)
			}
			this.attachEvents(this.contentZone, this.updateContainer, this.anchors);
			return true;
		}
		var subPages = $$('.updater');
		for (i=0; i<subPages.length; i++)
		{
			var subPageInstance = new subPage(subPages[i]);
		}
	},


	//*------------------------------------------------------------------//
	multibox: function()
	{
		if($$('.mb').length > 0)
		{
			var initMultiBox = new multiBox
			(
				{
					mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
					container: $(document.body),//where to inject multiBox
					descClassName: 'multiBoxDesc',//the class name of the description divs
					path: './Files/',//path to mp3 and flv players
					useOverlay: true,//use a semi-transparent background. default: false;
					maxWidth: 600,//max width (set to false to disable)
					maxHeight: 400,//max height (set to false to disable)
					addDownload: false,//do you want the files to be downloadable?
					//pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify download script
					addRollover: true,//add rollover fade to each multibox link
					addOverlayIcon: false,//adds overlay icons to images within multibox links
					addChain: true,//cycle through all images fading them out then in
					recalcTop: true//subtract the height of controls panel from top position
				}
			);
		
		
			/*var initMultiBox = new multiBox
			(
				'mb',
				{
					descClassName: 'multiBoxDesc',
					path: 'Flash/',
					useOverlay: true,
					maxWidth: 600,
					maxHeight: 250,
					addDownload: false,
					pathToDownloadScript: './Scripts/ForceDownload.asp',
					addRollover: true,
					addOverlayIcon: false,
					addChain: true,
					recalcTop: true
				}
			);*/
		};
	},


	//*------------------------------------------------------------------//
	linkFocus: function()
	{
		var links = $$('a');
		links.each
		(
			function(link)
			{
				link
				.addEvent
				(
					'focus',
		                	function()
		                	{
		                		link.addClass('focus');
		                	}
				)
				.addEvent
				(
					'blur',
		                	function()
		                	{
		                		link.removeClass('focus');
		                	}
				)
			}
		)
	},


	//*------------------------------------------------------------------//
	linkTooltips: function()
	{
		var tipLinks = $$('a[title], label[title], input[title]');
		var tooltips = new Tips(tipLinks,{className:'tip-wrapper', offsets:{'x':12, 'y': 12}});
	},


	//*------------------------------------------------------------------//
	init: function()
	{
		this.flash();
		if(Browser.Engine.trident && (Browser.Engine.version < 6))
  		{
			this.ieZIndexFix();
		}
		if($('navigation'))
		{
			this.navigation();
		}
		this.smoothScrollLinks();
		this.screenReaderLinks();
		this.externalLinks();
		this.popupLinks();
		this.tools();
		this.errorMessages();
		this.accordions();
		this.expandableModules();
		this.sortableModules();
		this.subPageUpdater();
		this.multibox();
		this.linkFocus();
		//this.linkTooltips();
	}
};


/*------------------------------------------------------------------
REGISTER MAIN EVENTS
------------------------------------------------------------------*/
if(Browser.Engine.trident && Browser.Engine.version < 6)
{
	window.addEvent
	(
		'domready',
		function()
		{
			if($('current-section'))
			{
				$('current-section').addClass('hidden');
			}
		}
	);
	window.addEvent
	(
		'load',
		function()
		{
			rbs.init();
		}
	);
}
else
{
	window.addEvent
	(
		'domready',
		function()
		{
			if($('current-section'))
			{
				$('current-section').addClass('hidden');
			}
			rbs.init();
		}
	);
}