/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* vScroll Object
* gives controls to a set of 2 layers for simple vertical scrolling
* Created by Mats Edlund, 20000914
* Modified by Mats Edlund
* 
*
* vScroll Object ORIGINATES FROM MiniScroll Object
* Copyright (C) 1999 Dan Steinman
* Distributed under the terms of the GNU Library General Public License
* Available at http://www.dansteinman.com/dynapi/
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var nVScrollObjectCounter = 0

function vScroll(window,content,updiv,dndiv,updisdiv,dndisdiv,bkgdiv) {
	this.window = window
	this.content = content
	this.updiv = updiv
	this.dndiv = dndiv
	this.updisdiv = updisdiv
	this.dndisdiv = dndisdiv
	this.bkgdiv = bkgdiv
	this.updivHideStr = (updiv == null) ? null : (updiv.obj + '.hide()')
	this.dndivHideStr = (dndiv == null) ? null : (dndiv.obj + '.hide()')
	this.inc = 10
	this.speed = 20
	this.contentHeight = this.content.getH()
	this.windowHeight = this.window.getH()
	this.up = vScrollUp
	this.down = vScrollDown
	this.stop = vScrollStop
	this.write = vScrollWrite
	this.activate = vScrollActivate
	this.checkScroll = hScrollCheckScroll
  
  nVScrollObjectCounter++
  this.obj = "objVScroll_" + nVScrollObjectCounter
	eval(this.obj + "=this")
        
	this.activate()
  
  // Windows IE bug -- adjust for scroll changes caused by .focus() on element inside content area, ONLY when using jsHscroll object
  if (is.win && is.ie) setInterval(this.obj + ".checkScroll()", 1000)
}

function vScrollActivate() {
	this.contentHeight = this.content.getH()
	this.windowHeight = this.window.getH()
	this.offsetHeight = this.contentHeight - this.windowHeight
	this.enableScroll = (this.offsetHeight>0)
  if (this.enableScroll) {
		if (this.bkgdiv != null) this.bkgdiv.show()
		if (this.updisdiv != null) this.updisdiv.show()
		if (this.dndisdiv != null) this.dndisdiv.show()
		this.dndiv.show()
	} else {
		if (this.bkgdiv != null) this.bkgdiv.hide()
		if (this.updisdiv != null) this.updisdiv.hide()
		if (this.dndisdiv != null) this.dndisdiv.hide()
		this.updiv.hide()
		this.dndiv.hide()
		this.content.moveTo(null,0)
	}
}

function vScrollUp() {
	if (this.enableScroll) {
		this.content.slideTo(null,0,this.inc,this.speed,this.updivHideStr)
		if (this.dndiv != null) this.dndiv.show()
	}
}

function vScrollDown() {
	if (this.enableScroll) {
		this.content.slideTo(null,-this.offsetHeight,this.inc,this.speed,this.dndivHideStr)
		if (this.updiv != null) this.updiv.show()
	}
}

function vScrollStop() {
	this.content.slideActive = false
}

function vScrollWrite(newContent) {
	this.stop()
	this.content.write(newContent)
	this.activate()
}

// Windows IE bug -- adjust for scroll changes caused by .focus() on element inside content area, ONLY when using jsHscroll object
function hScrollCheckScroll() {
	if (this.window.elm.scrollTop > 0) {
    this.content.moveBy(null, -this.window.elm.scrollTop)
    this.window.elm.scrollTop = 0
    this.updiv.show()
    this.activate()
  }
}