//Merge Text (Line by Line) (Javascript) is Copyright 2010 TextMechanic.com All Rights Reserved

function cleartext(){
document.tmerg.input1.value = '';
document.tmerg.input2.value = '';
document.tmerg.output.value = '';}

function reloadtextl(){
document.tmerg.input1.value = document.tmerg.output.value;
document.tmerg.output.value = '';}

function reloadtextr(){
document.tmerg.input2.value = document.tmerg.output.value;
document.tmerg.output.value = '';}

function mergetext(){
document.tmerg.output.value = 'Loading...';
var prex = document.tmerg.prefix.value;
var divd = document.tmerg.divider.value;
var sufx = document.tmerg.suffix.value;
var text1 = document.tmerg.input1.value;
var text2 = document.tmerg.input2.value;
var text3 = new Array();
text1 = text1.replace(/\r/g,'');
text2 = text2.replace(/\r/g,'');
text1 = text1.split('\n');
text2 = text2.split('\n');
if (text1.length > text2.length) len = text1.length; else len = text2.length;
for (var x = 0; x < len; x++){
if (text1[x] == undefined) text1a = ''; else text1a = text1[x];
if (text2[x] == undefined) text2a = ''; else text2a = text2[x];
text3[x] = prex + text1a + divd + text2a + sufx;}
text3 = text3.join('\n');
document.tmerg.output.value = text3;}

function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();}