<!--

function ShowCartCourses(BuyType, cboName) {
	addID = eval("document.form1." + cboName + ".value");
	if (addID == "") {
		alert("Please select an upcoming Start Date for this course. If you require assistance, please contact the BSC.");
		//return false;
	}
	else
	{
		URL = "/shoppingcart/viewcart.asp?typeID=" + BuyType + "&addID=" + addID;
		location.href = URL;
		//return false;
	}
}

function ShowCartMemberships(BuyType, addID) {
	URL = "/shoppingcart/viewcart.asp?typeID=" + BuyType + "&addID=" + addID;
	location.href = URL;
	return false;
}

function ShowCartOpenFormat(BuyType, CourseID) {
	URL = "/shoppingcart/viewcart.asp?typeID=" + BuyType + "&addID=" + CourseID;
	location.href = URL;
	return false;
}

function ShowCartGiftCert(BuyType) {
	Amount = document.form1.giftcertamount.value;
	URL = "/shoppingcart/viewcart.asp?typeID=" + BuyType + "&addID=" + Amount;
	location.href = URL;
	return false;
}

function purchaseEvents(BuyType) {
	var CartItems = "";
	var el = document.getElementsByName('chkPurchaseEvent')
	var numEventsPurchased = el.length;
	for(i=0;i<numEventsPurchased;i++){  //loop through array of event checkboxes
		if(el[i].checked){ //add this item to the cart list
			if (CartItems != "") CartItems += ":"
			CartItems += el[i].value;
		}
    }
	if (CartItems != "") {
		URL = "/shoppingcart/viewcart.asp?typeID=" + BuyType + "&addID=" + CartItems;
		location.href = URL;
	}
	else {
		alert("You must select at least one event for purchase.");
		//return false;
	}
}

function selectRadioButton(optName, optNumber) {
	eval("document.form1." + optName + "[" + optNumber + "].checked=true");
}

function doMacroValidate(BuyType, MacroID) {
var i=0, j;
var str;
var CartItems = MacroID;
var macroNames = document.form1.txtCourses.value;
var macroNameArray=macroNames.split(","); //hidden text box with English course names
var found=false;
var success=true;
	while (i < macroNameArray.length) {  //loop through array of courses
		str = macroNameArray[i];
		macroNameNoSpaces = str.replace(/ /g, "");
		el = document.getElementsByName(macroNameNoSpaces);
		numRadioButtons = el.length;
		j=0;
		found=false;
		//alert(numRadioButtons + " radio buttons")
		while (j < numRadioButtons) {  //loop through formats for this course
			if (el[j].checked==true) {
				thisFormat = el[j].value;
				if (thisFormat != "open") {
					cboName = "cbo" + macroNameNoSpaces;
					elCombo = document.getElementsByName(cboName);
					thisValue = elCombo[j].value;
					if (thisValue == "") {
						alert("You must select a valid upcoming date for the " + macroNameArray[i] + " course.");
						success = false;
					}
					else { //add this item to the cart list
						CartItems += ":" + thisValue;
					}
				}
				else { //open format
					CartItems += ":0:" + str;
				}
				found = true;
			}
			j+=1;
		}
		if (found==false) {
			alert("You must select one of the " + macroNameArray[i] + " course formats.");
			success = false;
		}
		i+=1;
	}
	//alert(CartItems);
	if (success == true) {
		URL = "/shoppingcart/viewcart.asp?typeID=" + BuyType + "&addID=" + CartItems;
		location.href = URL;
	}
	else return false;
}

//-->
