// Version 1 - 12th April 2001
function CreateContent(id,oBr,holder,content,delay,dir,loop){

	// Properties
	this.id = id
	this.oHolder=eval("oHldr_"+this.id)
    eval(this.id + "=this") 

	this.stepDelayMSecs=(delay)?delay:10
	this.scrolldirection=(dir)?dir:"vertical"
	this.loop=(loop)?loop:false

	this.timer
	this.active
	this.x 
	this.y


	// Get DIV object
	if(oBr.dom){
		this.div=document.getElementById(content)
	}
	else if(oBr.ie4){
		this.div=document.all[content]
	}
	else if(oBr.ns4){
		this.div=eval("document."+holder+".document."+content)
	}


	// Get CSS object
	if(oBr.dom){
		this.css=document.getElementById(content).style
	}
	else if(oBr.ie4){
		this.css=document.all[content].style
	}
	else if(oBr.ns4){
		this.css=this.div
	}

	// Get Dims
	this.scrollWidth=(oBr.ns4)
		?this.css.document.width
		:this.div.offsetWidth 

	this.scrollHeight=(oBr.ns4)
		?this.css.document.height
		:this.div.offsetHeight 


	// Methods
	this.moveleft=CC_MoveLeft
	this.moveright=CC_MoveRight 

	this.moveup=CC_MoveUp
	this.movedown=CC_MoveDown
	
	this.moveto=CC_MoveTo 
	
	this.start=CC_Start
	this.stop=CC_Stop

	this.setdelay=CC_SetDelay
	this.setdirection=CC_SetDirection
	this.setloop=CC_SetLoop

	this.moveto(0,0)
    return this 
}

function CC_SetDelay(n){
	this.stepDelayMSecs=n
}

function CC_SetDirection(dir){
	this.scrolldirection=dir
}

function CC_SetLoop(b){
	this.loop=b
}

function CC_MoveTo(x,y){ 
    this.css.left=this.x=x
	this.css.top=this.y=y 
} 
 
function CC_MoveRight(step){ 
	if (this.loop) {
		if(this.x > 0 - this.scrollWidth){ 
			this.moveto(this.x - step,0) 
		}
		else {
			this.moveto(this.oHolder.clipWidth,0)
			this.moveright(step)
			return
		}
	}
	else {
		if(this.x > this.oHolder.clipWidth - this.scrollWidth){ 
			this.moveto(this.x - step,0) 
		}
		else {
			if (this.timer){
				clearTimeout(this.timer)
				fScrollEnd(this.id,'R')
				return
			}
		}
	}
	if(this.active) this.timer=setTimeout(this.id+".moveright("+step+")",this.stepDelayMSecs) 
} 

function CC_MoveLeft(step){ 
	if (this.loop) {
		if(this.x < this.oHolder.clipWidth){ 
			this.moveto(this.x - step,0) 
		}
		else {
			this.moveto(0 - this.scrollWidth,0)
			this.moveleft(step)
			return
		}
	}
	else {
		if(this.x < 0){ 
			this.moveto(this.x - step,0) 
		}
		else {
			if (this.timer){
				clearTimeout(this.timer)
				fScrollEnd(this.id,'L')
				return
			}
		}
	}
	if(this.active) this.timer=setTimeout(this.id+".moveleft("+step+")",this.stepDelayMSecs) 
}

function CC_MoveDown(step){
	if (this.loop) {
		if(this.y > 0 - this.scrollHeight){ 
			this.moveto(0,this.y - step) 
		}
		else {
			this.moveto(0,this.oHolder.clipHeight)
			this.movedown(step)
			return
		}
	}
	else {
		if(this.y > this.oHolder.clipHeight - this.scrollHeight){ 
			this.moveto(0,this.y - step) 
		}
		else {
			if (this.timer){
				clearTimeout(this.timer)
				fScrollEnd(this.id,'D')
				return
			}
		}
	}
	if(this.active) this.timer=setTimeout(this.id+".movedown("+step+")",this.stepDelayMSecs) 
}

function CC_MoveUp(step){ 
	if (this.loop) {
		if(this.y < this.oHolder.clipHeight){ 
			this.moveto(0,this.y - step) 
		}
		else {
			this.moveto(0,0 - this.scrollHeight)
			this.moveup(step)
			return
		}
	}
	else {
		if(this.y < 0){ 
			this.moveto(0,this.y - step) 
		}
		else {
			if (this.timer){
				clearTimeout(this.timer)
				fScrollEnd(this.id,'U')
				return
			}
		}
	}
	if(this.active) this.timer=setTimeout(this.id+".moveup("+step+")",this.stepDelayMSecs) 
} 

function CC_Start(step){
	this.stop()
	if (this.timer){
		clearTimeout(this.timer)
	}
	this.active=true 
	if (this.scrolldirection=="vertical") {
		if(step > 0){
			this.movedown(step)
		}
		else {
			this.moveup(step)
		}
	}
	if (this.scrolldirection=="horizontal") {
		if(step > 0){
			this.moveright(step) 
		}
		else {
			this.moveleft(step)
		}
	}
} 
 
function CC_Stop(){
	this.active=false 
} 



////////////////////////////////////////////
////////////// HOLDER CLASS ////////////////


function CreateHolder(id,oBr,dv){
	// Get Properties (3 browsers)
	if(oBr.dom){
		this.div=document.getElementById(dv)
	}
	else if(oBr.ie4){
		this.div=document.all[dv]
	}
	else if(oBr.ns4){
		this.div=eval('document.'+dv)
	}

	// Get CSS values (3 browsers)
	if(oBr.dom){
		this.css=document.getElementById(dv).style
	}
	else if(oBr.ie4){
		this.css=document.all[dv].style
	}
	else if(oBr.ns4){
		this.css=eval('document.'+dv)
	}

	// Get dimensions
	this.clipWidth=(oBr.ns4)
		?this.css.clip.width
		:this.div.offsetWidth 

	this.clipHeight=(oBr.ns4)
		?this.css.clip.height
		:this.div.offsetHeight 

	this.css.visibility="visible"
}

function SetupScroll(id,oBr,dvContent,dvHolder,speed,dir,loop){
	eval("oHldr_"+id+" = new CreateHolder(id,oBr,dvHolder)")
    eval("oScrl_"+id+" = new CreateContent(id,oBr,dvHolder,dvContent,speed,dir,loop)")
} 

