﻿/*
Floating Menu script-  Roy Whittle (http://www.javascript-fx.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use

This script was adapted from the above and requires the function getScrollXY()
*/

var divid = "divStayTopLeft";

function JSFX_FloatTopDiv()
{
	var floatingid = findControl(divid,"div")
	var floatingmovesteps = 15;
	var	ftlObj = ml(floatingid);
	
	var startX = 0,
	startY = 0;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	
	function ml(id)
	{
		var el=document.getElementById(id);
		
		var values = Array();
		values = getScrollXY();
		
		if(el != null && el != undefined)
		{
			
			el.x = values[0];
			
			if (verticalpos=="fromtop")
				el.y = values[1];
			else
			{
				//el.y = ns ? pageYOffset + innerHeight : values[1] + document.body.clientHeight;
				//el.y -= values[1];
			}
			
			return el;
		}
		
		return null
	}
	window.stayTopLeft = function ()
	{
		if(ftlObj != null && ftlObj != undefined)
		{
			var values = Array();
			values = getScrollXY();
			if (verticalpos=="fromtop")
			{
				var pY = values[1];
				ftlObj.y += (pY + startY - ftlObj.y)/floatingmovesteps;
			}
			else
			{
				var pY = values[1];
				ftlObj.y += (pY - startY - ftlObj.y)/floatingmovesteps;
			}
			ftlObj.style.left = ftlObj.x + "px";
			ftlObj.style.top = ftlObj.y + "px";
			setTimeout("stayTopLeft()", 10);
		}
	}
	
	stayTopLeft();
}