
var monImg		= null;
var monAlt		= null;
var monLnk		= null;
var monIdx		= 0;

function montageEffects()
{
	var ugh	= document.getElementById("ugh");
	var html		= "<a href=\"" + monLnk[monIdx] + "\"><img src=\"" + monImg[monIdx].src + "\" alt=\"" + monAlt[monIdx] + "\" border=\"0\"></a>";
	
	// simple case where there's only one thing in the rotation... and no transitions
	if( monImg.length <= 1 )
	{
		ugh.innerHTML = html;
		return;
	}

	// run the transition
	if( readIEVer() >= 5.5 )
	{
		ugh.style.filter = "blendTrans(duration=1.5) revealTrans(duration=1.0,transition=7)";
		ugh.filters(0).apply();
		ugh.filters(1).apply();
		ugh.innerHTML = html;
		ugh.filters(0).play();
		ugh.filters(1).play();
	}
	else
	{
		ugh.innerHTML = html;
	}

	// move the image index along
	monIdx			= (monIdx + 1) % monImg.length;
	
	// asked to be called again in 4 seconds
	setTimeout( "montageEffects()", 4000 );
}

function montage( href, src, caption, width )
{
	if( isIE4 || isW3C )
	{
		monLnk		= href;
		monImg		= new Array( src.length );
		monAlt		= caption;
		
		// get just the first image right now...
		img = new Image( width );
			
		img.src		= src[0];
		img.border	= 0;
		monImg[0]	= img;

		// set up a placeholder
		document.write( "<div id=\"ugh\" style=\"width:" + width +"px;height:211px\"></div>" );
	
		// switch in the first image
		montageEffects();

		// now pre-cache the remaining images
		for( i = 1; i < src.length; i++ )
		{
			img = new Image( width );
			
			img.src		= src[i];
			img.border	= 0;
			monImg[i]	= img;
		}		

		return;
	}

	// this is the case for browsers that don't support filters...
	var cycle	= Math.floor( Math.random() * href.length );
	
	if( href[cycle] != null ) 
	{
		document.write( "<A HREF=\"" + href[cycle] + "\"><IMG SRC=\"" + src[cycle] + "\" alt=\"" + caption[cycle] + "\" BORDER=\"0\"></a>" );
	}
	else
	{
		document.write( "<IMG SRC=\"" + src[cycle] + "\" WIDTH=\"425\">" );
	}
}

