function StripDate(strDate) {
	var intI;
	var intJ;
	var intK;
	var bValid = false;
	var strTemp;
	var strMonth;
	var strDay;
	var strYear;
	while (1 == 1) {
		strTemp = "";
		for (intI = 0; intI < strDate.length; intI ++) {
			if (strDate.charAt(intI) == " ") {
				strTemp += "A";
			}
			else {	
				strTemp += strDate.charAt(intI);
			}
		}
		
//		window.alert(strTemp);
		
		intI = strTemp.indexOf("/", 0);
		if (intI < 1) {
			break;
		}
// window.alert("parseInt(strTemp.slice(intI - 2, intI)) = " + parseInt(strTemp.slice(intI - 2, intI)));
		if (isNaN(parseInt(strTemp.slice(intI - 2, intI)))) {
// window.alert("strTemp.slice(intI - 2, intI) = " + strTemp.slice(intI - 2, intI));
			if (isNaN(parseInt(strTemp.slice(intI - 1, intI)))) {
// window.alert("strTemp.slice(intI - 1, intI) = " + strTemp.slice(intI - 1, intI));
				break;
			}
			else {
				strMonth = strTemp.slice(intI - 1, intI);
			}
		}	
		else {
			strMonth = strTemp.slice(intI - 2, intI);
		}	

//		window.alert("Month = " + strMonth); 

		intI += 1;
		intJ = strTemp.indexOf("/", intI);
		if (intJ - intI < 1 || intJ - intI > 2) {
			break;
		}
		if (isNaN(strTemp.slice(intI, intJ))) {
			break;
		}
		else {
			strDay = strTemp.slice(intI, intJ);
		}

//		window.alert("Day = " + strDay); 

		intJ += 1;
		if (intJ + 2 > strTemp.length) {
			break;
		}	
		strTemp = strTemp + "AA";

		if (isNaN(strTemp.slice(intJ, intJ + 4))) {
			if (isNaN(strTemp.slice(intJ, intJ + 3))) {
				if (isNaN(strTemp.slice(intJ, intJ + 2))) {
					break;
				}
				else {
					strYear = "20" + strTemp.slice(intJ, intJ + 2);
				}
			}
			else {
				strYear = "2" + strTemp.slice(intJ, intJ + 3);
			}
		}
		else {
			strYear = strTemp.slice(intJ, intJ + 4);
		}
		bValid = true;
		break;
	}				
	if (bValid) {
		if (strMonth.length < 2) {
			strMonth = "0" + strMonth;
		}	
		if (strDay.length < 2) {
			strDay = "0" + strDay;
		}	
		return strMonth + "/" + strDay + "/" + strYear;
	}
	else {
		return "BAD"
	}	
	
}

