/* modified version of Aaron Boodman's chaser.js 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.
*/

var oHL = {
    topMargin  : document.all ? document.body.clientHeight-515 : window.innerHeight-515,    
    callRate   : 35,
    ceiling    : 55,
    slideTime  : 1200,
    isIE       : document.all ? true : false,
    HLblock  : document.all ? document.all.HL : document.HL
}

window.setInterval("oHL.main( )", oHL.callRate)

// Main loop. Updates targetY, and decides whether to start
// the animation over again, continue an existing animation,
// or do nothing at all.
oHL.main = function( )
{
	this.currentY	= this.isIE ? this.HLblock.style.pixelTop : document.getElementById('HL').offsetTop
	this.scrollTop	= this.isIE ? document.body.scrollTop : window.pageYOffset
	var newTargetY	= this.scrollTop + this.topMargin			
	if ( this.currentY != newTargetY ) {
		if ( newTargetY != this.targetY ) {

			this.targetY = newTargetY
			this.slideInit( )
	
		}

		this.slide( )
		
	}
}

// .slideInit( ). Initializes the slide animation. Sets properties
// of the oChaser object that will represent the various paramaters
// for the sine wave function.
oHL.slideInit = function( )
{
	var now	= new Date( )
	this.A     = this.targetY - this.currentY
    this.B     = Math.PI / ( 2 * this.slideTime )
    this.C     = now.getTime( )
    this.D     = this.currentY
}

// .slide( ). Moves the oChaser one frame. Its rate decreases and
// is defined by a sine wave.
oHL.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 )
	{		
			if (newY < 488) newY = 488
			if ( this.isIE )this.HLblock.style.pixelTop = newY
			else			document.getElementById('HL').style.top = newY
	}
	else if ( this.A < 0 && newY < this.currentY )
	{
		if (newY >= 488){
			if ( this.isIE )this.HLblock.style.pixelTop = newY
			else			document.getElementById('HL').style.top = newY
		}
	}
}