$(document).ready(function() {
	
		
	// Homepage carousel (bottom step plans)
		var testimonials = $('#testimonials');
			var testimonials_removeClasses = function() {
				testimonials.find('li').each(function() {
					testimonials.removeClass(  $(this).id );
				});
			};
			
			testimonials.find('li a').each(function(e) {
				$(this).mouseover(function(e) {
					testimonials_removeClasses();
					testimonials.toggleClass( $(this).parents('li')[0].id );
				});
				$(this).mouseout(function(e) {
					testimonials_removeClasses();
					testimonials.addClass('parents');
				});
			});
			
			
	// Homepage rotator
		
		
		var homepageCarouselRotate = function(sender)
		{
			
				
			// Rotate/load content
				var page = '/includes/homepage/pager-'+(cache.homepage.splash_counter+1)+'.htm';
				$.get(page, function(data) {
					var e = $(document.createElement('div'));
					e.html(data);
					
					var duration = 500;
					
					var splash_video	= $('#video-inner');
					var splash_msg		= $('#message');
					var splash_hdr		= splash_msg.find('h1 em:first');
					var splash_body		= splash_msg.find('p.body');
					var splash_link1	= splash_msg.find('p.story a:first');
					
					splash_video.fadeOut(duration);
					splash_msg.fadeOut(duration, function()
					{
						splash_hdr.html( e.find('div.title').html() );
						splash_body.html( e.find('div.copy').html() );
						splash_video.html( e.find('div.splash').html() );
						splash_link1.attr('href', e.find('a.more').attr('href'));
						
						splash_msg.fadeIn(duration);
						splash_video.fadeIn(duration);
					});
				});
			
		};
		
		
		
		var homepageAutoplay = function() {
	 
			var homepageCarouselOpts = {
					frequency : 8000,
					callback : function(ix) {
						//cache.homepage.splash_counter++;
						var link = $(cache.homepage.splash.find('li a[title="next"]')[0]);
						homepageCarouselRotate(link);
					}
				};
			
			var homepageCarouselTimer = new timedCallback();
				homepageCarouselTimer.start(homepageCarouselOpts); 
				
		};
		
		
		
			 
});
  
