//--form utility functions
//	Author: Charles Woerner
//	Date Last Modified: Nov 6, 2002
//	Purpose: Provide form utility functions



function rewriteArea(that, origVal, firstTime) {
	if (that.value != origVal) {
		var noSp = cutSpaces(that.value);
		if (noSp == "") { 
			that.value = origVal;
			firstTime = !firstTime;
		 	}
		else { that.value = noSp; }
	}
}

function clearArea(that, innerT, firstTime, origVal) {
	if (firstTime) {
		innerT = that.value;
		if (innerT == origVal) {
			that.value = "";
			firstTime = !firstTime;
		}
	}
}

function cutSpaces(valToCheck) {
	while (valToCheck.charAt(0) == " ") { 
		valToCheck = valToCheck.substring(1,valToCheck.length); 
	}
	while (valToCheck.charAt(valToCheck.length-1) == " ") { 
		valToCheck = valToCheck.substring(0,valToCheck.length-1);
	}
    return valToCheck;
}

function findBlank(form,nameString) {
	for (var i=0; i<form.elements.length; i++) {
		if ((form.elements[i].name.indexOf(nameString) > -1)&&(form.elements[i].value == "")) 
		{
			return chgFocus(null,i,form);
			break;
		}
	}
}

function chgFocus(fromFld,toFld,form)  {
	var doFocus = false;
	if (!form) { form = document.forms[0]; }
		 if (fromFld == null) {	doFocus = true; }
		 else {
		 	var strFromFieldVal
		 	strFromFieldVal = fromFld.value;
			if (strFromFieldVal.length == fromFld.maxLength)  { doFocus = true; }
		}
	if (doFocus) {
		form.elements[toFld].focus();
    	    	form.elements[toFld].select();
    	}
}

function makeThem(i,j,k) {
	k = k ? k : "";
	var opt = "";
	for (i; i<=j; i++) {
		opt += "<option id='" + i + "' name='" + i + "' value='" + i + "'>" + i + "</option>";
	}
    return opt;
}
