function new_inp(item) {

item = item.replace(/ /g,'')
item_array  = item.split("|");
inp=document.createElement('input') 

for(cx=0;cx < item_array.length ;cx++){ 
item_split  = item_array[cx].split("^");
inp.setAttribute(item_split[0], item_split[1]);
}

cell.appendChild(inp); 
row.appendChild(cell); 
tbo.appendChild(row); 

}

function table_head(head_array) {

row=document.createElement('tr');

for(cx=0;cx < head_array.length -1;cx++){ 

cell=document.createElement('td'); 
cont=document.createTextNode((head_array[cx])) 
cell.appendChild(cont); 
row.appendChild(cell); 
tbo.appendChild(row); 

}

tab.appendChild(tbo);
document.getElementById('main_table').appendChild(tab); 

}


function b_off(no_off) {

for (var i=0; i < 10 ; i++) {

var b_num = 'button_' + i

	if (document.getElementById(b_num)) {
	document.getElementById(b_num).disabled=false

		if (no_off.indexOf(i) < 0) {document.getElementById(b_num).disabled=true}
		
	}
}

return false

}


function check_deny(code_level) {if (top.user_function < code_level) {deny()}}


function ck_cookie() {if (c_ok < 0) {alert('You must Enable Cookies in your browser for the program to work correctly.')}}


function clear_body() {

top.body.document.open()
top.body.document.write('<html><head><style type="text/css" media="all" >@import "fnb.css";</style></head>')
top.body.document.write('<body><div class="c_r">Check the current period and set the correct date for posting.</div></body></html>')
top.body.document.close()

}


function clear_cookies() {

var c_ok
c_ok = w_c('lg','')
c_ok = w_c('pw','')
c_ok = w_c('speriod','')
c_ok = w_c('started','')

}


function d0(xxcknx) {

var xcknx = xxcknx.toString()
var len = xcknx.length
var dec = xcknx.indexOf('.') 
if (len == 0) {return '0'}
if (dec > 0) {return xcknx.substring(0,dec)}
return xcknx

}


function d2(xxcknx) {

var xcknx = xxcknx.toString()
var len = xcknx.length
var dec = xcknx.indexOf('.') 

if (len == 0) {return xcknx}
if (dec < 0) {return xcknx + '.00'}
if (dec == (len -1)) {return xcknx + '00'}
if (dec == (len -2)) {return xcknx + '0'}

return xcknx

}


function days()  {     

document.write('Date&nbsp;')
document.write(top.d_ss)

}


function deny() {

var deny = 'User -' + top.user.toUpperCase() + '- does not have Write Access to this function. Any posting you do will not be saved.'  
alert(deny)
return false

}


function disable_sel(this_sel,set,nobutton){

sel_reset(this_sel,0)
var b = this_sel + '_b'
var a = this_sel.substring(0,1)

if (a == "i" ) { 
top.neck_i.document.getElementById(this_sel).disabled=set
top.neck_i.document.getElementById(b).disabled=set
top.neck_i.document.getElementById('find_it').disabled=set
top.neck_i.document.getElementById('go_it').disabled=set
}

if (a == "c" ) { 
top.neck_c.document.getElementById(this_sel).disabled=set
top.neck_c.document.getElementById(b).disabled=set
}

if (a == "v" ) { 
top.neck_v.document.getElementById(this_sel).disabled=set
top.neck_v.document.getElementById(b).disabled=set
}

}

function f_lab() {document.write('<label for="addon" accesskey = "o"><strong><u>O</u>ther Charges/Freight</strong></label>')}

function f10(num) {

if (num == 0) { return '          ' }
tmp_str = '          ' + d2(num)
var tmp_len  = tmp_str.length
var start_at = tmp_len - 10
return tmp_str.substring(start_at)

}


function find_bar(try_bar) {

if (typeof(top.i_barco[try_bar]) != "undefined") {

// get id # from barcode array, then record # from id array
sel_reset('i_sel',top.i_idxno[top.i_barco[try_bar]] +1)
top.body.add_item()
return true

} else {

return false

}

}


