//__________________________________________________
function  Slideshow(imageURLs_arr,showTitle_str,displayPeriod_int,blendPeriod_int,foregroundImgID_str,backgroundImgID_str){

	var newImg_src;
	var backgroundImg_htm	= document.getElementById(backgroundImgID_str);
	var foregroundImg_htm	= document.getElementById(foregroundImgID_str);
	var cookieName_str		= 'imageShow_'+showTitle_str;
	
	var initialIndex_int	= getSelectedIndex();
	if(!initialIndex_int){
		initialIndex_int	= 1;
	}
	saveSelectedIndex(initialIndex_int);
	var nImages_int			= imageURLs_arr.length;

	
	foregroundImg_htm.src	= getCurrentImgSrc();
	saveSelectedIndex(initialIndex_int+1);
	handleForegroundCompletion();
	//----------------------------------------------
	function getCurrentImgSrc(){
	
		var selectedIndex_int 	= getSelectedIndex();
		var imgIndex_int		= (selectedIndex_int+nImages_int+1)%nImages_int;
		newImgSrc_str			= imageURLs_arr[imgIndex_int];
		
		return newImgSrc_str;		
	};
	//----------------------------------------------		
	function saveSelectedIndex(index_int){
	
		setCookie(cookieName_str,''+index_int);	
	};
	//----------------------------------------------		
	function getSelectedIndex(){
		
		return parseInt(getCookie(cookieName_str));
	};
	//----------------------------------------------		
	function fadeInNext(){
		
		// move foreground onto background and remove foreground
		var myAnim 			= new YAHOO.util.Anim(foregroundImg_htm, { opacity: {to: 1} }, blendPeriod_int);
		myAnim.onComplete.subscribe(handleForegroundCompletion);
		
		foregroundImg_htm.src 	= newImg_src;
		YAHOO.util.Dom.setStyle(foregroundImg_htm,'visibility','visible');
		myAnim.animate();
	};	
	//----------------------------------------------
	function handleForegroundCompletion(){
	
		newImg_src				= getCurrentImgSrc();
		
		// swap image to back and set foreground opacity to zero
		backgroundImg_htm.src	= foregroundImg_htm.src;
		YAHOO.util.Dom.setStyle(foregroundImg_htm, 'opacity', 0);
		YAHOO.util.Dom.setStyle(foregroundImg_htm,'visibility','hidden');
		
		// determine next image
		var selectedIndex_int = getSelectedIndex();
		selectedIndex_int++;
		saveSelectedIndex(selectedIndex_int);
		
		// set timeout for next fade
		window.setTimeout(fadeInNext,displayPeriod_int);
	};
};	//----------------------------------------------
//__________________________________________________