//requires prototype
//Automatically switches animal pages every refresh_rate minutes
Event.observe(window, 'load', start_swap);

var refresh_rate = .5;//in minutes
var animal_paths = ['/profile/1/swap_animal_page','/profile/2/swap_animal_page','/profile/3/swap_animal_page','/profile/4/swap_animal_page'];
var current_animal = 1;

function start_swap() {
	if(animal_paths.length > 1){
		setTimeout('refresh_animal()', refresh_rate*60000);
	}
}

function refresh_animal() {
	new Ajax.Request(animal_paths[current_animal], {asynchronous:true, evalScripts:true, method:'get',
		onSuccess: function () {
	    	current_animal += 1;
			if(current_animal >= animal_paths.length){
				current_animal = 0;
			}
			setTimeout('refresh_animal()', refresh_rate*60000);
	  	}
	});
}

