Without a framework, determining the position of a DOM element can be tricky, as this element can be absolutely positioned, or embedded in another element with its own offset.
Write a function to traverse the element's parents all the way to the document root, and add up the top and left offset values, as a very basic implementation.
function MyPosX(node,x){
if (node.parentNode==document.body) return node.offsetLeft;
return x+MyPosX(node.parentNode.offsetLeft,x);
}
alert(MyPosX(document.getElementById('test'),0));
Please double check the parent pointers and boundary conditions. The above code is for illustration only.