﻿rfloatX=-2;
rfloatY=98;
rlayerwidth=110;
rlayerheight=450;
rhalign="right";
rvalign="top";
rdelayspeed=1;

//http://www.poespoes.nl
// 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.
//http://www.poespoes.nl

NS6=false;
IE4=(document.all);
if (!IE4) {NS6=(document.getElementById);}
NS4=(document.layers);

function radjust() {
if ((NS4) || (NS6)) {
if (rlastX==-1 || rdelayspeed==0)
{
rlastX=window.pageXOffset + rfloatX;
rlastY=window.pageYOffset + rfloatY;
}
else
{
var rdx=Math.abs(window.pageXOffset+rfloatX-rlastX);
var rdy=Math.abs(window.pageYOffset+rfloatY-rlastY);
var rd=Math.sqrt(rdx*rdx+rdy*rdy);
var rc=Math.round(rd/10);
if (window.pageXOffset+rfloatX>rlastX) {rlastX=rlastX+rdelayspeed+rc;}
if (window.pageXOffset+rfloatX<rlastX) {rlastX=rlastX-rdelayspeed-rc;}
if (window.pageYOffset+rfloatY>rlastY) {rlastY=rlastY+rdelayspeed+rc;}
if (window.pageYOffset+rfloatY<rlastY) {rlastY=rlastY-rdelayspeed-rc;}
}
if (NS4){
document.layers['floatlayerR'].pageX = rlastX;
document.layers['floatlayerR'].pageY = rlastY;
}
if (NS6){
document.getElementById('floatlayerR').style.left=rlastX;
document.getElementById('floatlayerR').style.top=rlastY;
}
}
else if (IE4){
if (rlastX==-1 || rdelayspeed==0)
{
rlastX=document.body.scrollLeft + rfloatX;
rlastY=document.body.scrollTop + rfloatY;
}
else
{
var rdx=Math.abs(document.body.scrollLeft+rfloatX-rlastX);
var rdy=Math.abs(document.body.scrollTop+rfloatY-rlastY);
var rd=Math.sqrt(rdx*rdx+rdy*rdy);
var rc=Math.round(rd/10);
if (document.body.scrollLeft+rfloatX>rlastX) {rlastX=rlastX+rdelayspeed+rc;}
if (document.body.scrollLeft+rfloatX<rlastX) {rlastX=rlastX-rdelayspeed-rc;}
if (document.body.scrollTop+rfloatY>rlastY) {rlastY=rlastY+rdelayspeed+rc;}
if (document.body.scrollTop+rfloatY<rlastY) {rlastY=rlastY-rdelayspeed-rc;}
}
document.all['floatlayerR'].style.posLeft = rlastX;
document.all['floatlayerR'].style.posTop = rlastY;
} 
setTimeout('radjust()',50);
}

function rdefine()
{
if ((NS4) || (NS6)) 
{ 
if (rhalign=="left") {rfloatX=rifloatX};
if (rhalign=="right") {rfloatX=window.innerWidth-rifloatX-rlayerwidth-20};
if (rhalign=="center") {rfloatX=Math.round((window.innerWidth-20)/2)-Math.round(rlayerwidth/2)};
if (rvalign=="top") {rfloatY=rifloatY};
if (rvalign=="bottom") {rfloatY=window.innerHeight-rifloatY-rlayerheight};
if (rvalign=="center") {rfloatY=Math.round((window.innerHeight-20)/2)-Math.round(rlayerheight/2)};
}
if (IE4) 
{
if (rhalign=="left") {rfloatX=rifloatX};
if (rhalign=="right") {rfloatX=document.body.offsetWidth-rifloatX-rlayerwidth-20}
if (rhalign=="center") {rfloatX=Math.round((document.body.offsetWidth-20)/2)-Math.round(rlayerwidth/2)}
if (rvalign=="top") {rfloatY=rifloatY};
if (rvalign=="bottom") {rfloatY=document.body.offsetHeight-rifloatY-rlayerheight}
if (rvalign=="center") {rfloatY=Math.round((document.body.offsetHeight-20)/2)-Math.round(rlayerheight/2)}
}
}
