//-----------------------------------------Begin------------------------------------------//
			
	/*		
	===================================================================
	NAME: numberToTextDescription
	TYPE: javascript (User Defined Function)
	VERSION: 1.05.09.28
	CREATED ON: 9/28/2005
	AUTHOR: Dean Dal Bozzo, dean@pagefx.com
	===================================================================	

	DESIGNED FOR: Use within javascript coding

	DESCRIPTION: Converts a floaing point number to it's text description.

	NOTES: Does not round numbers. Because of a limit on higher numbers.

	USAGE:  
		
	ATTRIBUTES: 
		n				REQUIRED	string or number
		
	OUTPUT: text description of inputed number.
	
	EXAMPLES:
			n as a string 	numberToTextDescription('100.965'); 	outputs: 'One hundred and 97/100.'
			n as a number	numberToTextDescription(100.965); 		outputs: 'One hundred and 97/100.'
	
	UPDATES: None
	===================================================================
	*/

	//--numberToTextDescription--------------------------------------//	
	function numberToTextDescription(n){	
		re			= /^((\d+)(\.(\d{1,2})\d*)|(\.(\d{1,2})\d*)|([1-9]+\d*))$/
		num 		= re.exec(n);
	
		// Check if we have a number to convert
		if(!num){
			output = 'ERROR! This function can only convert floating point numbers.  To use this function change the input to a floating point number.';
		}else{
			numStr		= num[0];
			output 		= '';
			decStr		= '';
			decNum 		= '00';
			decPrefix 	= 'and ';
			decSuffix	= '/100.';
	
			// 1-19
			num1_19Str		= new Array();
			num1_19Str[0] 	= '';
			num1_19Str[1] 	= 'one ';
			num1_19Str[2] 	= 'two ';
			num1_19Str[3] 	= 'three ';
			num1_19Str[4] 	= 'four ';
			num1_19Str[5] 	= 'five ';
			num1_19Str[6] 	= 'six ';
			num1_19Str[7] 	= 'seven ';
			num1_19Str[8] 	= 'eight ';
			num1_19Str[9] 	= 'nine ';
			num1_19Str[10] 	= 'ten ';
			num1_19Str[11] 	= 'eleven ';
			num1_19Str[12] 	= 'twelve ';
			num1_19Str[13] 	= 'thirteen ';
			num1_19Str[14] 	= 'fourteen ';
			num1_19Str[15] 	= 'fifteen ';
			num1_19Str[16] 	= 'sixteen ';
			num1_19Str[17] 	= 'seventeen ';
			num1_19Str[18] 	= 'eighteen ';
			num1_19Str[19] 	= 'nineteen ';
	
			// 20-90 even ten numbers
			tensStr		= new Array();
			tensStr[20] 	= 'twenty';
			tensStr[30] 	= 'thirty';
			tensStr[40] 	= 'fourty';
			tensStr[50] 	= 'fifty';
			tensStr[60] 	= 'sixty';
			tensStr[70] 	= 'seventy';
			tensStr[80] 	= 'eighty';
			tensStr[90] 	= 'ninety';
	
			// power of 10 names
			pow10Str		= new Array();
			pow10Str[0] 	= '';
			pow10Str[1] 	= '';
			pow10Str[3] 	= 'hundred ';
			pow10Str[4] 	= 'thousand '; 			// zeros 3
			pow10Str[7] 	= 'million '; 			// zeros 6
			pow10Str[10] 	= 'billion '; 			// zeros 9
			pow10Str[13] 	= 'trillion '; 			// zeros 12
			pow10Str[16] 	= 'quadrillion '; 		// zeros 15
			pow10Str[19] 	= 'quintillion '; 		// zeros 18
			pow10Str[22] 	= 'sextillion '; 		// zeros 21
			pow10Str[25] 	= 'septillion '; 		// zeros 24
			pow10Str[28] 	= 'octillion '; 		// zeros 27
			pow10Str[31]	= 'nonillion '; 		// zeros 30
			pow10Str[34] 	= 'decillion '; 		// zeros 33	
			pow10Str[37] 	= 'undecillion '; 		// zeros 36
			pow10Str[40] 	= 'duodecillion '; 		// zeros 39
			pow10Str[43] 	= 'tredecillion '; 		// zeros 42
			pow10Str[46] 	= 'quattuordecillion '; // zeros 45
			pow10Str[49] 	= 'quindecillion '; 	// zeros 48
			pow10Str[52] 	= 'sexdecillion '; 		// zeros 51
			pow10Str[55] 	= 'septendecillion '; 	// zeros 54
			pow10Str[58] 	= 'octodecillion '; 	// zeros 57
			pow10Str[61] 	= 'novemdecillion '; 	// zeros 60
			pow10Str[64] 	= 'vigintillion '; 		// zeros 63	
	
			// Check for decimal point and extract fractional part (hundredths)
			if(numStr.indexOf('.') != -1){
				decIDX 	= numStr.indexOf('.');
				decNum	= numStr.substr((decIDX+1),2);

				// Check if decimal is in the tenths place
				if(decNum.length == 1){
					decNum	+= '0';
				}
				
				numStr 	= numStr.substr(0,decIDX);
			}	 

			// Check if first number is a zero or empty
			if(numStr.substr(0,1) == '0' || numStr.length == 0){
				decPrefix = '';
			}
	
			// Build decimal string
			decStr	= decPrefix + decNum + decSuffix;
			
			pow10StrIDX = numStr.length;
			loopLen		= pow10StrIDX / 3; 
			nextIDX 	= pow10StrIDX;
			posStart 	= 0;
	
			//--[Loop through numbers to build string]----//
			for(i=0; i < loopLen; i++){
				numSet = nextIDX % 3;
		
				// 1st digit in 3 number set
				switch(numSet){
					case 1:				
						// 1's
						dgt1 	= numStr.substr(posStart,1);
						dgt1IDX	= new Number(dgt1);
			
						output 	+= num1_19Str[dgt1IDX];
			
						modIDX 		= 0;
						modPOS 		= 1;
						numSetExt 	= 0;
						posStartAdd = 1;
					break;
		
					case 2:	
						// 10's			
						dgt1 	= numStr.substr(posStart,2);
						dgt1IDX	= new Number(dgt1);
			
						modIDX 		= -1;
						modPOS 		= 2;
						numSetExt 	= 2;
						posStartAdd = 0;
					break;
		
					case 0:	
						// 100's
						dgt1 	= numStr.substr(posStart,1);
						dgt1IDX	= new Number(dgt1);
			
						hunStr = '';
						
						// Check if we need to add hundred suffix
						if(dgt1IDX != 0){
							hunStr = pow10Str[3];
						}
									
						output 	+= num1_19Str[dgt1IDX] + hunStr;
			
						modIDX 		= -2;
						modPOS 		= 3;
						numSetExt 	= 2;
						posStartAdd	= 1;
					break;
				}
		
				// 2nd & 3rd digit in 3 number set
				dgt23IDX = 0;
		
				if(numSetExt == 2){
					dgt23 		= numStr.substr(posStart+posStartAdd,2);
					dgt23IDX 	= new Number(dgt23);
			
					if(dgt23IDX < 20){
						output += num1_19Str[dgt23IDX];
					}else{
						pos1 			= dgt23.substr(0,1) * 10;
						tensStrIDX		= new Number(pos1);
				
						pos2 			= dgt23.substr(1,2);
						num1_19StrIDX	= new Number(pos2);
				
						divStr = '-';
						
						// Check we need to add hyphen
						if(num1_19StrIDX == 0){
							divStr = ' ';
						}
						
						output += tensStr[tensStrIDX] + divStr + num1_19Str[num1_19StrIDX];
					}	
				}

				// Check if we need to add the suffix in 3 digit set
				if((dgt1IDX + dgt23IDX) != 0){
					output += pow10Str[nextIDX + modIDX];
				}
		
				// Reset variables for next loop		
				nextIDX  -= modPOS;
				posStart += modPOS;		
			}
			//--[End loop]------------------------//
	
			output += decStr;
	
			// Capitalize first character
			capFirstChr	= output.substr(0,1);
			capFirstChr	= capFirstChr.toUpperCase();	
			output 		= capFirstChr + output.substr(1,output.length);
		}
	
		return output;
	}
//----------------------------------End All-----------------------------------------------//