function getPosition(obj) { var leftPosition = 0; var topPosition = 0; do { topPosition += obj.offsetTop || 0; leftPosition += obj.offsetLeft || 0; obj = obj.offsetParent; } while (obj); return [leftPosition,topPosition]; } function setConvertBarPosition(element_id, e, action) { cursor = getPosition(e); if (action == false) { document.getElementById(element_id).style.display = 'none'; } else { document.getElementById(element_id).style.display = 'block'; document.getElementById(element_id).style.left = cursor[0]-(-20) + 'px'; document.getElementById(element_id).style.top = cursor[1] + 'px'; } //alert(cursor[0]); //alert(cursor[1]); }