/*
Cross browser Marquee script- c Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
Modified by bitstudio
*/

function Marquee(target, speed) {
	this.target = target;
	this.marqueespeed=speed ? speed : 2;
	this.iedom=document.all||document.getElementById;
	this.boxwidth='';
	this.actualwidth='';
	this.mouseover = false;
}

function _Marquee_start() {
	if (this.iedom){
		this.box=document.getElementById ? document.getElementById(this.target) : document.all.item(this.target)
		this.marquee=this.box.getElementsByTagName ? this.box.getElementsByTagName('div')[0] : this.box.firstChild;
		this.marquee.style.left=0+"px"
		this.boxwidth=this.box.offsetWidth
		this.actualwidth=this.marquee.offsetWidth
	}
	else if (document.layers){
		this.marquee=document.layers[this.target];
		this.marquee.left=0
		this.boxwidth=this.marquee.width
		this.actualwidth=this.marquee.document.width
	}
	
	if (this.boxwidth < this.actualwidth) {
		if (!this.lefttime) {
			this.lefttime=setInterval(this.constructor.scrollmarquee_closure(this),20)
		}
	}
	
	this.mouseover = true;
}

function _Marquee_reset() {
	this.mouseover = false;
}

function _Marquee_scrollmarquee() {
	if (this.iedom){
		if (parseInt(this.marquee.style.left)>(this.actualwidth*(-1)+8))
			this.marquee.style.left=parseInt(this.marquee.style.left)-this.marqueespeed+"px"
		else
			this.marquee.style.left=this.boxwidth+8+"px"
	}
	else if (document.layers){
		if (this.marquee.left>(this.actualwidth*(-1)+8))
			this.marquee.left-=this.marqueespeed
		else
			this.marquee.left=this.boxwidth+8
	}
	
	if (!this.mouseover) {
		clearInterval(this.lefttime);
		this.lefttime = null;
		
		if (this.iedom)
			this.marquee.style.left=0+"px"
		else if (document.layers)
			this.marquee.left=0
	}
}

function _Marquee_scrollmarquee_closure(scope) {
    return function(){scope.scrollmarquee.apply(scope)};
}

Marquee.prototype.start = _Marquee_start;
Marquee.prototype.reset = _Marquee_reset;
Marquee.prototype.scrollmarquee = _Marquee_scrollmarquee;
Marquee.scrollmarquee_closure = _Marquee_scrollmarquee_closure;

