/*
	Copyright © 2003 Specialized Systems. All rights reserved.

	This library constructs a global object 'lib' that is
	compatible with other scripts b/c the variables' scope
	is contained within the lib object. The goal is to keep
	this include universally includable without conflicting
	with global variables (and function references) of local
	scripting within html documents.

	When extracting a method or function from this library,
	you may encounter errors b/c it may query an attribute
	of the lib object. You will need to change the environment
	scope of lib.attribute variables.

*/
//»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
//---------------------------------------------------------------------------
//	JavaScript Library Object.
//
//	Usage:
//
//		ie4	= true if Internet Explorer 4+
//		ns4	= true if Netscape Navigator 4+
//
//		lib_Lib()
//			Library object constructor.
//			lib = new lib_Lib()
//
//		void init()
//			Used to initialize library routines.
//
//		void protect()
//			lib.protect()	: protects page from right-clicks.
//
//		void deprotect()
//			lib.deprotect()	: deprotect page from right-clicks.
//
//		void write(html)
//			lib.write(str)	: Write a String into
//
//		void find(string)
//			lib.find(str): finds string in HTML and highlights.
//
//		string parseTime12(arg)
//			Returns 12 hour time from dateobj.getTime().
//
//		string parseTime24(arg)
//			Returns 24 hour time from dateobj.getTime().
//
//		string offsetTime(arg)
//			Returns stopwatch frame of argument.
//			offsetTime(now.getTime()-then.getTime())
//
//		string cipher(steam,key)
//			Returns cipher code which is sometimes binary and
//			useless outside of cookies. Asyncronous.
//			text	= cipher(text,key)
//
//		string encipher(stream,key)
//			Returns ASCII Radix 64 encipher for clipboard copies.
//			ciphertext	= encipher(plaintext,key)
//
//		string decipher(stream,key)
//			Returns ASCII Radix 64 decipher for clipboard copies.
//			plaintext	= decipher(ciphertext,key)
//
//	Notes:
//		The Script Library runs the initialization function
//		for the lib_Lib object before the document is loaded.
//
//	Bugs:
//		None.
//
//---------------------------------------------------------------------------
ns4	= (document.layers) ? true:false
ie4	= (document.all)    ? true:false
EOL	= '\r\n'
ONLINE	= (window.location.protocol=='http:') ? true:false
OFFLINE	= (window.location.protocol=='file:') ? true:false
COPYYEAR  = new Date().getYear()
COPYRIGHT = 'Copyright © '+(COPYYEAR)+' Specialized Systems. All rights reserved.'

