function ChooseCat(catNumber, caller) {
	
	thePage = "DisplayCats.asp?f=" + caller
	window.open(thePage, "ChooseCatWindow", "height=500,width=600,toolbar=no,status=no,scrollbars=yes,resizable=no,top=200,left=300");
	document.SignUp2.catIndex.value = catNumber;
}
							
function ClearCat(catNumber) {
	//First count the number of total cats...if only one then present error and exit
	numCats = 0;
	for (i=1; i<=5; i++) {
		textBoxName = "Cat" + i;
		theCatObj = eval("document.SignUp2." + textBoxName);
		if (theCatObj.value != "") {
			lastCatID = i;
			numCats++;
		}
	}
																   
	if (numCats == 0) {
		return;
	}
	else if ((numCats == 1) && (lastCatID == catNumber)) {
		alert('You must have at least 1 category. This category will not be deleted.\nYou can change the category by clicking "Select Category".');
		return;
	}	
	else {					   
		textBoxName = "Cat" + catNumber;
		hiddenCatID = "CatID" + catNumber;
		theCatObj = eval("document.SignUp2." + textBoxName);
		theIDObj = eval("document.SignUp2." + hiddenCatID);
		theCatObj.value = "";
		theIDObj.value = "";
	}
																   
}
								
function EnableForm() {
	//document.SignUp2.Cat1.disabled = false;
	//document.SignUp2.Cat2.disabled = false;
	//document.SignUp2.Cat3.disabled = false;
	//document.SignUp2.Cat4.disabled = false;
	//document.SignUp2.Cat5.disabled = false;
	return true;
}

function EnableCats() {
	for (i=1; i<=5; i++) {	
		catIndex = "Cat" + i;
		document.SignUp2[catIndex].disabled = false;
	}
	return true;
}

function ValidateCats() {
	
	numCats = 0;
	numIDs = 0;
	for (i=1; i<=5; i++) {
		textBoxName = "Cat" + i;
		hiddenCatID = "CatID" + i;
		//alert('document.SignUp2[textBoxName].value: ' + document.SignUp2[textBoxName].value)
		//alert('document.SignUp2[hiddenCatID].Value: ' + document.SignUp2[hiddenCatID].value)
		if (document.SignUp2[textBoxName].value != "") {
			numCats++;
		}
		if (document.SignUp2[hiddenCatID].value != "") {
			numIDs++;
		}
	}
	
	if (numCats == 0) {
		alert('You have not selected a category for your company.\nPlease choose one or more categories.')
		return false;
	}	
	else if (numIDs == 0) {
		alert('There is a problem processing your inputs.\nYou may need to close your browser then start over.\nPlease contact the webmaster to report this problem.')
		return false;
		
	}	
	else if (numCats != numIDs) {
		alert('There is a problem processing your inputs.\nYou may need to close your browser then start over.\nPlease contact the webmaster to report this problem.')
		return false;
	}
	else
	{
		EnableCats();
		return true;
	}
}
	
