
function cycle(url, element, index) {
	$.get(url, {i: index},
		function (data) {
			$("#" + element).html(data);
		}
	);
}

/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.
***/
function slideSwitch() {
	var $active = $('#slideshow span.active');
	var $bubbles = $('.slider_bubble');
	var $active_b = $('.slider_bubble.active');
	var index = (($bubbles.index($active_b)+1)%$bubbles.length);
	
	if ( $active.length == 0 )
		$active = $('#slideshow span:last');
	
	var $next = $active.next().length ? $active.next() : $('#slideshow span:first');
	var $next_b = $bubbles.eq(index);
	
	$active.addClass('last-active').fadeTo(1000, 0.0);
	
	$next.css({opacity: 0.0})
		.addClass('active')
		.fadeTo(1000, 1.0, function() {
			$active.removeClass('active last-active');
		});
	$next_b.addClass('active');
	$active_b.removeClass('active');
}

$(function() {
    var i = setInterval("slideSwitch()", 8000);
	
	// Select the slider element that was clicked
	$('.slider_bubble').bind('click', function() {
		clearInterval(i);
		
		var $bubbles = $('.slider_bubble');
		var $panes = $('#slideshow span');
		var $active = $('#slideshow span.active');
		
		var index = $(".slider_bubble").index(this);
		$bubbles.removeClass('active');
		$bubbles.eq(index).addClass('active');
		
		$active.addClass('last-active').fadeTo(1000, 0.0);
		$panes.eq(index).css({opacity: 0.0})
			.addClass('active')
			.fadeTo(1000, 1.0, function() {
				$active.removeClass('active last-active');
			});
		i = setInterval("slideSwitch()", 8000);
		
	});
});
