var scrollers = new Array();

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

window.onload = function()
{
	var summaryScrollers = getElementsByClass( "summaryScroller" );
	createScrollers( summaryScrollers, 266, 160 );
	
	var articleScrollers = getElementsByClass( "articleScroller" );
	createScrollers( articleScrollers, 500, 105 );

	var articleScrollersCol3 = getElementsByClass( "articleScrollerCol3" );
	createScrollers( articleScrollersCol3, 320, 195 );	
}

function createScrollers( scr, width, height )
{
	for( var i = 0; i < scr.length; i++ )
	{
		var scrollerNode = scr[ i ];
		var scroller = new jsScroller( scrollerNode, width, height );
		var scrollerIndex = scrollers.push( scroller ) - 1;

		var up = getElementsByClass( "up", scrollerNode )[ 0 ];
		up.scrollerIndex = scrollerIndex;
		up.onmousedown = function() { scrollers[ this.scrollerIndex ].startScroll( 0, 5 ) };
		up.onmouseup = function() { scrollers[ this.scrollerIndex ].stopScroll() };

		/*up.onmouseover = function() { scrollers[ this.scrollerIndex ].startScroll( 0, 5 ) };
		up.onmouseout = function() { scrollers[ this.scrollerIndex ].stopScroll() };*/

		var down = getElementsByClass( "down", scrollerNode )[ 0 ];
		down.scrollerIndex = scrollerIndex;
		down.onmousedown = function() { scrollers[ this.scrollerIndex ].startScroll( 0, -5 ) };
		down.onmouseup = function() { scrollers[ this.scrollerIndex ].stopScroll() };
		/*down.onmouseover = function() { scrollers[ this.scrollerIndex ].startScroll( 0, -5 ) };
		down.onmouseout = function() { scrollers[ this.scrollerIndex ].stopScroll() };*/
		
	}
}

function openNewsletter( id )
{
	window.open( "newsletterBody.asp?idNewsletter=" + id, "newsletter", "width=600,height=400,menubar=yes,resizable,scrollbars=yes" );
}
