window.onerror = null;

if (navigator.userAgent.toUpperCase().indexOf('MAC') != -1)
	{isMac = true;}
else
	{isMac = false;}

if (window.LstartPos)
	{//variable is already defined
	LstartPos = LstartPos;}
else
	{LstartPos = 2200;}
if (window.RstartPos)
	{//variable is already defined
	RstartPos = RstartPos;}
else
	{RstartPos = 2200;}

var topMargin = 0;
var slideTime = 2500;
var menuHeight = 532;
var bannerHeight = 520;
bannerOffset = (menuHeight - bannerHeight) / 2;
//bannerOffset = 0;
RstartPos = RstartPos + bannerOffset;  //show them both at the same time
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);

function layerObject(id)
	{
	if (ns6)
		{
		this.obj = document.getElementById(id).style;
		return this.obj;
		}
	else if(ie4)
		{
		this.obj = document.all[id].style;
		return this.obj;
		}
	else if(ns4)
		{
		this.obj = document.layers[id];
		return this.obj;
		}
	}

function layerSetup()
	{
	floatLyr = new layerObject('floatLayer');
	window.setInterval("main()", 10)
	}

function floatObject()
	{
	if (ns4 || ns6)
		{
		findHt = window.innerHeight;
		}
	else if(ie4)
		{
		//document.body.???? doesn't work with doctype
		//findHt = document.body.clientHeight;
		findHt = document.documentElement.clientHeight;
		}
	}

function main()
	{
	if (ns4)
		{
		this.currentY = document.layers["floatLayer"].top;
		this.scrollTop = window.pageYOffset;
		mainTrigger();
		}
	else if(ns6)
		{
		this.currentY = parseInt(document.getElementById('floatLayer').style.top);
		this.scrollTop = scrollY;
		mainTrigger();
		}
	else if(ie4)
		{
		this.currentY = floatLayer.style.pixelTop;
		//this.scrollTop = document.body.scrollTop;
		this.scrollTop = document.documentElement.scrollTop;
		mainTrigger();
		}
	}

function mainTrigger()
	{
	var newTargetY = this.scrollTop + (findHt / 2 - (menuHeight / 2));
	if (newTargetY < this.scrollTop)
		{newTargetY = this.scrollTop;}
	if ( this.currentY != newTargetY )
		{
		if ( newTargetY != this.targetY )
			{
			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.findHt)
		{
		//if the screen is past where it is now, start at the screen edge
		this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
		this.A = this.A > 0 ? this.findHt : -this.findHt;
		}
	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);
	newY = newY;
	if ( (this.A > 0 && newY > this.currentY) || (this.A < 0 && newY < this.currentY) )
		{
		//decide if it should be shown
		if (newY >= LstartPos)
			{document.getElementById('floatLayer').style.visibility = 'visible';}
		else
			{document.getElementById('floatLayer').style.visibility = 'hidden';}
		
		if (!isMac || 1==1)
			{
			if (newY + bannerOffset >= RstartPos)
				{document.getElementById('bannerLayer').style.visibility = 'visible';}
			else
				{document.getElementById('bannerLayer').style.visibility = 'hidden';}
			}
		
		if (ie4)
			{
			document.all.floatLayer.style.pixelTop = newY;
			if (!isMac || 1==1)
				{document.all.bannerLayer.style.pixelTop = newY + bannerOffset;}
			}
		if (ns4)
			{
			document.layers["floatLayer"].top = newY;
			if (!isMac || 1==1)
				{document.layers["bannerLayer"].top = newY + bannerOffset;}
			}
		if (ns6)
			{
			document.getElementById('floatLayer').style.top = newY + "px";
			if (!isMac || 1==1)
				{document.getElementById('bannerLayer').style.top = newY + bannerOffset + "px";}
			}
		
		//clip it
		/*
		//to make it look like it's going behind
		clipTop = LstartPos - newY;
		document.getElementById('floatLayer').style.clip = 'rect('+clipTop+'px 109px 486px 0px)';
		*/
		}
	}

function start()
	{
	if(ns6||ns4)
		{
		pageWidth = innerWidth;
		pageHeight = innerHeight;
		layerSetup();
		floatObject();
		}
	else if(ie4)
		{
		//document.body.???? doesn't work with doctype
		//pageWidth = document.body.clientWidth;
		//pageHeight = document.body.clientHeight;
		pageWidth = document.documentElement.clientWidth;
		pageHeight = document.documentElement.clientHeight;
		layerSetup();
		floatObject();
		}
	}


/*
<div id="floatLayer" style="position:absolute; width:109px; height:403px; z-index:100; left: 0px; top: 0px; margin: 0px; visibility: hidden; border: 1px none ##000000;">
	<div style="position:absolute; left: 0; top: 0; padding-top:19px; z-index: 2;"><cfinclude template="#VARIABLES.DirectoryRoot#Common/_Menu.cfm"></div>
	<div style="position:absolute; left: 0; top: 0; width: 109; height: 403; z-index: 1;"><img src="/Images/ScrollingMenuCorners.gif"></div>
</div>
*/