
function RollingLeaf( )
{
	this.index = 0;
	this.img = new Array;
	this.link = new Array;

	var j = 0;

	// arguments are just that the arguments that are passed in
	this.name = arguments[ 0 ];
	for( var i = 1; i < arguments.length; i += 2 )
	{
		this.img[ j ] = arguments[ i ];
		this.link[ j++ ] = arguments[ i + 1 ];
	}
	this.rotate = RollingLeafRotate;
	this.follow = RollingLeafFollow;
	this.status = RollingLeafStatus;
	this.formatDesc = RollingLeafFormatDesc;
}

function RollingLeafStatus( link, text )
{
	var format = JavaScript_split( this.img[ this.index ], '_' );
	window.status = text + " - " + this.formatDesc( format[ 0 ] );

	//link.href = this.link[ this.index ];

	return true;
}

function RollingLeafRotate( )
{
	this.index = ( this.index + 1 ) % this.img.length;
	var image = document.images[ this.name ].src;
	var newimage = image.replace(/\w+\.\w+$/, this.img[ this.index ] + "_mult.gif");
	document.images[ this.name ].src = newimage;
}

function RollingLeafFollow( link, cc )
{
	if( cc && !CCEntry_required( ) ) return false;

	link.href = this.link[ this.index ];
	var pieces = link.href.split('?');
	link.search = pieces[1];
	
	var tree = JavaScript_extractTree( );
	
	var branch = JavaScript_extractBranch( docwin );
	var nextYear = JavaScript_nextYear( );
	
	document.cookie = "lastview=" + tree + "|" + branch + "; path=/; expires=" + nextYear;
	new_win( link.href, '', '' );
}

function RollingLeafFormatDesc( format )
{
	if( format == "mdb" )
		return "Access database";
	else if( format == "csv" || format == "xls" || format == "tab" )
		return "Excel spreadsheet";
	else if( format == "ie" || format == "ns" )
		return "HTML document";
	else if( format == "pdf" )
		return "PDF document";
	else if( format == "toc" )
		return "HTML outline";
	else if( format == "txt" )
		return "Text document";
	else if( format == "doc" || format == "rtf" )
		return "Word document";
	else
		return format;
}

