var montBlock	= null;
var montImg		= null;
var montIndex	= 0;
var montCont= null;
var montTimeout	= 5000;
var montEff	= 2;
var montHREF;
var montSource;
var montCapt;

function mont( href, src, caption, width, height, animate )
{
	if( montBlock )
	{
		return;
	}
		
	montHREF		= href;
	montSource		= src;
	montCapt	= caption;
	
	var cycle	= 0;

	var m_mont	= ( typeof(animate) != "undefined" ? animate : hasBroadband() );				
	if( m_mont == false || src.length <= 1 )
	{
		document.writeln( montPicker( cycle ) );
		return;
	}
	
	montIndex		= cycle;
	
	var nextImage	= (montIndex + 1) % src.length;

	if( height > 0 ) { document.writeln( "<div id=\"containermontage\" style=\"width:" + width +"px;height:" + height + "px\">" ); }
	else { document.writeln( "<div id=\"containermontage\" style=\"width:" + width +"px\">" ); }

	for( i = 0; i < src.length; i++ )
	{
		document.write( "<div id=\"mont" + i + "\" style=\"display:none\">" );
		
		if( i == nextImage )
		{
			document.write( montPicker( i ) );
		}
		
		document.write( "</div>" );
	}

	document.writeln( "</div>" );

	montBlock	= new Array( src.length );
	montImg		= new Array( src.length );

	for( i = 0; i < src.length; i++ )
	{
		montBlock[i]	= document.getElementById( "mont" + i );
		
		if( i == nextImage )
		{
			montImg[i] = document.getElementById( "montImg" + i );
		}
		else
		{
			montImg[i] = null;
		}
	}

	montCont = document.getElementById("containermontage");
	
	montEffects();
}

function montEffects()
{
	var nextImage	= (montIndex + 1) % montImg.length;
	
	if( montEff > 0 )
	{
		try
		{
			if( montEff == 1 )
			{
				montCont.style.filter = "blendTrans(duration=0.6)";
				montCont.filters(0).apply();
 				montSelect( nextImage );
				montCont.filters(0).play();
			}
			else
			{
				montCont.style.filter = "blendTrans(duration=1.5) revealTrans(duration=1.0,transition=7)";
				montCont.filters(0).apply();
				montCont.filters(1).apply();
 				montSelect( nextImage );
				montCont.filters(0).play();
				montCont.filters(1).play();
			}
		}
		catch( e ) { montSelect( nextImage ); }
	}
	else
	{
		montSelect( nextImage );
	}

	setTimeout( "montPrep()", montTimeout - 1500 );
	setTimeout( "montSwap()", montTimeout );
}

function montSelect( nextImage )
{
	montBlock[montIndex].style.display = "none";
	montIndex = nextImage;
	montBlock[montIndex].style.display = "block";
}		

function montPrep()
{
	var nextImage	= (montIndex + 1) % montImg.length;

	if( !montImg[nextImage] )
	{
		montBlock[nextImage].innerHTML = montPicker( nextImage );
		montImg[nextImage] = document.getElementById( "montImg" + nextImage );
	}
}

function montSwap()
{
	if( montImg[montIndex].complete )
	{
		montEffects();
	}
	else
	{
		setTimeout( "montSwap()", 3000 );
	}
}

function montPicker( cycle )
{
	var divHtml;

	if( montHREF[cycle] != null ) 
	{
		divHtml = "<A class='imglink' href=\"" + montHREF[cycle] + "\"><IMG src=\"" + montSource[cycle] + "\" alt=\"" + montCapt[cycle] + "\" BORDER=\"0\" ID=\"montImg" + cycle + "\"></a>";
	}
	else
	{
		divHtml = "<IMG src=\"" + montSource[cycle] + "\" ID=\"montImg" + cycle + "\">";
	}
	
	return divHtml;
}

function hasBroadband()
{
	return true
}