﻿/*
Javascript to Get or set current Caret position (cursor location) in textarea/input, to get selected value under textarea/input and replace selected value.
author: Vipul Limbachiya
http://vipulilmbachiya.com
*/

/* 
 * This program is free software. It comes without any warranty, to the extent permitted by applicable law. 
 * You can redistribute it and/or modify it without any terms.
 * Save developers, use Firefox http://firefox.com
*/

/*
    $textArea.GetCaretPos(element) -> Returns no as current cursor position at characters
    
    $textArea.SetCaretPos(element, position) -> Sets cursor position to mentioned character index
    
    $textArea.GetSelectedVal(element) -> Returns text selected value
    
    $textArea.ReplaceSelectedVal(element,text) -> Replaces selected text with text supplied
*/

eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('5 $p={r:c(1){5 b=0;3(f.d){1.j();5 2=f.d.i();2.l(\'k\',-1.4.h);b=2.6.h}e 3(1.7||1.7==\'0\'){b=1.7}o b},q:c(1,9){3(1.a){1.j();1.a(9,9)}e 3(1.m){5 2=1.m();2.s(v);2.t(\'k\',9);2.l(\'k\',9);2.u()}},x:c(1){5 8="";3(1.a){8=1.4.g(1.7,1.n)}e{8=f.d.i().6}1.j();o 8},w:c(1,6){5 8="";3(1.a){1.4=(1.4.g(0,1.7)+6+1.4.g(1.n,1.4.h))}e{f.d.i().6=6}}};',34,34,'|elm|curRange|if|value|var|text|selectionStart|selectedText|position|setSelectionRange|currentPos|function|selection|else|document|substring|length|createRange|focus|character|moveStart|createTextRange|selectionEnd|return|textArea|SetCaretPos|GetCaretPos|collapse|moveEnd|select|true|ReplaceSelectedVal|GetSelectedVal'.split('|'),0,{}))