function Calendar(strDate) {
//	window.alert(strDate);
	var arMonth = new Array("January", "February", "March", "April", "May", "June", "July",
									"August", "September", "October", "November", "December");
	var arCalendar = new Array();
	var intYear = 2000;
	var intMonth;
	var intDate;
	var intDay;
	var intStart = 6;
	var intBegin;
	var intEnd;
	var intIndex = -1;
	var intMnEnd = 12;
	var intPlus = 0;
	var intGo = 0;
	var intMn;
	var intYr;
	var intPlus;
	var intFrom;
	var intTo;
	var intI;
	var intJ;
//	var strDate = "register.asp?Course=1560&amp;Date=7/10/00 to 7/14/00&amp;Cost=2125";
	var strDate1;
	var strDate2 = "";
	var bNeedFrom = true;
	var bNeedTo = true;
	
	intI = strDate.indexOf("Date", 0);
	if (intI < 0) {
		return;
	}
	intJ = strDate.indexOf(" to ", intI + 4);
	if (intJ < 0) {
		strDate1 = StripDate(strDate.slice(intI));
		if (strDate1 == "BAD") {
//			window.alert("You bet!");
			return;
		}	
	}
	else {
		strDate1 = StripDate(strDate.slice(intI, intJ));
		if (strDate1 == "BAD") {
			return;
		}	
// window.alert(strDate.slice(intJ + 4, strDate.length) + " length = " + strDate.slice(intJ + 4, strDate.length).length);
		strDate2 = StripDate(strDate.slice(intJ + 4, strDate.length));
		if (strDate2 == "BAD") {
			return;
		}	
	}
	if (strDate1.slice(0, 1) == 0) {
		intMn = parseInt(strDate1.slice(1, 2));
	}
	else {
		intMn = parseInt(strDate1.slice(0, 2));
	}	
	intYr = parseInt(strDate1.slice(6, 10));
	if (strDate1.slice(3, 4) == 0) {
		intFrom = parseInt(strDate1.slice(4, 6));
	}
	else {
		intFrom = parseInt(strDate1.slice(3, 6));
	}	
	intTo = intFrom;
	if (!(strDate2 == "")) {
// window.alert(strDate2);
		if (strDate2.slice(3, 4) == 0) {
			intTo = parseInt(strDate2.slice(4, 6));
		}
		else {
			intTo = parseInt(strDate2.slice(3, 6));
		}	
	}
	if (intTo < intFrom) {
		intPlus = 1;
	}		

//	window.alert(intMn + "," + intYr + "," + intFrom + "," + intTo + "," + intPlus);		
	



	for (intYear = 2000; intYear <= intYr; intYear++) {
		if (intYear == intYr) {
			intMnEnd = intMn + intPlus;
			if (!(intGo)) {
//				window.alert("intMnEnd = " + intMnEnd);
			}	
			intGo = 1;
		}	
		for (intMonth = 1; intMonth <= intMnEnd; intMonth++) {
			intDate = 0;
			intBegin = 1;
			intEnd = 0;
			for (intDay = 0; intDay < 42; intDay++) {
				if (intEnd) {
					intDate = 0;
				}
				else {
					if (!(intDay < intStart)) {
						intDate += 1;
						intBegin = 0;
					}	
					if (intMonth % 12 == 1 || intMonth % 12 == 3 || intMonth % 12 == 5 || intMonth % 12 == 7 ||
							intMonth % 12 == 8 || intMonth % 12 == 10 || intMonth % 12 == 0) {
						if (intDate > 31) {
							intDate = 0;
							intStart = intDay % 7;
							intEnd = 1;
						}	
					}		
					if (intMonth % 12 == 4 || intMonth % 12 == 6 || intMonth % 12 == 9 || intMonth % 12 == 11) {
						if (intDate > 30) {
							intDate = 0;
							intStart = intDay % 7;
							intEnd = 1;
						}	
					}		
					if (intMonth % 12 == 2) {
						if (intYear % 4 == 0) {
							if (intDate > 29) {
								intDate = 0;
								intStart = intDay % 7;
								intEnd = 1;
							}
						}
						else {		
							if (intDate > 28) {
								intDate = 0;
								intStart = intDay % 7;
								intEnd = 1;
							}	
						}	
					}
				}			

				if (intGo) {
					if (!(intMonth < intMn)) {
						if (intPlus) {
//							if ((intBegin && (!(intMonth < intMnEnd))) || intEnd) {
							if (intBegin && (!(intMonth == intMn))) {
								continue;
							}
							if (intEnd && (!(intMonth == intMnEnd))) {
								continue;
							}
						}		
						if ((intDay > 0 ) && intDay % 7 == 0) {
							if (intDate == 0 || intEnd) {
								break;
							}
							if (intPlus && intMonth == intMnEnd && !(bNeedTo)) {
								break;
							}
						}		
						intIndex += 1;
						arCalendar[intIndex] = intDate;
						if (bNeedFrom && intDate == intFrom) {
							intFrom = intIndex;
							bNeedFrom = false;
						}	
						if (bNeedTo && !(bNeedFrom) && intDate == intTo) {
							intTo = intIndex;
							bNeedTo = false;
						}	
					}
				}

			}
		}
	}
	
//	window.alert(arCalendar.length);
//	window.alert("August" + arCalendar.slice(0,42));
//	window.alert("September" + arCalendar.slice(42,84));
	
	for (intDay = 0; intDay <= 6; intDay++) {
		document.all["mnuCLDay" + intDay].color = "#000000";
		if (intDay > 0) {
			document.all["mnuCLTR" + intDay].style.display = "none";
			document.all["mnuCLTR" + intDay].style.visibility = "hidden";
		}
	}

	intDate = 0;
	for (intDay = 1; intDay <= arCalendar.length; intDay++) {
		if ((intDay % 7) == 1) {
			intDate += 1;
			document.all["mnuCLTR" + intDate].style.display = "block";
			document.all["mnuCLTR" + intDate].style.visibility = "visible";
		}
		if (arCalendar[intDay - 1] == 0) {
			document.all["mnuCLDate" + intDay].innerText = " ";
			document.all["mnuCLDate" + intDay].color = "#000000";
		}
		else {
			document.all["mnuCLDate" + intDay].innerText = arCalendar[intDay - 1];
//			if ((arCalendar[intDay - 1] >= intFrom) && (arCalendar[intDay - 1] <= intTo)){
			if (((intDay - 1 >= intFrom) && (intDay - 1 <= intTo)) && 
				!(strDate.slice(0, 5) == "Month")){
				document.all["mnuCLDay" + intDay % 7].color = "#FF0000";
				document.all["mnuCLDate" + intDay].color = "#FF0000";
			}
			else
			{		
				document.all["mnuCLDate" + intDay].color = "#000000";
			}	
		}
	}		
	document.all["mnuCLHead"].innerText = arMonth[intMn - 1] + " " + intYr;
		
//	document.all["mnuCLMenu"].style.position = "absolute";
//	document.all["mnuCLMenu"].style.top = 10;
//	document.all["mnuCLMenu"].style.left = 10;
//	document.all["mnuCLMenu"].style.display = "block";
//	document.all["mnuCLMenu"].style.visibility = "visible";
//	document.all["mnuCLTR6"].style.visibility = "hidden";
//	window.alert("Well?");
	return true;
}


