String position = $element.css("position", true);
if ("static".equals(position)) {
$element.get(0).getStyle().setPosition(Position.RELATIVE);
}
Offset curOffset = $element.offset();
String curCSSTop = $element.css("top", true);
String curCSSLeft = $element.css("left", true);
long curTop = 0;
long curLeft = 0;
if (("absolute".equals(position) || "fixed".equals(position)) && ("auto".equals(curCSSTop) || "auto".equals
(curCSSLeft))) {
Offset curPosition = $element.position();
curTop = curPosition.top;
curLeft = curPosition.left;
} else {
try {
curTop = Long.parseLong(curCSSTop);