//Add Prefix and/or Suffix to Each Text Line (Javascript) is Copyright 2010 TextMechanic.com All Rights Reserved

function linecnt(){
if(document.form_area.input.value.length > 0){
f=document.form_area;
f.line_count.value=f.input.value.split(/\n/).length;}
else document.form_area.line_count.value = '0';}

function addpresufx(){
document.form_area.output.value = 'Loading...';
var prfx = document.form_area.prefix.value;
var sufx = document.form_area.suffix.value;
var text = document.form_area.input.value;
text = text.replace(/\r/g,'');
text = text.replace(/\n\n\n\n/g,'\n \n \n \n');
text = text.replace(/\n\n\n/g,'\n \n \n');
text = text.replace(/\n\n/g,'\n \n');
text = text.split(/\n/);
text.unshift('');
text.push('');
text = text.join(sufx + '\n' + prfx);
text = text.split('\n');
text = text.slice(1,text.length-1);
text = text.join('\n');
document.form_area.output.value = text;}

function cleartext(){
document.form_area.input.value = '';
document.form_area.output.value = '';}

function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();}