
function scrl_automaticScroll(k) {
	var e,c0,c1,s0,s1,a0,a1,v0,v1
	
	e  = scrl_objContent[k]
	v0 = scrl_intSpeed0[k]
	v1 = scrl_intSpeed1[k]
	c0 = scrl_intContainerWidth[k]
	c1 = scrl_intContainerHeight[k]
	s0 = scrl_intContentWidth[k]
	s1 = scrl_intContentHeight[k]
	a0 = gX(e)
	a1 = gY(e)
	
	function sgn(x) {
		return x < 0 ? -1 : x > 0 ? 1 : 0
	}

	function cyc(x,v,s) {
		return (v<0 ? x>-s : x<s) ? (x + v) : sgn(-v) * s
	}
	
	if (v0 == 0) sX(e, 0)
	if (v1 == 0) sX(e, 0)
	if (v0 != 0) sX(e, cyc(a0,v0,s0))
	if (v1 != 0) sY(e, cyc(a1,v1,s1))
	
	scrl_automaticScrollTimeout[k] = setTimeout("scrl_automaticScroll(" + k + ")", 40)
}

function scrl_showOrHideScrollButtons(k,hide) {
	var L,R,U,D
	L = gE("scrollMoveLeftButton_"+k)
	R = gE("scrollMoveRightButton_"+k)
	U = gE("scrollMoveUpButton_"+k)
	D = gE("scrollMoveDownButton_"+k)
	if (hide || scrl_intContentWidth[k] <= scrl_intContainerWidth[k]) {
		if (L) hE(L)
		if (R) hE(R)
	}
	else {
		if (L) sE(L)
		if (R) sE(R)
	}
	if (hide || scrl_intContentHeight[k] <= scrl_intContainerHeight[k]) {
		if (U) hE(U)
		if (D) hE(D)
	}
	else {
		if (U) sE(U)
		if (D) sE(D)
	}
}

function scrl_getContentWidth(aintScrollId){
	if (scrl_blnIeOrNs6) {
		scrl_intContainerWidth[aintScrollId] = scrl_objContainer[aintScrollId].offsetWidth;
		scrl_intContentWidth[aintScrollId] = scrl_objContent[aintScrollId].offsetWidth;
	} else if (scrl_blnNs4) {
		scrl_intContainerWidth[aintScrollId] = scrl_objContainer[aintScrollId].clip.width;
		scrl_intContentWidth[aintScrollId] = scrl_objContent[aintScrollId].clip.width;
	}
}

function scrl_getContentHeight(aintScrollId){
	if (scrl_blnIeOrNs6) {
		scrl_intContainerHeight[aintScrollId] = scrl_objContainer[aintScrollId].offsetHeight;
		scrl_intContentHeight[aintScrollId] = scrl_objContent[aintScrollId].offsetHeight;
	} else if (scrl_blnNs4) {
		scrl_intContainerHeight[aintScrollId] = scrl_objContainer[aintScrollId].clip.height;
		scrl_intContentHeight[aintScrollId] = scrl_objContent[aintScrollId].clip.height;
	}
}

function scrl_moveUp(aintScrollId){
	if (scrl_blnIeOrNs6 && parseInt(scrl_objContent[aintScrollId].style.top) <= (0 - scrl_intSpeed0[aintScrollId])) {
		scrl_objContent[aintScrollId].style.top = parseInt(scrl_objContent[aintScrollId].style.top) + 10
	} else if (scrl_blnNs4 && scrl_objContent[aintScrollId].top <= (0 - scrl_intSpeed0[aintScrollId])) {
		scrl_objContent[aintScrollId].top += 10
	}
	scrl_moveUpTimeout[aintScrollId] = setTimeout("scrl_moveUp(" + aintScrollId + ")", 100);
}

function scrl_moveDown(aintScrollId){
	if (scrl_blnIeOrNs6 && parseInt(scrl_objContent[aintScrollId].style.top) >= (scrl_intContentHeight[aintScrollId] * (-1) + scrl_intContainerHeight[aintScrollId])) {
		scrl_objContent[aintScrollId].style.top = parseInt(scrl_objContent[aintScrollId].style.top) - 10
	} else if (scrl_blnNs4 && scrl_objContent[aintScrollId].top >= (scrl_intContentHeight[aintScrollId] * (-1) + scrl_intContainerHeight[aintScrollId])) {
		scrl_objContent[aintScrollId].top -= 10
	}
	scrl_moveDownTimeout[aintScrollId] = setTimeout("scrl_moveDown(" + aintScrollId + ")", 100);
}

function scrl_moveLeft(aintScrollId){
	if (scrl_blnIeOrNs6 && parseInt(scrl_objContent[aintScrollId].style.left) < 0) {
		scrl_objContent[aintScrollId].style.left = parseInt(scrl_objContent[aintScrollId].style.left) + 10
	} else if (scrl_blnNs4 && scrl_objContent[aintScrollId].left < 0) {
		scrl_objContent[aintScrollId].left += 10
	}
	scrl_justifyPosition(aintScrollId)
	scrl_moveLeftTimeout[aintScrollId] = setTimeout("scrl_moveLeft(" + aintScrollId + ")", 100);
}

function scrl_moveRight(aintScrollId){
	if (scrl_blnIeOrNs6 && parseInt(scrl_objContent[aintScrollId].style.left) > (scrl_intContentWidth[aintScrollId] * (-1) + scrl_intContainerWidth[aintScrollId])) {
		scrl_objContent[aintScrollId].style.left = parseInt(scrl_objContent[aintScrollId].style.left) - 10
	} else if (scrl_blnNs4 && scrl_objContent[aintScrollId].left > (scrl_intContentWidth[aintScrollId] * (-1) + scrl_intContainerWidth[aintScrollId])) {
		scrl_objContent[aintScrollId].left -= 10
	}
	scrl_justifyPosition(aintScrollId)
	scrl_moveRightTimeout[aintScrollId] = setTimeout("scrl_moveRight(" + aintScrollId + ")", 100);
}

function scrl_justifyPosition(aintScrollId){
	if (scrl_blnIeOrNs6 && parseInt(scrl_objContent[aintScrollId].style.left) < (scrl_intContentWidth[aintScrollId] * (-1) + scrl_intContainerWidth[aintScrollId])) {
		scrl_objContent[aintScrollId].style.left = scrl_intContentWidth[aintScrollId] * (-1) + scrl_intContainerWidth[aintScrollId];
	} else if (scrl_blnNs4 && scrl_objContent[aintScrollId].left < (scrl_intContentWidth[aintScrollId] * (-1) + scrl_intContainerWidth[aintScrollId])) {
		scrl_objContent[aintScrollId].left = scrl_intContentWidth[aintScrollId] * (-1) + scrl_intContainerWidth[aintScrollId];
	}
	if (scrl_blnIeOrNs6 && parseInt(scrl_objContent[aintScrollId].style.left) > 0) {
		scrl_objContent[aintScrollId].style.left = 0;
	} else if (scrl_blnNs4 && scrl_objContent[aintScrollId].left > 0) {
		scrl_objContent[aintScrollId].left = 0;
	}
}
