var intervalID;
function onLoad_OpenGroups() {
	if (typeof(arrAutoOpenGroups) != "undefined") {
		// each group must be opened on an interval to avoid async postback confusion of parent node.
		intervalID = window.setInterval("autoOpenGroup()", 200);
	}
}
function autoOpenGroup(gID) {
	if (gID == null) {
		// if blank, was called by window interval, which cannot pass parameters
		if (arrAutoOpenGroups.length > 0) {
			gID = arrAutoOpenGroups.pop();		// pop removes this element from array
		} else {
			window.clearInterval(intervalID);
			return;
		}
	}
	var oGroup = document.getElementById("Item_1:" + gID);
	var oChildren = document.getElementById("Children_1:" + gID);
	var oImg;
	if (oGroup) {
		oImg = oGroup.getElementsByTagName("IMG")[0];
		if (oChildren) {
			// group already opened, set visible and click course
			oChildren.style.visibility = "visible";
			oChildren.style.display = "";
			oGroup.className = "treeItem_open";
			if (oImg != null) {
				oImg.setAttribute("src", "Images/group_Col.gif");
			}
			document.getElementById(sStepToItemID).click();
		} else {
			// group not yet opened
			itemChildren_get(oGroup);
		}
	}
}
function stepToItem(gID, cID, optID) {
	// called by search results item click, or by page load command (if an item was selected on a previous page)
	sStepToItemID = "item_" + gID + "$" + cID;		//after group is loaded, item will be auto-selected.
	sStepToOptionID = (optID == "") ? "" : "item_" + cID + "_opt_" + optID;
	autoOpenGroup(gID);
	itemSearch_Close();
}

//****  Item Search Controls ********************************************************************************
function itemSearch() {
	var d = document.getElementById("SearchWrapper");
	var qStr = document.getElementById("itemQuery").value;
	if (qStr != "") {
		d.className = "Agreement";
		var rex = new RegExp("[^a-zA-Z0-9'\\s]?", "gi");
		qStr = qStr.replace(rex, "");
		var sURL = "/WebSite/Register/_Util_ItemChildren.asp?level=1&itemID=0&xid=" + sXID + "&itemQuery=" + escape(qStr);
		htRequest(sURL, 'itemSearch_process');
	}
}
function itemSearch_process(str) {
	var dResults = document.getElementById("SearchResults");
	var sResults = "";
	var nResults;
	var oResults;
	var oRow;
	var tmpItem_ID;
	var tmpItem_Type;
	var sCourse_Type;
	var tmpSpacer = "";
	var sMinPriceAllowed;
	str = str.replace("<RESULTS><![CDATA[", "");
	str = str.replace("]]></RESULTS>", "");
	eval("oResults=" + str);
	if (oResults == null) {
		//no items returned
		dResults.innerHTML = "<span style=\"color:#993300;\"><b>No matches were found<b>. Please alter your search word(s) and try again.</span>";
		return;
	}
	try { nResults = oResults.Rows.length; } catch (exception) { return;}
	sResults = "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"565\">";
	for (i=0; i<nResults; i++) {
		oRow = oResults.Rows[i];
		tmpItem_ID = oRow.Parent_ID + "$" + oRow.Course_ID;
		tmpItem_Type = parseInt(oRow.Course_Type);
		sCourse_Type = item_TypeDisplay(tmpItem_Type);
		sResults += ((i % 2) == 0) ? "<tr rowStyle=\"odd\" class=\"odd\">" : "<tr rowStyle=\"\">";
		sResults += "<td width=\"525\"><img src=\"Images/icon_" + oRow.Course_Type + ".gif\" alt=\"" + sCourse_Type + "\"> ";
		sResults += "<span class=\"course\" onclick=\"stepToItem(" + oRow.Parent_ID + "," + oRow.Course_ID + ",'');\">" + oRow.Course_Name + "</span>";
		if (sCourse_Type != "") {
			sResults += "<span style=\"font:normal 8pt Arial; color:#000099; white-space:nowrap;\"> - " + sCourse_Type + "</span>";
		}
		sResults += "</td>";
		sResults += "<td width=\"40\" valign=\"top\" style=\"padding-top:3px;\">";
		sResults += "<a href=\"javascript:itemDescription_init(" + oRow.Course_ID + ",'false');\"><img src=\"Images/detail.gif\" alt=\"Course Description\"> Info</a>";
		sResults += "</td></tr>";
	}
	sResults += "</table>";
	dResults.innerHTML = sResults;
}
function itemSearch_Close() {
	var d = document.getElementById("SearchWrapper");
	d.className = "AlertBoxHidden";
	//document.getElementById("itemQuery").value = "";
	// note: do not clear sStempToItemID or sStempToOptionID here; clear them onclick of those levels.
}

//****  Alert Box Controls **********************************************************************************
function toggleAlertBox(sTitle, sAlert) {
	// handles:
	//	1. Special Alert(s) for specific course(s) when clicked
	//	2. Find My Info - special case where table is shown instead of simple text
	//		does NOT handle Course Descriptions; those are handled by WebDescriptionUtil.js
	var d = document.getElementById("AlertBox1");
	var fMI = document.getElementById("AlertBox_FindMyInfo");
	var oContent = document.getElementById("AlertBox_Content");
	document.getElementById("AlertBox_Title").innerHTML = sTitle;
	if (sAlert == "FindMyInfo") {
//		oContent.style.height = "70px";
//		oContent.style.overflow = "visible";
		oContent.innerHTML = "Enter your information in the boxes below to locate your account.<br>You can enter your email and zip code, or your last name and phone number.";
		fMI.style.visibility = "visible";
		fMI.style.display = "";
	} else {
		if (sAlert.length > 200) {
			oContent.style.height = "250px";
			oContent.style.overflow = "auto";
		} else {
			oContent.style.height = "70px";
			oContent.style.overflow = "visible";
		}
		oContent.innerHTML = sAlert;
		fMI.style.visibility = "hidden";
		fMI.style.display = "none";
	}
	if (sAlert == "") {
		toggleGrayOut(false);	// use background grayout from CourseDescriptions utility
		d.className = "AlertBoxHidden";
	} else {
		var h = f_clientHeight(false);
		var w = f_clientWidth();
		var s = f_scrollTop();
		toggleGrayOut(true);	// use background grayout from CourseDescriptions utility
		d.className = "AlertBox";
		d.style.top = (Math.floor(h / 2) - 175 + s) + "px";
		d.style.left = (Math.floor(w / 2) - 300) + "px";
	}
}
//****  End Alert Box Controls ******************************************************************************