function find_item() {

var f_string = top.trim(top.neck_i.document.getElementById("find_it").value.toUpperCase())

if (f_string.length == 0) {return false}

// try bar code
if (find_bar(f_string) == true) {return false}

var i_found = new Array
var split_var = String.fromCharCode(31)

i_found[0] = '<option value="0">Select an Item Containing : ' +f_string + '</option>'
var k = 1
var marker = 0

	for (var i=0; i < top.i_xxx.length; i++) {

		if (top.i_xxx[i].indexOf(f_string) >= 0) {
		var c = top.i_xxx[i].split(split_var)
		i_found[k] ='<option value="' + c[11] + '">'+ c[0] +'</option>'
		k++
		marker = i
		}

	}

// nothing found
if (i_found.length < 2) {
alert('Nothing found containing : ' + f_string)
top.document.focus()
return false
}

// on find of one item, go to it
if (i_found.length == 2) {
sel_reset('i_sel',marker + 1)
top.body.add_item()
return false
}

var i_fs = i_found.join('')

// display in window
ifound = window.open('','ifound','height=450px,width=300px,resizable=no,scrollbars=no,menubar=no')
ifound.document.write('<html><head><style type="text/css" media="all" >@import "fnb.css";</style>')
ifound.document.write('<title>Items Containing : ' + f_string  + ' </title></head>')
ifound.document.write('<body style="background:#eee"><form>' )
ifound.document.write('<p><select size="20" class="sel" id="i_fsel">'  + i_fs + ' </select></p>')
ifound.document.write('<p><input accesskey="s"  type="button" class="b_mx" value="Select (alt-s)" onfocus=\'className="b_mx_f"\' onblur=\'className="b_mx"\' onclick="opener.body.f_return(document.getElementById(\'i_fsel\').value);window.close()" /></p>')
ifound.document.write('</form></body></html>')
ifound.document.close()
ifound.window.focus()

return false

}


function fn(cknx,options, del_frac, size) {

var temp = ""
var valid ="01234567890"
var dec = -1

// add on options
if (options != '') { valid = valid + options}

// take out dot 
if (del_frac == 'Y') {valid = valid.replace(/\./g,"") }

var f_dec = cknx.indexOf('.')

// on decimal #, drop everything to right
if ( valid.indexOf('.') < 0 && f_dec >= 0) { cknx = cknx.substring(0,f_dec)}

var len = cknx.length

	for (var i=0 ; i < len ; i++) {

		if (valid.indexOf(cknx.charAt(i)) >= 0) {

		// only 1 decimal
		if ( (dec > -1 && cknx.charAt(i) == ".") || ( dec != -1 && temp.length > dec + 2 ) ) {
		}else{
		temp+=cknx.charAt(i)

			// set decimal place
			if (cknx.charAt(i) == ".") {dec = i}
			
		}

	}

// take out"-" after ist loop
valid = valid.replace(/-/g,"")

// no leading 0
if (i == 0 && temp == '0') {temp = ""}

}

// check size of number -------
if (parseFloat(temp) > 9999999.99 || parseFloat(temp) < -9999999.99) {
alert('Numeric entry is too large.')
return 0
}

if (size == '8') {

	if (parseFloat(temp) > 99999.99 || parseFloat(temp) < -99999.99) {
	alert('Numeric entry is too large.')
	return 0
	}

}

return temp

}


function get_head_login() {
var cookie_array = document.cookie.split ("; ")

	// find the desired cookie:
	for (var i = 0; i < cookie_array.length; ++ i){
	var s_cookie = cookie_array[i].split ("=");

		if (s_cookie.length != 2){continue}
		if ('lg' == unescape (s_cookie [0])) {return unescape (s_cookie [1]) }
		
	}

return 'Not Found!'

}


function gopage(gopage) {

// check for in_use
if (top.in_use != '') {
var confirm_s = 'You are about to exit the : ' + top.in_use + ' section.\n\nIf you do you will loose the entry that you have not posted.\n\nIs this what you want to do?'

	if (! confirm(confirm_s)) { return false}

}

top.go_page = '/' + gopage

if (gopage != '') { 

var this_cell = top.head.document.getElementById('desc_c')

	if (gopage == 'invoice.html')  {this_cell.childNodes[0].nodeValue='Create an Invoice'}
	if (gopage == 'accounts.html') {this_cell.childNodes[0].nodeValue='Customer/Client Accounts'}
	if (gopage == 'ar.html')       {this_cell.childNodes[0].nodeValue='Post Accounts Receivable'}
	if (gopage == 'items.html')    {this_cell.childNodes[0].nodeValue='Inventory/Billing Items'}
	if (gopage == 'vendors.html')  {this_cell.childNodes[0].nodeValue='Vendors'}
	if (gopage == 'purchase.html') {this_cell.childNodes[0].nodeValue='Enter Purchases of Inventory'}
	if (gopage == 'system.html')   {this_cell.childNodes[0].nodeValue='System Functions'}

	// set a special from for system functions
	if (gopage == 'system.html')   {top.head.document.getElementById('from').value='system_'}

top.ori_item = 'nogo'
top.ori_cust = 'nogo'
top.ori_vend = 'nogo'
top.in_use   = ''        
submit_r_fresh()

}

}


