var photoWidth  = 400;
var photoHeight = 300;
var borderWidth = 2;
var borderColor = 'blue';
var borderStyle = 'ridge';

var photoDelay	=2000; //ms
var transDelay	=  20; //ms
var transOpacity=   5; // percent

var photoLink = '';
var photoList = new Array ();
var photoListPreload = new Array ();

var tabPhotoLower,imgPhotoUpper,photoInd,curOpacity;
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function slideshowProcess ()
{
    if (! (photoListPreload[photoInd] && photoListPreload[(photoInd+1) % photoList.length]) )
    {
		setTimeout ('slideshowProcess()',5000);
        return;
    }
        
	if (curOpacity > 0)
	{
        curOpacity -= transOpacity;
        if (curOpacity < 0)
            curOpacity = 0;
            
	    if (typeof imgPhotoUpper.style.MozOpacity != "undefined")
	        imgPhotoUpper.style.MozOpacity = curOpacity / 100;
	    if (
	            imgPhotoUpper.filters && 
	            imgPhotoUpper.filters.alpha && 
	            typeof imgPhotoUpper.filters.alpha.opacity != "undefined"
	        ) 
	        imgPhotoUpper.filters.alpha.opacity = curOpacity;
		setTimeout ('slideshowProcess()',transDelay);
	}
    else
	if (curOpacity == 0)
	{
        curOpacity = -1;
		imgPhotoUpper.src = photoList[photoInd];
		setTimeout ('slideshowProcess()',photoDelay);
	}
    else
	if (curOpacity == -1)
	{
        curOpacity = -2;
	    if (typeof imgPhotoUpper.style.MozOpacity != "undefined")
	        imgPhotoUpper.style.MozOpacity = 1;
	    if (
	            imgPhotoUpper.filters && 
	            imgPhotoUpper.filters.alpha && 
	            typeof imgPhotoUpper.filters.alpha.opacity != "undefined"
	        ) 
	        imgPhotoUpper.filters.alpha.opacity = 100;
		setTimeout ('slideshowProcess()',transDelay);
    }
    else
	{
        curOpacity = 100;
		photoInd   = (++photoInd) % photoList.length;
		tabPhotoLower.style.backgroundImage = 'url('+photoList[photoInd]+')';
		setTimeout ('slideshowProcess()',transDelay);
    }
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function slideshowStart(divSlideshowId)
{
	var photoListPreload = new Array (photoList.length);
	for (var i=0; i<photoListPreload.length; i++)
	{
	    photoListPreload [i] = 0;
	}

	// generate HTML
	var slideshowHTML = '';
	slideshowHTML += '<table cellpadding="0" cellspacing="0" style="border: '+borderColor+' '+borderWidth+'px '+borderStyle+';"';
	slideshowHTML += '<tr><td style="width:'+photoWidth+'px;height:'+photoHeight+'px;background-image:url('+photoList[1]+');" id="tabPhotoLower">';
	if (photoLink != '')
	    slideshowHTML += '<a href="'+photoLink+'">';
	slideshowHTML += '<img src="'+photoList[0]+'" width="'+photoWidth+'" height="'+photoHeight+'" border="0" id="imgPhotoUpper" style="-moz-opacity:1.0;filter:alpha(opacity=100)">';
	if (photoLink != '')
	    slideshowHTML += '</a>';
	slideshowHTML += '</td></tr>';
	slideshowHTML += '</table>';
	slideshowHTML += '<div style="visibility:hidden">';
	for (var i=0; i<photoListPreload.length; i++)
	{
	    slideshowHTML += '<img src="'+photoList[i]+'" width="1" height="1" onload="photoListPreload['+i+']=1;">';
	}
	slideshowHTML += '</div>';

	var divSlideshow = document.getElementById(divSlideshowId);
	if (!divSlideshow)
		return;
		
	divSlideshow.innerHTML = slideshowHTML;
		
	// start slideshow
	tabPhotoLower = document.getElementById('tabPhotoLower');
	imgPhotoUpper = document.getElementById('imgPhotoUpper');
		
	photoInd   = 1;
    curOpacity = 100;

	setTimeout ('slideshowProcess()',5000);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
