
    var wnum = 0

    pop1      = '<a HREF=javascript:popUpWindow('
    pop2      = ',"med","resize","scroll")>'
    pop2b     = ',"big","resize","scroll")>'
    lnkPriv  = pop1 + '"p_priv.html"' + ',"sml","","")>'
    lnkFAQ   = pop1 + '"p_faq.html"'  + pop2
    lnkLink  = pop1 + '"p_links.html"'+ pop2
    lnkNewsL = pop1 + '"p_n030129.html"' + pop2b
    lnkNewsT = 'Jan 29: DNAsign launched web site ..'
    lnkLog   = pop1 + '"p_log.html"'  + pop2

    function popUpWindow(pg,w,r,s) {
	var sz = ''
	if(w == 'sml' )   { sz =  'width=250,height=320' }
	if(w == 'med' )   { sz =  'width=340,height=420' }
	if(w == 'cntct' ) { sz =  'width=440,height=660' }
	if(w == 'big' )   { sz =  'width=600,height=700' }
	if(r == 'resize') { sz += ',resizable' }
	if(s == 'scroll') { sz += ',scrollbars=yes' }
	picWindow = window.open(pg,w,sz)
	picWindow.focus()
    }

function procTXT() {
    var t_in  = document.converter.txt.value
    var l_in  = t_in.length
    var t_out = ''
    var wrd   = ''
    var str   = ''

    wnum = 0
    if(l_in ==0) {
        document.converter.txt.value = "Enter text here! \n\nIt is amazing that with some effort, humans can read text randomized text (all letters in each word are randomized with only the first and last letter keeping their position).  \n\nClick Randomize"
    }
    else {
      for(i=0;i<l_in;i++) {
	asc = t_in.charCodeAt(i)
	if(asc <= 64) { 
		str += endWORD(wrd) + String.fromCharCode(asc)
		wrd = ''
	}
	else { wrd += String.fromCharCode(asc)}
      }
      str += endWORD(wrd)
      res = l_in + ' characters read and ' + wnum + ' words processed.'
      document.converter.dna.value = str 
      document.converter.res.value = res 
    }
}

function endWORD(w) {
    var l_w = w.length
    var a = w.charCodeAt(0)
    var ww  = ''

    if(l_w < 1) { return(ww) }
    ww = String.fromCharCode(a)
    if(l_w == 1) { return(ww) }

    ws = ''
    for(k=1;k<l_w-1;k++) {
	a = w.charCodeAt(k)
	ws += String.fromCharCode(a)
    }
    ww += scramLET(ws)

    a = w.charCodeAt(l_w -1)
    ww += String.fromCharCode(a)
    wnum += 1
    return(ww)
}


function scramLET(l) {
    var l_l = l.length 
    for(j=0;j<=l_l*2;j++) {
    	from   = Math.floor(l_l * Math.random())
    	to     = Math.floor(l_l * Math.random())
    	c_to   = l.charCodeAt(to)
    	c_from = l.charCodeAt(from)
    	ws = ''
    	for(k=0;k<=l_l-1;k++) {
		x = l.charCodeAt(k)
		if(k == from) { x = c_to }
		if(k == to  ) { x = c_from }
		ws += String.fromCharCode(x)
    	}
	l = ws
    }
    return(ws)
}


function scramTXT() {
    var t_in = document.converter.txt.value
    var l_in = t_in.length
    var t_out = ''
    if(l_in ==0) {
        document.converter.txt.value = "Enter text here!"
    }
    else {
      for(i=0;i<l_in;i++) {
	pos = (l_in - i - 1) 
	asc = t_in.charCodeAt(pos)
	t_out += String.fromCharCode(asc)
      }
        document.converter.dna.value = t_out
    }
}