function h(h) {

alert(top.h_array[h])
return false

}


function help() {

var _help
_help = window.open("","help","height=525,width=750,resizable=yes,scrollbars=yes,menubar=yes")
_help.location.href="help.html"
_help.window.focus()
return 

}


function i5(num) {

if (num == 0) { return '     ' }

tmp_str = '          ' + num
var tmp_len  = tmp_str.length
var start_at = tmp_len - 5
return tmp_str.substring(start_at)

}


function js_r_close() {

top.creport.document.write('</pre></body></html>')
top.creport.document.close()

}


function js_r_start(title) {

top.creport.document.write('<html><head><title>' + title + '</title>\n')
top.creport.document.write('<style type="text/css" media="print"> .noprint {display : none}</style></head>\n')
top.creport.document.write('<body onunload="opener.reset_all()">\n')
top.creport.document.write("<input accesskey ='c' type='button' VALUE='Close (alt-c)' onclick='window.close()' class='noprint'>\n")
top.creport.document.write("<input accesskey ='p' type='button' VALUE='Print (alt-p)' onclick='window.print()' class='noprint'>\n")
top.creport.document.write('<pre style="media: all ; font-size:9pt; font-family:monospace">\n')

}


function kind(which_kind) {

var this_cell = top.body.document.getElementById('head_note')
this_cell.childNodes[0].nodeValue=which_kind

}

function kd(e) {

var code
var targ;
	
if(!e) {var e = window.event}

// key code
if (e.keyCode) {code = e.keyCode
} else {
if (e.which) {code = e.which}
}

// type of field
if (e.target) {targ = e.target}
if (e.srcElement) {targ = e.srcElement}
if (targ.nodeType == 3) {targ = targ.parentNode}


// reject key press
if (((code == 8) && targ.type != 'text' && targ.type != 'textarea')  || code == 116 )  {
return false 
} else {
return true
}
 
}