function validate_ClassList(f) {
	//make sure at least one item has been chosen; build encoded list of items chosen plus tuitions.
	// alert Errors if they occur, otherwise fill form field.
	f.elements["classList"].value = "";		//always reset before processing
	var sClassList = "";
	var oItemTable = document.getElementById("itemTableMain");
	var oItemSet = null;
	var elmt;
	var oParent;
	var tmpItem_ID;
	var oTuition;
	var sTuition;
	var sBase;
	var nTuition;
	var nBase;
	var sRowValue;
	var nGroups = 0;
	var nSelections = 0;
	var tmpName = "";
	var aSelectorChoices;
	var sSelectorChoice;
	var sPackSharePct;
	var nPackSharePct;
	var nPackShareTuition;
	var nPackShareBase;
	var oPriceSharePct;
	var sPriceSharePct;
	var oSelector;
	var oSelectorOpts;
	var oRadio;
	var i;
	var j;
	if (!allTuitionsValid) {
		alert("Error: One or more tuition values you've entered are not valid.");
		return false;
	}
	if (oItemTable) {
		// note: don't alert error if no item table; blank classList will be caught by page validator anyway, and there might be a CC roster selected.
		oItemSet = oItemTable.getElementsByTagName("INPUT");
		if (oItemSet == null) {
			return false;
		} else if (oItemSet.length == 0) {
			return false;
		}
	} else {
		return false;
	}
	for (i=0; i<oItemSet.length; i++) {
		elmt = oItemSet[i];
		if ((elmt.type == "checkbox") && (elmt.checked)) {
			tmpItem_ID = elmt.id.replace("item_", "");
			sRowValue = elmt.value;
			//concatenate the Class_ID with the Tuition value
			oTuition = document.getElementById("sTuition_" + elmt.id);
			if (!oTuition) {
				alert("Error: Your browser may not support this script. Please call us to register if the problem persists.");
				return false;
			}
			sTuition = (oTuition.tagName == "INPUT") ? oTuition.value : oTuition.innerHTML;
			sTuition = sTuition.replace("$", "");
			// for Rockwell Admin, base changes if tuition changes, always match
			sBase = (bRockwellAdmin) ? sTuition : oTuition.getAttribute("base");
			if ((oTuition.tagName == "INPUT") && ((sTuition == "") || (isNaN(sTuition)))) {
				alert("Error: Please enter a tuition for the selected item(s).");
				return false;
			}
			// any checked item that has a Selector control must add all selection values to ClassList;
			//	make sure number of selections for an item equals number of option groups.
			oSelector = document.getElementById("SelectorTool_Content_" + tmpItem_ID);
			if (oSelector) {
				aSelectorChoices = new Array();
				nTuition = parseFloat(sTuition);
				nBase = parseFloat(sBase);
				oSelectorOpts = oSelector.getElementsByTagName("INPUT");
				// get number of option groups in this selector
				for (j=0; j<oSelectorOpts.length; j++) {
					oRadio = oSelectorOpts[j];
					if (oRadio.getAttribute("myLevel") == "2") {
						if (oRadio.name != tmpName) {
							//new group
							tmpName = oRadio.name;
							nGroups++;
						}
					}
					//selections count if they're level 2 with no subselector, or level 3
					if (oRadio.checked && (((oRadio.getAttribute("myLevel") == "2") && (oRadio.value.indexOf("**") == -1)) || (oRadio.getAttribute("myLevel") == "3"))) {
						nSelections++;
						sSelectorChoice = oRadio.value;
						// PACKAGE SHARED TUITIONS
						// ignore items that do not have at least one star;  Package items have stars, Live class choices don't.
						if (oRadio.value.indexOf("*") != -1) {
							sPackSharePct = sSelectorChoice.substr(sSelectorChoice.indexOf("*") + 1);
							sPackSharePct = sPackSharePct.substr(0, sPackSharePct.indexOf("p"));
							if (isNaN(sPackSharePct)) {
								nPackSharePct = 0;
							} else {
								nPackSharePct = parseFloat(sPackSharePct);
							}
							//remove percentage from ClassID string; not needed in future reg steps.
							sSelectorChoice = sSelectorChoice.replace(("*" + sPackSharePct + "p"), "");
							nPackShareBase = nBase * (nPackSharePct * 0.01);
							nPackShareTuition = nTuition * (nPackSharePct * 0.01);
							sBase = formatNumber(nPackShareBase);
							sTuition = formatNumber(nPackShareTuition);
						}
						// check if item ID already exists in selector choices.
						//	If this is true, it means user chose a duplicate item within a single package selector.
						for (k=0; k<aSelectorChoices.length; k++) {
							if ((sSelectorChoice != "") && (aSelectorChoices[k].indexOf(sSelectorChoice) == 0)) {
								alert("Error: You have made a duplicate choice in one of your package selections. Please check your selections for duplication.");
								return false;
							}
						}
						// sRowValue is added at this point; it might be a PrePaid ID value, or another row-level modifier.
						aSelectorChoices.push(sSelectorChoice + sRowValue + ":" + sBase + ":" + sTuition);
					}
				}
				if (nGroups == 0) {
					alert("Error: Your browser may not support this script. Please call us to register if the error persists.");
					return false;
				}
				if (nGroups > nSelections) {
					alert("Error: You need to make a selection for one or more Option Groups in the package you've selected. If you chose a live-lecture course, be sure you selected a class date.");
					return false;
				}
				sClassList += aSelectorChoices.join("|") + "|";
			} else {
				sClassList += sRowValue + ":" + sBase + ":" + sTuition + "|";
			}
		} else if ((elmt.type == "radio") && (elmt.checked) && (elmt.getAttribute("myLevel") == "2")) {
			// if a radio button is selected, but its parent checkbox is not, it means user did not complete selection process for a Selector control (package/live)
			tmpItem_ID = elmt.id;
			tmpItem_ID = tmpItem_ID.substr(0, tmpItem_ID.indexOf("_opt_"));
			oParent = document.getElementById(tmpItem_ID);
			if (!oParent.checked) {
				alert("Error: Your package selections do not appear to be complete.\nYou may not have selected a choice in each OPTION GROUP in a package.\n\nPlease review your selections above. You can cancel a package selection by clicking the 'Cancel Selection' button.");
				return false;
			}
		}
	} // next INPUT element in item table
	// no other errors occurred, set the form field
	// NOTE: if the list is blank, this will be caught by the page validator.
	f.elements["classList"].value = sClassList;
}
function formatNumber(n) {
	//formats float number to 2 decimals, returns STRING
	var i = Math.floor(n);
	var r = Math.round((n - i) * 100);
	var rS;
	if (r >= 100) {
		i++;
		r = 0;
	}
	if (r < 10) {
		rS = "0" + r.toString();
	} else {
		rS = r.toString();
		if (rS.length < 2) {
			rS = rS + "0";
		}
	}
	var s = i.toString() + "." + rS;
	return s;
}
function hiRow(cBox) {
	var td = cBox.parentNode;
	var tr = td.parentNode;
	var bHasAlertMsg = false;
	var nCourse_ID = 0;
	if (cBox.getAttribute("alertMsg")) {
		bHasAlertMsg = (cBox.getAttribute("alertMsg") == "1");
		// only level 2 items (courses) have alerts;
		nCourse_ID = cBox.id.substr(cBox.id.indexOf("$") + 1);
	}
	if (cBox.checked) {
		tr.className = "hi";
		if (bHasAlertMsg) {
			itemAlertMsg_init(nCourse_ID);
		}
	} else {
		if (tr.getAttribute("rowStyle")) {
			tr.className = tr.getAttribute("rowStyle");
		} else {
			tr.className = "";
		}
	}
}
function itemAlertMsg_check(cBox) {
	//get item's alert message if it has one.  Called when checkbox is checked or clicked (selector_init), but not when it's unchecked.
	if (cBox.checked) {
		if (cBox.getAttribute("alertMsg") == "1") {
			var nCourse_ID = cBox.id.substr(cBox.id.indexOf("$") + 1);
			itemAlertMsg_init(nCourse_ID);
		}
	}
}
function itemAlertMsg_init(nCourse_ID) {
	sURL = "/WebSite/Register/_Util_ItemData.asp?mode=alertMsg&cid=" + nCourse_ID;
	htRequest(sURL, 'itemAlertMsg_display');
}
function itemAlertMsg_display(msg) {
	msg = msg.replace("<RESULTS><![CDATA[", "");
	msg = msg.replace("]]></RESULTS>", "");
	toggleAlertBox("Special Message", msg);
}

function validateTuition(elmt,rowid,nMin) {
	//For Online courses
	// validate edited tuition value for numeric, and for > minimum allowed.
	var nValue = elmt.value;
	var myvalue;
	var minvalue;
	if (nValue.indexOf("$") > -1) {
		nValue = nValue.replace("$", "");
	}
	if (isNaN(nMin)) {
		minvalue = 0;
	} else {
		minvalue = parseFloat(nMin);
	}
	if (isNaN(nValue)) {
		alert("The value you enter must be a number.");
		elmt.value = "";
		allTuitionsValid = false;
		return false;
	} else {
		myvalue = parseFloat(nValue);
	}
	if (!bRockwellAdmin && (myvalue < minvalue)) {
		alert("The value you entered is lower than your allowed minimum price.\nPlease enter a value higher than $" + nMin + ".");
		elmt.value = "";
		allTuitionsValid = false;
		return false;
	}
	// if those two things are valid, auto-check the checkbox
	allTuitionsValid = true;
	var cBox = document.forms[0].elements["item_" + rowid];
	if (!cBox.checked) { cBox.click();}
}

