// check whether the passed data is an integer
function IsInteger(strSubmittedChars){
	strValidChars = '0123456789'
	flgDecimalFound = 'N'
	  
	for (count = 0; count < strSubmittedChars.length; count++) {
		chrCurrentChar = strSubmittedChars.substring (count, count + 1)
		
		if (strValidChars.indexOf(chrCurrentChar) == -1)
			return (false)
	}
	
	return (true)
}

// check whether the passed data is a decimal
function IsDecimal(strSubmittedChars){
	strValidChars = '0123456789.'
	chrDecimalPresent = 'N'
	chrNumberSubmitted = 'N'
	  
	for (count = 0; count < strSubmittedChars.length; count++) {
		chrCurrentChar = strSubmittedChars.substring (count, count + 1)
		
		if (strValidChars.indexOf(chrCurrentChar) == -1)
			return (false)
		else 
			if (strValidChars.indexOf(chrCurrentChar) == 10)
				if (chrDecimalPresent == 'Y')
					return(false)
				else
					chrDecimalPresent = 'Y'
			else
				chrNumberSubmitted = 'Y'		
	}
	
	if (chrNumberSubmitted == 'Y')
		return (true)
	else
		return (false)
}

// format valid number as currency
function FormatCurrency(strValidCurrency) {
	var strFormattedCurrency
	  
	// locate decimal point
	intDecimalPosition = strValidCurrency.indexOf(".")
	
	// if no decimal point present
	if (intDecimalPosition == -1) {
		// add decimal point & 2 zeros
		strValidCurrency = strValidCurrency + '.00'
	}
	else {
		// determine no. of values after decimal point
		intDecimalPlaces = (strValidCurrency.length - 1) - intDecimalPosition
			
		// add missing zeros 
		switch (intDecimalPlaces) {
			case 0:
				strValidCurrency = strValidCurrency + '00'
				break
			case 1:
				strValidCurrency = strValidCurrency + '0'
		}
	}
	
	// get value only up to 2 decimal places
	strFormattedCurrency = strValidCurrency.substr(0, strValidCurrency.indexOf(".") + 3)
	
	return strFormattedCurrency
}