function legal(s) {

if (s.search(/[\\\"|`^<>;\x1F]/) != -1) {return false}
return true

}


function lj(str,len) {

return (str + '                              ').substring(0,len)

}


function logout() {

top.window.close()
clear_cookies()

}


function make_cust() {

var split_var = String.fromCharCode(31)
var l = top.c_xxx.length
var a = new Array
var b = new Array

	for (var i = 0; i < l ; i++) {
	var c = top.c_xxx[i].split(split_var)
	a[i] = c[0]
	b[c[12]]=i
	}

top.c_names  = a
top.c_idxno  = b
make_cust2()

}


function make_cust2() {

var split_var = String.fromCharCode(31)
top.c_ss = top.c_names.join('</option><option>')

if (top.c_names.length > 0) {
top.c_ss = '<select id="c_sel"><option>Select an Account</option><option>' + top.c_ss + '</option></select>'
} else {
top.c_ss = '<select id="c_sel"><option>Select an Account</option></select>'
}

}


function make_cust3() {

var split_var = String.fromCharCode(31)
var l = top.c_xxx.length
var b = new Array

	for (var i = 0; i < l ; i++) {
	var c = top.c_xxx[i].split(split_var)
	b[c[12]]=i
	}

top.c_idxno  = b

}


function make_date() {

top.selected_day = 0
var mn = new Date().getMonth() + 1
mn = mn + ''

if (mn.length == 1) { mn = '0' + mn}
  
var da = new Date().getDate()

da = da + ''

if (da.length == 1) { da = '0' + da}

var yr = new Date().getFullYear()
yr = ' ' + yr
yr = yr.substring(3)
var today = mn + '/' + da + '/' + yr
top.d_ss = '<select class="sel4" id="d_sel" onchange="set_day()">'
    
	for (var d_sc=0; d_sc < top.d_xx.length ; d_sc++) {
	top.d_ss = top.d_ss + '<option '

		if ( top.d_xx[d_sc] == today) { top.selected_day = d_sc}
		top.d_ss = top.d_ss + 'value="' + top.d_xx[d_sc] + '">'+ top.d_xx[d_sc]+'</option>'
		}

	top.d_ss = top.d_ss + '</select>'

	}


function make_item() {

var split_var = String.fromCharCode(31)
var l = top.i_xxx.length
var a = new Array
var b = new Array
var x = new Array

	for (var i = 0; i < l ; i++) {
	var c = top.i_xxx[i].split(split_var)
	a[i] = c[0]
	b[c[11]]=i
	x[c[9]]=c[11]	
	}	
	
top.i_names  = a
top.i_idxno  = b
top.i_barco  = x
make_item2()

}


function make_item2() {

var split_var = String.fromCharCode(31)
top.i_ss = top.i_names.join('</option><option>')

if (top.i_names.length > 0) {
top.i_ss = '<select id="i_sel"><option>Select an Item</option><option>' + top.i_ss + '</option></select>'
} else {
top.i_ss = '<select id="i_sel"><option>Select an Item</option></select>'
}

}


function make_item3() {

var split_var = String.fromCharCode(31)
var l = top.i_xxx.length
var b = new Array

	for (var i = 0; i < l ; i++) {
	var c = top.i_xxx[i].split(split_var)
	b[c[11]]=i
	}

top.i_idxno  = b

}


function make_vend() {

var split_var = String.fromCharCode(31)
var l = top.v_xxx.length
var a = new Array
var b = new Array

	for (var i = 0; i < l ; i++) {
	var c = top.v_xxx[i].split(split_var)
	a[i] = c[0]
	b[c[2]]=i
	}

top.v_names  = a
top.v_idxno  = b
make_vend2()

}


function make_vend2() {

var split_var = String.fromCharCode(31)
top.v_ss = top.v_names.join('</option><option>')

if (top.v_names.length > 0) {
top.v_ss = '<select id="v_sel"><option>Select a Vendor</option><option>' + top.v_ss + '</option></select>'
} else {
top.v_ss = '<select id="v_sel"><option>Select a Vendor</option></select>'
}

}


function make_vend3() {

var split_var = String.fromCharCode(31)
var l = top.v_xxx.length
var b = new Array

	for (var i = 0; i < l ; i++) {
	var c = top.v_xxx[i].split(split_var)
	b[c[2]]=i
	}

top.v_idxno  = b

}



function nc_sel() {

top.neck_c.document.open()
var w = ''
w += '<html><head>'
w += '<script type="text/javascript">function kd(e) {var code; if(!e) {var e = window.event}; if (e.keyCode) {code = e.keyCode} else {code = e.which};if (code == 8  || code == 116 )  {return false ;} else {return true;}; }</script>'
w += '<style> .x  {width: 100px; font: 12px verdana, arial, sans-serif; background:#fff; color:#000; margin: 1px 0px 0px 0px; padding: 0; text-align: left;}'
w += '.b_s {width: 60px;}'
w += '.b_s_f {background-color:#ff6;width: 60px;}'
w += '</style></head><body onkeydown="return kd(event);">'
w += '<table><tr><td class="x">'
w += '&nbsp;<label for="c_sel" accesskey = "a">Account (alt-a)</label>'
w += '</td><td>'
top.neck_c.document.write(w)
top.neck_c.document.write(top.c_ss)
w = ''
w += '&nbsp;<input type="button" id="c_sel_b" class="b_s" onclick="top.body.add_cust();top.body.try_focus()" value="Select" onfocus=\'className="b_s_f"\' onblur=\'className="b_s"\' />'
w += '</td></tr></table>'
w += '</body></html>'
top.neck_c.document.write(w)
top.neck_c.document.close()
return false

}


function ni_sel() {

top.neck_i.document.open()
var w = ''
w += '<html><head>'
w += '<script type="text/javascript">function kd(e) {var code; if(!e) {var e = window.event}; if (e.keyCode) {code = e.keyCode} else {code = e.which};if (code == 8  || code == 116 )  {return false ;} else {return true;}; }</script>'
w += '<style> .x  {width: 100px; font: 12px verdana, arial, sans-serif; background:#fff; color:#000; margin: 1px 0px 0px 0px; padding: 0; text-align: left;}'
w += '.xx {font: 12px verdana, arial, sans-serif; background:#fff; color:#000; margin: 1px 0px 0px 0px; padding: 0; text-align: left;}'
w += '.b_s {width: 60px;}'
w += '.b_s_f {background-color:#ff6;width: 60px;}'
w += '.b_m {width: 75px;}'
w += '.b_m_f {background-color:#ff6;width: 75px;}'
w += '.lj {background-color:#fff;}'
w += '.ljf {background-color:#ff6;}'
w += '</style></head><body onkeydown="return kd(event);">'
w += '<table><tr><td class="x">'
w += '&nbsp;<label for="i_sel" accesskey = "i">Item (alt-i)</label>'
w += '</td><td class="xx">'
top.neck_i.document.write(w)
top.neck_i.document.write(top.i_ss)
w = ''
w += '&nbsp;<input type="button" id="i_sel_b" class="b_s" onclick="top.body.add_item();top.body.try_focus()" value="Select" onfocus=\'className="b_s_f"\' onblur=\'className="b_s"\' />'
w += '&nbsp;&nbsp;Find (alt-f)&nbsp;<input accesskey="f" type="text" name="find_it" id="find_it" size="9" maxlength="25" onfocus=\'className="ljf"\' onblur=\'className="lj"\'  /> '
w += '<input accesskey="g" id="go_it" type="button" class="b_m" value="Go (alt-g)" onclick="top.find_item()" onfocus=\'className="b_m_f"\' onblur=\'className="b_m"\' />'
w += '</td></tr></table>'
w += '</body></html>'
top.neck_i.document.write(w)
top.neck_i.document.close()
return false

}


function note_box() {document.write('<strong><u>N</u>otes</strong>')}


function nv_sel() {

top.neck_v.document.open()
var w = ''
w += '<html><head>'
w += '<script type="text/javascript">function kd(e) {var code; if(!e) {var e = window.event}; if (e.keyCode) {code = e.keyCode} else {code = e.which};if (code == 8  || code == 116 )  {return false ;} else {return true;}; }</script>'
w += '<style> .x  {width: 100px; font: 12px verdana, arial, sans-serif; background:#fff; color:#000; margin: 1px 0px 0px 0px; padding: 0; text-align: left;}'
w += '.b_s {width: 60px;}'
w += '.b_s_f {background-color:#ff6;width: 60px;}'
w += '</style></head><body onkeydown="return kd(event);">'
w += '<table><tr><td class="x">'
w += '&nbsp;<label for="v_sel" accesskey = "v">Vendor (alt-v)</label>'
w += '</td><td>'
top.neck_v.document.write(w)
top.neck_v.document.write(top.v_ss)
w = ''
w += '&nbsp;<input type="button" id="v_sel_b" class="b_s" onclick="top.body.add_vend();top.body.try_focus()" value="Select" onfocus=\'className="b_s_f"\' onblur=\'className="b_s"\' />'
w += '</td></tr></table>00'
w += '</body></html>'
top.neck_v.document.write(w)
top.neck_v.document.close()
return false

}

function nz() {

top.neck_z.document.open()
var w = ''
w += '<html>'
w += '<head>'
w += '<script type="text/javascript">function kd(e) {var code; if(!e) {var e = window.event}; if (e.keyCode) {code = e.keyCode} else {code = e.which};if (code == 8  || code == 116 )  {return false ;} else {return true;}; }</script>'
w += '</head>'
w += '<body onkeydown="return kd(event);"><hr>'
w += '</body></html>'
top.neck_z.document.write(w)
top.neck_z.document.close()
return false

}


function ok() {

top.tail.document.open()
top.tail.document.write('<html><head></head>')
top.tail.document.write('<body style="background:#ddd;font:12px sans-serif"><div>&nbsp; Ok</div></body></html>')
top.tail.document.close()

}


function r_head(title,p,t_line) {

var right_now = new Date()
right_now = right_now.toString()
right_now = right_now.substring(0,right_now.indexOf(':') +3)

top.creport.document.write(lj(top.s_name,30) + title + rj('Page '+ p,30) + '<br />')
top.creport.document.write(lj(right_now,30)  + '                                      ' + rj('Period : ' + top.cur_mon,30) + '<br />')
top.creport.document.write('--------------------------------------------------------------------------------------------------' + '<br />')
top.creport.document.write(t_line + '<br />')
top.creport.document.write('--------------------------------------------------------------------------------------------------' + '<br />')

}


function rj(str,len) {

var tmp_str  = '                              ' + str
var tmp_len  = tmp_str.length
var start_at = tmp_len - len
return tmp_str.substring(start_at)

}


function round(rd) {

var add_on = .005

if (rd < 0) {add_on = -.005}
rd = Math.round((rd * 100)+add_on)/100
return rd

}


function sel_mon() {

var mon_array = ''

	for (var k = 1; k <13; k++){
	mon_array = mon_array + "<option "

		if ( parseFloat(top.speriod.substring(4,7)) == k) { mon_array = mon_array + " selected='selected' " }

	mon_array = mon_array + "value='"+k+"' >"+k+"</option>"
	
	}

document.write('&nbsp; Mon ')
document.write('<select id=sel_mon>')
document.write(mon_array)
document.write('</select>')

var yr_array = ''
var cur_year =parseFloat(top.speriod.substring(0,4))
var start_year = 2001
var stop_year  = 2051
  
  // assign limits to years
if (cur_year > 2000) {
start_year = cur_year -10
stop_year  = cur_year + 1
    
	if (start_year < 2001) { start_year = 2001 }    

}
  
	for (var k = start_year; k < stop_year; k++){
	yr_array = yr_array + "<option "

		if ( parseFloat(top.speriod.substring(0,4)) == k) { yr_array = yr_array + " selected='selected' " }

	yr_array = yr_array + "value='"+k+"' >"+k+"</option>"
	
	}

document.write('&nbsp; ')
document.write('Yr ')
document.write('<select id=sel_yr>')
document.write(yr_array)
document.write('</select>')

}


function sel_report() {

document.write('<p>Type &nbsp;')
document.write('<select id=sel_report>')
document.write('<option value="sum">Summary</option>')
document.write('<option value="ar">Transactions</option>')
document.write('<option value="pur">Purchases</option>')
document.write('<option value="gain">Gain/Loss</option>')
document.write('<option value="sales">Sales</option>')
document.write('<option value="inv_m">Items-Mon.</option>')
document.write('<option value="inv_y">Items-Year</option>')
document.write('<option value="act_m">Accounts-Mon.</option>')
document.write('<option value="act_y">Accounts-Year</option>')
document.write('</select></p>')

}


function sel_reset(which_one,which_index) {

var a = which_one.substring(0,1)

if (a == "i" ) {top.neck_i.document.getElementById(which_one).selectedIndex=which_index}

if (a == "c" ) {top.neck_c.document.getElementById(which_one).selectedIndex=which_index}

if (a == "v" ) {top.neck_v.document.getElementById(which_one).selectedIndex=which_index}

return false

}


function sel_reset_b(which_one,which_index) {

document.getElementById(which_one).selectedIndex=which_index
return false

}


function set_a(set) {

document.getElementById('action').value = set
return false

}


function set_day() {

var this_day = document.getElementById("d_sel").selectedIndex
top.selected_day = this_day

}


function set_r_period() {

var this_period = ''

if (document.getElementById('sel_mon').value < 10) {
this_period = document.getElementById('sel_yr').value + '0' + document.getElementById('sel_mon').value
}else{
this_period = document.getElementById('sel_yr').value + document.getElementById('sel_mon').value
}

document.getElementById('r_period').value = this_period
return false

}

function set_r_s_type() {

document.getElementById('r_s_type').value = document.getElementById('sel_report').value

}

function submit_r_fresh() {

// update form in head & submit
top.head.document.getElementById('s_c_lch').value = top.s_c_lch
top.head.document.getElementById('s_i_lch').value = top.s_i_lch
top.head.document.getElementById('s_v_lch').value = top.s_v_lch

var j = top.head.document.getElementById('r_fresh').elements.length
var inputs = ''
var name
var value

	for (var i = 0; i < j ; i++) {
	type  = top.head.document.getElementById('r_fresh').elements[i].type
	name  = top.head.document.getElementById('r_fresh').elements[i].name
	value = top.head.document.getElementById('r_fresh').elements[i].value
	inputs += '<input type="hidden" name="' + name + '" value="' + value + '"/>' + ' \n'
	}

top.tail.document.write('<html><body><form id="transfer" action="/cgi-bin/fnb.tcl" method="post">')
top.tail.document.write(inputs)
top.tail.document.write('</form></body></html>')
top.tail.document.close()
top.tail.document.getElementById("transfer").submit()
return false

}


function transfer(forx, which) {

var inputs = ''
var pattern = /^(text|hidden|checkbox)/
var j = document.getElementById(forx).elements.length
var type
var name

	for (var i = 0; i < j ; i++) {
	type = document.getElementById(forx).elements[i].type
	name = document.getElementById(forx).elements[i].name

		if (pattern.test(type) && name != '') {
    
			if (type != 'checkbox') {
			value = document.getElementById(forx).elements[i].value		
			inputs += '<input type="hidden" name="' + name + '" value="' + value + '"/>' + ' \n'
    
			} else {
    
			check = document.getElementById(forx).elements[i].checked
      
				if (check == true) {
				inputs += '<input type="hidden" name="' + name + '" value="Y"/>' + ' \n'
				}
	
			}
		}   
	}


if (which == 't') {
top.tail.document.write('<html><body><form id="transfer" action="/cgi-bin/fnb.tcl" method="post">')
top.tail.document.write(inputs)
top.tail.document.write('</form></body></html>')
top.tail.document.close()
top.tail.document.getElementById("transfer").submit()
} else {
top.creport.document.write('<html><body><form id="transfer" action="/cgi-bin/fnb.tcl" method="post">')
top.creport.document.write(inputs)
top.creport.document.write('</form></body></html>')
top.creport.document.close()
top.creport.document.getElementById("transfer").submit()
}

}


function trim(s) {

	// remove leading spaces and carriage returns  
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))  {
	s = s.substring(1,s.length);
	}

	// remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')){
	s = s.substring(0,s.length-1);
	}
  
return s;

}


