jQuery(document).ready(function($){
	//clear out all the a's in the slideshow list and make it into an array.
	if ($("#slides").length) {
		images = new Array();
		curimg = 0;
		$("#slides a").each(function(i){
			images[i] = $(this).attr("href");
			$(this).parents("li").remove();
		});
		setTimeout("nextImg()",3000);
		var newimg = "<img src='" + images[curimg] + "' />";
		$(newimg).load(function(){
			$("<li>" + newimg + "</li>").appendTo("#slides").show();
			curimg++;
			
		});
	}
});

//slideshow function
function nextImg() {
	if (curimg >= images.length) {
		curimg = 0;
	}
	jQuery("#slides li").addClass("lastimg");
	var newimg = "<img src='" + images[curimg] + "' />";
	jQuery(newimg).load(function(){
		jQuery("<li>" + newimg + "</li>").appendTo("#slides").hide().fadeIn("slow",function(){
			jQuery(".lastimg").remove();
			curimg++;
			setTimeout("nextImg()",3000);
		});
	});
}
