//News scroller javascript.
//Conway IT Services Ltd
//http://www.conway-it.com
/*
Instructions

Create a div named news.  
Text scrolls from bottom to top.
Adjust vars to position as required.
var theTop = 360;  The position where the scrolling text will disappear.
var theHeight = 190;(This is now calculated automatically from the scrollHeight property.
var theWidth = 190; Adjust as required.
var theLeft = 0; (optionally use padding)
var toClip = 160; (the number of pixels which will be cut from the bottom of the div)

Adjust padding (theDiv.padding = "160px 0px 160px 15px";) [top right bottom left]

Style as required.


function testlength() {
var x = document.getElementById('news').innerHTML;
alert(x.length);

}
*/
function getObject( obj ) {

var strObj

if ( document.all ) {

strObj = document.all.item( obj );

} else if ( document.getElementById ) {

strObj = document.getElementById( obj );

}

return strObj;

}

var theTop = 345;

var theHeight = 0;

var theWidth = 190;

var theLeft = 0;

var toClip = 180;

var sStop = 0;



function gotcha() {


sStop = 1;
//alert(document.getElementById('news').scrollHeight);
}

function resumeScroll() {
sStop = 0;
}

function scrollNews( newsDiv, toMove ) {

//var chars = document.getElementById('news').innerHTML.length;


//theHeight = (document.getElementById('news').scrollHeight/4);
theHeight = 225;
//toClip = theHeight+20;
toClip = theHeight;
if (document.getElementById('idx')) {theTop = 310;}

theDiv = getObject( newsDiv.toString() );

if ( theDiv == null ) { return; }

if ( document.layers ) {

theDiv.clip.top = toMove;

theDiv.clip.bottom = toMove + toClip;

theDiv.top = theTop - toMove;

} else {

theDiv = theDiv.style;

theDiv.padding = "160px 0px 160px 15px";

theDiv.clip = "rect(" + toMove + "px " + (theWidth + theLeft) + "px " + (toMove + toClip) + "px 0px)";

theDiv.top = theTop - toMove + 'px';

}

if ( ( theTop + theHeight - toMove ) < ( theTop - theHeight - 20 ) ) {



toMove = 0;

if ( document.layers ) {

theDiv.clip.top = theTop;

theDiv.clip.bottom = toClip;

theDiv.top = theTop

} else {

theDiv.clip = "rect(" + toMove + "px " + (theWidth + theLeft) + "px " + (toMove + toClip) + "px 0px)";

theDiv.top = theTop + 'px';

}

}

if (sStop==0) {toMove = (toMove + 1);}



setTimeout("scrollNews('" + newsDiv + "'," + toMove + ")", 20);

}
