var gallery_pos = 1;
var curr_image = 0;

function next_image()
{
	my_int = setTimeout('rotate_image()', 3e3);
}

function rotate_image()
{
	var images = window.gallery_images.split(',');
	var old_image = window.curr_image;
	window.curr_image = window.curr_image * -1 + 1;
	if( ++window.gallery_pos == images.length ) window.gallery_pos = 0;
	$('#image_'+old_image).fadeOut(1500, function() {
		$('#image_'+old_image).attr('src','/_images/slides/'+images[gallery_pos]);
		next_image();
  	});
	$('#image_'+window.curr_image).fadeIn(1500)
}

$(document).ready(function() {
	next_image();
});

