//Add a Prefix and/or Suffix to Text - (Line by Line) (Javascript) is Copyright 2008 My-i-p.com

function linecnt(){
if(document.form_area.input.value.length > 0){
var lc = document.form_area;
lc.line_count.value = lc.input.value.split(/\n/).length;}
else document.form_area.line_count.value = '0';}

function inputcontrol(){
if (document.form_area.count_warning.value != 'Been warned!'){
var inputtext = document.form_area.input.value;
var len = inputtext.split('\n').length;
if (len > 10000) {var overload = confirm("WARNING: You have entered over 10,000 lines of text which could slow down or even lock-up your computer! Please click \"Cancel\" to stop text loading or click \"OK\" to proceed with text loading at your own risk. After clicking \"OK\" no more text line overload warnings will be issued and \"Been warned!\" will display next to the line count display.");
if (overload == true) {document.form_area.count_warning.value = 'Been warned!'; document.form_area.input.value = inputtext;} if (overload == false) {document.form_area.input.value = 'Text loading cancelled.'; document.form_area.output.value = ''; document.form_area.count_warning.value = 'Warning issued.';}}}}

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();}
