Get the html object position of current cursor

Get the html object position of current cursor

pass the html object
eg: obj = document.getElementById("test");

var posX = getObj_Position_X(obj);
var posy = getObj_Position_Y(obj);


function getObj_Position_Y(oElement) //get the html object position
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function getObj_Position_X(oElement)
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetLeft;
oElement = oElement.offsetParent;
}
return iReturnValue;
}