 // CheckMandatoryFields - This function checks the received field and displays it's message if has no value
	//		sObjectName - The object name to check
	//		sErrorMessage - The error message to display if field is empty
	// Returns no value
	function CheckMandatoryFieldsWithMsgs(sObjectName,sErrorMessage) {
		var iReply = true;
		var oColl = document.getElementById(sObjectName);
		if (oColl != null) {
				if (oColl.length == null) {
				if (oColl != null) {
					if (TrimString(oColl.value) == '') iReply = false;
					var oCurrent = oColl;
				}
			} else {
				if (oColl.tagName == 'SELECT') {
					if (oColl.selectedIndex == -1) iReply = false;
					var oCurrent = oColl;
				} else {
					var i = 0;
					while (i < oColl.length && iReply) {
						if (TrimString(oColl[i].value) == '')	iReply = false;
						var oCurrent = oColl[i];
						i++;
					}
				}
			}
		}
		if (!iReply) {
			rc_alert (sErrorMessage);
			oCurrent.focus();
		}
		return (iReply);
	}

	// CheckMandatoryFields - This function checks an individual field according to it's type and quantity
	//		sObjectName - The name of the mandatory object
	//		bIsSetFocus - Indication whether to set focus on field in case it is empty
	// Returns true or false
	function CheckMandatoryFields(sObjectName, bIsSetFocus) {
		var bReply = true;

		var oColl = document.getElementById(sObjectName);
		if (oColl != null) {
				if (oColl.length == null) {
				if (oColl != null) {
					if (TrimString(oColl.value) == '') bReply = false;
					var oCurrent = oColl;
				}
			} else {
				if (oColl.tagName == 'SELECT') {
					if (oColl.selectedIndex == -1) bReply = false;
					var oCurrent = oColl;
				} else {
					var i = 0;
					while (i < oColl.length && bReply) {
						if (TrimString(oColl[i].value) == '')	bReply = false;
						var oCurrent = oColl[i];
						i++;
					}
				}
			}
		}
		// Set focus on the field if necessary
		if ( !bReply && bIsSetFocus )	oCurrent.focus();

		return (bReply);
	}

	// CheckMandatoryArrayOfFields - This function checks a list of fields and displays a message for all missing values
	//		arrObjectNames - The object names to check
	//		arrErrorMessage - The error message to display if field is empty
	// Returns no value
	function CheckMandatoryArrayOfFields ( arrObjectNames, arrErrorMessages ) {
		var bReply = true;
		var sErrorMessage = "";
		var bIsFocusSet = true;

		if ( arrObjectNames.length != arrErrorMessages.length ) {
			alert('The arrays received are not correlating in size!');
		}
		for ( var Index = 0 ; Index < arrObjectNames.length ; Index++ ) {
			bReply = CheckMandatoryFields (arrObjectNames[Index], bIsFocusSet);
			if (!bReply) {
				sErrorMessage += arrErrorMessages[Index];
				bIsFocusSet = false;
			}
		}
		rc_alert (sErrorMessage);

		return;
	}

	// SetNullFields - This function inserts one space character into non-mandatory fields
	//		sObjectName - The name of the non-mandatory field
	// Returns no value
	function SetNullFields(sObjectName) {
		i = 0;
		var oColl = document.getElementById(sObjectName);
		if (oColl != null) {
			if (oColl.length == null) {
				if (oColl!= null) {
					if (TrimString(oColl.value) == '') {
						oColl.value = ' ';
					}
				}
			} else {
				while (i < oColl.length) {
					if (TrimString(oColl[i].value) == '') {
						oColl[i].value = ' ';
					}
					i++;
				}
			}
		}

		return;
	}

	//  CheckEMailAddress - This function checks the validity of an E-Mail Address 
	//	Checks if E-Mail Address contains ONE "@" and doesn't ends with a dot (".")
	//		EMailAddress - The value for checking
	//  Returns True or False
	function CheckEMailAddress ( EMailAddress ) {
		// Declare RegularExpression of E-Mail address
		EMailAddressRegExp = new RegExp ( "^[^@ ]+@([^@\. ]+\.)+[^@\. ]+$" );
		return ( EMailAddressRegExp.test ( EMailAddress ) );};

	//  CheckDate - This function checks the validity of a date
	//		DateValue - The value for checking
	//  Returns True or False
	function CheckDate ( DateValue ) {
		if ( DateValue.length > 0 ) {
			CenturyBegin = CheckDate.arguments[1] >= 0 ? CheckDate.arguments[1] : -1;
			RegExpString = "^((0|1|2|3)?\d)[\./-]((0|1)?\d)[\./-]";
			RegExpString += CenturyBegin != -1 ? "(\d{2}|\d{4})$" : "(\d{4})$";
			var DateRegExp = new RegExp ( RegExpString );
			retVal = null;

			if ( DateRegExp.test ( DateValue ) ) {
				DateRegExp.exec ( DateValue );
				var Day = RegExp.$1.valueOf();
				var Month = RegExp.$3.valueOf();
				var Year = RegExp.$5.valueOf();
				if ( Year.length == 2 )	{
					var Today = new Date();
					CurrYear = Math.round(Today.getFullYear() / 100) * 100;
					Year = Year <= CenturyBegin ? CurrYear + (Year - 0) : CurrYear + (Year - 100);
				}
				MaxDay = getNoOfDaysInMnth ( Month, Year);
				if ( (1 <= Day && Day <= MaxDay) && (1 <= Month && Month <= 12) ) {
					var d = new Date ( Year, Month - 1, Day );
					CheckDate.Date = d;
					CheckDate.FixedDate = d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear();
					retVal = true;
				} else {
					CheckDate.FixedDate = "";
					retVal = false;
				}
			} else {
				CheckDate.FixedDate = "";
				retVal = false;
			}
		} else {
			CheckDate.FixedDate = "";
			retVal = true;
		}
		return retVal;
	}

	//  CheckNumber - This function checks the validity of a number
	//		NumberValue - The value for checking
	//		TotalDigits - The number of digits allowed, including decimal digits
	//		DecimalDigits - The number of decimal digits allowed
	//  Returns True or False
	function CheckNumber ( NumberValue, TotalDigits, DecimalDigits ) {
		var RegExpString = "^(\\d{0," + (TotalDigits - DecimalDigits) + "})(\\.(\\d{0," + DecimalDigits + "}))?$";
		var NumberRegExp = new RegExp ( RegExpString );
		retVal = null;
		if ( NumberRegExp.test ( NumberValue ) ) {
			NumberRegExp.exec ( NumberValue );
			var Integer = RegExp.$1.valueOf();
			var Decimal = RegExp.$3.valueOf();
			retVal = true;
		} else {
			retVal = false;
		}
		return retVal;
	}