function update_all() {

var split_var = String.fromCharCode(31)

// get the returning changed items
top.tail.read_tail_refresh()

// item
top.rework_i = 'N'

if (top.i_xx[0].length > 0) {

	for (var i=0; i < top.i_xx.length; i++) {
	var this_one = top.i_xx[i]
	var c = this_one.split(split_var)
	var this_id  = c[11]
	var new_name = c[0] 
	var new_bar  = c[9]

	update_item_2(this_one,this_id,new_name,new_bar)
	
	}

	if (top.rework_i == 'Y') {

	top.i_xxx.sort()
	top.i_names.sort()
	make_item2()
	make_item3()
	ni_sel()
	
	}

}

// cust
top.rework_c = 'N'

if (top.c_xx[0].length > 0) {

	for (var i=0; i < top.c_xx.length; i++) {
	var this_one = top.c_xx[i]
	var this_id  = this_one.substr(this_one.lastIndexOf(split_var)+1)
	var new_name = this_one.substr(0,this_one.indexOf(split_var))
	update_cust_2(this_one,this_id,new_name)
	}

	if (top.rework_c == 'Y') {

	top.c_xxx.sort()
	top.c_names.sort()
	make_cust2()
	make_cust3()
	nc_sel()
	
	}

}

// vend
top.rework_v = 'N'

if (top.v_xx[0].length > 0) {

	for (var i=0; i < top.v_xx.length; i++) {
	var this_one = top.v_xx[i]
	var this_id  = this_one.substr(this_one.lastIndexOf(split_var)+1)
	var new_name = this_one.substr(0,this_one.indexOf(split_var))
	update_vend_2(this_one,this_id,new_name)
	}

	if (top.rework_v == 'Y') {

	top.v_xxx.sort()
	top.v_names.sort()
	make_vend2()
	make_vend3()
	nv_sel()
	
	}

}

// go to selected page
top.ori_item  = 'nogo'
top.ori_cust  = 'nogo'
top.ori_vend  = 'nogo'

top.body.location.href=top.go_page

}


