/*õäöü*/
//document.title = document.compatMode;
//Doctype is really not too important (in regards to JavaScript, and whatnot), and "document.compatMode" would probably have more relevance.
//It checks the doctype and returns either "BackCompat" or "CSS1Compat" and uses that to determine which box model to use.
floatX = 0;
floatY = 0;
layerwidth = 1;
layerheight = 1;
halign = "left";
valign = "top";
delayspeed = 1;
/*
floatX Defines the horizontal distance from the border. 
	positive numbers. 
floatY Defines the vertical distance from the border. 
	positive numbers. 
layerwidth Defines the width of the menu layer. 
	positive numbers. 
layerheight Defines the height of the menu layer. 
	positive numbers. 
halign Defines which border floatX should be counted from. 
	left
	center
	right. 
valign Defines which border floatY should be counted from. 
	top
	center
	bottom. 
delayspeed Defines the time delay before the layer's position is updated. 
	If set to 0 (zero) the layer will move to its correct position immediately. 
	If set to a value the layer will be slightly delayed before moving to its correct position.
	(Do not set to values beyond 3). 
*/
/*
   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 Christian Fecteau for modern browsers in Standards Mode
   http://forum.echoechoplus.com/showthread.php?s=&postid=46626#post46626
*/

function adjust()
{


	  /* ////////////
	 //  assign   //
	//////////// */

	var xs=0, ys=0;
	if (typeof(window.pageYOffset) == 'number')
	{
		ys = window.pageYOffset;
		xs = window.pageXOffset;
	}
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop))
	{
		ys = Number(document.body.scrollTop);
		xs = Number(document.body.scrollLeft);
	}
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
	{
		ys = Number(document.documentElement.scrollTop);
		xs = Number(document.documentElement.scrollLeft);
	}

	  /* ///////////////
	 //  calculate   //
	/////////////// */

	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 - lastY); }
		if (ys + floatY < lastY) { var dy = Math.abs(ys + floatY - 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 (!isNaN(lastX))
	{
		document.getElementById('floatlayer').style.left = lastX + 'px';
		lastX_ = lastX;
	}
	else
	{
		document.getElementById('floatlayer').style.left = lastX_ + 'px';
		lastX = lastX_;
	}
	if (!isNaN(lastY))
	{
		document.getElementById('floatlayer').style.top = lastY + 'px';
		lastY_ = lastY;
	}
	else
	{
		document.getElementById('floatlayer').style.top = lastY_ + 'px';
		lastY = lastY_;
	}

	// do it again
	window.setTimeout('adjust()',50);
}


function define()
{
	var wo=0, ho=0;
	if (typeof(window.innerWidth) == 'number')
	{
		wo = window.innerWidth;
		ho = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		wo = Number(document.documentElement.clientWidth);
		ho = Number(document.documentElement.clientHeight);
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		wo = Number(document.body.clientWidth);
		ho = Number(document.body.clientHeight);
	}
	if (halign == "left")   { floatX = ifloatX; }
	if (halign == "right")  { floatX = wo - ifloatX - layerwidth; }
	if (halign == "center") { floatX = Math.round(wo/2) - Math.round(layerwidth/2); }

	if (valign == "top")    { floatY = ifloatY; }
	if (valign == "bottom") { floatY = ho - ifloatY - layerheight; }
	if (valign == "center") { floatY = Math.round(ho/2) - Math.round(layerheight/2); }
}