/*var showBlurb = function(elIndex) {
	$$('.blurb').each(function (el, i){
		if (elIndex == i) {
			el.removeClass('hidden')
		}else{
			el.addClass('hidden');
		}   
	})
}

var hideBlurb = function(elIndex) {
	$$('.blurb').each(function (el, i){
		el.addClass('hidden');
	})
}

var removeTabOn = function(el) {
	$$('#news-list li a').each(function (el, i){
		el.removeClass('tabOn');
	}); 
}; 

var showFirstItem = function() {
	var firstBlurb = $$('.blurb:first-child');
	firstBlurb.removeClass('hidden');
	$$('#news-list li a').each(function (el, i){
		if (i == 0) {
			el.addClass('tabOn');
		}
	});
	
};

window.addEvent('domready', function() {  
	var index = 1;
	var resumePeriodical;
	var pos = 0;
	
	//Show the first Blurb and News Headline
	showFirstItem();   
	
	var periodical = rotateItems.periodical(2000);
	
	//Set up on hover events for News Headlines	
	$$('#news-list li a').each(function (el, i){
		el.addEvent('mouseenter', function(event){
			
			pos = index;
			//get rid of .tabOn on all list items
			removeTabOn(el);
			
			//show associated blurb
			showBlurb(i);
			
			//Stop any periodical from running 
			$clear(periodical);
			$clear(resumePeriodical);
		});
		el.addEvent('mouseleave', function(event){
			hideBlurb(i); 
            console.log(index);
			//Start the Periodical again by showing the last one
			showLastPeriodical();
 			resumePeriodical = rotateItems.periodical(2000);
		});
	}) 
	
	 

function rotateItems() {   
	$$('.blurb').each(function (el, i){
		if (index == i ) {
			el.removeClass('hidden');
		} else {
			el.addClass('hidden');
		}
	});
	$$('#news-list li a').each(function (el, i){
		if (index == i) {
			el.addClass('tabOn');
		} else {
			el.removeClass('tabOn');
		}
	});
	//Once the end of the News headline list has been reached, start again
	if (index == 3) {
		index = 0;
	} else {
		index++;  
	} 
};

function showLastPeriodical() {
	//If Last Periodical was the first one, reset the list, otherwise show last Periodical
	index = pos;
	
	if(index == 0) {
		
	} else {
		//index--;
	}  
	$$('.blurb').each(function (el, i){
		if (index == i ) {
			el.removeClass('hidden');
		} else {
			el.addClass('hidden');
		}
	});
	$$('#news-list li a').each(function (el, i){
		if (index == i) {
			el.addClass('tabOn');
		} else {
			el.removeClass('tabOn');
		}
	});
};
}); */

var showBlurb = function(elIndex) {
	$$('.blurb').each(function (el, i){
		if (elIndex == i) {
			el.removeClass('hidden')
		}else{
			el.addClass('hidden');
		}   
	})
}

var hideBlurb = function(elIndex) {
	$$('.blurb').each(function (el, i){
		el.addClass('hidden');
	})
}

var removeTabOn = function(el) {
	$$('#news-list li a').each(function (el, i){
		el.removeClass('tabOn');
	}); 
}; 



window.addEvent('domready', function() {  
	var index = 0;
	var resumePeriodical;
	
	//Show the first Blurb and News Headline
	showFirstItem();
	var periodical = rotateItems.periodical(5000);
	
	//Set up on hover events for News Headlines	
	$$('#news-list').each(function (el) {
		el.addEvent('mouseenter', function(event){
			$clear(periodical);
			$clear(resumePeriodical);    
		});
		el.addEvent('mouseleave', function(event){
			//Start the Periodical again by showing the last one
			showLastPeriodical();
 			resumePeriodical = rotateItems.periodical(5000);   
		})
	})
	
	$$('#news-list li a').each(function (el, i){
		el.addEvent('mouseenter', function(event){
			//get rid of .tabOn on all list items, :hover styles are in affect
			removeTabOn(el);
			showBlurb(i);
		});
		el.addEvent('mouseleave', function(event){
			hideBlurb(i); 
		}); 
	})   

function showFirstItem () {
	$$('.blurb').each(function (el, i){
		if (i == 0) {
			el.removeClass('hidden');
		}
	});
	$$('#news-list li a').each(function (el, i){
		if (i == 0) {
			el.addClass('tabOn');
		}
	});
	
};    

function rotateItems() {
	if (index == 3) {
		index = 0;
	} else {
		index++;  
	}   
	$$('.blurb').each(function (el, i){
		if (index == i ) {
			el.removeClass('hidden');
		} else {
			el.addClass('hidden');
		}
	})
	$$('#news-list li a').each(function (el, i){
		if (index == i) {
			el.addClass('tabOn');
		} else {
			el.removeClass('tabOn');
		}
	})
};

function showLastPeriodical() { 
	$$('.blurb').each(function (el, i){
		if (index == i ) {
			el.removeClass('hidden');
		} else {
			el.addClass('hidden');
		}
	});
	$$('#news-list li a').each(function (el, i){
		if (index == i) {
			el.addClass('tabOn');
		} else {
			el.removeClass('tabOn');
		}
	});
}; 


//show homepage more data
if($('mainCopyContentContainer')){
	var the_content = $('mainCopyContentContainer').get('html');

	$('mainCopyContent').setStyle('height', $('mainCopyContent').scrollHeight);
	if($('mainCopyMore')){
		$('mainCopyMore').addEvent('click', function(event){
			$('mainCopyContent').set('html', the_content);
			$('mainCopyContent').tween('height', $('mainCopyContent').scrollHeight)
			$('mainCopyMore').dispose();	
		});
	}
}


 
});	