function update_cust() {

// get the return values
top.tail.cust_return() 
var split_var = String.fromCharCode(31)
var this_one = top.cust_return
var this_id  = this_one.substr(this_one.lastIndexOf(split_var)+1)
var new_name = this_one.substr(0,this_one.indexOf(split_var))

top.rework_c = 'N'

update_cust_2(this_one,this_id,new_name)

if (top.rework_c == 'Y') {

	top.c_xxx.sort()
	top.c_names.sort()
	make_cust2()
	make_cust3()
	nc_sel()
	top.body.ori_cust()
	
} else {

	top.body.ori_cust()

}

}


function update_cust_2(this_one,this_id,new_name) {

var split_var = String.fromCharCode(31)

if (typeof(top.c_idxno[this_id]) != "undefined") {

	var record = top.c_idxno[this_id]

	// check main array to see if name has changed and needs rework
	var ori_name = top.c_xxx[record].split(split_var)[0]

	if (ori_name != new_name) { top.rework_c = 'Y'}

	// replace in main array
	top.c_xxx[record] = this_one

	// regexp replace in options string
	var findx    = '<option>' + ori_name + '</option>'
	var replacex = '<option>' + new_name + '</option>'	    
	top.c_ss = top.c_ss.replace(findx , replacex)
	    
	// replace in name array
	top.c_names[record] = new_name
	    
} else {	
       
	// append for reworking
	top.c_xxx   = top.c_xxx.concat(this_one)
	top.c_names = top.c_names.concat(new_name)
	top.rework_c = 'Y'

}

top.ori_cust = this_id

}


