//Delimited Column Extractor Tool (Javascript) is Copyright 2010 TextMechanic.com All Rights Reserved

function cleartext(){
document.form_colext.input.value = '';
document.form_colext.output.value = '';
document.form_colext.prefix.value = '';
document.form_colext.suffix.value = '';}

function reloadtext(){
document.form_colext.input.value = document.form_colext.output.value;
document.form_colext.output.value = '';}

function grabcolumn(){
if (document.form_colext.loop_output.checked == true){
var prefix = document.form_colext.prefix.value;
var suffix = document.form_colext.suffix.value;
var text = document.form_colext.input.value;
var outtext = document.form_colext.output.value;
text = text.replace(/\r/g,'');
outtext = outtext.replace(/\r/g,'');
text = text.split('\n');
outtext = outtext.split('\n');
var delim = document.form_colext.delimiter_is.value;
var col_num = document.form_colext.col_num.value - 1;
var out = new Array();
for (x = 0; x < text.length; x++){
text2 = text[x]; text3 = text2.split(delim);
col = text3[col_num];
if (col != undefined) col = col; else col = '';
outtext2 = outtext[x];
if (outtext2 != undefined) outtext2 = outtext2; else outtext2 = '';
out[x] = outtext2 + prefix + col + suffix;}
out2 = out.join('\n');
document.form_colext.output.value = out2;}
if (document.form_colext.loop_output.checked == false){
var text = document.form_colext.input.value;
var prefix = document.form_colext.prefix.value;
var suffix = document.form_colext.suffix.value;
text = text.replace(/\r/g,'');
text = text.split('\n');
var delim = document.form_colext.delimiter_is.value;
var col_num = document.form_colext.col_num.value - 1;
var out = new Array();
for (x = 0; x < text.length; x++){
text2 = text[x]; text3 = text2.split(delim);
col = text3[col_num];
if (col != undefined) col = col; else col = '';
out[x] = prefix + col + suffix;}
out2 = out.join('\n');
document.form_colext.output.value = out2;}}

function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();}