<script type="text/javascript">
  var activeImage = null;
  var lastXY = null;
  var stepX = 1;
  var stepY = 1;
  
  document.onmouseup = mouseUp;
  document.onmousemove = mouseMove;

  function mousePos(evt)
  {
    //treść funkcji mousePos
  }

  function startScaling(obj)
  {
    if(!obj) return;
    activeImage = obj;
    lastXY = {x:0, y:0};
  }

  function mouseUp(evt)
  {
    activeImage = null;
  }

  function mouseMove(evt)
  {
    if(activeImage){
      var currXY = mousePos(evt);
      if(currXY.x > lastXY.x) activeImage.width += stepX;
      else if(currXY.x < lastXY.x) activeImage.width -= stepX;
      if(currXY.y < lastXY.y) activeImage.height -= stepY;
      else if(currXY.y > lastXY.y) activeImage.height += stepY;
      lastXY = currXY;
      return false;
    }
  }
</script>