// JavaScript Document
var fp_anim = {
	timer: null,
	start: function() {
		this.timer = setInterval(this.tick, 2500);
	},
	stop: function() {
		var index = $('#homenav A.animated').index(); //'.animated');	
		if (index >= 0) {
			//remove the hover class name
			var hover_class = $('#homenav A.animated').attr('class').split(' ').slice(0, 1) + "_hover";
			$('#homenav A.animated').removeClass(hover_class);
		}

		clearInterval(this.timer);
	},
	tick: function() {
		var index = $('#homenav A.animated').index(); //'.animated');	
		if (index >= 0) {
			//remove the animated class name, and the hover class name
			var hover_class = $('#homenav A.animated').attr('class').split(' ').slice(0, 1) + "_hover";
			$('#homenav A.animated').removeClass("animated").removeClass(hover_class);

		}
		var next_index = (index+1) % $('#homenav A').length;
		var next_link = $('#homenav A').slice(next_index, next_index+1).get(0);
		var hover_class = $(next_link).attr('class').split(' ').slice(0, 1) + "_hover";
		$(next_link).addClass('animated').addClass(hover_class);
	}
}


 $(document).ready(function(){
	$("#homenav A").mouseover(function(evt) {
		if (evt.which) { fp_anim.stop();}
	}).mouseout(function(evt) {
		if (evt.which) { fp_anim.start();}
	})

	fp_anim.start();
 });

