function floatingStart() {
  if (brw) {
    var speed = 50; //少ないほどスクロール遅れが小さくなるけど、負荷は高くなる
    var x = 775;      //固定する横位置(左端からの距離)
    var y = 0;    //固定する縦位置(上端からの距離)
    var id = "floatingID"; //<div>に設定してあるID名
    var d = document;
    floatingObj = d.all ? d.all(id).style : (d.layers ? d.layers[id] : d.getElementById(id).style);
    floatingTimer = setInterval("floating(" + x + "," + y + ")", speed);
  }
}

var brw = document.all || document.layers || (document.getElementById && !window.opera);
var floatingTimer, floatingObj;

function floating(posX, posY) {
  if (document.all) {
    floatingObj.pixelLeft = document.body.scrollLeft + posX;
    floatingObj.pixelTop = document.body.scrollTop + posY;
  } else if (document.getElementById) {
    floatingObj.left = window.pageXOffset + posX + "px";
    floatingObj.top = window.pageYOffset + posY + "px";
  } else {
    floatingObj.left = window.pageXOffset + posX;
    floatingObj.top = window.pageYOffset + posY;
  }
}

function floatingToggle() {
  if (floatingTimer) {
    clearInterval(floatingTimer);
    floatingTimer = null;
    alert("位置の固定を解除しました");
  } else {
    floatingStart();
    alert("位置を固定しました");
  }
}

window.onload = floatingStart;//-->

