function getCursorPosition( ctrl ) {
var CaretPos = 0;
if ( document.selection ) {
ctrl.focus ();
var Sel = document.selection.createRange();
Sel.moveStart ('character', -ctrl.value.length);
CaretPos = Sel.text.length;
} else if ( ctrl.selectionStart || ctrl.selectionStart == '0' ) {
CaretPos = ctrl.selectionStart;
}
return CaretPos;
}