//Dynamic Text Counter (Javascript) is Copyright TextMechanic.com All Rights Reserved

function cleartext(){
document.form_count.input.value = '';
document.form_count.char_count.value = '0';
document.form_count.c.value = '0';
document.form_count.s.value = '0';
document.form_count.line_count.value = '0';
document.form_count.custom_count.value = '0'}

function linecnt(){
if(document.form_count.input.value.length > 0){
f=document.form_count;
f.line_count.value=f.input.value.split(/\n/).length;}
else document.form_count.line_count.value = '0';}

function sentcnt(){
var sentcont = document.form_count.input.value;
sentcont = sentcont.replace(/\r/g,'');
sentcont = sentcont.replace(/  /g,' ');
sentcont = sentcont.replace(/ \n/g,'\n');
sentcont = sentcont + '\n';
sentcont1 = sentcont.split('. ').length -1;
sentcont1b = sentcont.split('.\n').length -1;
sentcont2 = sentcont.split('! ').length -1;
sentcont2b = sentcont.split('!\n').length -1;
sentcont3 = sentcont.split('? ').length -1;
sentcont3b = sentcont.split('?\n').length -1;
sentcontout = sentcont1 + sentcont1b + sentcont2 + sentcont2b + sentcont3 + sentcont3b;
document.form_count.s.value = sentcontout;}

function cuscnt(){
if (document.form_count.case_sen.checked == true){var char=document.form_count.custom_count_query.value; var z=document.form_count.input.value;}
else {var char=document.form_count.custom_count_query.value.toLowerCase(); var z=document.form_count.input.value.toLowerCase();}
var charlen = char.length;
a=z.split(char);
if (charlen > 0) carcnt = a.length-1; else carcnt = "0";
document.form_count.custom_count.value = carcnt;}

function tolcnt(input,x){
if (document.form_count.no_spaces.checked == true){
var y=input.value;
var spacecnt=y.split(' ').length;
a=y.replace(/\n/g,'');
b=a.replace(/\r/g,'');
z=b.length-spacecnt;
x.value=z+1;} else{
var y=input.value;
a=y.replace(/\n/g,'');
b=a.replace(/\r/g,'');
z=b.length;
x.value=z;}}

function wrdcnt(input,x){
var y=input.value;
var r = 0;
a=y.replace(/\s/g,' ');
a=a.split(' ');
for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}
x.value=r;}

function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();}