$(function() {
	var outDur = 250;
	var pauseDur = 4000;
	var vertOffset = 70;
	
	function nextQuote(el) {
		el = el ? el : $(this);
		var n = el.next();
		if (!n || n.length < 1) {
			n = el.parent().children().eq(0);
		}
		el
			.delay(pauseDur)
			.animate({
			opacity: 0,
			top: -vertOffset
		}, outDur, function() { el.css('display', 'none') });
		n
			.delay(pauseDur)
			.css({display: 'block', opacity: 0, top: vertOffset})
			.animate({
					opacity: 1,
					top: 0
				}, outDur, nextQuote
			);
	}
	
	nextQuote($("ul.pull-quotes li").eq(0));
	
	$("a.screenshot-thumb").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	400, 
		'speedOut'		:	200
	});
	var bholder = $('.bee-holder');
	$('ul.bee-switcher > li > a').click(function() {
		var el = $(this);
		$('ul.bee-switcher > li > a').removeClass('on');
		el.addClass('on');
		var left = '';
		switch(el.attr('rel')) {
			case 'basic':  left = '0%'; break;
			case 'basket': left = '-100%'; break;
			case 'brave':  left = '-200%'; break;
		}
		bholder
			.stop() // stop all current animations
			.animate({left: left}, 300);
	});
	
	$('.buy-link').click(function() {
		try {
			el = $(this);
			var newhref = el.attr('href');
			window.pageTracker._trackEvent('Purchase Links', el.attr('rel'));
			setTimeout(function() {
				document.location = newhref;
			}, 100);
			return false;
		} catch (err) {};
	});
});
