$(document).ready(function(){

	// set the ID of the element to animate and other variables
	var slideshow_element = $("#slideshow");
	var animation_duration = 2500;
	var img_height = 410;
	var img_width  = 990;

	// Automatically set variables - do not change
	var img_cols  = Math.round(slideshow_element.width() / img_width);
	var img_count = slideshow_element.children().length;
	var img_rows  = Math.ceil(img_count / img_cols);
	var cur_img   = 0; // zero will be first
	var cur_col   = 0;
	var cur_row   = 0;

	$.timer(3000, function (timer) {
		++cur_img;
		if( cur_img == img_count ){
			cur_col = 0;
			cur_row = 0;
			cur_img = 0;
		}
		else if( cur_img % img_cols == 0 ){
			++cur_row;
			cur_col = 0;
		}
		else
			++cur_col;
		slideshow_element.stop().animate({left: -(cur_col*img_width)+"px", top: -(cur_row*img_height)+"px"}, {easing: 'easeOutBack', duration: animation_duration});
		//timer.reset(12000);
	});

});
