var FPSS = { 

	current :  0, 
	next :  0, 
	total :  0,
	speed : 6000, 
	transitionSpeed : 1000, 
	caption : function(t){ 	
		$('.fpss_slideshow .fpssTextBox').fadeOut(FPSS.transitionSpeed, function(){ $(this).remove(); }); 
		data = $(t).find('img').attr('data-caption'); 
		link = $(t).find('img').attr('data-link'); 
		if(typeof(data) != 'undefined' && typeof(link) != 'undefined'){ 
			textbox = $('<div class="fpssTextBox" style="display: none; ">' + data + '<a href="' + link + '">more &raquo; </a>'); 	
			$('.fpss_slideshow').append(textbox); 
			textbox.fadeIn(FPSS.transitionSpeed); 
		}
	},
	init : function(slideshow){ 
		FPSS.current = 1; 
		/* make sure it can handle absolute positioning */
		$(slideshow).css('position', 'relative'); 
		FPSS.total = $(slideshow).children().length; 
		FPSS.caption($('.fpss_slideshow #fpss_slide_1'));  	
		setInterval(function(){ FPSS.rotateSlideshow(); }, FPSS.speed); 
	},
 	rotateSlideshow : function(){ 
		if(FPSS.current >= FPSS.total){  FPSS.next = 1; } else{ FPSS.next = FPSS.current + 1; } 
			
		next = $('.fpss_slideshow #fpss_slide_' + FPSS.next); 
		next.fadeIn(500).addClass('sel'); 
		FPSS.caption(next);  	

		$('.fpss_slideshow').css('background','url(' + $('#fpss_slide_' + FPSS.current + ' img').attr('src'));  
		$('.fpss_slideshow #fpss_slide_' + FPSS.current).fadeOut(FPSS.transitionSpeed).removeClass('sel'); 
		if(FPSS.current < FPSS.total){ FPSS.current++; }else{ FPSS.current = 1; } 
	}
}
$(document).ready(function(){ 
	FPSS.init('.fpss_slideshow'); 
});  

