/*
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
*/
//Enter "frombottom" or "fromtop"
var verticalpos="frombottom"
if (!document.layers)
document.write('</div>')
function JSFX_FloatTopDiv()
{
var startX = 3,
startY = 150;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x;this.style.top=y;};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopDiv();
</script>
<html>
<head>
<style>
#sc {
position:absolute;
left:0;top:0;
height:100px;width:100px;
background:lavenderblush;
}
#multi {
height:2000px;
}
</style>
<script>
var gTop=null;
var gTimer=null;
function scSlide(){
var bsc = document.body.scrollTop;
var sc = document.getElementById('sc');
var n = parseInt(sc.style.top);
if (!n){ n = 0; }
var speed = 20;
var dir = n > bsc?-1:1; //-1 = go up, 1 = go down
sc.style.top = (Math.abs(n-bsc) > 200)
?(bsc+dir*-200)+'px'
:sc.style.top = (n+dir*speed)+'px';
if ((parseInt(sc.style.top) - bsc)*dir > 0){
sc.style.top = bsc+'px';
}
if (n==bsc){
return;
}
if (gTimer){clearTimeout(gTimer);}
gTimer=setTimeout(function(){scSlide();},15);
}
function scf(){
var sc = document.getElementById('sc');
var n = parseInt(sc.style.top);
if (!n){ n = 0; }
if (n!=document.body.scrollTop){
scSlide();
}
setTimeout(function(){scf();},500);
}
window.onload=function(){ scf();}
</script>
</head>
<body>
<div id="sc">
<a href="#">Home</a><br />
<a href="#">Contents</a><br />
<a href="#">Links</a><br />
</div>
<div id="multi"></div>
</body>
</html>