window.addEvent('domready', function() {

	var i=0;

	var myScroller2 = new Scroller(document.getElementById('authorScroller'));
	myScroller2.start();
	
	var authorScrolldiv = $('authors');		// id of the first element to scroll
	var authorScroll = new Fx.Tween(authorScrolldiv);

	var numAuthors = 0;
	var authorkWidth = 0;
	var totalAuthorWidth = $('authorholder').getStyle('width').toInt();	
	var authorKids = authorScrolldiv.childNodes;
	for (i=0; i<authorKids.length; i++) {
		if (authorKids[i].nodeType==1) {
			numAuthors++;
			authorWidth = authorKids[i].getStyle('width').toInt() + authorKids[i].getStyle('padding-left').toInt() + authorKids[i].getStyle('padding-right').toInt();
		}
	}



	$('authorBtnNext').addEvent('click', function(event) {
		var offset = authorScrolldiv.getStyle('margin-left').toInt()-authorWidth;
		if ((numAuthors*authorWidth) + offset >= totalAuthorWidth) authorScroll.start( 'margin-left', offset );
		
	});
	
	$('authorBtnLast').addEvent('click', function(event) {
		var offset = authorScrolldiv.getStyle('margin-left').toInt();
		if (offset<0) authorScroll.start( 'margin-left', offset+authorWidth );
	});
	
	$('authors').setStyle('margin-left', -authorWidth+'px' );
	
//	authorScroll.start( 'margin-left', -authorWidth );

});

