function setPosition(r) {
  // create by uoon
  var store = {
    ram : {top : 0, left : 0, right : 0, bottom : 0},
    rom : {element: null, minWidth: 0, minHeight: 0, top : null, left : null, right : null, bottom : null
    }
  };

  for (var i in r) {store.rom[i] = r[i];}
  var element = document.getElementById(store.rom.element);
  if (!element) {
      alert("Please check the argument: 'element'.");
      return false;
  }
  for (i in store) {element[i] = store[i];}

  element.rom.move = function() {
    if (window.innerHeight) {
        var htmlTag = document.getElementsByTagName("html")[0];
        var topPage = window.pageYOffset;
        var leftPage = window.pageXOffset;
        var rightPage = leftPage + window.innerWidth - element.offsetWidth;
        if (htmlTag.scrollHeight > window.innerHeight) rightPage -= 17;
        var bottomPage = topPage + window.innerHeight - element.offsetHeight;
        if (htmlTag.scrollWidth > window.innerWidth) bottomPage -= 17;
        var browserHeight = window.innerHeight;
        var browserWidth = window.innerWidth;
    } else {
        if (document.documentElement && document.documentElement.clientWidth) {
            var topPage = document.documentElement.scrollTop;
            var leftPage = document.documentElement.scrollLeft;
            var browserHeight = document.documentElement.clientHeight;
            var browserWidth = document.documentElement.clientWidth;
        } else if (document.body) {
            var topPage = document.body.scrollTop;
            var leftPage = document.body.scrollLeft;
            var browserHeight = document.body.clientHeight;
            var browserWidth = document.body.clientWidth;
        }
        var rightPage = leftPage + browserWidth - element.offsetWidth;
        var bottomPage = topPage + browserHeight - element.offsetHeight;
    }

    if ((browserWidth < element.rom.minWidth) || (browserHeight < element.rom.minHeight)) element.style.display = "none";
    else element.style.display = "block";

    element.style.position = "absolute";

    if (element.rom.top != null) {
        var Condition = (Math.abs(topPage + element.rom.top - element.ram.top) < 2 || !element.firstTime);
        if (Condition) element.ram.top = topPage + element.rom.top;
        else element.ram.top += ((topPage + element.rom.top - element.ram.top) / 20);
        element.style.top = element.ram.top + "px";
    }
    if (element.rom.left != null) {
        var Condition = (Math.abs(leftPage + element.rom.left - element.ram.left) < 2 || !element.firstTime);
        if (Condition) element.ram.left = leftPage + element.rom.left;
        else element.ram.left += ((leftPage + element.rom.left - element.ram.left) / 20);
        element.style.left = element.ram.left + "px";
    }
    if (element.rom.right != null) {
        var Condition = (Math.abs(rightPage - element.rom.right - element.ram.right) < 2 || !element.firstTime);
        if (Condition) element.ram.right = rightPage - element.rom.right;
        else element.ram.right += ((rightPage - element.rom.right - element.ram.right) / 20);
        element.style.left = element.ram.right + "px";
    }
    if (element.rom.bottom != null) {
        var Condition = (Math.abs(bottomPage - element.rom.bottom - element.ram.bottom) < 2 || !element.firstTime);
        if (Condition) element.ram.bottom = bottomPage - element.rom.bottom;
        else element.ram.bottom += ((bottomPage - element.rom.bottom - element.ram.bottom) / 20);
        element.style.top = element.ram.bottom + "px";
    }
    element.firstTime = true;
    setTimeout("document.getElementById('"+element.id+"').rom.move()", 20);
  };
  element.rom.move();
};