	// format percent only
	var nFormatPOnly;
	nFormatP = 1;

	// format Percent, decimal
	var nFormatPD;
	nFormatPD = 2;
	
	// format dollar,comma,decimal
	var nFormatDCD;
	nFormatDCD = 3;
	
	// format dollar, comma
	var nFormatDC;
	nFormatDC = 4;
	
	// format dollar only
	var nFormatDollars;
	nFormatDollars = 5;
	
	// format comma only
	var nFormatCommaOnly;
	nFormatCommaOnly = 6;
	
		function rNavigate(action)
		{
//			try
//			{
				switch(action)
				{
					case "PREV":
						Previous();		//requires each calc-xx-cs.asp to have a Previous() function
						break;
					case "NEXT":
						Next();				//requires each calc-xx-cs.asp to have a Next() function
						break;
					case "CALC":
						Calculate();	//requires each calc-xx-cs.asp to have a Calculate() function
						break;
					case "RESET":
						Reset();			//requires each calc-xx-cs.asp to have a Reset() function
						break;
					case "HELP":
						alert("You've selected HELP");
						break;
					default:
						alert("How did you get here?");
				}
//			}
//			catch(exception)
//			{
//				alert("Not implemented");
//			}
		}

		function rOnMouseOver(msg)
		{
			window.status = msg;
			return true;
		}
		
		function swapImage(targetImage, newImageSrc)
		{
			if(document.images)
			{
				if(targetImage && targetImage.src)
				{
					targetImage.src = newImageSrc;
				}
			}
		}


//		function rNewWindow(mypage, myname, w, h, scroll)
		function rNewWindow(mypage)
		{
//			var w = 800;
//			var h = 600;
//			var scroll = "yes";
			
//			var winl = (screen.width - w) / 2;
//			var wint = (screen.height - h) / 2;
//			winprops = 'menubar=yes,status=yes,toolbar=yes,resizable=yes,scrollbars=yes,';	//height='+h+',width='+w+',top='+wint+',left='+winl;
//			win = window.open(mypage, 'Help', winprops);
			win = window.open(mypage);
//			win.resizeTo(w,h);
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}
		
		function Previous()
		{
			alert("Not implemented");
		}
		
		function Next()
		{
			alert("Not implemented");
		}
		
		function Calculate()
		{
			alert("Not implemented");
		}
		
		function Reset()
		{
			alert("Not implemented");
		}
		
		function UnFormatText(theval)
		{
			// Take out anything that's not a number or a decimal
			var strtemp;
			var strmain;
								
			strtemp = theval.value.toString();
			strtemp = strtemp.replace(/[^0-9 | .]|\,/g,'');
			strmain = strtemp;

			// now we have a dollar value so we need to find the first decimal.
			res = strtemp.indexOf(".");
			if (res != -1)
			{
				strmain = strtemp.slice(0, res+1);
				strtemp = strtemp.slice(res + 1);

				// we're past the first decimal so just remove any remaining.
				strtemp = strtemp.replace(/\$|[^0-9]/g,'');
				strmain = strmain + strtemp;
			}
					
			theval.value = strmain;
		}
				
		<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
		<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->

		<!-- This script and many more are available free online at -->
		<!-- The JavaScript Source!! http://javascript.internet.com -->

		<!-- Begin
		function formatCurrency(theval) 
		{
			var num = theval;
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num*100+0.50000000001);
			cents = num%100;
			num = Math.floor(num/100).toString();
			if(cents<10)
			cents = "0" + cents;
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+
			num.substring(num.length-(4*i+3));
			theval = ((sign)?'':'-') + '$' + num + '.' + cents;

			return theval;
		}
		//  End -->
		
		function formatDecimal(theval)
		{
			var num = theval;

			num = Math.floor(num*100+0.50000000001);
			cents = num%100;
			num = Math.floor(num/100).toString();
			if(cents<10)
			cents = "0" + cents;
			
			theval = num + "." + cents;
			
			return theval;
		}


		function formatComma(theval, bDec)
		{
			var num = theval;

			if (bDec)
			{
				num = Math.floor(num*100+0.50000000001);
				cents = num%100;
				num = Math.floor(num/100).toString();
				if(cents<10)
				cents = "0" + cents;
			}				
			else
			{
				num = Math.round(num);
				num = num.toString();
			}
			
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			{
				num = num.substring(0,num.length-(4*i+3))+','+
					num.substring(num.length-(4*i+3));
			}
			
			if (bDec)
			{
				theval = num + "." + cents;
			}
			else
			{
				theval = num;
			}
			
			return theval;
		}
		
		function formatPercent(theval, bDec)
		{
			var num = theval;
			
			if (bDec)
			{
				num = Math.floor(num*100+0.50000000001);
				cents = num%100;
				num = Math.floor(num/100).toString();
				if(cents<10)
				cents = "0" + cents;
				
				theval = num + "." + cents + "%";
			}		
			else
			{
				num = Math.round(num);
				num = num.toString();
				theval = num + "%";
			}
			
			return theval;
		}
		
		function formatDollars(theval, bRound)
		{
			if (bRound)
			{
				num = Math.round(num);
				num = num.toString();
			}
			
			theval = "$" + theval;
			
			return theval;
		}


		function LostFocus(theval, bitFormat)
		{
			// bit & 1000 = dollar
			var FormatVal;
			var test3;
			test3 = 1100;
			
			UnFormatText(theval);
			FormatVal = theval.value;
			
			if (bitFormat == nFormatP)
			{
				FormatVal = formatPercent(FormatVal, false);
			}
			else if (bitFormat == nFormatPD)
			{
				FormatVal = formatPercent(FormatVal, true);
			}
			else if (bitFormat == nFormatDCD)			
			{
				FormatVal = formatComma(FormatVal, true);
				FormatVal = formatDollars(FormatVal, false);
			}			
			else if (bitFormat == nFormatDC)
			{
				FormatVal = formatComma(FormatVal, false);
				FormatVal = formatDollars(FormatVal, false);
			}
			else if (bitFormat == nFormatDollars)
			{
				FormatVal = formatDollars(FormatVal, true);
			}
			else if (bitFormat == nFormatCommaOnly) 
			{
				FormatVal = formatComma(FormatVal, false);
			}
			
			theval.value = FormatVal;
		}
		
		function OnTextFocus(theval)
		{
			UnFormatText(theval);
			
			theval.select();
		}