//floatLayer v4.0
//last updated on 10/23/02 by jcl

var begMargin = 400;
var topMargin = 250;    //when float is beyond page header, this variable defines the gap between the top of the page and top of the float 
var slideTime = 1200;  //speed of the float: higher = slower, lower = faster
var strPath = 'http://www.martindale.com/susie/images' //Image path to access the spacer.gif file.
var strFileName = 'cleardot.gif' //Image used for adjusting the middle section of each web page so the navigation doesn't overlap the footer.

var ns6 = (!document.all && document.getElementById); 
var ie4 = (document.all);
var ns4 = (document.layers);

window.setInterval("main()", 10);

function setProperties() {
	if (this.ns4) { 
		this.currentY = document.floatLayer.top; 
		this.scrollTop = window.pageYOffset;
		this.objHeight = document.floatLayer.clip.height;
		this.winHeight = window.innerHeight;
	} 
	else if(this.ns6) {
		this.currentY = parseInt(document.getElementById('floatLayer').style.top); 
		this.scrollTop = scrollY;
		this.objHeight = document.getElementById('floatLayer').offsetHeight;
		this.winHeight = window.innerHeight;
	} 
	else if(this.ie4) { 
		this.currentY = floatLayer.style.pixelTop;
		this.scrollTop = document.body.scrollTop; 
		this.objHeight = document.getElementById('floatLayer').offsetHeight;
		this.winHeight = document.body.clientHeight;
	} 
} 

function main() {
	setProperties();
	
	if ( this.pushPin != 1 ) {	
		if (this.scrollTop > this.begMargin) {
			//header is off screen so keep menu against top margin
			var newTargetY	= this.scrollTop + this.topMargin 
			}
		else {
			//header is within range so adjust scroll to make sure it doesn't overlap header
			var newTargetY	= this.scrollTop + this.begMargin
		}

		//browser height is greater than floating navigation menu so leave float speed alone
		if (this.objHeight < this.winHeight) {	
			if ( this.currentY != newTargetY ) { 
				if ( newTargetY != this.targetY ) { 
					this.targetY = newTargetY;
					floatStart(); 
				} 
				animator(); 
			} 
		}
		//browser height is smaller than float height so delay the float so the user can get to the bottom of the menu
		else {
			if ( this.currentY != newTargetY ) { 
				if ( newTargetY != this.targetY ) {
					//Use the size of the floating navigation menu to determine how far the user can scroll before float resumes.
					//The 180 at the end of the next line forces the animation to kick in before the menu leaves the screen on an up scroll.
					if (this.scrollTop > (this.currentY+this.objHeight) || this.scrollTop < (this.currentY-this.objHeight+180) ) { 
						//subtracting 100 from the winHeight keeps the menu from overlapping the footer by keeping the trigger point outside the range of the footer
						this.winHeight = this.winHeight - 100;
						if (this.scrollTop > this.begMargin + this.objHeight) {
							newTargetY = newTargetY - (this.objHeight-this.winHeight);
						}
						this.targetY = newTargetY;
						floatStart(); 
					}
					//this if loop keeps the float tight against the begMargin whenever the header is within sight
					//this prevents a one or two inch gap between the header and the float, which can occur occasionally
					if (this.scrollTop < this.begMargin) {
						newTargetY	= this.scrollTop + this.begMargin 
						this.targetY = newTargetY;
						floatStart(); 
					}
				} 
				animator(); 
			} 
		}
	}
} 

function floatStart() {
	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.winHeight) { 
		this.D = this.A > 0 ? this.targetY - this.winHeight : this.targetY + this.winHeight; 
		this.A = this.A > 0 ? this.winHeight : -this.winHeight; 
	} 
	else {	 
		this.D = this.currentY; 
	} 
}

function animator() {
	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 )) { 
		if ( this.ie4 )floatLayer.style.pixelTop = newY; 
		if ( this.ns4 )document.floatLayer.top = newY;
		if ( this.ns6 )document.getElementById('floatLayer').style.top = newY + "px"; 
	} 
} 

function pinSet() {
	if (this.pushPin !=1) {
		this.pushPin = 1;
		document.pushPin.src = 'burton_files/pinon.gif';	
	}
	else {
		this.pushPin = 0;
		document.pushPin.src = 'burton_files/pinoff.gif';
	}
}