
floatX = 29;
floatY = 20;
logoHeight = 176;
layerwidth = 100;
layerheight = 130;
halign = "left";
valign = "top";
delayspeed = -5;

/*
   This script is copyright (c) Henrik Petersen, NetKontoret
   Feel free to use this script on your own pages as long as you do not change it.
   It is illegal to distribute the script as part of a tutorial / script archive.
   Updated version available at: http://www.echoecho.com/toolfloatinglayer.htm
   This comment and the 4 lines above may not be removed from the code.
*/

/*
   Modified by cfec on October 13th 2004 for a static logo on top of the page and above the menu:
   http://forum.echoechoplus.com/showthread.php?s=&threadid=7330
   To have the script act as originally, simply set 'logoHeight' to 0 and 'delayspeed' to 1
*/


NS6 = false;
IE4 = (document.all);
if (!IE4) { NS6 = (document.getElementById); }
NS4 = (document.layers);

function adjust()
{


	  /*////////////
	 //  assign  //
	////////////*/

	if (IE4)
	{
		var xs = document.body.scrollLeft;
		var ys = document.body.scrollTop;
	}
	else
	{
		var xs = window.pageXOffset;
		var ys = window.pageYOffset;
	}


	  /*///////////////
	 //  calculate  //
	///////////////*/

	if (ys < logoHeight)
	{
		lastY = floatY + logoHeight;
		lastX = floatX;
	}
	else if (lastX==-1 || delayspeed==0)
	{
		lastX = xs + floatX;
		lastY = ys + floatY;
	}
	else
	{
		var dx = Math.abs(xs + floatX - lastX);
		if (ys + floatY > lastY) { var dy = Math.abs(ys + floatY + logoHeight - lastY); }
		if (ys + floatY < lastY) { var dy = Math.abs(ys + floatY - logoHeight - lastY); }
		var d = Math.sqrt(dx * dx + dy * dy);
		var c = Math.round(d/10);
		if (xs + floatX > lastX) { lastX = lastX + delayspeed + c; }
		if (xs + floatX < lastX) { lastX = lastX - delayspeed - c; }
		if (ys + floatY > lastY) { lastY = lastY + delayspeed + c; }
		if (ys + floatY < lastY) { lastY = lastY - delayspeed - c; }
	}


	  /*///////////////
	 //     move    //
	///////////////*/

	if (IE4)
	{
		document.all['floatlayer'].style.posLeft = lastX;
		document.all['floatlayer'].style.posTop = lastY;
	}
	else if (NS4)
	{
		document.layers['floatlayer'].pageX = lastX;
		document.layers['floatlayer'].pageY = lastY;
	}
	else if (NS6)
	{
		document.getElementById('floatlayer').style.left = lastX;
		document.getElementById('floatlayer').style.top = lastY;
	}


	// do it again
	setTimeout('adjust()',50);
}



function define()
{
	if (IE4)
	{
		var wo = document.body.offsetWidth;
		var ho = document.body.offsetHeight;
	}
	else if (NS4 || NS6)
	{
		var wo = window.innerWidth;
		var ho = window.innerHeight;
	}
	if (IE4 || NS4 || NS6) 
	{ 
		if (halign == "left")   { floatX = ifloatX; }
		if (halign == "right")  { floatX = wo - ifloatX - layerwidth - 20; }
		if (halign == "center") { floatX = Math.round((wo-20)/2) - Math.round(layerwidth/2); }

		if (valign == "top")    { floatY = ifloatY; }
		if (valign == "bottom") { floatY = ho - ifloatY - layerheight; }
		if (valign == "center") { floatY = Math.round((ho-20)/2) - Math.round(layerheight/2); }
	}
}


