// JavaScript Document

function IsTextBoxValueNumeric(cField, oField, bValidateNonNegative, bRequired) {
//-----------------------------------------------------------------------------
// Modified by MMurillo
//-----------------------------------------------------------------------------
	/*********************
	 * Algorithm:
	 *	- Check to see if the field exists
	 *	- Check to see if the field is empty, but required
	 *	- Check to see if the value of the field is numeric
	 *	- Check to see if the value of the field is positive if
	 *		the bValidateNonNegative flag is on
	 *********************/
	try{
		if (!oField) {
			alert("The field " + cField + " does not exist");
			return false;
		}
		else {
			oField.value = Trim(oField.value);

			if (oField.value == "") {
				if (bRequired) {
					alert("You must enter a value for the field " + cField);
					return false;
				}
			}
			else if (isNaN(oField.value)) {
				alert("The value for " + cField + " must be numeric.\nThis is the value you attempted to add: " + oField.value);
				oField.value = "";
				oField.focus();
				return false;
			}
			else {
				nValue = parseInt(oField.value);
				
					if ((bValidateNonNegative) && (nValue < 0)) {
					alert("The value for " + cField + " must be positive.\nThis is the value you attempted to add: " + oField.value);
					oField.value = "";
					oField.focus();
					return false;
				}
			}
		}

		//if we get here, it means value is a number, return true
		return true;
	}catch(e){
		alert(e.message);
	}	
}

function IsNumeric(nNumber)
{
	//jd - 11/09/01: takes a number and returns true if it's numeric and false otherwise
	
	//error handler
		try
		{
	
		//verify number var is not null or empty
			if(nNumber == '' || nNumber == null) return false;
			
		//verify if it is a number
			if(isNaN(nNumber)){
				return false;
			}else{
				return true;
			}
			
		}catch(e){
			return false;
		}
}

function Val(cNumber)
{
	//jd - 11/09/01: takes a string and turns it into a number: if string is not a number (including empty or null), then it returns zero
		
	//validate cNumber
		if(!IsNumeric(cNumber)) cNumber = 0;
		
	//turn into number and return
		return parseInt(cNumber);
}


function HasBinaryValue(nBinaryValue, nValueToCheck)
{
	/** jd - 11/09/2001: takes a binary value and ANDS it with the value to check. Returns true if the value to check is in the binary value
	*	false otherwise
	*/	
		
		//error handler
		try
		{
			
			//and both numbers and return
				if(Val(nBinaryValue) & Val(nValueToCheck)){
					return true;	
				}else{
					return false;
				}	
	
	
		}catch(e){
			alert('Error attempting to validate Binary Value: ' + nBinaryValue + ' and ' + nValueToCheck);		
		}

}

