function getRangeById(id) {
var word = '';
if (document.selection) {
o = document.selection.createRange(); if (o.text.length > 0) word = o.text;
} else {
o = document.getElementById(id); p1 = o.selectionStart; p2 = o.selectionEnd;
if (p1 || p1 == '0') { if (p1 != p2) word = o.value.substring(p1, p2); }
}
return word;
}