function treeItemHover(oItem) {
	if (oItem.className == "treeItem") {
		oItem.className = "treeItem_hover";
	}
}
function treeItemUnHover(oItem) {
	if (oItem.className == "treeItem_hover") {
		oItem.className = "treeItem";
	}
}
function itemChildren_get(oItem) {
	var sLevel = oItem.getAttribute("myLevel");
	var nID = oItem.getAttribute("myID");
	var oChildren;
	var oImg = null;
	var sLoading;
	var oLoading = document.getElementById("msgLoading");
	if (oLoading) {
		oLoading.parentNode.removeChild(oLoading);
	}
	if (sLevel == "1") {
		// only level 1 has expand/collapse images
		oImg = oItem.getElementsByTagName("IMG")[0];
	}
	oClickedItem = oItem;
	oChildren = document.getElementById("Children_" + sLevel + ":" + nID);
	if (oChildren) {
		//children already populated; close if open, show if hidden.
		if (oItem.className == "treeItem_open") {
			oChildren.style.visibility = "hidden";
			oChildren.style.display = "none";
			oItem.className = "treeItem";
			if (oImg != null) {
				oImg.setAttribute("src", "Images/group_Exp.gif");
			}
		} else {
			oChildren.style.visibility = "visible";
			oChildren.style.display = "";
			oItem.className = "treeItem_open";
			if (oImg != null) {
				oImg.setAttribute("src", "Images/group_Col.gif");
			}
		}
	} else {
		//children not yet populated
		if (oImg != null) {
			oImg.setAttribute("src", "Images/group_Col.gif");
		}
		oItem.className = "treeItem_open";
		sLoading = "<div id=\"msgLoading\" style=\"color:#888888; padding-left:20px;\">Loading...</div>";
		itemChildren_render(oClickedItem, sLoading);
		var d = new Date();
		var sURL = "/WebSite/Register/_Util_ItemChildren.asp?level=" + sLevel + "&itemID=" + nID + "&xid=" + sXID + "&uid=" + sUID + "&t=" + d.getTime();
		htRequest(sURL, 'itemChildren_process');
	}
}
function itemChildren_process(str) {
	var sResults = "";
	var parentLevel = parseInt(oClickedItem.getAttribute("myLevel"));
	var parentID = oClickedItem.getAttribute("myID");
	var oLoading = document.getElementById("msgLoading");
	if (oLoading) {
		oLoading.parentNode.removeChild(oLoading);
	}
	var nResults;
	var oResults;
	var oRow;
	var tmpItem_ID;
	var tmpItem_Type;
	var sCourse_Type;
	var tmpSpacer = "";
	var hasChildren;
	var nPrePaids;
	var sPrePaid_ID;
	var bShowHoursTmp = bShowHours;		//override page setting if item hours = 0
	str = str.replace("<RESULTS><![CDATA[", "");
	str = str.replace("]]></RESULTS>", "");
	eval("oResults=" + str);
	if (oResults == null) {
		//no items returned
		sResults = "<div id=\"Children_" + parentLevel + ":" + parentID + "\" style=\"padding-left:20px;\">No Items to Display</div>";
		itemChildren_render(oClickedItem, sResults);
		return;
	}
	try { nResults = oResults.Rows.length; } catch (exception) { return;}
	sResults = "<div id=\"Children_" + parentLevel + ":" + parentID + "\" style=\"padding-left:10px; padding-right:5px;\">";
	sResults += "<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">";
	for (i=0; i<nResults; i++) {
		oRow = oResults.Rows[i];
		//do not render item if the ChildData was blank (could happen due to DB error)
		if (oRow.ChildData != "") {
			tmpItem_ID = oRow.Parent_ID + "$" + oRow.Course_ID;
			tmpItem_Type = parseInt(oRow.Course_Type);
			nPrePaids = parseInt(oRow.NumPrePaids);
			sPrePaid_ID = (oRow.PrePaid_ID == "") ? "" : "[" + oRow.PrePaid_ID + "]";
			sCourse_Type = item_TypeDisplay(tmpItem_Type);
			hasChildren = true;
			if (!isNaN(oRow.ChildData)) {
				if (parseInt(oRow.ChildData) == 0) {
					hasChildren = false;
				}
			}
			if (oRow.Course_Hours == 0) {
				bShowHoursTmp = false;
			}
			sResults += ((i % 2) == 0) ? "<tr rowStyle=\"odd\" class=\"odd\">" : "<tr rowStyle=\"\">";
			sResults += "<td width=\"40\" align=\"right\" valign=\"top\" style=\"text-align:right;\">";
			if (!bForPrePaid && (nPrePaids > 0)) {
				sResults += "<span class=\"PPIndicator\" title=\"You have " + nPrePaids + " pre-paid enrollments available for this item.\">" + nPrePaids + "</span>";
			}
			sResults += "<input type=\"checkbox\" id=\"item_" + tmpItem_ID + "\" name=\"item_" + tmpItem_ID + "\"";
			switch (tmpItem_Type) {
				case 2000:
					sResults += " onClick=\"this.checked=false;hiRow(this);selector_init(this);itemAlertMsg_check(this);\" value=\"" + sPrePaid_ID + "\"";
					break;
				case 1101:
					sResults += " onClick=\"this.checked=false;hiRow(this);selector_init(this);itemAlertMsg_check(this);\" value=\"" + sPrePaid_ID + "\"";
					break;
				case 1000:
					//Online Course: If this item has ROSTERS associated with it or it has multiple overlapping active versions, Selector mode.
					if (hasChildren) {
						if (parseInt(oRow.ChildData) > 1000) {
							// single Class_ID
							sResults += " onClick=\"hiRow(this);itemAlertMsg_check(this);\" value=\"" + oRow.ChildData + sPrePaid_ID + "\"";
						} else {
							// multiple choices for this online item
							sResults += " onClick=\"this.checked=false;hiRow(this);selector_init(this);itemAlertMsg_check(this);\" value=\"" + sPrePaid_ID + "\"";
						}
					}
					break;
				default:
					sResults += " onClick=\"hiRow(this);itemAlertMsg_check(this);\" value=\"" + oRow.ChildData + sPrePaid_ID + "\"";
					break;
			}
			if (!hasChildren) {
				sResults += " disabled title=\"No available choices for this item\"";
			} else if (oRow.MetPreReq == "0") {
				sResults += " disabled title=\"Prerequisite Not Met\"";
			} else if (bForPrePaid && (nPrePaids == 0)) {
				sResults += " disabled title=\"Registration for this item is currently on hold.\"";
			}
			//ATTRIBUTES:
			//- iType: 		tells subselector how to query
			//- alertMsg:	when 1, this item has a special message that needs to be displayed to all registrants.
			sResults += " iType=\"" + tmpItem_Type + "\" alertMsg=\"" + oRow.RegAlertMsg + "\"";
			sResults += ">"		//end INPUT tag
			sResults += "</td>";
			sResults += "<td valign=\"top\">";
			sResults += "<label for=\"item_" + tmpItem_ID + "\"";
			if (!hasChildren) {
				sResults += " title=\"This item is not currently available.\" class=\"course_ia\"";
			} else if (oRow.MetPreReq == "0") {
				//No-PreReq: LABEL is grayed out
				sResults += " title=\"PreRequisite Not Met\" style=\"color:#949494;\"";
			} else if (bForPrePaid && (nPrePaids == 0)) {
				sResults += " title=\"Registration for this item is currently on hold.\" class=\"course_ia\"";
			} else {
				sResults += " class=\"course\"";
			}
			sResults += ">";
			sResults += "<img src=\"Images/icon_" + oRow.Course_Type + ".gif\" alt=\"" + sCourse_Type + "\"> " + oRow.Course_Name + "</label>";
			if (bForPrePaid && (nPrePaids == 0)) {
				sResults += "<span style=\"font:normal 8pt Arial; color:#cc0000; white-space:nowrap;\"> &nbsp; * Registration Currently On Hold *</span>";
			} else {
				if (sCourse_Type != "") {
					sResults += "<span style=\"font:normal 8pt Arial; color:#000099; white-space:nowrap;\"> - " + sCourse_Type + "</span>";
				}
				if (oRow.RegAlertMsg == "1") {
					sResults += "<span style=\"font:normal 8pt Arial; color:#cc0000; white-space:nowrap;\"> &nbsp; *Special Alert*</span>";
				}
			}
			sResults += "</td>";
			sResults += "<td width=\"40\" valign=\"top\" style=\"padding-top:3px;\">";
			sResults += "<a href=\"javascript:itemDescription_init(" + oRow.Course_ID + ",'" + bShowHoursTmp.toString() + "');\"><img src=\"Images/detail.gif\" alt=\"Course Description\"> Info</a>";
			sResults += "</td>";
			sResults += "<td width=\"95\" valign=\"top\" style=\"font-size:8pt; padding-top:3px; white-space:nowrap;\">&nbsp; ";
			if (bShowHoursTmp) { sResults += oRow.Course_Hours + " clock hours"; }
			sResults += "</td>";
			sResults += "<td width=\"80\" valign=\"top\" align=\"right\" style=\"padding-top:3px;\">";
			if (bEditableTuitions) {
				// PRE-PAID REDEMPTION
				// If this item is pre-paid, the base value is set to zero, all tuition is rebated to broker;
				// minimum price allowed in box is still Branch_Base, so a broker cannot enter below that amount
				sResults += "<input class=\"box\" type=\"text\" name=\"sTuition_item_" + tmpItem_ID + "\" id=\"sTuition_item_" + tmpItem_ID + "\" size=\"6\" maxlength=\"7\" onchange=\"validateTuition(this,'" + tmpItem_ID + "','" + oRow.Branch_Base + "');\" value=\"" + oRow.Tuition + "\"";
				if (oRow.PrePaid_ID != "") {
					sResults += " base=\"0\" title=\"Minimum Price Allowed: $" + oRow.Branch_Base + "\">";
				} else {
					sResults += " base=\"" + oRow.Branch_Base + "\" title=\"Minimum Price Allowed: $" + oRow.Branch_Base + "\">";
				}
			} else {
				sResults += "<span id=\"sTuition_item_" + tmpItem_ID + "\" base=\"" + oRow.Branch_Base + "\">" + oRow.Tuition + "</span>";
			}
			sResults += "</td></tr>";
		}	// end check for blank ChildData
	}	// next result Row
	sResults += "</table></div>";
	itemChildren_render(oClickedItem, sResults);
	if (sStepToItemID != "") {
		try {
			document.getElementById(sStepToItemID).click();
		} catch(exception) {}
		sStepToItemID = "";
	}
}
function itemChildren_render(oParent, sChildren) {
	//render children in position after parent
	var r;
	var parsedHTML;
	if (((typeof(HTMLElement) != "undefined") && (!HTMLElement.prototype.insertAdjacentElement)) || (!oParent.insertAdjacentHTML)) {
		//Mozilla/FireFox; Safari
		//	- safari's problem is that HTMLElement.insertAdjacentHTML IS a function, but when applied to a DIV object it fails.
		r = oParent.ownerDocument.createRange();
		r.setStartBefore(oParent);
		parsedHTML = r.createContextualFragment(sChildren);
		if (oParent.nextSibling) {
			oParent.parentNode.insertBefore(parsedHTML, oParent.nextSibling);
		} else {
			oParent.parentNode.appendChild(parsedHTML);
		}
	} else {
		// IE
		oParent.insertAdjacentHTML("afterEnd", sChildren);
	}
}
function item_TypeDisplay(nItemType) {
	var sType = "";
	switch(nItemType) {
		case 2000:
			sType = "Package";
			break;
		case 1101:
			sType = "Live Lecture Course";
			break;
		case 1100:
			sType = "Live Lecture Course (Flexible Dates)";
			break;
		case 1000:
			sType = "Online Course";
			break;
		case 1002:
			sType = "Correspondence Course";
			break;
		case 11:
			sType = "Textbook";
			break;
	}
	return sType;
}

