
function slideSwitch(next) {

	var $active = $('#quotes div div.quote.active');

	if ($active.length == 0) {
		if (next) {
			$active = $('#quotes div div.quote:last');
		} else {
			$active = $('#quotes div div.quote:first');
		}
	}

	if (next) {
		var $next = $active.next().length ? $active.next() : $('#quotes div.quote:first');
	} else {
		var $next = $active.prev().length ? $active.prev() : $('#quotes div.quote:last');
	}

	$active.addClass('last-active');

	$active
		.animate({opacity: 0}, 300, function() {

			$next
				.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 300, function() {
					$active.removeClass('active last-active');
				});

		});

}

$(document).ready(function() {

	var wrapper = $('#quotes');

	if (wrapper) {
		$('#quotes').append('<ul><li class="firstChild"><a href="#" class="quoteBack">back</a></li><li><a href="#" class="quoteNext">next</a></li></ul>');
	}

	$('#quotes .quoteBack').click(function() { slideSwitch(false); return false; });
	$('#quotes .quoteNext').click(function() { slideSwitch(true);  return false; });

    //setInterval(slideSwitch, 6000);

});