function PopCalendar(strParam) {
	var arMonth = new Array("January", "February", "March", "April", "May", "June", "July",
				"August", "September", "October", "November", "December");

// The foolowing 4 lines can be fixed by making the VB program use blank for the high order zero 
	if (strParam.slice(0, 1) == "0") {
		var intMonth = parseInt(strParam.slice(1, 2));
	}
	else {
		var intMonth = parseInt(strParam.slice(0, 2));
	}

	var intYear = parseInt(strParam.slice(2, 6));
	var intStart = parseInt(strParam.slice(6, 8));
	var intReset = parseInt(strParam.slice(8, 10));
	var intStop = parseInt(strParam.slice(10, 12));
	var intBegin = parseInt(strParam.slice(12, 14));
	var intEnd = parseInt(strParam.slice(14, 16));
	var arCalendar = new Array();
	var intDate = 0;
	var intI;
	var bStop = false;

// window.alert("strParam = " + strParam + ", strParam.slice(12, 14) = " + strParam.slice(12, 14))	
// window.alert(intMonth + "," + intYear + "," + intStart + "," + intReset + "," + intStop + "," + intBegin + "," + intEnd) 
	for (intI = 0; intI < intStart; intI++) {
		arCalendar[intI] = 0;
	}
	for (intI = intStart; intI < intStop; intI++) {
		if (intDate == intReset) {
			intDate = 0;
			if (intI > intEnd) {
				bStop = true;
			}
		}
		if (bStop) {
			arCalendar[intI] = 0;
		}
		else {
			intDate++;
			arCalendar[intI] = intDate;
		}
	}
//	window.alert(arCalendar.length);
//	window.alert("August " + arCalendar.slice(0,42));





	for (intI = 0; intI < 7; intI++) {
		document.all["mnuCLDay" + intI].color = "#000000";
		document.all["mnuCLTR" + (intI + 1)].style.display = "none";
		document.all["mnuCLTR" + (intI + 1)].style.visibility = "hidden";
	}
	intDate = 0;
	for (intI = 1; intI <= arCalendar.length; intI++) {
		if ((intI % 7) == 1) {
			intDate += 1;
			document.all["mnuCLTR" + intDate].style.display = "block";
			document.all["mnuCLTR" + intDate].style.visibility = "visible";
		}
		if (arCalendar[intI - 1] == 0) {
			document.all["mnuCLDate" + intI].innerText = " ";
			document.all["mnuCLDate" + intI].color = "#000000";
		}
		else {
			document.all["mnuCLDate" + intI].innerText = arCalendar[intI - 1];
//			if (((intI - 1 >= intBegin) && (intI - 1 <= intEnd)) && 
//				!(strParam.slice(0, 5) == "Month")){
			if ((intI - 1 >= intBegin) && (intI - 1 <= intEnd) &&
				(intBegin > 0) && ( 
				!(intEnd - intBegin > 4) ||
				(intEnd - intBegin > 4 && (!(intI % 7 == 0) && !(intI % 7 == 1)))
				)){
// if (intI - 1 == 7){
// window.alert ("intBegin = " + intBegin + " intEnd = " + intEnd + " intI = " + intI)
// }
				document.all["mnuCLDay" + intI % 7].color = "#FF0000";
				document.all["mnuCLDate" + intI].color = "#FF0000";
			}
			else
			{		
				document.all["mnuCLDate" + intI].color = "#000000";
			}	
		}
	}		
	document.all["mnuCLHead"].innerText = arMonth[intMonth - 1] + " " + intYear;


	return true;
}