function update_item() {

// get the return values
top.tail.item_return() 
var split_var = String.fromCharCode(31)
var this_one = top.item_return
var c = this_one.split(split_var)
var this_id  = c[11]
var new_name = c[0]
var new_bar  = c[9]

top.rework_i = 'N'

update_item_2(this_one,this_id,new_name,new_bar)

if (top.rework_i == 'Y') {

	top.i_xxx.sort()
	top.i_names.sort()
	make_item2()
	make_item3()
	ni_sel()
	top.body.ori_item()
	
} else {
        	
	top.body.ori_item()

}

}


function update_item_2(this_one,this_id,new_name,new_bar) {

var split_var = String.fromCharCode(31)

if (typeof(top.i_idxno[this_id]) != "undefined") {

	var record = top.i_idxno[this_id]

	// check main array to see if name has changed and needs rework
	var cc = top.i_xxx[record].split(split_var)
        var ori_name = cc[0]
        var ori_bar  = cc[9]

	if (ori_name != new_name) {top.rework_i = 'Y'}

	// replace in main array
	top.i_xxx[record] = this_one

	// regexp replace in options string
	var findx    = '<option>' + ori_name + '</option>'
	var replacex = '<option>' + new_name + '</option>'	    
	top.i_ss = top.i_ss.replace(findx , replacex)
	    
	// replace in name array
	top.i_names[record] = new_name
	    
		// change bar code
		if (ori_bar != new_bar) {

		delete top.i_barco[ori_bar]
		if (new_bar != '') {top.i_barco[new_bar] = this_id}
		
		}
	    
} else {	
       
	// append for reworking
	top.i_xxx   = top.i_xxx.concat(this_one)
	top.i_names = top.i_names.concat(new_name)
	top.rework_i = 'Y'

}

top.ori_item = this_id

}


