$(document).ready(function() {
	
	$('#navbody ul').cycle({
		fx:     'fade',
		speed:  500,
		timeout: 5000,
		pause: 	 1,
		before:  onBefore,
		after:   onAfter,
		pager:  '#navtab ul',
		pagerAnchorBuilder: function(idx, slide) {
			// return selector string for existing anchor
			return '#navtab li:eq(' + idx + ') a';
		}
	});
	
	$('#block-views-homepageitems ul').cycle({
		fx:			'scrollLeft',
		speed:		1000,
		timeout:	8000,
		pause:		1,
		easing:		'easeInOutBack'
	});
});

function onBefore() {
	var $class = $(this).attr('class');
	$('#navtab ul li a').animate({backgroundColor: '#393d37', color: '#ffffff', height: '64px'}, 250);
	$('#navtab ul li.' + $class + ' a').animate({backgroundColor: '#c9dd37', color: '#393d37', height: '68px'}, 250);
	$('#navpic ul li.story').animate({ left: '555px', width: '73px', opacity: 0.4}).css({zIndex: 1 });
	$('#navpic ul li.start').animate({ left: '632px', width: '73px', opacity: 0.4}).css({zIndex: 1 });
	$('#navpic ul li.award').animate({ left: '709px', width: '73px', opacity: 0.4}).css({zIndex: 1 });
	$('#navpic ul li.events').animate({ left: '786px', width: '73px', opacity: 0.4}).css({zIndex: 1 });
	$('#navpic ul li.newsletter').animate({ left: '863px', width: '73px', opacity: 0.4}).css({zIndex: 1 });
	$('#navpic ul li.' + $class + '').css({zIndex: 10}).animate({
		left: '555px',
		width: '379px',
		opacity: 1
		});
}

function onAfter() {
	var $class = $(this).attr('class');

}