var scroll_layers = new Array();
var scroll_layer_widths = new Array();
var scrollcontainerwidth = 514;
var scrollcontainerheight = 13;
var scrollcontainer = false;
var scrollcontent = false;
var scrollcurrentx = 0;
var scrollcurrenty = 0;
var scrollspeedy = 0; // vertical pixels to move per repeat
var scrollspeedx = 2; // horizontal pixels to move per repeat
var scrollrepeat = 20; // milliseconds per repeat
var scrollmove = false;
var scrollinit = false;
var current = 0;

function addScrollContent(layer_name) {
	len = scroll_layers.length;
	scroll_layers[len] = layer_name;
}
function scroll(scrollcontent) {
	if (scrollinit) {
		scrollcurrentx -= scrollspeedx;
		scrollcurrenty += scrollspeedy;
		
		sP(scrollcontent,scrollcurrentx,scrollcurrenty);
		imgpos = getPos(scroll_layers[current]+'img', scroll_layers[current]);
		if (scrollmove) {
			if (imgpos[0] < 0) {
				setTimeout("contentScroll()", 0);
			} else {
				setTimeout("scroll(scrollcontent)",scrollrepeat);
			}
		}
	}
}

function contentScroll() {
	scrollcontent = gE(scroll_layers[current], scrollcontainer);
	hE(scrollcontent);
	current+=1;
	if (current >= scroll_layers.length) {
		current = 0;
	}
	scrollcontent = contentInit();
	setTimeout("scroll(scrollcontent)",400);
}
function contentInit() {
	scrollcontent = gE(scroll_layers[current], scrollcontainer);
	scrollcurrentx = 378;
	sX(scrollcontent, scrollcurrentx);
	sE(scrollcontent);
	return scrollcontent;
}

function scrollOut() {
	scrollmove = false;
}
function scrollIn() {
	scrollmove = true;
	scroll();
}

function scrollerInit() {
	var noscroll = false;
	scrollcontainer = gE('scrollcontainer');
	if (!scrollcontainer) {
		scrollcontainer = gE('scrollstatic');
		noscroll = true;
	}
	if (scrollcontainer) {
		scrollcontent = contentInit();
		if (scrollcontainer && scrollcontent) {
			sS(scrollcontainer,scrollcontainerwidth,scrollcontainerheight);
			sC(scrollcontainer,0,scrollcontainerwidth,scrollcontainerheight,0);
			pos = getPos('newsticker');
			pos[0]+=104;
			pos[1]-=9;
			if (ie && ua.indexOf('win')>-1) {
				if (ua.indexOf('msie 5.0')!=-1 || ua.indexOf('msie 5.5')!=-1) {
					pos[0]-=6;
					pos[1]-=7;
				} else {
					pos[0]+=4;
					pos[1]+=2;
				}
			} else if (ie && ua.indexOf('mac')>-1) {
				pos[0]-=0;
				pos[1]+=1;
			} else if (nn) {
				pos[0]-=23;
				pos[1]-=12;
			} else if (ua.indexOf('gecko')>-1 && ua.indexOf('khtml')==-1) {
				pos[0]-=4;
				pos[1]-=7;
			} else {
				pos[0]+=4;
				pos[1]+=4;
			}
			sP(scrollcontainer, pos[0], pos[1]);
			sE(scrollcontainer);
				
			if (noscroll == false) {
				scrollmove = true;
				scrollinit = true;
				scroll(scrollcontent);
			} else {
				sX(scrollcontent, 0);
				sE(scrollcontent);
			}
		}
	}
}

// initialize scroller
if (typeof window.addEventListener != 'undefined') {
	window.addEventListener('load', scrollerInit, false);
} else if (typeof window.attachEvent != "undefined") { // IE
	window.attachEvent('onload', scrollerInit );
} else {
	if (window.onload != null) {
		// maintain any other onload events
		var oldOnload = window.onload;
		window.onload = function (e) {
			oldOnload(e);
			scrollerInit();
		};
	} else {
		window.onload = scrollerInit;
	}
}