//****  Class Option Selector Tool **************************************************************************
function selector_init(oItem) {
	var sItem_ID = oItem.id.replace("item_", "");
	var itemType = oItem.getAttribute("iType");
	var tr = oItem;
	var oTbl;
	var oTR;
	var oCell;
	var oContent;
	var sSelectorHTML = "";
	var bSubSelector = false;
	if (sItem_ID.indexOf("**") != -1) {
		// level 3 selector (sub-selector of live-lecture item within package)
		sItem_ID = sItem_ID.substr(sItem_ID.indexOf("**"));
		bSubSelector = true;
		nCurrentItemLevel = 3;
	} else {
		nCurrentItemLevel = 2;
	}
	if (!document.getElementById("SelectorTool_" + sItem_ID)) {
		while (tr.tagName != "TR") {
			tr = tr.parentNode;
		}
		oTbl = tr.parentNode.parentNode;
		oTR = oTbl.insertRow(tr.rowIndex + 1);
		if (!bSubSelector) {
			oCell = oTR.insertCell(-1);
			oCell.innerHTML = "&nbsp;";
		}
		oCell = oTR.insertCell(-1);
		if (!bSubSelector) {
			oCell.colSpan = 4;
		}
		sSelectorHTML += "<table id=\"SelectorTool_" + sItem_ID + "\" class=\"SelectorTool\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"90%\" style=\"border:solid 1px black;";
		sSelectorHTML += (nCurrentItemLevel == 2) ? "background-color:#f8f9dd;\">" : "background-color:#ffffff;\">";
		if (!bSubSelector) {
			sSelectorHTML += "<tr><td class=\"tItem\" style=\"text-align:left;\">Make your selection(s) below:</td>";
			sSelectorHTML += "<td class=\"tItem\" style=\"text-align:right;\">";
			sSelectorHTML += "<a class=\"tabGray\" href=\"javascript:selector_Close('" + sItem_ID + "',false);\"><img src=\"Images/close.gif\" alt=\"Cancel Selection\"> Cancel this Selection</a>";
			sSelectorHTML += "</td></tr>";
		}
		sSelectorHTML += "<tr><td colspan=\"2\"><div id=\"SelectorTool_Content_" + sItem_ID + "\" class=\"SelectorContent\">Loading...</div></td></tr>";
		sSelectorHTML += "</table>";
		oCell.innerHTML = sSelectorHTML;
		nCurrentItemID = sItem_ID;
		var sURL = "/WebSite/Register/_Util_ItemChildren.asp?level=2&itemID=" + sItem_ID + "&xid=" + sXID + "&itemType=" + itemType;
		htRequest(sURL, 'selector_process');
	}
}
function selector_process(sGroupItem) {
	var d = document.getElementById("SelectorTool_Content_" + nCurrentItemID);
	var oResults;
	var oRow;
	var sResults = "";
	var tmpGroupNum = 0;
	var maxGroupNum = 0;
	var sRadioItemID;
	var sRadioGroupName;
	var n;
	var arrGroupItemCount = new Array(0,0,0,0,0,0,0,0);
	sGroupItem = sGroupItem.replace("<RESULTS><![CDATA[", "");
	sGroupItem = sGroupItem.replace("]]></RESULTS>", "");
	eval("oResults=" + sGroupItem);
	if (oResults == null) {
		d.innerHTML = "Sorry, there are no options available at this time.";
	} else {
		// set max group number (determines if "Option Group" text is shown)
		// set count of items in each group (determines auto-selected)
		for (i=0; i<oResults.Rows.length; i++) {
			oRow = oResults.Rows[i];
			if (oRow.Group_Num > maxGroupNum) {
				maxGroupNum = oRow.Group_Num;
			}
			arrGroupItemCount[oRow.Group_Num] += 1;
		}
		for (i=0; i<oResults.Rows.length; i++) {
			oRow = oResults.Rows[i];
			if (oRow.Group_Num != tmpGroupNum) {
				if (sResults != "") {
					sResults += "</table><br>";
				}
				sResults += "<table border=\"0\" cellspacing=\"0\" width=\"100%\" id=\"itemOptGroup_" + oRow.Group_Num + "_" + nCurrentItemID + "\">";
				if (maxGroupNum > 1) {
					sResults += "<tr><td style=\"border-top:solid 1px #777777;\"><b>Option Group " + oRow.Group_Num + "</b></td></tr>";
				}
				tmpGroupNum = oRow.Group_Num;
			}
			if (arrGroupItemCount[oRow.Group_Num] == 1) {
				sResults += "<tr class=\"hi\">";
			} else {
				sResults += "<tr>";
			}
			// both ID and NAME need to have Radio Group Number.  Reason: there are packages that offer the same item multiple times (a set of options that are all electives)
			sRadioItemID = "item_" + nCurrentItemID + "_opt_" + tmpGroupNum + ";" + oRow.Item_ID;
			sRadioGroupName = "item_" + oRow.Group_Num + "-" + nCurrentItemID + "_opts_" + tmpGroupNum;
			sResults += "<td class=\"optItem\"><input type=\"radio\" name=\"" + sRadioGroupName + "\" id=\"" + sRadioItemID + "\"";
			if (arrGroupItemCount[oRow.Group_Num] == 1) {
				sResults += " checked";
			}
			sResults += " iType=\"" + oRow.Item_Type + "\"";
			sResults += " myLevel=\"" + nCurrentItemLevel + "\"";
			if (oRow.Item_Type == "1101") {
				//live-lecture package item; will open 2nd level selector
				nCourseID = oRow.Item_ID;
				sResults += " value=\"" + oRow.Item_ID + "\" onclick=\"selector_hiliteChoice(this);selector_init(this);parentCheckReadyState(this);\"> ";
			} else {
				//not a live-lecture package item
				sResults += " value=\"" + oRow.Item_ID + "\" onclick=\"selector_hiliteChoice(this);parentCheckReadyState(this);\"> ";
			}
			sResults += "<label for=\"" + sRadioItemID + "\" class=\"course\">";
			if (oRow.Item_Type != "") {
				sResults += "<img src=\"Images/icon_" + oRow.Item_Type + ".gif\" alt=\"\"> ";
			}
			sResults += oRow.Item_Name + "</label>";
			if ((oRow.Item_Type != "") || (oRow.Item_Info != "")) {
				sResults += "&nbsp; &nbsp; <span style=\"width:180px;font-size:8pt;\">";
				if (oRow.Item_Type != "") {
					sResults += item_TypeDisplay(parseInt(oRow.Item_Type));
				}
				sResults += "&nbsp; " + oRow.Item_Info + "</span>";
			}
			sResults += "</td></tr>";
		}
		sResults += "</table>";
		d.innerHTML = sResults;
		parentCheckReadyState("SelectorTool_Content_" + nCurrentItemID);
		if (sStepToOptionID != "") {
			// auto-select an option (level 2 only, no package auto-selection)
			try {
				document.getElementById(sStepToOptionID).click();
			} catch(exception) {}
			sStepToOptionID = "";
		}
	}
	nCurrentItemID = "";
}
function selector_hiliteChoice(oItem) {
	// unhilite any previously selected option;
	//  if selected option had a 2nd-level selector, hide it.
	var f = document.getElementById("f");
	var opts = f.elements[oItem.name];
	var itm_ID = oItem.id;
	var sSubSelectorId;
	var dSub;
	for (i=0; i<opts.length; i++) {
		if (opts[i].id != itm_ID) {
			if (opts[i].parentNode.parentNode.className = "hi") {
				opts[i].parentNode.parentNode.className = "";
			}
			if (opts[i].getAttribute("iType") == "1101") {
				//this is a live-lecture that might have a visible subselector
				sSubSelectorId = opts[i].id;
				sSubSelectorId = sSubSelectorId.substr(sSubSelectorId.indexOf("_opt_") + 5);
				sSubSelectorId = sSubSelectorId;
				dSub = document.getElementById("SelectorTool_" + sSubSelectorId);
				if (dSub) {
					selector_Close(sSubSelectorId);
				}
			}
		}
	}
	// hilite the SELECTOR row, not the parent (course) row
	hiRow(oItem);
}
function parentCheckReadyState(oItem) {
	// when any item in a selector is selected, see if the parent checkbox row is ready to be checked
	// example:  all options in a package have been set.
	// note:  oItem can be string, which is when a selector is first rendered and is initially checked for state
	//		(because on render, every necessary item might have been auto-selected)
	var oSelector;
	var aRadios;
	var i;
	var tmpName = "";
	var nGroups = 0;
	var nSelections = 0;
	var oParent;
	if (typeof(oItem) == "string") {
		oSelector = document.getElementById(oItem);
	} else {
		oSelector = oItem;
		while (oSelector.tagName != "DIV") {
			oSelector = oSelector.parentNode;
		}
	}
	if (!oSelector) { return;}
	aRadios = oSelector.getElementsByTagName("INPUT");
	if (aRadios.length > 0) {
		// loop all radio groups in this selector.  if a selection is made in each one, the parent is ready to be checked.
		for (i=0; i<aRadios.length; i++) {
			if (aRadios[i].getAttribute("myLevel") == "2") {
				if (aRadios[i].name != tmpName) {
					//new group
					tmpName = aRadios[i].name;
					nGroups++;
				}
				if (aRadios[i].checked) {
					nSelections++;
				}
			}
		}
		if ((nGroups > 0) && (nGroups == nSelections)) {
			// check parent row
			oParent = document.getElementById(oSelector.id.replace("SelectorTool_Content_", "item_"));
			if (oParent) {
				oParent.checked = true;
				hiRow(oParent);
			}
		}
	}
}
function selector_Close(itemID) {
	// unload selector or subselector; uncheck parent row checkbox
	// do not need to bother unchecking Radio choices; if reloaded, they're reset.
	var f = document.getElementById("f");
	var cBox = f.elements["item_" + itemID];
	var oSelector = document.getElementById("SelectorTool_" + itemID);
	var oTbl;
	var oTR;
	oTR = oSelector.parentNode;
	while (oTR.tagName != "TR") {
		oTR = oTR.parentNode;
	}
	oTbl = oTR.parentNode.parentNode;
	oTbl.deleteRow(oTR.rowIndex);
	if (cBox) {
		cBox.checked = false;
		hiRow(cBox);
	}
}
//****  End Class Date Selector Tool *************************************************************************
//****  CC Roster Selector Tool ******************************************************************************
var sCC_SelectorLevel;
function cc_listOptions(selectedVal, selectorLevel) {
	sCC_SelectorLevel = selectorLevel;
	if (selectedVal != "") {
		with (document.getElementById("dCCRosterSelector_KeyCode").style) {
			visibility = "hidden";
			display = "none";
		}
		var dColleges = document.getElementById("dCCRosterSelector_Colleges");
		var dRosters = document.getElementById("dCCRosterSelector_Rosters");
		var sURL;
		if (selectorLevel == 1) {
			dColleges.innerHTML = "Loading...";
			dRosters.innerHTML = "";
			sURL = "/WebSite/Register/_Util_ItemChildren.asp?level=colleges&xid=" + sXID + "&itemID=" + selectedVal;
		} else {
			dRosters.innerHTML = "Loading...";
			sURL = "/WebSite/Register/_Util_ItemChildren.asp?level=rosters&xid=" + sXID + "&itemID=" + selectedVal;
		}
		htRequest(sURL, 'cc_listOptions_process');
	}
}
function cc_listOptions_process(str) {
	var dColleges = document.getElementById("dCCRosterSelector_Colleges");
	var dRosters = document.getElementById("dCCRosterSelector_Rosters");
	var sResults = "";
	var oResults;
	var oRow;
	str = str.replace("<RESULTS><![CDATA[", "");
	str = str.replace("]]></RESULTS>", "");
	eval("oResults=" + str);
	if (oResults == null) {
		//no items returned
		if (sCC_SelectorLevel == 1) {
			dColleges.innerHTML = "<span style=\"color:#993300; font-weight:bold;\">Error: No colleges are available from this state.</span>";
			dRosters.innerHTML = "";
		} else {
			dRosters.innerHTML = "<span style=\"color:#993300; font-weight:bold;\">Error: No active rosters are available from this college.</span>";
		}
		return;
	}
	if (sCC_SelectorLevel == 1) {
		sResults = "Select your college:<br>";
		sResults += "<div id=\"ccSchoolDropDown\" style=\"border-style:inset;border-width:2px; background-color:InfoBackground; width:500px; height:18px; padding:0px;\" onclick=\"toggleCCOpts('ccSchoolOpts',1);\">";
		sResults += "<img id=\"ccSchoolDropDown_img\" src=\"images/arrow_select.gif\" alt=\"\" style=\"margin:0px;float:right;\">&nbsp;<span id=\"ccSchoolDropDown_Text\" style=\"cursor:default;\">- Please make a selection below -</span></div>";
		sResults += "<div id=\"ccSchoolOpts\" style=\"visibility:hidden; position:absolute; z-index:100; border-style:solid; border-color:Black; border-width:1px 2px 2px 1px; background-color:#eff2f5; width:500px; margin:0px;";
		if (oResults.Rows.length > 6) {
			sResults += "height:250px; overflow:auto;"
		}
		sResults += "\">";
		for (i=0; i<oResults.Rows.length; i++) {
			oRow = oResults.Rows[i];
			sResults += "<a class=\"ccRoster\" href=\"javascript:ccSelectorSet('ccSchoolDropDown_Text'," + oRow.Branch_ID + ",'" + oRow.Branch_Name + "');\">"
			sResults += (oRow.Skin_Graphic != "") ? "<img src=\"/SatelliteLogos/" + oRow.Skin_Graphic + ".jpg\" alt=\"\" style=\"float:left;\" height=\"30\"> " : "<img src=\"/SatelliteLogos/default.jpg\" alt=\"\" style=\"float:left;\" height=\"30\"> ";
			sResults += "<b>" + oRow.Branch_Name + "</b>";
			sResults += "<br><span style=\"color:#66cc00;\">&nbsp; &nbsp; Location: " + oRow.City + ", " + oRow.State + "</a></span>";
		}
		sResults += "</div>";
		dColleges.innerHTML = sResults;
	} else {
		sResults = "Select your instructor and class:<br>";
		sResults += "<div id=\"ccRosterDropDown\" style=\"border-style:inset;border-width:2px; background-color:InfoBackground; width:500px; height:18px; padding:0px;\" onclick=\"toggleCCOpts('ccRosterOpts',1);\">";
		sResults += "<img id=\"ccRosterDropDown_img\" src=\"images/arrow_select.gif\" alt=\"\" style=\"margin:0px;float:right;\">&nbsp;<span id=\"ccRosterDropDown_Text\" style=\"cursor:default;\">- Please make a selection below -</span></div>";
		sResults += "<div id=\"ccRosterOpts\" style=\"visibility:hidden; position:absolute; z-index:100; border-style:solid; border-color:Black; border-width:1px 2px 2px 1px; background-color:#eff2f5; width:500px; margin:0px;";
		if (oResults.Rows.length > 6) {
			sResults += "height:250px; overflow:auto;"
		}
		sResults += "\">";
		for (i=0; i<oResults.Rows.length; i++) {
			oRow = oResults.Rows[i];
			sResults += "<a class=\"ccRoster\" href=\"javascript:ccSelectorSet('ccRosterDropDown_Text'," + oRow.Roster_ID + ",'" + oRow.Roster_Name + "');\"><b>" + oRow.Roster_Name + "</b><br>&nbsp; &nbsp;" + oRow.Instructor_Name + "</a>";
		}
		sResults += "</div>";
		dRosters.innerHTML = sResults;
	}
}
function ccSelectorSet(idSelector, nItem_ID, sItemName) {
	document.getElementById(idSelector).innerHTML = sItemName;
	if (idSelector == "ccSchoolDropDown_Text") {
		//save Branch_ID selection in hiddenfield
		document.getElementById("sBranchID").value = nItem_ID;
		// This assumes the reg page is set up correctly with the option BranchSelect=cc.  If not, this will cause error.
		cc_listOptions(nItem_ID, 2);
	} else {
		//save roster selection in hiddenfield
		document.getElementById("ccSelector_Roster_ID").value = nItem_ID;
		with (document.getElementById("dCCRosterSelector_KeyCode").style) {
			visibility = "visible";
			display = "";
		}
	}
}
function toggleCCOpts(optsID,flag) {
	var d = document.getElementById(optsID);
	d.style.visibility = (flag == 1) ? "visible" : "hidden";
}
function ccKCOptSelect(oOpt) {
	switch (oOpt.id) {
		case "CC_kc_yes":
			document.getElementById("CC_kc_no").checked = false;
			with (document.getElementById("CC_kc_box").style) {
				visibility = "visible";
				display = "";
			}
			with (document.getElementById("CC_nokc_box").style) {
				visibility = "hidden";
				display = "none";
			}
			with (document.getElementById("CC_kc_boxinstr").style) {
				visibility = "visible";
				display = "";
			}
			break;
		case "CC_kc_no":
			document.getElementById("CC_kc_yes").checked = false;
			with (document.getElementById("CC_kc_box").style) {
				visibility = "hidden";
				display = "none";
			}
			with (document.getElementById("CC_nokc_box").style) {
				visibility = "visible";
				display = "";
			}
			with (document.getElementById("CC_kc_boxinstr").style) {
				visibility = "hidden";
				display = "none";
			}
			break;
	}
}
function cc_KCValidate() {
	var kc1 = document.getElementById("CC_kc1").value;
	var kc2 = document.getElementById("CC_kc2").value;
	var kc3 = document.getElementById("CC_kc3").value;
	if ((kc1.length == 4) && (kc2.length == 4) && (kc3.length == 4)) {
		//complete keycode, validate.
		var sURL = "/WebSite/Register/_Util_KCValidate.asp?kc=" + kc1 + "-" + kc2 + "-" + kc3;
		htRequest(sURL, 'cc_KCValidate_process');
	}
}
function cc_KCValidate_process(str) {
	var oMsg = document.getElementById("ccKC_result");
	var oKCPkID = document.getElementById("ccSelector_KC_PkID");
	str = str.replace("<RESULTS><![CDATA[", "");
	str = str.replace("]]></RESULTS>", "");
	var kcResult = parseInt(str);
	switch(kcResult) {
		case -1:
			oMsg.className = "ccKCInvalid";
			oMsg.innerHTML = "<img src=\"/edu/control_imgs/course_incomplete.gif\" alt=\"\"> KeyCode Already Used";
			oKCPkID.value = "";
			alert("The KeyCode you entered has already been redeemed and cannot be used.");
			break;
		case 0:
			oMsg.className = "ccKCInvalid";
			oMsg.innerHTML = "<img src=\"/edu/control_imgs/course_incomplete.gif\" alt=\"\"> KeyCode Not Found";
			oKCPkID.value = "";
			alert("The KeyCode you entered was not found.");
			break;
		default:
			oMsg.className = "ccKCValid";
			oMsg.innerHTML = "<img src=\"/edu/control_imgs/course_complete.gif\" alt=\"\"> KeyCode is Valid";
			oKCPkID.value = kcResult;
			break;
	}
}
//****  End CC Roster Selector *******************************************************************************
//****  "Find My Info" Processing ****************************************************************************
function findMyInfo_init() {
	var f = document.getElementById("f");
	var sURL = "/WebSite/Register/_Util_AcctLookup.asp?";
	if (((f.elements["FMI_email"].value != "") && (f.elements["FMI_zip"].value != "")) || ((f.elements["FMI_last_name"].value != "") && (f.elements["FMI_phone"].value != ""))) {
		sURL += "em=" + f.elements["FMI_email"].value;
		sURL += "&zip=" + f.elements["FMI_zip"].value;
		sURL += "&ln=" + f.elements["FMI_last_name"].value;
		sURL += "&ph=" + f.elements["FMI_phone"].value;
		htRequest(sURL, 'findMyInfo_process');
	} else {
		alert("You must supply your email address AND zip code,\nOR your last name AND phone number.\n\nYou may call our registration line for help finding your account.");
	}
}
function findMyInfo_process(str) {
	var sResults = "";
	var fMI = document.getElementById("AlertBox_FindMyInfo");
	str = str.replace("<RESULTS><![CDATA[", "");
	str = str.replace("]]></RESULTS>", "");
	eval("oFMIResult=" + str);
	sResults = "<a href=\"javascript:toggleAlertBox('Find My Account','FindMyInfo');\"><img src=\"Images/arrow_bk.gif\" alt=\"Go Back\"> Go Back</a><br><br>";
	if (oFMIResult == null) {
		sResults += "<b>Sorry, no matching accounts were found</b>. Our records may be out of date.<br><br>You can continue registration as a new account, or call us for help finding your existing account.";
	} else if (oFMIResult == "overflow") {
		sResults += "Sorry, <b>multiple possible matches</b> were found. Your account could not be precisely located.<br><br>You may have multiple accounts in our system. Please call our registration line to register and have your accounts combined.";
	} else {
		sResults += "<span style=\"color:#336600\"><b>A matching account was found!</b></span> Please make sure the information below is yours.<br><br>";
		sResults += "<p style=\"margin:10px; color:#336600;\">" + oFMIResult.First_Name + " " + oFMIResult.Last_Name + "<br>";
		sResults += oFMIResult.Address + ", &nbsp; " + oFMIResult.City + ", " + oFMIResult.State + " &nbsp;" + oFMIResult.Zip + "<br>";
		sResults += "&nbsp; &nbsp; Phone: " + oFMIResult.Day_Phone + "<br>";
		sResults += "Email: " + oFMIResult.Email + "</p>";
		sResults += "<p><a href=\"javascript:findMyInfo_select(1);\"><img src=\"/edu/control_imgs/course_complete.gif\" alt=\"\"> <b>Yes</b>, this is me</a>. (any changes you make will be saved to your account)</p>";
		sResults += "<p><a href=\"javascript:findMyInfo_select(0);\"><img src=\"/edu/control_imgs/course_incomplete.gif\" alt=\"\"> <b>No, this is not my account</b></a>. (contine as a new account)</p>";
	}
	fMI.style.visibility = "hidden";
	fMI.style.display = "none";
	document.getElementById("AlertBox_Content").innerHTML = sResults;
}
function findMyInfo_select(flag) {
	var f = document.getElementById("f");
	var rex = /\(|\)|\-|\ /gi;
	var tmpPhoneStr;
	if ((flag == 0) || (oFMIResult == null)) {
		f.elements["uid"].value = "";
		f.elements["First_Name"].value = "";
		f.elements["Middle_Name"].value = "";
		f.elements["Last_Name"].value = "";
		f.elements["Address"].value = "";
		f.elements["City"].value = "";
		f.elements["State"].value = "";
		f.elements["Zip"].value = "";
		f.elements["Email"].value = "";
		f.elements["sD1"].value = "";
		f.elements["sD2"].value = "";
		f.elements["sD3"].value = "";
		// these may not be shown on this page
		if (f.elements["sE1"]) {
			f.elements["sE1"].value = "";
			f.elements["sE2"].value = "";
			f.elements["sE3"].value = "";
		}
		if (f.elements["sF1"]) {
			f.elements["sF1"].value = "";
			f.elements["sF2"].value = "";
			f.elements["sF3"].value = "";
		}
	} else {
		//load info into boxes
		f.elements["uid"].value = oFMIResult.User_ID;
		f.elements["First_Name"].value = oFMIResult.First_Name;
		f.elements["Middle_Name"].value = oFMIResult.Middle_Name;
		f.elements["Last_Name"].value = oFMIResult.Last_Name;
		f.elements["Address"].value = oFMIResult.Address;
		f.elements["City"].value = oFMIResult.City;
		f.elements["State"].value = oFMIResult.State;
		f.elements["Zip"].value = oFMIResult.Zip;
		f.elements["Email"].value = oFMIResult.Email;
		tmpPhoneStr = oFMIResult.Day_Phone;
		if (tmpPhoneStr != "") {
			tmpPhoneStr = tmpPhoneStr.replace(rex, "");
			if (tmpPhoneStr.length == 10) {
				f.elements["sD1"].value = tmpPhoneStr.substr(0, 3);
				f.elements["sD2"].value = tmpPhoneStr.substr(3, 3);
				f.elements["sD3"].value = tmpPhoneStr.substr(6);
			}
		}
		if (f.elements["sE1"]) {
			tmpPhoneStr = oFMIResult.Eve_Phone;
			if (tmpPhoneStr != "") {
				tmpPhoneStr = tmpPhoneStr.replace(rex, "");
				if (tmpPhoneStr.length == 10) {
					f.elements["sE1"].value = tmpPhoneStr.substr(0, 3);
					f.elements["sE2"].value = tmpPhoneStr.substr(3, 3);
					f.elements["sE3"].value = tmpPhoneStr.substr(6);
				}
			}
		}
		if (f.elements["sF1"]) {
			tmpPhoneStr = oFMIResult.Fax;
			if (tmpPhoneStr != "") {
				tmpPhoneStr = tmpPhoneStr.replace(rex, "");
				if (tmpPhoneStr.length == 10) {
					f.elements["sF1"].value = tmpPhoneStr.substr(0, 3);
					f.elements["sF2"].value = tmpPhoneStr.substr(3, 3);
					f.elements["sF3"].value = tmpPhoneStr.substr(6);
				}
			}
		}
	}
	oFMIResult = null;
	toggleAlertBox('', '');
}
//****  End "Find My Info" ***********************************************************************************
//****  Final Validation and Submit **************************************************************************
function verifyForm(f) {
	// called when user clicks CONTINUE
	//	1. call to validate ClassList
	//		if successful, this function will populate the form field "classList"
	//		function will raise errors if there are any.
	//	2. make sure classList and/or CC Roster ID have been filled.  If not, student chose nothing.
	//	3. call to validate StudentInfo
	//		- that function will check state and zip, which is async call.
	//		- if async return value is valid, continues to Student Agreement
	//		- Student Agreement continues to next page.
	validate_ClassList(f);
	if ((f.elements["classList"].value == "") && (f.elements["ccSelector_Roster_ID"].value == "")) {
		//nothing has been selected
		alert("Error: You have not chosen any items or your selection(s) are incomplete.\nPlease review your selections again. If you selected any packages, make sure you've chosen each option properly.");
	} else {
		validate_StudentInfo(f);
	}
}
function validate_StudentInfo(f) {
	var sDay_Phone;
	var sEve_Phone;
	var sFax;
	for (i=0; i<f.elements.length; i++) {
		var e = f.elements[i];
		if ((e.type == "text") && (e.getAttribute("req") == "1") && (e.value == "")) {
			alert("Please complete all required fields.")
			return false; 
			break;
		} // end if
	} // end loop form.elements
	if (sBranchSelect == "select") {
		//make sure a branch office was selected in this case.
		if (f.sBranchID.selectedIndex == 0) {
			alert("Please choose your office location from the Branch Office list.");
			return false;
		}
	}
	if (document.getElementById("CC_StudentNumber")) {
		var oCCSN1 = document.getElementById("CC_StudentNumber");
		var oCCSN2 = document.getElementById("CC_StudentNumber2");
		if ((oCCSN1.value != "") && (oCCSN1.value != oCCSN2.value)) {
			alert("The College Student ID Numbers you entered do not match. Please double-check the number you entered.\n\nYour college instructor must have the correct number to track your grades!");
			return false;
		}
	}
	//build phone number strings in proper format
	try {
		sDay_Phone = "(" + f.elements["sD1"].value + ") " + f.elements["sD2"].value + "-" + f.elements["sD3"].value;
		if (sDay_Phone == "() -") { sDay_Phone = "";}
	} catch (exception) {
		sDay_Phone = "";
	}
	try {
		sEve_Phone = "(" + f.elements["sE1"].value + ") " + f.elements["sE2"].value + "-" + f.elements["sE3"].value;
		if (sEve_Phone == "() -") { sEve_Phone = "";}
	} catch (exception) {
		sEve_Phone = "";
	}
	try {
		sFax = "(" + f.elements["sF1"].value + ") " + f.elements["sF2"].value + "-" + f.elements["sF3"].value;
		if (sFax == "() -") { sFax = "";}
	} catch (exception) {
		sFax = "";
	}
	f.elements["Day_Phone"].value = sDay_Phone;
	f.elements["Eve_Phone"].value = sEve_Phone;
	f.elements["Fax"].value = sFax;
	//alert user if they entered a PO Box as an address, that they won't receive materials.
	// if they say OK anyway, continue with reg.
	if (CheckPOBOX(f.elements["Address"].value)) {
		if (!CheckEmail(f.elements["Email"])) {
			alert("Please input a proper E-Mail address\n (i.e. support@rockwellinstitute.com)");
			return false;
		}
	} else {
		return false;
	}
	// final check: Zip + State matching
	ZipStateCheck(f);
}
function CheckEmail(oBox){
	var sEmail = oBox.value;
	var emailexp = /^[a-z_0-9][a-z_0-9\-\.]*\@[a-z_0-9\.\-]+\.[a-z]{2,3}$/i;
	if (!emailexp.test(sEmail) && sEmail != "") {
		if (oBox.name == "Email") {
			document.getElementById("vEmail").innerHTML = " Please enter a valid email address!"
		} else {
			// also handles "Find My Info" email box.
			alert("The email address you've entered does not appear to be valid.");
		}
		return false;
	} else {
		if (oBox.name == "Email") {
			document.getElementById("vEmail").innerHTML = "*"
		}
		return true;
	}
}
function CheckPOBOX(str) {
	str = str.toLowerCase();
	var alertStr = "";
	if ((str.indexOf("po box") != -1) || (str.indexOf("p.o. box") != -1) || (str.indexOf("pobox") != -1) || (str.indexOf("post office box") != -1)) {
		alertStr += "PLEASE NOTE: UPS does not ship to P.O. Boxes!\n\n";
		alertStr += "Delivery of any course materials will be delayed\n";
		alertStr += "if you enter a P.O. Box as your mailing address.\n\n";
		alertStr += "Click OK to CONTINUE and IGNORE this message.\n Click CANCEL to CHANGE YOUR ADDRESS now.";
		return (confirm(alertStr));
	} else {
		return true;
	}
}
function CheckSpecial_AtHomeBranchMD(str) {
	var rex = /[a-z0-9]{3}-[a-z0-9]{3}/i;
	if (!rex.test(str)) {
		alert("Please enter the Branch-MD in the form AAA-AAA only!\n\nThe field should be three letters, a dash, and three more letters,\ndenoting the branch code and the Managing Director code.");
	}
}
function checkHeardAbout(d) {
	var otherBox = document.getElementById("HeardAbout_OtherBox");
	otherBox.style.visibility = (d.value == "other") ? "visible" : "hidden";
}
function ZipStateCheck(f) {
	//called as last step of verification (due to async callback)
	// note: if state or zip are left blank, validate_StudentInfo will catch it.
	var sState = f.elements["State"].value;
	var sZip = f.elements["Zip"].value;
	if (sState != "") {
		sState = sState.toUpperCase();
		f.elements["State"].value = sState;
	}
	if (sZip != "") {
		//handle zip codes for USA and Canada.
		// If USA, must be all numbers and only 5 characters.
		// If CA, will be 6 characters alphanumeric.
		if (isNaN(sZip)) {
			if (sZip.length != 6) {
				alert("Postal Code Error: If this is a Canadian postal code, please make sure it is only 6 characters.");
				return false;
			}
		} else if (sZip.length != 5) {
			alert("The zip code you entered does not appear to be valid.\nPlease make sure you enter your 5-digit zip code correctly. (we do not need the +4 code)");
			return false;
		}
	}
	if ((sState != "") && (sZip != "")) {
		// proceed to async server check of zip/state
		var sURL = "/WebSite/Register/_Util_ZipCheck.asp?st=" + sState + "&z=" + sZip;
		htRequest(sURL, 'ZipStateCheck_process');
	}
}
function ZipStateCheck_process(str) {
	str = str.replace("<RESULTS><![CDATA[", "");
	str = str.replace("]]></RESULTS>", "");
	switch (str) {
		case "missing":
			// no alert needed; value is empty
			break;
		case "state":
			alert("The state abbreviation you entered does not appear to be valid. Please check it and try again.\n\nOnly US states and Canadian provinces are allowed.");
			break;
		case "zip":
			alert("ERROR: According to our database, the zip code and state you entered do not match. Please be sure you've entered your zip code correctly.");
			break;
		default:
			// State/Zip check Passed - continue to Agreement
			// Skip Student Agreement for Community College students.
			if (document.getElementById("ccSelector_Roster_ID").value != "") {
				submitForm();
			} else {
				agreementShow();
			}
	}
}
function agreementShow() {
	//student must click I Agree to continue.
	var h = f_clientHeight();
	var w = f_clientWidth();
	var s = f_scrollTop();
	var d = document.getElementById("StudentAgreement");
	d.className = "Agreement";
	d.style.top = (Math.floor(h / 2) - 175 + s) + "px";
	d.style.left = (Math.floor(w / 2) - 350) + "px";
	toggleGrayOut(true);
}
function submitForm() {
	// called when user clicks "I Agree" on agreement panel.
	// check ClassList/CCRoster one last time, make sure it didn't get cleared somehow.
	var f = document.getElementById("f");
	if ((f.elements["classList"].value == "") && (f.elements["ccSelector_Roster_ID"].value == "")) {
		//nothing has been selected
		alert("Error: You have not chosen any items or your selection(s) are incomplete.\nPlease review your selections again. If you selected any packages, make sure you've chosen each option properly.");
		var d = document.getElementById("StudentAgreement");
		d.className = "AlertBoxHidden";
		toggleGrayOut(false);
		return false;
	}
	if ((f.elements["ccSelector_Roster_ID"].value != "") && (f.elements["ccSelector_KC_PkID"].value == "") && (!f.elements["CC_kc_no"].checked)) {
		// CC roster selected, but keycode not entered or not valid.
		alert("You have selected a Community College Online course, but did not enter a valid Activation KeyCode. If you do not have one, check the box that says 'I do not have a KeyCode and must pay now.'");
		return false;
	}
	f.submit();
}
