function slideShow(speed) {


	//append a LI item to the UL list for displaying caption

	//Set the opacity of all images to 0
	
	
	//Get the first image and display it (set it to full opacity)
	var items = jQuery('ul.slideshow li:not(.show,#slideshow-caption)');
	var itemscount= items.length;
	//var first=items.first();
	//first.animate({opacity: 1.0},2000);
	//first.addClass('show');
	//var title=first.find('img').attr('title');
	//Get the caption of the first image from REL attribute and display it
	//jQuery('#slideshow-caption h3').html(title);
		
	//Display the caption
	//jQuery('#slideshow-caption').css({opacity: 0.7, bottom:0});
	
	//Call the gallery function to run the slideshow	
	var timer = setInterval('gallery()',speed);
	
	//pause the slideshow on mouse over
	
}

function gallery() {


	//if no IMGs have the show class, grab the first image
	var current = (jQuery('ul.slideshow li.show')?  jQuery('ul.slideshow li.show') : jQuery('#ul.slideshow li:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	/*var items = jQuery('ul.slideshow li:.show');
	var itemscount= items.length;
	var next=jQuery(items.get(Math.round(Math.random()*(itemscount-1))));*/
	var next=(current.next().length ? current.next() : jQuery('ul.slideshow li:not(.show,#slideshow-caption)').first());
		
	//Get next image caption
	//var title = next.find('img').attr('title');	

	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
	
	//Hide the caption first, and then set and display the caption
	//jQuery('#slideshow-caption').animate({bottom:-40}, 300, function () {
			//Display the content
	//		jQuery('#slideshow-caption h3').html(title);					
	//});	

	//Hide the current image
	current.animate({opacity: 0.0}, 2000).removeClass('show');

}

function initSlideshow(){
	//$('#tmp_content_image img').css('display','none');
	$.ajax({
		type: "GET",
		url: "images.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('page').each(function(){
				if ($(this).attr('name')==pageFilename()){ 
					doc='<ul class="slideshow">';
					$(this).find('img').each(function(){
						doc+='<li><img src="'+$(this).attr('src')+'" /></li>';
					});
					doc+='</ul>';
					$('#tmp_header').html(doc);
					jQuery('ul.slideshow li').css({opacity: 0.0});
					jQuery('ul.slideshow li:first').css({opacity: 1.0}).addClass('show');
				}
			});
		}
	       });
	
}

function startSlideshow() {
	slideShow(10000);
}
function pageFilename(){
	var filename=location.pathname;
	filename=filename.substring(filename.lastIndexOf('/')+1,filename.lastIndexOf('.'));
	if (location.pathname.lastIndexOf('.')<=0)
		filename="index";
	return filename;
}

$(document).ready(function(){
	
	//initSlideshow();
});

