<!--
if (!window.w3c) {
	var w3c=(document.getElementById)?true:false;
	var ns4=(document.layers)?true:false;
	var ie4=(document.all && !w3c)?true:false;
	var ie5=(document.all && w3c)?true:false;
	var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;
	var ns =(navigator.appName.indexOf("Netscape")>=0)?true:false;
	var saf=(navigator.userAgent.toLowerCase().indexOf("safari")>=0)?true:false;
	var fox=(navigator.userAgent.toLowerCase().indexOf("firefox")>=0)?true:false;
	var opera=(navigator.userAgent.toLowerCase().indexOf("opera")>=0)?true:false;
	var netscape=(navigator.appName.indexOf("Netscape")>=0 && !saf && !fox)?true:false;
	var hideForm=(ie5 || saf || fox || opera)?true:false;
}

function amountObj (amount) {
	if (amount <= '          ') {
		this.amount = 0;
	}
	else {
		this.amount = amount;
	}
	this.isValid = false;
	this.withDollar = '';
	if (typeof(_amountObj_prototype) == 'undefined') {
		_amountObj_prototype = true;
		amountObj.prototype.edit = amountEdit;
	}
	this.edit();
}

function amountEdit () {
	var amount = parseFloat(this.amount)
	if (isNaN(amount)) {
		this.amount = '0.00';
		this.withDollar = '';
		this.isValid = false;
		return;
	}

	var str = '' + Math.round(amount * Math.pow(10, 2))
	while (str.length <= 2) {
		str = '0' + str
	}
	var decpoint = str.length - 2
	this.amount = str.substring(0, decpoint) + '.' + str.substring(decpoint, str.length)
	this.withDollar = '$' + this.amount;
	this.isValid = true;
}

//
// form field functions
//
function getElement(theForm, field) {
	var theElement;
	for (i=0; i < theForm.elements.length; i++) {
		theElement = theForm.elements[i];
		if (theElement.name.toLowerCase() == field.toLowerCase()) {
			return theElement;
		}
	}
	return null;
}

function testField(theForm, field, err, index, alias) {
	edit = true;
	if (index == null) {
		index = 0;
	}	
	var theElement = getElement(theForm, field);
	if (theElement != null) {
		if (theElement.type && theElement.type.indexOf('select') >= 0) {
			if (theElement.selectedIndex < index) {
				edit = false;
				if (err && err == 'show') {
					showError(theElement, alias);
				}
			}
			else {
				if (trimIt(theElement[theElement.selectedIndex].value) <= ' ') { 
					theElement[theElement.selectedIndex].value = theElement[theElement.selectedIndex].text; 
				}
			}
		}	
		else {
			theElement.value = trimIt(theElement.value);				
			if (theElement.value <= ' ') {
				edit = false;
				if (index != -1) {
					if (err && err == 'show') {
						showError(theElement, alias);
					}
				}
			}	
		}
	}
	return edit;
}

function showError(theElement, alias) {
	var n = '';
	if (alias && trimIt(alias) > ' ') {
		n = alias;
	}
	else {
		n = theElement.name;
	}	 
	alert(n + ' is a required piece of information!\n\nWe can NOT process this Request without it.');
	selectField(theElement);  
}

function gotoField(theForm, field) {
	var theElement = getElement(theForm, field);
	if (theElement != null) {
		selectField(theElement);  
	}
}

function selectField(theElement) {
	theElement.focus();
	if (theElement.type) {
		if (theElement.type == 'text') {
			theElement.select();
		}
	}		
}

function trimIt(s) {
	return s.replace(/\s+$/,'');
}

function setTextArea (mesg) {
	var aEnd = '%0D%0A';
	var re = /%3Cbr%3E/;
	var mesg = escape(unescape(mesg));
	var doit = true;
	var newM;
	while (doit) {
		newM = mesg.replace(re , aEnd);
		if (newM == mesg) {
			doit = false;
		}	
		else {
			mesg = newM;
		}		
	}

	return unescape(newM);
}

//-->