function getPosition(target) {
var left = 0, top = 0;
do {
left += target.offsetLeft || 0;
top += target.offsetTop || 0;
target = target.offsetParent;
} while(target);
return {
left: left,
top: top
};
}