// press room js

		var currYear = '2011';
		var urlPrefix = 'press-'; // this is the URL that will be requested IE: urlPrefix + year + .html
		
		// The XHR request for content
		var moreNewsRequest = new Request.HTML({
			onRequest: function() {
				$('loading-container').toggleClass('loading');
			},
			onFailure: function() {
				$('loading-container').toggleClass('loading');
				$('loading-container').addClass('error');
				$('loading-container').removeClass.delay(3000, $('loading-container'), 'error');
			},
			onSuccess: function(rt, re, rh, rjs) {
				$('news_content').adopt.delay(1000, $('news_content'), rt);
				$('loading-container').toggleClass.delay(1000, $('loading-container'), 'loading');
				newsContentTween.callChain.delay(1000, newsContentTween);
			}
		});			
		
		//This changes the year being viewed		
		function changeYear(newYear) {	
			
			// Start animation, shrink height		
			newsContentTween.start(0).chain(
				
				// remove content, change active li, get new content
				function() {
					$('news_content').set('html', '');
					$(currYear).toggleClass('active');
					currYear = newYear;
					$(currYear).toggleClass('active');
					
					yearURL = urlPrefix + newYear +'.html'
					moreNewsRequest.get(yearURL);
				},
				
				// animate to the new height
				function() {
					$('news_content').setStyles({
						height: '',
						visibility: 'hidden'
					});
					var newHeight = $('news_content').getSize().y;
					$('news_content').setStyles({
						height: 0,
						visibility: 'visible'
					});
					newsContentTween.start(0, newHeight);
				},
				
				// remove set height
				function() {
					$('news_content').setStyle('height', '');
				}
			);				
		}
		
		// Add event handlers & initialize animations
		document.addEvent('domready', function() {
		 	newsContentTween = new Fx.Tween('news_content', {property: 'height'});
			
			// The Year list items
			$$('#news_list .year_nav ul li').addEvent('click', function() {
				var clickedYear = this.id;
				changeYear(clickedYear);
			});
			
			// The Year links
			$$('#news_list .year_nav ul li a').addEvent('click', function(event) {
			    event.preventDefault();
			});	
		});
