// Compatible for use with NS4,NS6,IE4+, and the latest DOM standard browsers (IE,NS,Mozilla,Gecko)
// Must enclose the menu in a DIV with an ID of "boxcar" with style set, especially Top.
// based on...
/* chaser.js
 * by Aaron Boodman v1.0 000919
 * Copyright (c) 2000 Aaron Boodman. All Rights Reserved.
 * Created for GreatEqualizer.com (http://www.greatequalizer.com/) and
 * documented at DHTML Lab (http://www.webreference.com/dhtml/)
 * License to use is granted if and only if this entire
 * copyright notice is included.
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
*/

//initialize - topMargin is hard coded here for max top position for the DIV container (boxCar)
// callRate affects the visual affect of the boxCar movement as does the slideTime.
var oMoveVert = {
	topMargin	: 5,
	callRate	: 10,
	slideTime	: 1200,
	maxDiff		: document.all ? document.body.clientHeight : window.innerHeight
}
//get reference to the DIV (menu container) with ID of "boxCar" that exists in the html file.
//NS4
if (document.layers) oMoveVert.boxCar = document.layers["boxcar"]
//IE4+
else if (document.all) oMoveVert.boxCar = document.all["boxcar"]
//DOM standard
else if (!document.layers && document.getElementById) oMoveVert.boxCar = document.getElementById("boxcar")

//initializes variables used to control the visual smoothness of the movement.
oMoveVert.slideInit = function( )
{
	var now	= new Date( )
	this.A		= this.targetY - this.currentY
	this.B		= Math.PI / ( 2 * this.slideTime )
	this.C		= now.getTime( )
	if (Math.abs(this.A) > this.maxDiff) {
		this.D = this.A > 0 ? this.targetY - this.maxDiff : this.targetY + this.maxDiff
		this.A = this.A > 0 ? this.maxDiff : -this.maxDiff
	} else {
		this.D = this.currentY
	}
}

// determines the next Y (vertical) position and makes the move.
// repeatedly called from main until required position is reached.
oMoveVert.slide = function( )
{
	var now	= new Date( )
	var newY	= this.A * Math.sin( this.B * ( now.getTime( ) - this.C ) ) + this.D
	newY		= Math.round( newY )
	if (( this.A > 0 && newY > this.currentY ) ||
		( this.A < 0 && newY < this.currentY )) {
			//IE4+,DOM
			if ( this.boxCar.style.top )this.boxCar.style.top = newY + "px"
			//NS4
			else			this.boxCar.top = newY
	}
}

oMoveVert.main = function( )
{
    //if browser uses "style.top" (IE4+,NS6,DOM) or "top" (NS4) and "scrollTop"(IE4+,DOM) or "pageYOffset(NS4,NS6)
	this.currentY	= this.boxCar.style.top ? parseInt(this.boxCar.style.top) : this.boxCar.top;
    this.scrollTop = document.body.scrollTop ? document.body.scrollTop : window.pageYOffset ;
    if (!this.scrollTop) this.scrollTop = 0;
	var newTargetY	= this.scrollTop + this.topMargin;
	if ( this.currentY != newTargetY ) {
		if ( newTargetY != this.targetY ) {
			this.targetY = newTargetY
			this.slideInit( )
		}
		this.slide( )
	}
}
window.setInterval("oMoveVert.main( )", oMoveVert.callRate)