getPositionWhen a layer is inside another layer, it's style.left and style.top positions can both be '0' but the layer itself can be 500 pixels away from the actual margin. These functions will return the true offset.
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s). The script is yours!!!