
//- Check if the user is on Mac MSIE. -//
var isMacIEscrollCheck = navigator.userAgent.indexOf( 'Mac' ) > -1 && navigator.userAgent.indexOf( 'MSIE' ) > -1;

//- Write the buttons to the document. -//
if ( isMacIEscrollCheck )
	document.write( '<div style="position: absolute; left: 0px; top: 300px; z-index: 1000;">' );
document.write( ''
	+ '<table border=0 cellpadding=0 cellspacing=0 align=center style="margin-top: 4px;" id="vertScrollButtonContainer">'
	+ '<tr>'
	+ '	<td><a href="#" class="scrollButtons" onclick="return false;" onfocus="this.blur()"'
	+ '		onmouseover="MouseScroll( \'down\', \'down\' );"'
	+ '		onmouseout="MouseScroll( \'up\', \'down\' );">'
	+ '		<img src="../images/bio/scrolldown.gif" width="45" height="29" border="0" name="text_scroll_down"></a></td>'
	+ '	<td><a href="#" class="scrollButtons" onclick="return false;" onfocus="this.blur()"'
	+ '		onmouseover="MouseScroll( \'down\', \'up\' );"'
	+ '		onmouseout="MouseScroll( \'up\', \'up\' );">'
	+ '		<img src="../images/bio/scrollup.gif" width="45" height="29" border="0" name="text_scroll_up"></a></td>'
	+ '</tr>'
	+ '</table>'
	);
if ( isMacIEscrollCheck )
	document.write( '</div>' );


//- See if the user is on a Mac. -//
var isWinIE = navigator.userAgent.indexOf( 'Windows' ) > -1 && navigator.userAgent.indexOf( 'MSIE' ) > -1;

//- Global variables for scrolling. -//
var scrollTime = 15;
var scrollIncrement = isWinIE ? 1 : 2;
var currentScrollDirection = null;
var scrollTimer = null;

//- Handle all mouse scrolling events. -//
function MouseScroll( evt, direction )
{
	if ( evt == 'up' )
	{
		currentScrollDirection = null;
		clearTimeout( scrollTimer );
	}
	else
	{
		//- Get the scroll areas. -//
		var scrollContainer = document.getElementById( 'bodyContainerOuter' );
		var scrollObj = document.getElementById( 'bodyContainerInner' );
		if ( scrollContainer == null || scrollObj == null )
			return;
		
		//- Get the direction to scroll. -//
		if ( typeof( direction ) == 'undefined' )
			direction = currentScrollDirection;
		else
			currentScrollDirection = direction;
		
		//- If the scroll object doesn't have a value, set one. -//
		if ( scrollObj.style.top == '' )
			scrollObj.style.top = '0px';
		
		//- Get the current position of the content. -//
		var currentPos = parseInt( scrollObj.style.top );
		
		if ( direction == 'up' )
		{
			//- Don't do anything if the content is less than the scroll container. -//
			if ( scrollObj.offsetHeight < scrollContainer.offsetHeight )
				return;
			
			//- Make sure the text doesn't go below the top of the window. -//
			var newPos = currentPos + scrollIncrement;
			if ( newPos > 0 )
				newPos = 0;
			
			scrollObj.style.top = newPos + 'px';
		}
		else if ( direction == 'down' )
		{
			//- Don't do anything if the content is less than the scroll container. -//
			if ( scrollObj.offsetHeight < scrollContainer.offsetHeight )
				return;
			
			//- Make sure the text doesn't go above the bottom of the window. -//
			var maxHeight = scrollObj.offsetHeight - scrollContainer.offsetHeight;
			var newPos = Math.abs( currentPos - scrollIncrement );
			if ( newPos > maxHeight )
				newPos = maxHeight;
			
			scrollObj.style.top = ( 0 - newPos ) + 'px';
		}
		
		scrollTimer = setTimeout( "MouseScroll()", scrollTime );
	}
}

//- Handle all swapping of scroll images. -//
var scrollImgPath = '/images/textscroll/'
function SwapTextScrollImage( imgName, evt )
{
	var imgObj = document.images[imgName];
	if ( imgObj == null )
		return;
	
	if ( evt == 'out' )
	{
		imgObj.src = scrollImgPath + imgName + '.up.gif';
	}
	else if ( evt == 'over' )
	{
		imgObj.src = scrollImgPath + imgName + '.over.gif';
	}
	else if ( evt == 'click' )
	{
		imgObj.src = scrollImgPath + imgName + '.down.gif';
	}
}

//- Preload images. -//
function MM_preloadScrollImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadScrollImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


//- Preload rollover images. -//
/*
MM_preloadScrollImages(
	'/images/textscroll/text_scroll_up.over.gif', '/images/textscroll/text_scroll_up.down.gif',
	'/images/textscroll/text_scroll_down.over.gif', '/images/textscroll/text_scroll_down.down.gif'
);
*/
