function ucDate_getComboValue(controlId, name) {
	var oCbo = document.getElementById
		((controlId != "")?controlId + "_" + name: name);

	return oCbo.options[oCbo.selectedIndex].value;
}

function ucDate_getMin(controlId) {
	return ucDate_getComboValue(controlId, "cboMinute");
}

function ucDate_getHour(controlId) {
	return ucDate_getComboValue(controlId, "cboHour");
}

function ucDate_getDay(controlId) {
	return ucDate_getComboValue(controlId, "cboDay");
}

function ucDate_getMonth(controlId) {
	return ucDate_getComboValue(controlId, "cboMonth");
}

function ucDate_getYear(controlId) {
	return ucDate_getComboValue(controlId, "cboYear");
}

function ucDate_getValue(controlId) {
	return ucDate_buildDate(ucDate_getDay(controlId), ucDate_getMonth(controlId), ucDate_getYear(controlId));
}

function ucDate_buildDate(day, month, year) {
	if (day == "" || month == "" || year == "") {
		return null;
	}
	month--;
	var oDate = new Date();
	oDate.setDate(1); // to stop month roll-over issue below
	oDate.setYear(year);
	oDate.setMonth(month);
	oDate.setDate(day);
	if (oDate.getDate() == day && oDate.getMonth() == month && oDate.getFullYear() == year) {
		return oDate;
	} else {
		return null;
	}
}

function ucDate_toString(date) {
	if (date == null) return "";
	var sMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	return date.getDate() + "-" + sMonths[date.getMonth()] + "-" + date.getFullYear();
}

function ucDate_validate(description, controlId, mandatory, optional, minDay, minMth, minYr, maxDay, maxMth, maxYr) {
	var iDay = ucDate_getDay(controlId);
	var iMth = ucDate_getMonth(controlId);
	var iYr = ucDate_getYear(controlId);
	
	if (iDay == "" && iMth == "" && iYr == "") {
		if (mandatory) {
			alert(Translate(MSG_PLEASE_SPECIFY_VALUE) + " " + description);
			return false;
		} 
		else if (optional) {
		   	return confirm(Translate(MSG_NOT_A_VALID_VALUE) + " " + description + ". " + Translate(MSG_CLICK_OK_TO_PROCEED) + " " + description);
		} 	
	} else {
		if (iDay == "" || iMth == "" || iYr == "") {
			alert(Translate(MSG_PLEASE_SPEFICY_FOR_ALL_PARTS) + " " + description + "\n" + Translate(MSG_IE_DMY));
			return false;
		} else {
			var oDate = ucDate_buildDate(iDay, iMth, iYr);
			if (oDate == null) {
				alert(Translate(MSG_INVALID_VALUE_FOR) + " '" + description + "'.");
				return false;
			} else {
				if (minDay > 0) {
					var oMinDate = ucDate_buildDate(minDay, minMth, minYr);
					if (oDate < oMinDate) {
						alert("'" + description + "' " + Translate(MSG_CANNONT_BE_BEFORE) + " " + ucDate_toString(oMinDate));
						return false;
					}
				}
				if (maxDay > 0) {
					var oMaxDate = ucDate_buildDate(maxDay, maxMth, maxYr);
					if (oDate > oMaxDate) {
						alert("'" + description + "' " + Translate(MSG_CANNONT_BE_AFTER) + " " + ucDate_toString(oMaxDate));
						return false;
					}
				}
			}
		}
	}
	return true;
}