//**	Scrolling Text Layer Script
//**	OIL, Incorporated
var dom=false;if(document.getElementById)dom=true;var ie4=document.all;var net4=document.layers;var scrollDebug=false;var posRules="";
var SCROLL_DIST=22;var CONTINUE_SCROLL_DELAY=150;var scrollRepeatInterval=150;var KEEP_SCROLL_BAR=false;var textToScrollBarRatio = 1;
var scrollLimits = new Object();scrollLimits.slScrollBarLayer = new Object();scrollLimits.slScrollBarLayer.top = 0;scrollLimits.slScrollBarLayer.bottom = 0;
scrollLimits.ScrollBarGraphicsLayer = new Object();scrollLimits.ScrollBarGraphicsLayer.top = 0;scrollLimits.ScrollBarGraphicsLayer.bottom = 0;
scrollLimits.slTextLayer = new Object();scrollLimits.slTextLayer.top = 0;scrollLimits.slTextLayer.bottom = 0;var scrlLayObj = new Object();
scrlLayObj.slCuttingLayer = null;scrlLayObj.slControlsLayer = null;scrlLayObj.slDownArrowLayer = null;scrlLayObj.slUpArrowLayer = null;
scrlLayObj.slScrollBarLayer = null;scrlLayObj.slTextLayer = null;scrlLayObj.ScrollBarGraphicsLayer = null;scrlLayObj.ScrollBarBotLayer = null;
if(ie4||!dom)scrlLayObj.ScrollBarTopShim = null;var dragableObjs = new Object();dragableObjs.slScrollBarLayer = null;if(ie4||!dom)dragableObjs.ScrollBarTopShim = null;
var layerPositions = new Object();var cutLayerH = null;var upLayerH = null;var downLayerH = null;var controlsLayerH = null;var maxScrollDist = null;
var textLayerWidth = null; var insideTextLayerStart;var insideTextLayerEnd;function initScrollingText(){findObj(document,scrlLayObj);
if(!findObjs_checkFound(scrlLayObj))return;dragableObjs.slScrollBarLayer = scrlLayObj.slScrollBarLayer;if(ie4||!dom)dragableObjs.ScrollBarTopShim = scrlLayObj.ScrollBarTopShim;
if(typeof posRules == "object")	positionTextLayer(posRules);insideTextLayerStart = startLayer({id:'InsideTextLayer', position:'absolute', top: 0, width:textLayerWidth, left:0});
insideTextLayerEnd = endLayer();cutLayerH = getHeight(scrlLayObj.slCuttingLayer);upLayerH = getHeight(scrlLayObj.slUpArrowLayer);
downLayerH = getHeight(scrlLayObj.slDownArrowLayer);controlsLayerH = cutLayerH;setHeight(scrlLayObj.slControlsLayer, controlsLayerH);
setTop(scrlLayObj.slDownArrowLayer, (controlsLayerH - downLayerH));maxScrollDist = controlsLayerH - (upLayerH + downLayerH);initDragEvents();
};function setText(menu,dataObj,item){if(!scrlLayObj.slCuttingLayer || !scrlLayObj.slTextLayer)return;var content="";if(dataObj&&dataObj.content)content=dataObj.content;
hideLayer(scrlLayObj.slCuttingLayer);writeToLayer(scrlLayObj.slTextLayer, insideTextLayerStart + content + insideTextLayerEnd);
setTimeout("calcAndDisplayText();", 500);};function calcAndDisplayText(){var hideScrollBar = false;var insideTextLayObj = findObj(document,"InsideTextLayer");
if(!insideTextLayObj)return;var textLayerH = getHeight(insideTextLayObj);scrollBarLayerH = (cutLayerH * maxScrollDist)/textLayerH;
if(scrollBarLayerH > maxScrollDist) {scrollBarLayerH = maxScrollDist; hideScrollBar = true;}setHeight(scrlLayObj.slScrollBarLayer, scrollBarLayerH);
if(ie4)scrlLayObj.slScrollBarLayer.style.clip="rect(0px 20px " + scrollBarLayerH + "px 0px)";setHeight(scrlLayObj.ScrollBarGraphicsLayer, scrollBarLayerH);
setTop(scrlLayObj.slScrollBarLayer, upLayerH);setTop(scrlLayObj.ScrollBarGraphicsLayer, upLayerH);setTop(scrlLayObj.ScrollBarBotLayer, (scrollBarLayerH - downLayerH));
setTop(scrlLayObj.slTextLayer, 0);textToScrollBarRatio = scrollBarLayerH/cutLayerH;setScrollLimit("slScrollBarLayer", upLayerH, (maxScrollDist - scrollBarLayerH) + upLayerH);
setScrollLimit("ScrollBarGraphicsLayer", upLayerH, (maxScrollDist - scrollBarLayerH) + upLayerH);setScrollLimit("slTextLayer", -(textLayerH - cutLayerH), 0);
var x = initAbsPos(scrlLayObj.slScrollBarLayer);var y = initAbsPos(scrlLayObj.slTextLayer);var y = initAbsPos(scrlLayObj.ScrollBarGraphicsLayer);
if(hideScrollBar == true && !KEEP_SCROLL_BAR) hideLayer(scrlLayObj.slControlsLayer);else inheritVisibility(scrlLayObj.slControlsLayer);
if(ie4){scrlLayObj.slCuttingLayer.style.overflow='hidden';
scrlLayObj.slCuttingLayer.style.clip='rect(0px ' + getWidth(scrlLayObj.slCuttingLayer) + "px " + getHeight(scrlLayObj.slCuttingLayer) + 'px 0px)';}
else if(net4){
scrlLayObj.slCuttingLayer.clip='rect(0px ' + getWidth(scrlLayObj.slCuttingLayer) + "px " + getHeight(scrlLayObj.slCuttingLayer) + 'px 0px)';}
showLayer(scrlLayObj.slCuttingLayer);};function createScrollingText(){var d=document;var scrollDebug = false;var protoLayer = {position:'absolute', top: 0, left:0,  zindex:'10'};
protoLayer.id = "slCuttingLayer";
protoLayer.left = "7"; protoLayer.top = "42"; protoLayer.zindex = "50"; protoLayer.overflow = "hidden"; protoLayer.visibility='hidden';
writeToDoc(d, startLayer(protoLayer), scrollDebug);protoLayer.visibility = "inherit"; protoLayer.top = "0";protoLayer.id = "slControlsLayer"; protoLayer.zindex = '2';
protoLayer.left = "3"; protoLayer.width = "30";writeToDoc(d, startLayer(protoLayer), scrollDebug);protoLayer.left = "0"; protoLayer.width = null; protoLayer.height = null;
protoLayer.id = "slUpArrowLayer";  protoLayer.height = "20"; protoLayer.width = "20";writeToDoc(d, startLayer(protoLayer), scrollDebug);
writeToDoc(d, "<IMG NAME=\"UpArrow\" SRC=\"/images/UpArrow.gif\" WIDTH=\"20\" HEIGHT=\"20\" BORDER=\"0\" HSPACE=\"0\" VSPACE=\"0\" ONMOUSEOVER=\"swapImage(this,false);\" ONMOUSEOUT=\"swapImage(this,true);\" ONCLICK=\"return false;\" ONDBLCLICK=\"return false;\" onMouseDown=\"scroll(1);\" onMouseUp=\"stopScroll();\">",scrollDebug);
writeToDoc(d, endLayer(), scrollDebug);protoLayer.id = "slDownArrowLayer"; writeToDoc(d, startLayer(protoLayer), scrollDebug);
writeToDoc(d, "<IMG NAME=\"DownArrow\" SRC=\"/images/DownArrow.gif\" WIDTH=\"20\" HEIGHT=\"20\" BORDER=\"0\" ONMOUSEOUT=\"swapImage(this,true);\"  style=\"outline-style:none;\" ONMOUSEOVER=\"swapImage(this,false);\" ONCLICK=\"return false;\" ONDBLCLICK=\"return false;\" onMouseDown=\"scroll(-1);\" onMouseUp=\"stopScroll();\">",scrollDebug);
writeToDoc(d, endLayer(), scrollDebug);protoLayer.height = null; protoLayer.width = null;protoLayer.id = "slScrollBarLayer"; protoLayer.overflow = "hidden"; protoLayer.zindex = "50";
if(!ie4||dom)protoLayer.width="30";writeToDoc(d, startLayer(protoLayer), scrollDebug);
if(ie4||!dom)writeToDoc(d, "<IMG NAME=\"ScrollBarTopShim\" SRC=\"/images/shim.gif\" WIDTH=\"25\" HEIGHT=\"800\" BORDER=\"0\" VSPACE=\"0\" HSPACE=\"0\" ALT=\"\">",scrollDebug);
writeToDoc(d, endLayer(), scrollDebug);if(!ie4||dom)protoLayer.width=null;protoLayer.id = "ScrollBarGraphicsLayer"; protoLayer.zindex = "20"; protoLayer.border = "border: 0px none #000000";
writeToDoc(d, startLayer(protoLayer), scrollDebug);writeToDoc(d, "<IMG SRC=\"/images/ScrollBarBack.gif\" WIDTH=\"20\" HEIGHT=\"95%\" BORDER=0 VSPACE=0 HSPACE=0>",scrollDebug);
protoLayer.bgcolor = null;protoLayer.id = "ScrollBarTopLayer"; protoLayer.zindex = "1"; writeToDoc(d, startLayer(protoLayer), scrollDebug);
protoLayer.height = "20"; protoLayer.width = "20";
writeToDoc(d, "<IMG SRC=\"/images/ScrollBarTop.gif\" WIDTH=\"20\" HEIGHT=\"20\" BORDER=\"0\" VSPACE=\"0\" HSPACE=\"0\" ALT=\"\">",scrollDebug);
writeToDoc(d, endLayer(), scrollDebug);protoLayer.id = "ScrollBarBotLayer"; writeToDoc(d, startLayer(protoLayer), scrollDebug);
writeToDoc(d, "<IMG SRC=\"/images/ScrollBarBot.gif\" WIDTH=\"20\" HEIGHT=\"20\" BORDER=\"0\" VSPACE=\"0\" HSPACE=\"0\" ALT=\"\">",scrollDebug);
writeToDoc(d, endLayer(), scrollDebug);writeToDoc(d, endLayer(), scrollDebug);writeToDoc(d, endLayer(), scrollDebug);protoLayer.id = "slTextLayer"; protoLayer.zindex = "0"; protoLayer.bgcolor = null; protoLayer.border = null;
protoLayer.width = "365"; protoLayer.left = "50"; protoLayer.overflow = "visible"; protoLayer.height = "3000";protoLayer.visibility = "visible";
writeToDoc(d, startLayer(protoLayer), scrollDebug);writeToDoc(d, endLayer(), scrollDebug);writeToDoc(d, endLayer(), scrollDebug);
closeDoc(d, scrollDebug);};function dragObjBy(obj, distX, distY){scrollText(distY/(-1*textToScrollBarRatio*SCROLL_DIST));};function setScrollLimit(layer, topLimit, bottomLimit) {
if ((scrollLimits) && (scrollLimits[layer])){scrollLimits[layer].top = topLimit; scrollLimits[layer].bottom = bottomLimit;}};
var scrollCount = 0; var intervalObj = null; var timeoutObj = null; var isScrolling = false;function continueScrolling(amount){
if(isScrolling == true){if (intervalObj) window.clearInterval(intervalObj);intervalObj = window.setInterval("scrollText(" + amount + ");", scrollRepeatInterval);}
};function stopScroll(){isScrolling = false;if (intervalObj) window.clearInterval(intervalObj);if (timeoutObj) window.clearTimeout(timeoutObj);
};function scroll(amount) {isScrolling = true;if (timeoutObj)	window.clearTimeout(timeoutObj);timeoutObj = setTimeout("continueScrolling(" + amount + ");",CONTINUE_SCROLL_DELAY);
scrollText(amount);};function scrollText(scrollAmount){var distMoved = 0;scrollAmount *= SCROLL_DIST;distMoved = setScrollLayerTop(scrlLayObj.slTextLayer, scrollAmount);
if((distMoved/scrollAmount) != 1) scrollAmount *= Math.abs(distMoved/scrollAmount);var scrollbarScrollAmount = -1 * (textToScrollBarRatio * scrollAmount);
distMoved = setScrollLayerTop(scrlLayObj.slScrollBarLayer, scrollbarScrollAmount);distMoved = setScrollLayerTop(scrlLayObj.ScrollBarGraphicsLayer, scrollbarScrollAmount);
};function setScrollLayerTop(layerObj, scrollAmount) {var originalTop = 0;if((typeof scrollAmount == "number") && (typeof layerObj == "object")) {
var layerTop = getAbsPos(layerObj.id);var newTopVal = originalTop = layerTop + scrollAmount;if ((scrollLimits) && (scrollLimits[layerObj.id])) {
if (newTopVal < scrollLimits[layerObj.id].top) {newTopVal = scrollLimits[layerObj.id].top; scrollAmount = scrollAmount - (originalTop - newTopVal);}
if (newTopVal > scrollLimits[layerObj.id].bottom) {newTopVal = scrollLimits[layerObj.id].bottom; scrollAmount = scrollAmount - (originalTop - newTopVal);}}
setTop(layerObj, newTopVal);setAbsPos(layerObj.id, newTopVal);return scrollAmount;}return 0;};function getAbsPos(layer) {if((layerPositions) && (layerPositions[layer])) return layerPositions[layer];else return initAbsPos(scrlLayObj[layer])};
function setAbsPos(layer, position) {if(layerPositions) layerPositions[layer] = position;};function initAbsPos(layerObj) {if(layerPositions && layerObj) {return layerPositions[layerObj.id] = getTop(layerObj);}return null;};
function positionTextLayer(rules){var topRule=rules[0]; var heightRule=rules[1]; var leftRule=rules[2]; var widthRule=rules[3];
var top=null; var height=null; var left=null; var width=null;var offsetVals = calcPosition(topRule, heightRule, getAbsTop, getHeight);
if(typeof offsetVals == "object") {top=offsetVals[0]; height=offsetVals[1];}var offsetVals = calcPosition(leftRule, widthRule, getAbsLeft, getWidth);
if(typeof offsetVals == "object") {left=offsetVals[0]; width=offsetVals[1];}if(top) setTop(scrlLayObj.slCuttingLayer, top);if(height){
var heightObj = findObj(document, heightRule);setHeight(scrlLayObj.slCuttingLayer, height);if(ie4)setHeight(scrlLayObj.slTextLayer, height);}
if(left) setLeft(scrlLayObj.slCuttingLayer, left);if(width){textLayerWidth = width-getLeft(scrlLayObj.slTextLayer);setWidth(scrlLayObj.slTextLayer, textLayerWidth);
setWidth(scrlLayObj.slCuttingLayer, width);}};function calcPosition(offsetRule, dimensionRule, getOffset, getDimension){var offset = 0; var dimension = 0; var topTop; var extraOffset=0; var extraDimension=0;
if((typeof offsetRule=="object")&&(offsetRule.length==2)&&(typeof offsetRule[0]=="string")&&(typeof offsetRule[1]=="number")){
extraOffset=offsetRule[1];offsetRule=offsetRule[0];}if((typeof offsetRule=="string")&&(typeof (offsetRule=findObj(document, offsetRule))=="object")){
offsetVal=getOffset(offsetRule)+extraOffset;
if((typeof dimensionRule=="object")&&(dimensionRule.length==2)&&(typeof dimensionRule[0]=="string")&&(typeof dimensionRule[1]=="number")){
extraDimension=dimensionRule[1];dimensionRule=dimensionRule[0];}if(typeof dimensionRule=="number"){dimension=dimensionRule;if(dimensionRule>=0)		
{offset=getDimension(offsetRule)+offsetVal;}else if(dimensionRule<0)	{dimension*=-1; offset=offsetVal + dimensionRule;}	}else if((typeof dimensionRule=="string")&&(typeof (dimensionRule=findObj(document, dimensionRule))=="object")) 
{offset=offsetVal; dimension=getOffset(dimensionRule)-offsetVal+extraDimension;}}else if(typeof offsetRule=="number"){offset=offsetRule;
if((typeof dimensionRule=="object")&&(dimensionRule.length==2)&&(typeof dimensionRule[0]=="string")&&(typeof dimensionRule[1]=="number")){
extraDimension=dimensionRule[1];dimensionRule=dimensionRule[0];}if(dimensionRule=="screenheight")dimensionRule=getScreenHeight();
else if(dimensionRule=="screenwidth")dimensionRule=getScreenWidth();if(typeof dimensionRule=="number"){dimension=dimensionRule+extraDimension;
if(dimensionRule<0){dimension*=-1;}}else if((typeof dimensionRule=="string")&&(typeof (dimensionRule=findObj(document, dimensionRule))=="object")) 
{dimension=getOffset(dimensionRule)-offset+extraDimension;}}return new Array(offset, dimension);};