function lib_Lib() {
	//----------------------------------------------
	// lib_Lib Environment.
	//----------------------------------------------
	this.obj	= eval(this.obj + '=this')
	this.lib_find_n	= 0
	//----------------------------------------------
	// lib_Lib Methods and Functions.
	//----------------------------------------------
	this.css	= lib_css
	this.protect	= lib_protect
	this.deprotect	= lib_deprotect
	this.noerror	= lib_noerror
	this.find	= lib_find
	this.writefind	= lib_writefind
	this.bubblesort	= lib_bubblesort
	this.quicksort	= lib_quicksort
	this.findselect = lib_findselect
	this.parseTime12= lib_parseTime12
	this.parseTime24= lib_parseTime24
	this.offsetTime	= lib_offsetTime
	this.sleep	= lib_sleep
	this.cipher	= lib_cipher
	this.encipher	= lib_encipher
	this.decipher	= lib_decipher

	this.noframe	= lib_noframe
	this.select	= lib_select
	//----------------------------------------------
	// Lib Objects.
	//----------------------------------------------
	this.cookie	= new lib_Cookie()
}
function lib_init() {
	lib = new lib_Lib()
	if(ONLINE) {
		//lib_protect()
		lib_noerror()
	}
}
lib_init()
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//	JavaScript User/Source Control Functions.
//	
//	Usage:
//		void lib_no_rightclick() {
//			init	= document.onmousedown=click
//		void lib_no_cp(e) {
//			init	= document.onmouseup = display
//		void lib_protect()
//			initializes lib_click()|lib_display(e)
//		void lib_deprotect()
//			deinitializes all mouse monitoring.
//		Netscape(e) Usage: init():
//			if(ns4) {
//				if (window.Event) {
//					document.captureEvents(Event.MOUSEUP);
//					document.captureEvents(Event.MOUSEDOWN);
//				}
//			}
//	Notes:
//		None.
//	Bugs:
//		None.
//
//---------------------------------------------------------------------------
function lib_no_rightclick(e) {
	var mesg = COPYRIGHT
	if(ie4)
		if(event.button==2)
			alert(mesg)
	else if(ns4)
		if(e.which==3)
			alert(mesg)
}
function lib_no_cp(e) {
	var mesg = COPYRIGHT
	if(document.getSelection)
		var str = document.getSelection()
	else if(document.selection && document.selection.createRange)
		var str = document.selection.createRange().text
	if(str.length>0) {	// select arg instead of selection
		var arg = ' '
		if(ns4)
			window.find(arg)
		else if(ie4) {
			var text = window.document.body.createTextRange()
			if(text.findText(arg))
				text.select()
		}
	}
}
function lib_protect() {
	if(ns4) {
		if(window.Event) {
			document.captureEvents(Event.MOUSEUP)
			document.captureEvents(Event.MOUSEDOWN)
		}
	}
	document.onmousedown	= lib_no_rightclick
	document.onmouseup	= lib_no_cp
}
function lib_deprotect() {
	document.onmousedown	= null
	document.onmouseup	= null
}
function lib_noerror() {
	window.onerror = new Function('return true')
}
function lib_debug(target,sort) {
	target = (target) ? target : window.document
	sort = (sort) ? sort : 0
	if(typeof(target)!='object')
		return alert(target)
	var buf = new String()
	for(prop in target)
		buf += prop+'<br>'
	if(sort)
		buf = lib_bubblesort(buf)
	win = window.open('','','status=0,scrollbars=1')
	win.document.write(buf)
	win.document.close()
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//	Cookie Object Contructor/Functions.
//
//	Usage:
//		cook = new lib_Cookie()		: Declares cook as a new lib_Cookie object.
//		void cook.set(name,data)	: Sets local cookie.
//		void cook.xset()		: Sets local cookie w/ expiration date exp and domain.
//			cook.xset(name,data,expires,path,domain,secure)
//		string cook.get(name)		: Returns data of cookie 'name'.
//		void cook.del(name)		: Deletes microcookie 'name'.
//	Notes:
//		None.
//	Bugs:
//		Local usage sets 'cook.del' on ~~local~~ cookie.
//		Local usage sets the domain global.
//		delall() function misses some cookies.
//
//---------------------------------------------------------------------------
function lib_Cookie() {
	//----------------------------------------------
	// Cookie Environment.
	//----------------------------------------------
	this.obj	= eval(this.obj + '=this')
	this.self	= document.cookie
	this.list	= new Array()
	this.active	= 0
	//----------------------------------------------
	// Cookie Methods and Functions.
	//----------------------------------------------
	this.get	= lib_getCookie
	this.set	= lib_Cookie_set
	this.del	= lib_Cookie_del
	this.delall	= lib_Cookie_delall
	this.xset	= lib_setCookie
	this.timeset	= lib_Cookie_timeset
	this.delall	= new Function('for(var i=0;i<this.list.length;i++) this.del(this.list[i])')
	this.report	= lib_Cookie_active_toggle
	this.init	= lib_Cookie_init
	//----------------------------------------------
	// Initialize Cookie Object.
	//----------------------------------------------
	this.init()
}
function lib_Cookie_init() {
	//----------------------------------------------
	// Build microcookie list (this.list).
	//----------------------------------------------
	this.list = new Array()
	this.escmicrocookie = document.cookie.split(';')
	for(var i=0;i<this.escmicrocookie.length;i++) {
		var microcookiename	= unescape(this.escmicrocookie[i]).split('=')[0]
		//----------------------------------------------
		// Remove spaces from microcookiename.
		//----------------------------------------------
		var string = ''
		for(var j=0;j<microcookiename.length;j++)
			if(microcookiename.charAt(j)!=' ')
				string += microcookiename.charAt(j)
		//----------------------------------------------
		this.list[this.list.length] = string
	}
}
function lib_Cookie_active_toggle() {
	this.init()
	if(this.active<this.list.length-1)
		this.active++
	else
		this.active = 0
	return this.list[this.active]
}
function lib_getCookieVal(offset) {
	var endstr	= document.cookie.indexOf(";", offset)
	if(endstr == -1)
		endstr	= document.cookie.length
	return unescape(document.cookie.substring(offset, endstr))
}
function lib_getCookie(name) {
	var arg		= name + "="
	var alen	= arg.length
	var clen	= document.cookie.length
	var i=0
	while(i<clen) {
		var j = i + alen
		if(document.cookie.substring(i, j) == arg)
			return lib_getCookieVal(j)
		i = document.cookie.indexOf(" ", i) + 1;
		if(i==0)
			break
	}
	return null
}
function lib_setCookie(arg,value) {
        var argv	= lib_setCookie.arguments
	var argc	= lib_setCookie.arguments.length
	var expires	= (argc>2) ? argv[2] : null
	var path	= (argc>3) ? argv[3] : null
	var domain	= (argc>4) ? argv[4] : null
	var secure	= (argc>5) ? argv[5] : false
	document.cookie = arg + "=" + escape(value) +
	((expires == null)	? "" : ("; expires=" + expires.toGMTString())) +
	((path    == null)	? "" : ("; path=" + path)) +
	((domain  == null)	? "" : ("; domain=" + domain)) +
	((secure  == true)	? "; secure" : "")
}
function lib_Cookie_set(cook,data) {
	var domain	= location.pathname.substring(0,location.pathname.lastIndexOf('/')) +'/'
	var expdate	= new Date()
	expdate.setTime(expdate.getTime() + (3*365*24*60*60*1000))
	lib_setCookie(cook,data,expdate,domain)
}
function lib_Cookie_timeset(cook,data,time) {
	//----------------------------------------------
	//	1 second	= 1000
	//	1 minute	= 1000 * 60
	//	1 hour		= 1000 * 60 * 60
	//	1 day		= 1000 * 60 * 60 * 24
	//	1 year		= 1000 * 60 * 60 * 24 * 365
	//	8 years		= 1000 * 60 * 60 * 24 * 365 * 8
	//----------------------------------------------
	var domain	= location.pathname.substring(0,location.pathname.lastIndexOf('/')) +'/'
	var expdate	= new Date()
	expdate.setTime(expdate.getTime() + time)
	lib_setCookie(cook,data,expdate,domain)
}
function lib_Cookie_del(name) {
	var exp		= new Date()
	exp.setTime(exp.getTime() - 1)
	document.cookie	= name + "=" + null +"; expires=" + exp.toGMTString()
	//----------------------------------------------
	// Remove cookie from this.list.
	//----------------------------------------------
	for(var j=0;j<this.list.length;j++) {
		if(this.list[j]==name) {
			for(var k=j;k<=this.list.length-2;k++)
				this.list[k] = this.list[k+1]
			this.list[this.list.length-1] = null
			this.list.length -= 1
			break
		}
	}
}
function lib_Cookie_delall() {
	this.init()
	alert()
	for(var i=0;i<this.list.length;i++)
		this.del(this.list[i])
}
//---------------------------------------------------------------------------
//	Cipher Security Functions.
//
//	Usage:
//		string lib_cipher(pt,pk)	: returns ciphertext.
//			ciphertext	= lib_cipher(plaintext,publickey)
//		string lib_cipher(ct,pk)	: returns plaintext.
//			plaintext	= lib_cipher(ciphertext,publickey)
//		string lib_encipher(ct,pk)	: ASCII Radix format.
//			ciphertext	= lib_cipher(plaintext,publickey)
//		string lib_decipher(ct,pk)	: ASCII Radix format.
//			plaintext	= lib_cipher(ciphertext,publickey)
//	Notes:
//		The cipher works best with integer based keys but will
//		supports 16 bit keys.
//		This routine will return either ciphertext or plaintext
//		depending upon which form is passed into the routine.
//	Internal Notes:
//		Block encipher on % in escape.
//	Bugs:
//		None.
//	Next Version:
//		Implement both SHA1 and MD5 hash of passphrase to
//		use as the cipherkey.
//
//---------------------------------------------------------------------------
function lib_cipher_xor(a,b) {
	return a ^ b
}
function lib_cipher(buf,key) {
	var bufx = new String()
	if(buf)
		for(var i=0;i<buf.length;i++)
			bufx += String.fromCharCode(lib_cipher_xor(parseInt(buf.charCodeAt(i)),parseInt(key)))
	return bufx
}
function lib_encipher(buf,key) {
	if(!key.match(/[0-9]/)) {
		var tmp = 0
		for(var i=0;i<key.length;i++)
			tmp += parseInt(key.charCodeAt(i))
		key = tmp
	}
	var bufx = new String()
	if(buf)
		for(var i=0;i<buf.length;i++)
			bufx += String.fromCharCode(lib_cipher_xor(parseInt(buf.charCodeAt(i)),parseInt(key)))
	return escape(bufx)
}
function lib_decipher(buf,key) {
	if(!key.match(/[0-9]/)) {
		var tmp = 0
		for(var i=0;i<key.length;i++)
			tmp += parseInt(key.charCodeAt(i))
		key = tmp
	}
	var bufx	= new String()
	if(buf) {
		buf = unescape(buf)
		for(var i=0;i<buf.length;i++)
			bufx += String.fromCharCode(lib_cipher_xor(parseInt(buf.charCodeAt(i)),parseInt(key)))
	}
	return bufx
}
function lib_cipher_link(src,salt,sw) {
	if(!src) return prompt('',lib_cipher(prompt('',''),10))
	sw = (sw) ? sw : 0
	salt = (!salt) ? 10 : salt
	src = lib_cipher(src,salt)
	if(sw)	// if sw = 1, src is an email address
		document.write('<a href="mailto:'+(src)+'">'+(src)+'</a>')
	else	// else just a link
		document.write('<a href="'+(src)+'">'+(src)+'</a>')
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//	Math and Binary Functions.
//
//	Usage:
//		lib_random(INTEGER,INTEGER)
//			returns a random integer between MINimum and MAXimum
//		lib_bin2dec(BINARY_STRING)
//			returns decimal
//		lib_dec2bin(DECIMAL)
//			returns binary string
//		lib_int2str(DECIMAL)
//			returns comma punctuated string of DECIMAL
//	Notes:
//		Implement endian vectors.
//			use arr.split('') and arr.reverse()
//	Bugs:
//		None.
//
//---------------------------------------------------------------------------
function lib_random(min,max) {
	return parseInt(Math.random() * (max+1-min) + min)
}
function lib_bin2dec(arg) {
	arg = arg.toString()			// arg must be a string
	var j = 0				// build decimal w/bin code
	for(var i=0;i<arg.length;i++) {		// move through arg string
		j <<= 1				// shift in a 0 from right
		if(arg.charAt(i)==1)		// if i='1' in arg string
			j |= 1			// OR the 0 bit to 1
	}
	return j				// return decimal
}
function lib_dec2bin(arg) {
	var j = parseInt(arg)			// arg must be an integer
	var bin = new String()			// create bin string buffer
	for(i=0;i<8;++i) {
		if(j&1) bin = '1' + bin
		else    bin = '0' + bin
		j >>>= 1
	}
	return bin
}
function lib_int2str(num) {
	if(num<1000) return num			// traps -#s also
	num = num.toString()			// convert int to string
	var arr = new Array()			// create 3s array
	for(var i=num.length,j=0;i>0;i=i-3,j++)	// go backwards stepping 3
		arr[j] = num.substring(i-3,i)	// insert value into cell
	return(arr.reverse().toString())	// reverse and string
}
function lib_AND(a,b) {
	return a & b
}
function lib_OR(a,b) {
	return a | b
}
function lib_XOR(a,b) {
	return a ^ b
}
function lib_NOT(a) {
	return ~a
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//	Document Find/Search Function.
//
//	Usage:
//		obj.find(string)	: highlights 'string' on web-page.
//	Notes:
//		This routine is used to find a text string on the
//		HTML page it is implemented. Upon run-time, the
//		function will highlight the string if found and
//		continue to the next occurence if invoked again.
//		To de-class:
//			global var lib_find_n	= 0
//			remove 'this.' for all cases of 'this.lib_find_n'
//	Bugs:
//		None.
//
//---------------------------------------------------------------------------
function lib_find(string) {
	if(string=='')
		return false
	if(ns4) {
		if(!window.find(string))
			while(window.find(string, false, true))
				this.lib_find_n++
		else
			this.lib_find_n++
		if(this.lib_find_n==0)
			alert('Finished searching the document')
	} else if(ie4) {
		var text = window.document.body.createTextRange()
		for(var i=0;i<=this.lib_find_n && (found=text.findText(string))!=false;i++) {
			text.moveStart('character', 1)
			text.moveEnd("textedit")
		}
		if(found) {
			text.moveStart('character', -1)
			text.findText(string)
			text.select()
			text.scrollIntoView()
			this.lib_find_n++
		} else {
			if(this.lib_find_n>0) {
				this.lib_find_n = 0
				lib_find(string)
			}
			else
				alert('Finished searching the document')
		}
	}
	return false
}
function lib_writefind(arg) {
	arg	= (arg) ? arg : ''
	var buf = new String()
	var tcss = ''//color:#000000; background-color:#cccccc; font-family:verdana,helvetica,arial; font-size:12px; line-height:1.2em; font-weight:400; text-decoration:none'
	var bcss = ''//color:#FFFFFF; background-color:#111111; font-family:verdana,helvetica,arial; font-size:10px; line-height:1.2em; font-weight:400; text-decoration:none'
	buf += '<form name="search" onSubmit="return lib.find(this.string.value);">'
		buf += '<input type="text"   style="'+tcss+'" name="string" size="35" onchange="lib.lib_find_n=0;" onfocus="this.select()" value="'+arg+'">'
		buf += '<input type="submit" style="'+bcss+'" value="Find">'
		buf += '<input type="reset"  style="'+bcss+'" value="Clear" onclick="lib.lib_find_n=0;">'
	buf += '</form>'
	document.write(buf)
}
function lib_findselect(arg) {
	if(ns4)
		window.find(arg)
	else if(ie4) {
		var text = window.document.body.createTextRange()
		if(text.findText(arg))
			text.select()
	}
}
//---------------------------------------------------------------------------
//	Sorting Algorithms.
//
//	Usage:
//		data = bubblesort(data)
//		data = quicksort(data)
//	Notes:
//		The data argument is a one dimensional array containing
//		data that will be sorted according to element contents.
//	Bugs:
//		None.
//	Internal:
//		To apply two dimensional arrays, swap the array cell that
//		is to be sorted, parse the sort, and swap the contents to
//		their orignal position. This can apply to any dimensional
//		array.
//
//		The sorting array's comparison algorithms do not check
//		data types. Comparison of data is dependant on javascripts
//		interpretation of variable typing and the following
//		operators: == < > <= >=
//
//---------------------------------------------------------------------------
function lib_sortaz(a,b) {
	return (a==b) ? 0 : (a>b) ? 1 : -1
}
function lib_sortza(a,b) {
	return (a==b) ? 0 : (a<b) ? 1 : -1
}
function lib_sortswap(data,i,j) {
	j = (j) ? j : (i+1)
	var temp = data[i]
	data[i]  = data[j]
	data[j]  = temp
	return data
}
function lib_bubblesort(data) {
	// bubble-sort algorithm.
	var swapped = false
	do {
		swapped = false
		for(var i=0;i<data.length;i++) {
			if(data[i] > data[i+1]) {
				var temp  = data[i]
				data[i]   = data[i+1]
				data[i+1] = temp
				swapped   = true
			}
		}
	} while(swapped)
	return data
}
function lib_quicksort_alg(data,l,r,test) {
	// quick-sort algorithm.
	var pivot, i, j, temp
	if((r-l)==1) {
		if(data[l]>data[r]) {
			temp    = data[l]
			data[l] = data[r]
			data[r] = temp
		}
		return data
	}
	var mid = parseInt((l+r)/2)
	pivot = data[mid]
	data[mid] = data[l]
	data[l] = pivot
	i = l + 1
	j = r
	do {
		//while(i<=j && data[i]<=pivot)
		while(i<=j && test(data[i],pivot)<=0)
			i++
		//while(data[j]>pivot)
		while(test(data[j],pivot)>0)
			j--
		if(i<j) {
			temp    = data[i]
			data[i] = data[j]
			data[j] = temp
		}
	} while(i<j)
	data[l] = data[j]
	data[j] = pivot
	if(l < j - 1) lib_quicksort_alg(data,l,j-1,test)
	if(j + 1 < r) lib_quicksort_alg(data,j+1,r,test)
	return data
}
function lib_quicksort(data,test) {
	if(data == null)
		return
	test = (test!=null) ? test : lib_sortaz
	return lib_quicksort_alg(data,0,(data.length-1),test)
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//	Date and Time Functions.
//
//	Usage:
//		string returnDate()
//			Format: [Wednesday, December 15, 1999]
//		string returnTime()
//			Format: [10:36:38 PM]
//		string returnMessage()
//			Time dependant greeting [good morning, good evening]
//		string lib_parseTime12(arg)
//			Returns 12 hour time from dateobj.getTime().
//		string lib_parseTime24(arg)
//			Returns 24 hour time from dateobj.getTime().
//		string lib_offsetTime(arg)
//			Returns stopwatch frame of argument.
//			offsetTime(now.getTime()-then.getTime())
//		void lib_clockspan()
//			Used at runtime [init()] for dhtml clock.
//			[Wednesday, December 15, 1999 10:41:36 PM]
//			<span id="clockSpan" style="position:absolute"></span>
//	Notes:
//		None.
//	Bugs:
//		None.
//
//---------------------------------------------------------------------------
function lib_parseTime12(arg) {
	if(!arg) return
	var date = new Date()
	date.setTime(arg)
	var hrs	= date.getHours()
	var mil	= date.getHours()
	var min	= date.getMinutes()
	var sec	= date.getSeconds()
	var buf	= new String()
	buf += ((hrs >12) ? hrs-12 : hrs)
	if(hrs==0) buf = 12
	buf += ((min < 10) ? ':0' : ':') + min
	buf += ((sec < 10) ? ':0' : ':') + sec
	buf += (mil >= 12) ? ' PM' : ' AM'
	return buf
}
function lib_parseTime24(arg) {
	if(!arg) return
	var date = new Date()
	date.setTime(arg)
	var hrs = date.getHours()
	var min = date.getMinutes()
	var sec = date.getSeconds()
	var buf = new String()
	buf += ((hrs < 10) ?  '0' : '')  + hrs
	buf += ((min < 10) ? ':0' : ':') + min
	buf += ((sec < 10) ? ':0' : ':') + sec
	return buf
}
function lib_offsetTime(arg) {
	var sec = '0'
	var min = '0'
	var hrs = '0'
	var day = '0'
	sec = Math.ceil(arg/1000)
	if(sec>=60) {
		min = Math.floor(sec/60)
		sec %= 60
		if(min>=60) {
			hrs = Math.floor(min/60)
			min %= 60
			if(hrs>=24) {
				day = Math.floor(hrs/24)
				hrs %= 24
			}
		}
	}
	if(sec<10) sec = '0'+sec
	if(min<10) min = '0'+min
	if(hrs<10) hrs = '0'+hrs
	if(day>0)
		arg = day+(day<=1 ? ' day ' : ' days ')+hrs+':'+min+':'+sec
	else
		arg = hrs+':'+min+':'+sec
	return arg
}
function lib_date() {
	var date	= new Date()
	var day		= new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')
	var month	= new Array('January','Febuary','March','April','May','June','July','August','September','October','November','December')
	return day[date.getDay()]+', '+month[date.getMonth()]+' '+date.getDate()+', '+date.getYear()
}
function lib_time() {
	var date	= new Date()
	var hours	= date.getHours()
	var milhours	= date.getHours()
	var minutes	= date.getMinutes()
	var seconds	= date.getSeconds()
	var buf		= new String()
	buf += ((hours >12) ? hours-12 : hours)
	if(hours==0) buf = 12
	buf += ((minutes < 10) ? ':0' : ':') + minutes
	buf += ((seconds < 10) ? ':0' : ':') + seconds
	buf += (milhours >= 12) ? ' PM' : ' AM'
	return buf
}
function lib_greeting() {
	var date	= new Date()
	var message	= new String()
	if(date.getHours() <= 11)
		message = 'Good Morning!'
	else if(date.getHours() <= 17)
		message = 'Good Afternoon!'
	else if(date.getHours() <  24)
		message = 'Good Evening!'
	return message
}
var lib_timer_id	= null
var lib_timer_running	= false
function lib_timer_init(arg) {
	lib_timer_then	= new Date()
	lib_timer_func(arg)
}
function lib_timer_stop(arg) {
	if(lib_timer_running)
		clearTimeout(lib_timer_id)
	lib_timer_running = false
	if(arg)
		eval(arg)
}
function lib_timer_func(arg) {
	var timer_now		= new Date()
	lib_timer_running	= true
	lib_timer_id		= setTimeout('lib_timer_func("'+arg+'")',50)
	if(arg)
		eval(arg)
}
function lib_sleep(arg) {
	arg = arg ? arg*1000 : 0*1000
	var now  = new Date()
	var then = now.getTime()+arg
	while(true) {
		var now = new Date()
		if(now.getTime() >= then) break
	}
}
function lib_clockspan() {
	if (ns4) {
		document.layers.clockspan.document.write(lib_date()+' '+lib_time())
		document.layers.clockspan.document.close()
	}
	else if (ie4)
		clockspan.innerHTML = lib_date() +' '+ lib_time()
	setTimeout("lib_clockspan()",1000)
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//	HTML Layout/Format Functions.
//
//	Usage:
//		void lib_css('loc/name.ext')	: inserts style-sheet.
//		void lib_noframe()		: prevent document sub-classing.
//		void lib_noframe()		: ensures that document is not framed.
//		void lib_toframe(parent_href)	: forces frames.
//		void lib_select()		: highlights body of document.
//	Notes:
//		None.
//	Bugs:
//		None.
//
//---------------------------------------------------------------------------
function lib_css(src) {
	if(ns4||ie4)
		document.write('<link rel="stylesheet" type="text/css" href="' + src + '">')
}
function lib_noframe() {
	if(self!=top)
		top.location.href = self.location.href
}
function lib_select(object) {
	window.document.object.createTextRange().select()
}
function lib_selection_load(win,form,sel) {
	win.location.href = form.sel.options[form.sel.selectedIndex].value
}
function lib_go(href) {
	if(typeof(href)=='string')
		this.location.href = href
	//else if(debug) alert('typeof() mismatch in href call to function lib_go()')
}
function lib_writespan(span,string) {
	if(ns4) {
		document.layers[span].document.write(string)
		document.layers[span].document.close()
	} else if(ie4)
		eval(span).innerHTML = string
}
// TOMBSTONE: deprivated by the unix bash syntax and extensible lib_basename(), stop using.
function lib_parsefilename() {
	return(window.location.href.split('/')[window.location.href.split('/').length-1])
}
function lib_basename(arg) {
	arg = (arg) ? arg : false
	if(arg)
		return(arg.split('/')[arg.split('/').length-1])
	else
		return(window.location.href.split('/')[window.location.href.split('/').length-1])
}
// TOMBSTONE: To be renamed to match the unix bash syntax of pathname
function lib_parsepath(file) {
	// parse_domain+next_folder.
	if(!file[file.length]=='/')
		// Protect from www.com/urls without trailing slash (urls/)
		file += '/'
	return file.substring(0,file.lastIndexOf('/')+1)
}
function lib_input_stylex(ofbgcolor,obbgcolor) {
	// Makes inputboxes turn colors with focus
	// Usage: input_text_style('yellow','white')
	ofbgcolor = (ofbgcolor) ? ofbgcolor : 'YELLOW'
	obbgcolor = (obbgcolor) ? obbgcolor : '#FFFFFF'
	for(var i=0;i<document.forms.length;i++) {
		for(var j=0;j<document.forms[i].elements.length;j++) {
			if(document.forms[i].elements[j].type == 'text'||document.forms[i].elements[j].type == 'password') {
				var onfocus = (document.forms[i].elements[j].onfocus) ? document.forms[i].elements[j].onfocus+'()' : ''
				var onblur  = (document.forms[i].elements[j].onblur ) ? document.forms[i].elements[j].onblur +'()' : ''
				document.forms[i].elements[j].onfocus = new Function('this.select();this.style.backgroundColor = "'+ofbgcolor+'";eval('+onfocus+')')
				document.forms[i].elements[j].onblur  = new Function('this.style.backgroundColor = "'+obbgcolor+'";eval('+onblur+')')
			}
		}
	}
}
function lib_input_style() {
	// todo: must preserve html onfocus tags before global implementation.
	var onfocus = new Function('this.select();this.style.backgroundColor = "YELLOW"')
	var onblur  = new Function('this.style.backgroundColor = "#FFFFFF"')
	for(var i=0;i<document.forms.length;i++) {
		for(var j=0;j<document.forms[i].elements.length;j++) {
			if(document.forms[i].elements[j].type == 'text'||document.forms[i].elements[j].type == 'password') {
				document.forms[i].elements[j].onfocus = onfocus
				document.forms[i].elements[j].onblur  = onblur
			}
		}
	}
}
//---------------------------------------------------------------------------
function browser() {
	var b		= navigator.appName
	if(b=="Netscape")
		this.b = "ns"
	else if(b=="Microsoft Internet Explorer")
		this.b = "ie"
	else
		this.b	= b
	this.version	= navigator.appVersion
	this.v		= parseInt(this.version)
	this.ns		= (this.b=="ns" && this.v>=4)
	this.ns4	= (this.b=="ns" && this.v==4)
	this.ns5	= (this.b=="ns" && this.v==5)
	this.ie		= (this.b=="ie" && this.v>=4)
	this.ie4	= (this.version.indexOf('MSIE 4')>0)
	this.ie5	= (this.version.indexOf('MSIE 5')>0)
	this.min	= (this.ns||this.ie)
}
is = new browser()
function layerobj(id,nestref,frame) {
	if(is.ns) {
		if(is.ns) {
			if(!frame) {
				if(!nestref)
					var nestref = layerobj.nestRefArray[id]
				this.css = (!nestref) ?  document.layers[id] : eval("document."+nestref+".document."+id)
			}
			else
				this.css = (nestref)? eval("parent."+frame+".document."+nestref+".document."+id) : parent.frames[frame].document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		if(is.ns5) {
			this.elm = document.getElementById(id)
			this.css = this.elm.style
			this.doc = document
		}
		this.x = this.css.left
		this.y = this.css.top
		this.w = this.css.clip.width
		this.h = this.css.clip.height
	}
	else if(is.ie) {
		this.elm = this.event = (frame)? parent.frames[frame].document.all[id] : document.all[id]
		this.css = (frame)? parent.frames[frame].document.all[id].style : document.all[id].style
		this.doc = document
		this.x = this.elm.offsetLeft
		this.y = this.elm.offsetTop
		this.w = (is.ie4)? this.css.pixelWidth	: this.elm.offsetWidth
		this.h = (is.ie4)? this.css.pixelHeight	: this.elm.offsetHeight
	}
	this.id = id
	this.obj = id + "layerobj"
	eval(this.obj + "=this")

	this.moveTo	= layerobj_move_to
	this.moveBy	= layerobj_move_by
	this.show	= layerobj_show
	this.hide	= layerobj_hide
}
function layerobj_move_to(x,y) {
	if(x!=null) {
		this.x = x
		if(is.ns) this.css.left = this.x
		else this.css.pixelLeft = this.x
	}
	if(y!=null) {
		this.y = y
		if(is.ns) this.css.top = this.y
		else this.css.pixelTop = this.y
	}
}
function layerobj_move_by(x,y) {
	this.moveTo(this.x+x,this.y+y)
}
function layerobj_show() {
	this.css.visibility = (is.ns) ? "show" : "visible"
}
function layerobj_hide() {
	this.css.visibility = (is.ns) ? "hide" : "hidden"
}
// alleviate Netscape's document.write bug
function lib_ns4redraw() {
	if(innerWidth!=lib_origwidth || innerHeight!=lib_origheight)
		location.reload()
}
if(ns4) {
	lib_origwidth	= innerWidth
	lib_origheight	= innerHeight
	onresize	= lib_ns4redraw
}
//---------------------------------------------------------------------------
//	End of JavaScript Library.
//«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««