How can I get the current cursor position via javascript? I need it so I can insert a string at the current cursor position.

Please help!