function slideShowLeft(speed) 
{
	//append a LI item to the UL list for displaying caption
	$('ul.topleft').append('<li id="slideshow-captionleft" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');

	//Set the opacity of all images to 0
	$('ul.topleft li').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('ul.topleft li:first').css({opacity: 1.0});
	
	//Get the caption of the first image from REL attribute and display it
	$('#slideshow-captionleft h3').html($('ul.topleft a:first').find('img').attr('title'));
	$('#slideshow-captionleft p').html($('ul.topleft a:first').find('img').attr('alt'));
		
	//Display the caption
	$('#slideshow-captionleft').css({opacity: 0.85, bottom:0});
	
	var total = $('ul.topleft li').length;
	if (total > 2) //dont count caption <li>
	{
		//Call the gallery function to run the slideshow	
		var timer = setInterval('galleryLeft()',speed);
		
		//pause the slideshow on mouse over
		$('ul.topleft').hover(
			function () {
				clearInterval(timer);	
			}, 	
			function () {
				galleryLeft();
				timer = setInterval('galleryLeft()',speed);			
			}
		);
	}
}

function galleryLeft() 
{
	//if no imgs have the show class, grab the first image
	var current = ($('ul.topleft li.show')?  $('ul.topleft li.show') : $('#ul.topleft li:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-captionleft')? $('ul.topleft li:first') :current.next()) : $('ul.topleft li:first'));
		
	//Get next image caption
	var title = next.find('img').attr('title');	
	var desc = next.find('img').attr('alt');	

	//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
	$('#slideshow-captionleft').slideToggle(300, function () { 
		$('#slideshow-captionleft h3').html(title); 
		$('#slideshow-captionleft p').html(desc); 
		$('#slideshow-captionleft').slideToggle(500); 
	});		

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

function slideShowRight(speed) 
{
	//append a LI item to the UL list for displaying caption
	$('ul.topright').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');

	//Set the opacity of all images to 0
	$('ul.topright li').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('ul.topright li:first').css({opacity: 1.0});
	
	//Get the caption of the first image from REL attribute and display it
	$('#slideshow-caption h3').html($('ul.topright a:first').find('img').attr('title'));
	$('#slideshow-caption p').html($('ul.topright a:first').find('img').attr('alt'));
		
	//Display the caption
	$('#slideshow-caption').css({opacity: 0.85, bottom:0});
	
	var total = $('ul.topright li').length;
	if (total > 2) 
	{
		//Call the gallery function to run the slideshow	
		var timer = setInterval('galleryRight()',speed);
	
		//pause the slideshow on mouse over
		$('ul.topright').hover(
			function () {
				clearInterval(timer);	
			}, 	
			function () {
				galleryRight();
				timer = setInterval('galleryRight()',speed);			
			}
		);
	}
}

function galleryRight() 
{
	//if no imgs have the show class, grab the first image
	var current = ($('ul.topright li.show')?  $('ul.topright li.show') : $('#ul.topright li:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.topright li:first') :current.next()) : $('ul.topright li:first'));
		
	//Get next image caption
	var title = next.find('img').attr('title');	
	var desc = next.find('img').attr('alt');	

	//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
	$('#slideshow-caption').slideToggle(300, function () { 
		$('#slideshow-caption h3').html(title); 
		$('#slideshow-caption p').html(desc); 
		$('#slideshow-caption').slideToggle(500); 
	});		

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

function thumbRollover(img_id, link_id, thumbnail_on) {	
	if (thumbnail_on.length > 0) MM_swapImage(img_id, '', thumbnail_on, 1);
	document.getElementById(link_id).style.color = '#f30';
}
function thumbRollout(link_id) {	
	MM_swapImgRestore();
	document.getElementById(link_id).style.color = '#fff';
}
