jQuery(document).ready(function() {
	position = jQuery('#whats-your-persona').position();
	jQuery('#persona #view-this').css('top', position.top);
	
	jQuery('#whats-your-persona').hover(function() {
		jQuery('#persona a').addClass('focused');
	},
	function() {
		jQuery('#persona a').removeClass('focused');
	});
	
});

jQuery(document).ready(function() {
	
	// hide all except the first slide
	jQuery('#persona ul li:gt(0)').hide();
	
	// get first slide's link and color
	var current_link        = jQuery('#persona ul li:eq(0) a').attr('href');
	var current_color       = jQuery('#persona ul li:eq(0) div.color-code').html();
	var slide_transition    = 750;
	
	// set sidebar link's color and url location
	jQuery('#whats-your-persona #enhanced').animate({backgroundColor: "#" + current_color});
	jQuery('#whats-your-persona a').attr("href", current_link);
	
	if(parseInt(jQuery('#persona ul li').length) > 1) {
		setInterval(function() {
			// hide current slide
			var current_slide = jQuery('#persona ul li:eq(0)');
			current_slide.fadeOut(slide_transition);
			
			// get color and link information from next slide
			var next_slide  = current_slide.next("li");
			var next_link   = next_slide.find("a").attr("href");
			var next_color  = next_slide.find("div.color-code").html();
			
			// show next slide, update sidebar button link and color
			next_slide.fadeIn(slide_transition);
			jQuery('#whats-your-persona #enhanced').animate({backgroundColor: "#" + next_color}, slide_transition);
			jQuery('#whats-your-persona a').attr("href", next_link);
			
			// make sure arrow is aligned with sidebar button
			position = jQuery('#whats-your-persona').position();
			jQuery('#persona #view-this').css('top', position.top);
			
			// move the last slide to the end of the element
			current_slide.appendTo("#persona ul");
		}, 5000);
	}
});