function oScrollNav(sLayerId, iTopOffset, iSlideTime, iCeiling, iFloor) {
	this.chaserDiv = null
	this.layerId   = sLayerId
	this.topOffset = iTopOffset
	this.slideTime = iSlideTime
	this.ceiling   = iCeiling
	this.floor     = iFloor
	
	oScrollNav.registry[oScrollNav.registry.length] = this
}

oScrollNav.isIE = window.clientInformation ? true : false
oScrollNav.isN4 = document.layers ? true : false
oScrollNav.isN6	= navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 5
oScrollNav.isO5 = navigator.userAgent.indexOf("Opera") != -1 && parseInt(navigator.appVersion) >= 4
oScrollNav.registry = new Array( )
oScrollNav.callRate = 10

window.setInterval("oScrollNav.timer( )", oScrollNav.callRate)

// this is the main loop of the program. To avoid having multiple timers
// running concurrently (CPU-intensive) this goes through oScrollNav.registry[ ]
// and calls the .main( ) method of each instance of oScrollNav in turn.
oScrollNav.timer = function() {
	for (var i = 0; chObj = this.registry[i]; i++) {
		if (!chObj.chaserDiv) chObj.attemptLoad()
		if (chObj.chaserDiv)  chObj.main()
	}
}

// attempts to find the target layer.
// sets the chaserDiv property of the parent object to
// found layer, or null if none is found.
oScrollNav.prototype.attemptLoad = function() {
	var chDiv = null

	if (oScrollNav.isN6 || oScrollNav.isO5)	chDiv = document.getElementById(this.layerId)
	else if (oScrollNav.isIE)			chDiv = document.all[this.layerId]
	else if (oScrollNav.isN4)			chDiv = document.layers[this.layerId]

	if (chDiv && chDiv != null) {
		this.chaserDiv = chDiv
	}
}

// Main function. gets called very often by oScrollNav.timer().
// Updates targetY, and decides whether to start
// the animation over again, continue an existing animation,
// or do nothing at all.
oScrollNav.prototype.main = function( )
{
	this.currentY	= this.getCurrentY()
	var scrollTop	= oScrollNav.getWindowScroll() 
	var newTargetY	= scrollTop + this.topOffset
	var floor		= oScrollNav.getDocumentHeight() - this.floor

	newTargetY = Math.max( newTargetY, this.ceiling)
	if (!oScrollNav.isO5) newTargetY = Math.min(newTargetY, floor)

	if ( this.currentY != newTargetY ) {

		if ( newTargetY != this.targetY ) {
			this.targetY = newTargetY
			this.slideInit( )
   		}
		this.slide( )
	}
}

// .slideInit( ). Initializes the slide animation.
oScrollNav.prototype.slideInit = function( )
{
	//window.status = this.targetY + " " + this.currentY
	this.A		= (this.targetY - this.currentY) / this.slideTime / this.slideTime
	this.startT	= (new Date()).getTime()
	this.startP	= this.getCurrentY()
	this.D		= this.targetY - this.startP
}

// .slide( ). Moves the Chaser one frame. Its rate decreases and
// is defined by a sine wave.
oScrollNav.prototype.slide = function( )
{
	var elapsed	= (new Date()).getTime() - this.startT
	if (elapsed < this.slideTime) {
		this.moveTo(this.D - (Math.round(Math.pow(this.slideTime - elapsed, 2) * this.A)) + this.startP)
	}
}

oScrollNav.prototype.moveTo = function(ny) {
	if (oScrollNav.isN4)	this.chaserDiv.top = ny
	else				this.chaserDiv.style.top = ny
}
	
oScrollNav.prototype.getCurrentY = function() {
	var n = oScrollNav.isN4 ? this.chaserDiv.top : parseInt(this.chaserDiv.style.top)
	return isNaN(n) ? 0 : n
}

oScrollNav.getWindowScroll = function() {
	if (oScrollNav.isIE)	return document.body.scrollTop
	else				return window.pageYOffset
}

oScrollNav.getDocumentHeight = function() {
	if (oScrollNav.isO5)		return 0 // opera can't retreive this property.
	else if (oScrollNav.isIE)	return document.body.scrollHeight
	else					return window.document.height
}

function CreateObj(obj) {
	if (!isNav) {

		if (document.all){
			newobj = eval("document.all." + obj + ".style")
		}
		else {
			newobj = eval("document.getElementById(\"" + obj + "\").style")
		}	
	} else {
	newobj = eval("document.layers['" + obj + "']")
	}
	return newobj
}

function showObj(obj) {
	visObj = CreateObj(obj)
    if (!isNav) {
		visObj.visibility = "visible"
	} else {
		visObj.visibility = "show"
    }
}

function hideObj(obj) {
	visObj = CreateObj(obj)
    if (!isNav) {
		visObj.visibility = "hidden"
	} else {
		visObj.visibility = "hide"
	}
}

function changeSNImages() {
        if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeSNImages.arguments.length; i+=2) {
			if (!isNav) {
				document[changeSNImages.arguments[i]].src = changeSNImages.arguments[i+1];
			}	
            else {
            	document.layers['Tododiv2'].document[changeSNImages.arguments[i]].src = changeSNImages.arguments[i+1];
            }
		}
	}
}

function popwin(item, idnum){
    eval("window.open('/admissions/adm_todo_window.asp?iTaskID=" + idnum + "&item=" + item + "','todo','toolbar=no,menubar=no,address=no,status=no,dependent=no,resizable=0,scrollbars=no,height=200,width=312')");
}

function preloadScroll(){
    preloadFlag = false;
    	if (document.images) {
            todo_tellON = newImage("/images/admission/todo/todo_tellON.gif");
            todo_tellONCK = newImage("/images/admission/todo/todo_tellONCK.gif");
            todo_customON = newImage("/images/admission/todo/todo_customON.gif");
            todo_customONCK = newImage("/images/admission/todo/todo_customONCK.gif");
            todo_getinfoON = newImage("/images/admission/todo/todo_getinfoON.gif");
            todo_getinfoONCK = newImage("/images/admission/todo/todo_getinfoONCK.gif");
            todo_vtourON = newImage("/images/admission/todo/todo_vtourON.gif");
            todo_vtourONCK = newImage("/images/admission/todo/todo_vtourONCK.gif");
            todo_visitON = newImage("/images/admission/todo/todo_visitON.gif");
            todo_visitONCK = newImage("/images/admission/todo/todo_visitONCK.gif");
            todo_applyON = newImage("/images/admission/todo/todo_applyON.gif");
            todo_applyONCK = newImage("/images/admission/todo/todo_applyONCK.gif");
            todo_statusON = newImage("/images/admission/todo/todo_statusON.gif");
            todo_statusONCK = newImage("/images/admission/todo/todo_statusONCK.gif");
            todo_scholarON = newImage("/images/admission/todo/todo_scholarON.gif");
            todo_scholarONCK = newImage("/images/admission/todo/todo_scholarONCK.gif");	
			preloadFlag = true;
    	}
    }
