// ------------[+]-- DynamicHTML Elevating.Navi 
// ------------[+]-- Copyright (C) 2002- HP-DESIGN.NET. 
// ------------[+]-- Takeru [ http://hp-design.net/ ] 
// No reproduction , no republication without written permission of HP-DESIGN.NET 
// Must not delete this copyright in order to use this script 

function initElevatingNavi(id,mt,mb,tp) {

	this.id = getObjectById(id) ;
	if( this.id.style.position != 'absolute' ) 
		{ this.id.style.position = 'absolute' }
	this.marginTop = mt ? mt : 0 ;
	this.marginBottom = mb ? mb : 0 ;
	this.currentY = tp ? tp : getObjectY(this.id) ;
	this.topY = tp ? tp : getObjectY(this.id) ;

	return this ;
}

var elevator ;
function startElevatingNavi(id, mt, mb, tp) { // DIVid, margin-top, margin-bottom, position-top,
	if( _bw.ie5up || _bw.net6 || _bw.opera6up ) {
		elevator = new initElevatingNavi(id,mt,mb,tp) ;
		moveElevatingNavi();
	} 
}

function moveElevatingNavi() {
	var winh = getWindowHeight() ; var yt = getScrollY() ;
	var divh = getObjectHeight(elevator.id);

	if( winh >= divh ) {
		if(winh >= elevator.marginTop + divh + elevator.marginBottom) {
			yt = Math.max(yt + elevator.marginTop, elevator.topY) ;
		} else {
			// downpower
			var yt1 = Math.max(yt + elevator.marginTop, elevator.topY) ;
			var f1 = (yt1 > elevator.currentY) ? 1 : 0 ;
			// uppower
			var yt2 = yt - (divh + elevator.marginBottom - winh) ;
			yt2 = Math.max(yt2, elevator.topY) ;
			var f2 = (yt2 < elevator.currentY) ? 1 : 0 ;
			// offset when down and up powers work
			if (f1 && f2) { yt = elevator.currentY }
			else { yt = f2 ? Math.max(yt1, yt2) : Math.min(yt1, yt2) }
		} 
	
		if(yt != elevator.currentY) {
			// gradually reach to line
			var vy = (yt - elevator.currentY) * 0.1;
			if (Math.abs(vy) < 1) { vy = (vy > 0) ? 1 : (vy < 0) ? -1 : 0 }
			elevator.currentY += Math.round(vy);
			setObjectY(elevator.id , elevator.currentY) ;
		}
	}
	setTimeout('moveElevatingNavi()', 20);
}

