//### [JAVASCRIPTS]		

	//# Function: C
	
		//# fnCalculateChars: This function calculates the number of characters entered in a textarea box
		function fnCalculateChars(objObject,intMaxChars) {
			if(objObject.value.length > intMaxChars) {
			//# Yes, the characters length have exceeded the maximum length
				return true; 
			} else {
			//# No, it is not exceeded
				return false; 
			}
		}
		
		//# fnCalculateRowNumbers: This function calculates the number of rows in a textarea.
		function fnCalculateRowNumbers(objName) {

			//# The first line must be calculated
			var intCRLFCount = 1;
			
			for (var i = 0; i < strText.length; i++) {   		
				//# The first character
				var strChar1 = strText.substring(i, i+1);
				
				if (strChar1 == '\n') {
				// if the first character is a carriage return
					intCRLFCount = intCRLFCount + 1;
		   		}
			}	

			/*
			if (intCRLFCount >= intMax) {
				alert('You have entered ' + intCRLFCount + ' lines.\nYou are not allowed to type more than ' + intMax + ' lines.');		
				return false;
			} else {
			//# No alert at all, return the texts
				return true;
			}
			*/
			
			return intCRLFCount;
		
		}		
		
		//# fnCheckDate: This function checks the validity of dates
		function fnCheckDate(strDate) {
			
			if (strDate == "") { 
			//# If there is empty value, ignore it
				return true;
			} else {
			
				day = strDate.substr(0,2);
				month = strDate.substr(3,2);
				year = strDate.substr(6,4);
				
				var today = new Date();
				year = ((!year) ? fnY2K(today.getYear()):year);
				month = ((!month) ? today.getMonth():month-1);
				if (!day) return false
				var test = new Date(year,month,day);
				if ((fnY2K(test.getYear()) == year) && (month == test.getMonth()) && (day == test.getDate())) { return true; } else { return false; }
			
			}
			
		}	
	

	//# Function: G
	
		//# fnGetTodayDate: This function gets today date.
		function fnGetTodayDate() {

			var d=new Date();
			var day=d.getDate();
			var month=d.getMonth() + 1;
			var year=d.getFullYear();
			
			//# To pad with 0 in front
			if (month < 10) { month = "0" + month; }
			
			return day + "-" + month + "-" + year;
			
		}		
	
	
	//# Function: I
			
		
		//# fnIsCurrency: This function checks whether a value is currency format.
		function fnIsCurrency(objName){

			val = objName.value;
			cur = /^-?\d{1,3}(,\d{3})*(\.\d{1,2})?$/;
			anum = /(^-?\d+$)|(^-?\d+\.\d+$)/;
			ret = false;

			if (val.indexOf(",") > -1) { 
			 	ret = cur.test(val);
			} else {
			 	ret = anum.test(val);
			}

			if (!ret) {		 	
			 	return false;
			} else {
			 	return true;
			}
		}
		
		
		//# fnIsNumeric: To check whether the text is numeric
		function fnIsNumeric(sText) {
		   
		   var ValidChars = "0123456789.";
		   var IsNumber=true;
		   var Char;
		 
		   for (i = 0; i < sText.length && IsNumber == true; i++) { 
		      Char = sText.charAt(i); 
		      if (ValidChars.indexOf(Char) == -1) 
		         {
		         IsNumber = false;
		         }
		   }
		   return IsNumber;
		   
		}	


	//# Function: P

		//# pad_with_zeros: (Used in fnRound)
		function pad_with_zeros(rounded_value, decimal_places) {

			// Convert the number to a string
			var value_string = rounded_value.toString()
			
			// Locate the decimal point
			var decimal_location = value_string.indexOf(".")

			// Is there a decimal point?
			if (decimal_location == -1) {
				
				// If no, then all decimal places will be padded with 0s
				decimal_part_length = 0
				
				// If decimal_places is greater than zero, tack on a decimal point
				value_string += decimal_places > 0 ? "." : ""
			}
			else {

				// If yes, then only the extra decimal places will be padded with 0s
				decimal_part_length = value_string.length - decimal_location - 1
			}
			
			// Calculate the number of decimal places that need to be padded with 0s
			var pad_total = decimal_places - decimal_part_length
			
			if (pad_total > 0) {
				
				// Pad the string with 0s
				for (var counter = 1; counter <= pad_total; counter++) 
					value_string += "0"
				}
			return value_string
		}	
	
	//# Function: R	
	
		//# fnRound: To round up a value.
		function fnRound(original_number, decimals) {
			var result1 = original_number * Math.pow(10, decimals)
			var result2 = Math.round(result1)
			var result3 = result2 / Math.pow(10, decimals)
			return pad_with_zeros(result3, decimals)
		}
	
	
	//# Function: S
	
	//# Function: V

		//# fnValidateEmailAddress: This function validates the email address format
		function fnValidateEmailAddress($field) {
			with ($field) {
				apos=value.indexOf("@");
				dotpos=value.lastIndexOf(".");
				if (apos<1||dotpos-apos<2) { 
					return false;
				} else {
					return true;
				}
			}
		}
		
		//# fnValidatePhoneNumber:  This function validates phone numbers
		function fnValidatePhoneNumber(sText) {
		   
		   var ValidChars = "0123456789.()#+-";
		   var IsNumber=true;
		   var Char;
		 
		   for (i = 0; i < sText.length && IsNumber == true; i++) { 
		      Char = sText.charAt(i); 
		      if (ValidChars.indexOf(Char) == -1) 
		         {
		         IsNumber = false;
		         }
		   }
		   return IsNumber;
		   
		}			

		
	
	//# Function: Y
	
		//# fnY2K: To solve the problems with Y2K error. (Used in fnCheckDate)
		function fnY2K(number) { return (number < 1000) ? number + 1900 : number; }
	
	