(function(a){a.fn.selection=function(){var b,c,a,d;if(this[0].selectionStart==undefined){var f=document.selection;if(this[0].tagName.toLowerCase()!="textarea"){var e=this.val();a=f.createRange().duplicate();a.moveEnd("character",e.length);b=a.text==""?e.length:e.lastIndexOf(a.text);a=f.createRange().duplicate();a.moveStart("character",-e.length);c=a.text.length}else{a=f.createRange(),d=a.duplicate();d.moveToElementText(this[0]);d.setEndPoint("EndToEnd",a);b=d.text.length-a.text.length;c=b+a.text.length}}else b=this[0].selectionStart,c=this[0].selectionEnd;var g=this[0].value.substring(b,c);return{start:b,end:c,text:g}}})(jQuery)