function update_vend() {

// get the return values
top.tail.vend_return() 
var split_var = String.fromCharCode(31)
var this_one = top.vend_return
var this_id  = this_one.substr(this_one.lastIndexOf(split_var)+1)
var new_name = this_one.substr(0,this_one.indexOf(split_var))

top.rework_v = 'N'

update_vend_2(this_one,this_id,new_name)

if (top.rework_v == 'Y') {

	top.v_xxx.sort()
	top.v_names.sort()
	make_vend2()
	make_vend3()
	nv_sel()
	top.body.ori_vend()
	
} else {

	top.body.ori_vend()

}

}


function update_vend_2(this_one,this_id,new_name) {

var split_var = String.fromCharCode(31)

if (typeof(top.v_idxno[this_id]) != "undefined") {

	var record = top.v_idxno[this_id]

	// check main array to see if name has changed and needs rework
	var ori_name = top.v_xxx[record].split(split_var)[0]

	if (ori_name != new_name) { top.rework_v = 'Y'}

	// replace in main array
	top.v_xxx[record] = this_one

	// regexp replace in options string
	var findx    = '<option>' + ori_name + '</option>'
	var replacex = '<option>' + new_name + '</option>'	    
	top.v_ss = top.v_ss.replace(findx , replacex)
	    
	// replace in name array
	top.v_names[record] = new_name
	    
} else {	
       
	// append for reworking
	top.v_xxx   = top.v_xxx.concat(this_one)
	top.v_names = top.v_names.concat(new_name)
	top.rework_v = 'Y'

}

top.ori_vend = this_id

}


function w_c (cname, cvalue,sec)  {

var c_string = cname + "=" 
document.cookie = c_string
c_string = cname + "=" + cvalue 
document.cookie = c_string
return document.cookie.indexOf(c_string)

}


function lnpw() {

var lnpw = '<table class="pw"><tr><td class="rj">Account</td><td><input type="text" name = "lg" id="lg" size="10" maxlength="10" onfocus=\'className="ljf"\' onblur=\'className="lj"\'  /></td></tr>' +
'<tr><td class="rj">Password</td><td><input type="password" name="pw" id="pw"  size="10" maxlength="10" onfocus=\'className="ljf"\' onblur=\'className="lj"\'  /></td></tr>' + 
'<tr><td colspan="2"><input type="button" class="b_s" value="Login" onclick="startup()" /></td></tr></table>'
document.write(lnpw)

}


function startup() {

if (!document.getElementById) {
alert('This site is designed to work with modern Standards Compliant Browsers.\n\nYou will have to update your browser before you can access the working section of the site. ')
return false
}

if (screen.height < 768 || screen.width < 1024) {
alert('A minimum screen resolution of 1024 x 768 is required for the working section of the program.')
return false
}

if (document.cookie.indexOf('freenetbillingstarted') != -1) {
var confirm_s = 'You already have a Free Net Billing working window opened, or you did not properly log out of the system.\n\nIf you login again, any un-confirmed work in the open window will be lost.\n\nDo you want to continue?'

	if (! confirm(confirm_s)) { return false}

}

//  store  values in cookie
var c_ok
c_ok = w_c('lg',document.getElementById("lg").value)
c_ok = w_c('pw',document.getElementById("pw").value)
c_ok = w_c('speriod',' ')
c_ok = w_c('started','freenetbillingstarted')

if (c_ok < 0) {
alert('You must Enable Cookies in your browser before you can access the working section of the site. ')
return false
}

// clear the values
document.getElementById('lg').value = ''
document.getElementById('pw').value = ''
freenetbilling = window.open('','freenetbilling','height=690,width=1000,resizable=yes,scrollbars=no,menubar=no')
//freenetbilling = window.open('','freenetbilling')
freenetbilling.location.href='frame.html'
freenetbilling.window.focus()
return

}

