<!--
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;
	try {return eval('document.'+theForm.name+'.'+field);}
	catch(e){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);
}
function getElementValue(theForm, field) {
	var el = getElement(theForm, field);
	if (!el || el == null || !el.type) {
		return '';
	}
	if (el.type.toLowerCase().indexOf('button') >= 0) {
		return '';
	}
	if (el.type.indexOf('select') >= 0) {
		if (trimIt(el.options[el.selectedIndex].value) > ' ') {
			return trimIt(el.options[el.selectedIndex].value);
		}
		else {
			return trimIt(el.options[el.selectedIndex].text);
		}
	}
	else
	if (el.type.toLowerCase().indexOf('checkbox') >= 0) {
		if (el.checked) {
			if (trimIt(el.value) > ' ') {
				return trimIt(el.value);
			}
			else {
				return 'on';
			}
		}
		else {
			return 'off';
		}
	}
	else {
		return trimIt(el.value);
	}
}
function setElementValue(theForm, field, val) {
	var el = getElement(theForm, field);
	if (!el || el == null || !el.type) {
		return;
	}
	if (el.type.toLowerCase().indexOf('button') >= 0) {
		return;
	}
	if (el.type && el.type.toLowerCase().indexOf('select') >= 0) {
		if (el.selectedIndex && el.selectedIndex >= 0) {
			el[el.selectedIndex].value = val;
		}
	}
	else {
		el.value = val;
	}
}
function getNumberValue(theForm, field, what) {
	if (what) {
		if (what == 'int' || what == 'float') {
		}
		else {
			what = 'int';
		}
	}
	else {
		what = 'int';
	}
	var v = 0;
	var val = getElementValue(theForm, field);
//	var obj = getElement(theForm, field);
//	if (obj == null) {
//		return v;
//	}
//	if (obj.type && obj.type.indexOf('select') >= 0) {
//		if (obj.selectedIndex && obj.selectedIndex >= 0) {
//			if (trimIt(obj[obj.selectedIndex].value) <= ' ') { 
//				val = obj[obj.selectedIndex].text; 
//			}
//			else {
//				val = obj[obj.selectedIndex].text;
//			}
//		}
//		else {
//			v = 0;
//		}
//	}
//	else {
//		val = obj.value;
//	}
	if (trimIt(val) <= ' ') {
	}
	else
	if (isNaN(val)) {
	}
	else {
		v = val;
	}	
	if (what == 'int') {
		v = parseInt(v);
	}
	else {
		v = parseFloat(v);
	}		
//	if (obj.type && obj.type.indexOf('select') >= 0) {
//		if (obj.selectedIndex && obj.selectedIndex >= 0) {
//			obj[obj.selectedIndex].value = v;
//		}
//	}
//	else {
//		obj.value = v;
//	}
	setElementValue(theForm, field, v);
	return v;
}
function setAmount2Value (theForm, field, amount) {
	var obj = getElement(theForm, field);
	if (obj == null) {
		return;
	}
	var myAmount = new WOP.amountObj(amount);
	if (myAmount.isValid) {
		obj.value = myAmount.withDollar;
	}
	else {
		obj.value = '';
	}
	 
}
//-->