var scrollPosY = ""; //position of vertical scrollbar
var scrollPosX = ""; //position of horizontal scrollbar

var scrollable = new Array();
var scrolling = new Array();
var scrollableHor = new Array();
var scrollingHor = new Array();

var curBrowser = "";
var extension = "";
var timerID = "";

function scrollText(textField) {
	var scrollKey = textField.replace("myText", "");
	scrollKey = parseInt(scrollKey);
	
	scrollable[scrollKey] = 1;
	if (scrolling[scrollKey] == 0) {
		timerID = setInterval("scrollNow('"+textField+"')", 75);
	}
}

function scrollNow(textField) {
	var scrollKey = textField.replace("myText", "");
	scrollKey = parseInt(scrollKey);
	
	textObj = $(textField);
	curHeight = textObj.offsetHeight;

	if (curHeight > 128) {
		if (scrollable[scrollKey] == 1) {
			scrolling[scrollKey] = 1;
			curTop = textObj.style.top;
			
			if (curTop.match("pt")) {
				curBrowser = "notIE";
				extension = "pt";
				curTop = curTop.replace("pt", "");
			}
			else {
				curBrowser = "IE";
				extension = "px";
				curTop = curTop.replace("px", "");
			}
			curTopInt = parseInt(curTop);
			newTop = curTop - 1;
			if (newTop == -curHeight) newTop = 158;
			
			textObj.style.top = newTop+extension;
			
			
		}
	}
}


function stopScroll(textField) {
	var scrollKey = textField.replace("myText", "");
	scrollKey = parseInt(scrollKey);
	
	scrolling[scrollKey] = 0;
	scrollable[scrollKey] = 0;
	if (timerID != null && timerID != "undefined") clearInterval(timerID);
	setTimeout("resetScroll('"+textField+"')", 30);
}

function resetScroll(textField) {
	var scrollKey = textField.replace("myText", "");
	scrollKey = parseInt(scrollKey);
	
	if (scrolling[scrollKey] == 0 && scrollable[scrollKey] == 0) {
		textObj = $(textField);
		textObj.style.top = 0+extension;
	}
}


function checkScrollExist(scrollKey) {
	if (scrollingHor[scrollKey] == 0 || scrollingHor[scrollKey] == null || scrollingHor[scrollKey] == false) {
		return false;
	}
	else return true;
}

function scrollTextHor(textField) {
	var curScrollField = textField.replace(/[0-9]+/, "");
	var scrollKey = textField.replace(curScrollField, "");
	scrollKey = parseInt(scrollKey);
	scrollableHor[scrollKey] = 1;
	if (checkScrollExist(scrollKey) == false) {
		timerID = setInterval("scrollNowHor('"+textField+"')", 35);
	}
}

function scrollNowHor(textField) {
	var curScrollField = textField.replace(/[0-9]+/, "");
	var scrollKey = textField.replace(curScrollField, "");
	scrollKey = parseInt(scrollKey);
	
	textObj = $(textField);
	
	textNObj = $(curScrollField+'N'+scrollKey);
	curWidth = textNObj.offsetWidth;

	if (curWidth > 150) {
		if (scrollableHor[scrollKey] == 1) {
			scrollingHor[scrollKey] = 1;
			curLeft = textObj.style.left;
			
			if (curLeft.match("pt")) {
				curBrowser = "notIE";
				extension = "pt";
				curLeft = curLeft.replace("pt", "");
			}
			else {
				curBrowser = "IE";
				extension = "px";
				curLeft = curLeft.replace("px", "");
			}
			curLeftInt = parseInt(curLeft);
			newLeft = curLeft - 1;
			
			if (newLeft == -curWidth) newLeft = 158;
			
			textObj.style.left = newLeft+extension;
			
			
		}
	}
}


function stopScrollHor(textField) {
	var curScrollField = textField.replace(/[0-9]+/, "");
	var scrollKey = textField.replace(curScrollField, "");
	scrollKey = parseInt(scrollKey);
	
	scrollingHor[scrollKey] = 0;
	scrollableHor[scrollKey] = 0;
	if (timerID != null && timerID != "undefined") clearInterval(timerID);
	setTimeout("resetScrollHor('"+textField+"')", 30);
}

function resetScrollHor(textField) {
	var curScrollField = textField.replace(/[0-9]+/, "");
	var scrollKey = textField.replace(curScrollField, "");
	scrollKey = parseInt(scrollKey);
	
	if (scrollableHor[scrollKey] == 0 && scrollableHor[scrollKey] == 0) {
		textObj = $(textField);
		textObj.style.left = 0+extension;
	}
}