
	function MM_openBrWindow(theURL,winName,features) { //v2.0
			window.open(theURL,winName,features);
		}



// ... e-mail check
function emailCheck (emailStr,Silent) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/;
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]\\'";
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]";
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")";
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+';
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")";
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	if (!Silent) alert("L'Email Sembra essere non corretto (controlla @ e .)")
	return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    if (!Silent) alert("Lo user name dell'email non e' corretto.")
    return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        if (!Silent) alert("L'IP di destinazione della mail non e' valido!")
		return false;
	    }
    }
    return true;
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	if (!Silent) alert("Il dominio dell'E-mail non e' corretto.")
    return false;
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   if (!Silent) alert("L'indirizzo E-mail deve terminare con tre o due caratteri.")
   return false;
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="L'indirizzo E-Mail non ha l'Hostname";
   if (!Silent) alert(errStr)
   return false;
}

// If we've gotten this far, everything's valid!
return true;
}

// ****************************************************************************************
// ****************************************************************************************




// Dizionario	
	var top		= 0;
	var c		= 0;
	var data	= new Array();
	var mmComp	= new Array();

function clsDictionary() {

	this.Comp		= mComp		;
	this.Add		= mAdd		;
	this.Item		= mItem		;
	this.Exists		= mExists	;
	this.Count		= mCount	;
	this.GetKey		= mGetKey	;
	this.GetData	= mGetData	;
	
	// Leggere un Dato
	function mItem(strKeyName) {
	var ris = '';	
		//for (c=0; c< top; c+=2)
		for (c=0; c< data.length; c+=2)
			{	
				if (data[c] == strKeyName){
					ris = data[c + 1];		
				}
			}
		
		if (ris==''){
			return(null);
			}
		else
			{
			// risolvo la compressione
			for (c=0; c<mmComp.length; c+=2){
					ris = ris.replace(mmComp[c] ,mmComp[c+1]);
					ris = ris.replace(mmComp[c] ,mmComp[c+1]); // anche x due volte
				}
			return(ris);
		}
	}

	// Aggiungere Dati
	function mAdd() {
			
			data[top]	  = mAdd.arguments[0]; 
			data[top + 1] = mAdd.arguments[1];
			top = top + 2;
	
	}
	
	// se esite
	function mExists(strKeyName) {
			for (c=0; c<=top;c+=2)
			{
				if (data[c]==strKeyName){
					return(true);
				}
			}
			return(false);
	}
	
	function mComp(strComp){
		//alert (strComp);
		mmComp = strComp.split(',');
		//alert (mmComp[0]);
		//alert (mmComp[1]);
	}

	
	// Recuperare Key e Data tramite indice
	function mGetKey(pos){
			return(data[pos * 2]);
	}
	
	function mGetData(pos){
	var ris  = '';	
	ris = data[pos * 2 + 1]
	// risolvo la compressione
			for (c=0; c<mmComp.length; c+=2){
				 
					ris = ris.replace(mmComp[c] ,mmComp[c+1]);
					ris = ris.replace(mmComp[c] ,mmComp[c+1]); // anche x due volte
				}
			return(ris);
			
	}


	// Conteggio elementi
	function mCount(){
	var ris = 0;
	ris = top - 2;
			return(ris);
		}

}



			function PopUpCenter(urlPagina,nomeWindow,wWindow,hWindow,scroll){ // by Ultima v1.2 
			var win = null;
			Left = (screen.width) ? (screen.width-wWindow)/2 : 0;
			Top = (screen.height) ? (screen.height-hWindow)/2 : 0;
			settings = 'height='+hWindow+',width='+wWindow+',top='+Top+',left='+Left+',scrollbars='+scroll+''
			win = window.open(urlPagina,nomeWindow,settings)
			if(win.window.focus){win.window.focus();}
			}


			function popImage(imageURL,imageTitle,wWindow,hWindow){
			
				// Set the horizontal and vertical position for the popup

				//PositionX = 100;
				//PositionY = 100;

				PositionX = (screen.width) ? (screen.width-wWindow)/2 : 0;
				PositionY = (screen.height) ? (screen.height-hWindow)/2 : 0;
				// Set these value approximately 20 pixels greater than the
				// size of the largest image to be used (needed for Netscape)

				defaultWidth  = 500;
				defaultHeight = 500;

				// Set autoclose true to have the window close automatically
				// Set autoclose false to allow multiple popup windows

				var AutoClose = true;

				// ================================
				//alert(parseInt(navigator.appVersion.charAt(0)));
				//alert(navigator.appName);
				//alert(navigator.appVersion);
				//alert(navigator.appCodeName);
				//alert(navigator.userAgent);
				if (parseInt(navigator.appVersion.charAt(0))>=4 && parseInt(navigator.appVersion.charAt(0))<7)
				{
					if (navigator.userAgent.indexOf("MSIE 7.0")!=-1)
					{
						//alert(navigator.appCodeName);
						var isIE=0;
						var isIE7=1;
						var isNN=0;						
					}
					else{
						var isNN=(navigator.appName=="Netscape")?1:0;
						var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
						var isIE7=0;
					}
				}
				else if(parseInt(navigator.appVersion.charAt(0)) >= 7)
				{
					//alert(navigator.appName)
					var isIE=0;
					var isNN=0;
					var isIE7=1;
				}
				
				//alert(navigator.appName);
				var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
				var optIE='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;			
				var optIE7='resizable=no,scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
				
				//alert(navigator.appVersion);
				if (isNN){imgWin=window.open('about:blank','',optNN);}
				if (isIE){imgWin=window.open('about:blank','',optIE);}
				if (isIE7){imgWin=window.open('about:blank','',optIE7);}
				with (imgWin.document){
					writeln('<html><head><title>ZOOM</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
					writeln('var isNN,isIE,isIE7;');
					//writeln('if (parseInt(navigator.appVersion.charAt(0))>=4 && parseInt(navigator.appVersion.charAt(0))<7){');
					//writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');

					writeln('if (parseInt(navigator.appVersion.charAt(0))>=4 && parseInt(navigator.appVersion.charAt(0))<7){');
						//writeln('alert("AAAAAAAAAA " + navigator.userAgent + navigator.userAgent.indexOf("MSIE 7.0"));');
						writeln('if (navigator.userAgent.indexOf("MSIE 7.0")!=-1)');
						writeln('		{isIE=0;isNN=0; isIE7=1;}');
						writeln('else {');
						writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;isIE7=0;')
						writeln('} ');		
					writeln('} ');		
					writeln('else if(parseInt(navigator.appVersion.charAt(0)) >=7 ){');
					writeln('isNN=0;isIE7=1;');
					writeln('isIE=0;} ');
					
					writeln('function reSizeToImage(){');
					
					writeln('if (isIE){');writeln('window.resizeTo(100,100);');
					writeln('width=100-(document.body.clientWidth-document.images[0].width);');
					writeln('height=100-(document.body.clientHeight-document.images[0].height);');
					writeln('window.resizeTo(width,height);}');
					
					writeln('if (isIE7){');       
					writeln('window.resizeTo(250,100);');
					writeln('width=250-(document.body.clientWidth-document.images[0].width);');
					writeln('height=100-(document.body.clientHeight-document.images[0].height);');
					writeln('window.resizeTo(width,height);}');					
					//writeln('window.innerWidth=document.images["foto"].width;');writeln('window.innerHeight=document.images["foto"].height;}');
										
					writeln('if (isNN){');       
					writeln('window.innerWidth=document.images["foto"].width;');writeln('window.innerHeight=document.images["foto"].height;}}');
					writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
					if (!AutoClose) 
						writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
					else 
						writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
					writeln('<img name="foto" src="'+imageURL+'" style="display:block"></body></html>');
					close();		
				}
			}				
			
			
			
	function isDateString(stringValue) {

		// this function is designed to mimic the "date" portion of the
		// VBScript IsDate() function, allowing dates to be validated
		// with JavaScript in browsers before you run into a problem
		// in ASP pages with date database columns or the VBScript
		// CDate() function; an exception is that string months
		// ("Jan," etc.) are not accepted
		
		// this function does not handle BC dates or dates past 12/31/9999
		
		// you obviously want to strip the comments from production scripts
		
		// create a String object
		var theString = new String(stringValue);
		
		// determine the delimiter character (must be "/" "-" or space)
		var delimiterCharacter
		if ( theString.indexOf('/') > 0 )
			delimiterCharacter = '/';
		else
			if ( theString.indexOf('-') > 0 )
				delimiterCharacter = '-';
			else
				if ( theString.indexOf(' ') > 0 )
					delimiterCharacter = ' ';
				else
					return false;
					
		// split the string into an array of tokens
		var theTokens = theString.split(delimiterCharacter);
		
		// there must be either two or three tokens
		if ( theTokens.length < 2 || theTokens.length > 3 )
			return false;
		
		// convert the tokens to String objects, which will be needed later,
		// stripping a single leading 0
		var tokenIndex;
		for ( tokenIndex = 0; tokenIndex < theTokens.length; tokenIndex++ ) {
			theTokens[tokenIndex] = new String(theTokens[tokenIndex])			
			if ( theTokens[tokenIndex].charAt(0) == '0' )
				theTokens[tokenIndex] = theTokens[tokenIndex].substring(1, theTokens[tokenIndex].length);
		}

		// all of the tokens must be positive integers
		for ( tokenIndex = 0; tokenIndex < theTokens.length; tokenIndex++ ) {
			if ( ! isNonnegativeInteger(theTokens[tokenIndex]) )
				return false;
		}
		
		// we need to identify the year, month, and day tokens
		var numericValue;
		var yearTokenIndex = -1;
		var monthTokenIndex = -1;
		var dayTokenIndex = -1;
		for ( tokenIndex = 0; tokenIndex < theTokens.length; tokenIndex++ ) {
					
			// convert the value
			numericValue = parseInt(theTokens[tokenIndex], 10);
					
			// could this token be a month?
			if ( numericValue <= 12 ) {
					
				// yes; do we already have a month?
				if ( monthTokenIndex == -1 ) {
						
					// no; assign this token to the month and continue
					monthTokenIndex = tokenIndex;
					continue;
				}
				else {
							
					// we already have a month; this token could
					// also be the day; do we already have a day?
					if ( dayTokenIndex == -1 ) {
						
						// no; assign this token to the day and continue
						dayTokenIndex = tokenIndex;
						continue;
					}
					else {
							
						// we already have a day; this token could
						// also be the year; do we alreay have a year?
						if ( yearTokenIndex == -1 ) {
						
							// no; assign this token to the year and continue
							dayTokenIndex = tokenIndex;
							continue;
						}
					}
				}
			}
			else {
						
				// the value is too large for a month;
				// could this token be a day?
				if ( numericValue <= 31 ) {
						
					// yes; do we already have a day?
					if ( dayTokenIndex == -1 ) {
						
						// no; assign this token to the day and continue
						dayTokenIndex = tokenIndex;
						continue;
					}
					else {
							
						// we already have a day; this token could
						// also be the year; do we alreay have a year?
						if ( yearTokenIndex == -1 ) {
						
							// no; assign this token to the year and continue
							dayTokenIndex = tokenIndex;
							continue;
						}
					}
				}
				else {
						
					// the value is too large for a day;
					// could this token be a year?
					if ( numericValue <= 9999 ) {
					
						// yes; do we already have a year?
						if ( yearTokenIndex == -1 ) {
						
							// no; assign this token to the year
							yearTokenIndex = tokenIndex;
						}
					}
				}
			}
		}	// end of for loop
		
		// evaluate, based on the number of tokens
		if ( theTokens.length == 2 ) {
			
			// two tokens can be either a month/year combination or a month/day
			// combination with the current year assumed; either way, we must have
			// a month
			if ( monthTokenIndex == -1 )
				
				// no month
				return false;
				
			// do we have a year?
			if ( ! (yearTokenIndex == -1) ) {
			
				// yes; month/year combination; must be okay
				return true;
			}
			else
				
				// no year; do we have a day?
				if ( ! (dayTokenIndex == -1) ) {
				
					// yes; month/day combination; get the current year
					var today = new Date();
					var currentYear = today.getYear();

					// make sure it's a valid date (we were testing days using
					// 31, and that might be too many for the month)
					return isDate(currentYear, theTokens[monthTokenIndex], theTokens[dayTokenIndex]);
				}
				else
				
					// we have neither a year nor a day
					return false;
		}
		else {
			
			// three tokens; we should have found tokens for year, month, and day
			if ( yearTokenIndex == -1 || monthTokenIndex == -1 || dayTokenIndex == -1 )
				
				// missing one or more
				return false;
			else
				
				// found all; however, VBScript can only handle the following sequences
				if ( monthTokenIndex == 0 ) {
				
					// must be m/d/y
					if ( dayTokenIndex != 1 || yearTokenIndex != 2)
						return false;
				}
				else
					if ( dayTokenIndex == 0 ) {
				
						// must be d/m/y
						if ( monthTokenIndex != 1 || yearTokenIndex != 2)
							return false;
					}
					else
						if ( yearTokenIndex == 0 ) {
				
							// must be y/m/d
							if ( monthTokenIndex != 1 || dayTokenIndex != 2)
								return false;
						}
						else
						
							// something is wrong
							return false;
				
				// make sure it's a valid date (we were testing days using a value
				// of 31, and that might be too many for the actual month)
				return isDate(theTokens[yearTokenIndex], theTokens[monthTokenIndex], theTokens[dayTokenIndex]);
		}
	}

	function isTimeString(stringValue) {

		// this function is designed to mimic the "time" portion of the
		// VBScript IsDate() function, allowing times to be validated
		// with JavaScript in browsers before you run into a problem
		// in ASP pages with date database columns or the VBScript
		// CDate() function
		
		// you obviously want to strip the comments from production scripts
		// and place this function in the library file

		// create a String object
		var theString = new String(stringValue);
		
		// the string must have either two (hours and minutes) or three
		// (hours, minutes and seconds) tokens, delimited by ":";
		// split the string into an array of tokens
		var theTokens = theString.split(':');
		if ( theTokens.length < 2 || theTokens.length > 3 )
			return false;
		
		// convert the tokens to String objects, which will be needed later,
		// stripping whitespace
		var firstToken = new String(theTokens[0])
		firstToken = trim(firstToken);
		var middleToken;
		if ( theTokens.length == 3 ) {
			middleToken = new String(theTokens[1])
			middleToken = trim(middleToken);
		}
		var lastToken = new String(theTokens[theTokens.length - 1])
		lastToken = trim(lastToken);

		// the first token (hours) must be an integer between 0 and 23
		if ( ! isInteger(firstToken) )
			return false;
		if ( ! isIntegerInRange(firstToken, 0, 23) )
			return false;
		
		// are there three tokens?
		if ( theTokens.length == 3 ){
		
			// the middle token (minutes) must be an integer between 0 and 59
			if ( ! isInteger(middleToken) )
				return false;
			if ( ! isIntegerInRange(middleToken, 0, 59) )
				return false;
		}
			
		// the first one or two characters of the last token (either minutes
		// and optional am/pm indicator or seconds and am/pm indicator) must
		// be digits
		if ( ! isDigit(lastToken.charAt(0)) )
			return false;
		
		// the first character is a digit; split the last token into the minutes
		// or seconds value and the indicator; depending on the second character
		var lastValue;
		var ampmIndicator;
		if ( isDigit(lastToken.charAt(1)) ) {
			lastValue = new String(lastToken.substring(0, 2));
			if ( lastToken.length >= 3 )
				ampmIndicator = new String(trim(lastToken.substring(2, lastToken.length)));
			else
				ampmIndicator = new String();
		}
		else {
			lastValue = new String(lastToken.substring(0, 1));
			if ( lastToken.length >= 2 )
				ampmIndicator = new String(trim(lastToken.substring(1, lastToken.length)));
			else
				ampmIndicator = new String();
		}
		ampmIndicator = ampmIndicator.toUpperCase();
		
		// the last value must be between 0 and 59
		if ( ! isIntegerInRange(lastValue, 0, 59) )
			return false;
		
		// check the am/pm indicator, if there is one
		if ( ampmIndicator.length > 0 )
			if ( ! ( ampmIndicator == "AM" || ampmIndicator == "PM" ) )
				return false;
				
		// valid time
		return true;
	}

	// most of the following was derived from Netscape's FormChek.js
	// library, which should be reviewed for documentation and comments

	var daysInMonth = makeArray(12);
	daysInMonth[1] = 31;
	daysInMonth[2] = 29;
	daysInMonth[3] = 31;
	daysInMonth[4] = 30;
	daysInMonth[5] = 31;
	daysInMonth[6] = 30;
	daysInMonth[7] = 31;
	daysInMonth[8] = 31;
	daysInMonth[9] = 30;
	daysInMonth[10] = 31;
	daysInMonth[11] = 30;
	daysInMonth[12] = 31;

	var whitespace = " \t\n\r";

	function charInString(c, s) {
		for (i = 0; i < s.length; i++) {
			if (s.charAt(i) == c)
				return true;
	    }
	    return false
	}

	function daysInFebruary(year) {
	    return ( ((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}

	function isDate(year, month, day) {
	    if ( ! ( isYear(year) && isMonth(month) && isDay(day) ) ) return false;
	    var intYear = parseInt(year);
	    var intMonth = parseInt(month);
	    var intDay = parseInt(day);
	    if ( intDay > daysInMonth[intMonth] ) return false; 
	    if ( ( intMonth == 2 ) && ( intDay > daysInFebruary(intYear) ) ) return false;
	    return true;
	}

	function isDay(s) {
	    return isIntegerInRange(s, 1, 31);
	}

	function isDigit(c) {
		return ( ( c >= "0" ) && ( c <= "9" ) )
	}

	function isInteger(s) {
		var i;
	    for ( i = 0; i < s.length; i++ )
	    {   
	        var c = s.charAt(i);
	        if ( ! isDigit(c) ) return false;
	    }
	    return true;
	}

	function isIntegerInRange(s, a, b) {
	    if ( ! isInteger(s) ) return false;
	    var num = parseInt (s);
	    return ( ( num >= a ) && ( num <= b ) );
	}

	function isMonth(s) {
	    return isIntegerInRange (s, 1, 12);
	}

	function isNonnegativeInteger(s) {
	    return ( isSignedInteger(s) && ( parseInt(s) >= 0 ) );
	}

	function isSignedInteger(s) {
	    var startPos = 0;
	    if ( ( s.charAt(0) == "-" ) || ( s.charAt(0) == "+" ) )
	       startPos = 1;    
	    return ( isInteger(s.substring(startPos, s.length)) )
	}

	function isYear(s) {
		if ( ! isNonnegativeInteger(s) ) return false;
	    return ( (s.length == 2) || (s.length == 4) );
	}

	function lTrim(s) {
		var i = 0;
	    while ( (i < s.length) && charInString(s.charAt(i), whitespace) )
	       i++;
	    return s.substring(i, s.length);
	}

	function makeArray(n) {
	   for ( var i = 1; i <= n; i++ ) {
	      this[i] = 0
	   } 
	   return this
	}

	function rTrim(s) {
		var i = 0;
	    while ( (i < s.length) && charInString(s.charAt(i), whitespace) )
	       i++;
	    return s.substring(i, s.length);
	}

	function trim(s) {
		return lTrim(rTrim(s));
	}			
	
function isCurrency(f, field)
{
	var nNum = 0;			// Total numbers for currency value.
	var nDollarSign = 0;	// Total times a dollar sign occurs.
	var nDecimal = 0;		// Total times a decimal point occurs.
	var nCommas = 0;		// Total times a comma occurs.
	var txtLen;				// Length of string passed.
	var xTxt;				// Assigned object passed.
	var sDollarVal;			// Assigned dollar amount with or without commas.
	var bComma;				
	var decPos;				// Assigned value of numbers or positions after decimal point.
	var nNumCount = 0;		// Total number between commas.
	var i;					// For forloop indexing.
	var x;					// Assigned each indivual character in string.

	// Set the xTxt variable to the object passed to this function.
	// Assign the length of the string to txtLen.

	xTxt = field;
	txtLen = xTxt.value.length

	for(i = 0; i < txtLen; i++)
	{
		// Assign charater in substring to x.
		x = xTxt.value.substr(i, 1);
		/*
		if(x == "$")
			nDollarSign = nDollarSign + 1; // Sum total times dollar sign occurs.
		else 
		*/
		if(x == ",")
			nDecimal = nDecimal + 1; // Sum total times decimal point occurs.
		else if(x == ".")
			nCommas = nCommas + 1; // Sum total times comma occurs.
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; // If the character is a number sum total times a number occurs.
		else
		{
			// Error occurs if any other character value is in the string
			// othere then the valid characters.
			//alert("ERROR! \n\nYou have entered an illegal value!\nPlease enter only: Dollar" +
			//	  " Signs, Commas, Decimal Points, and numbers between 0...9!");
			return false;
		} // end else
	} // end for

	/*
	if(nDollarSign > 1)
	{
		alert("ERROR! \n\nYou have entered more then one dollar sign!\nPlease only enter one!");
		return false;
	} // end if
	*/
	
	if(nDecimal > 1)
	{
		//alert("ERROR! \n\nYou have entered more then one decimal point!\nPlease only enter one!");
		return false;
	} // end if

	/*
	if(nDollarSign == 1)
	{
		// Make sure dollar sign in the first character in string
		// if there is a dollar sign present.
		if(xTxt.value.indexOf("$") != 0)
		{
			alert("ERROR!  \n\nThe dollar sign you entered is not in the correct position!");
			return false;
		} // end if

	}// end if
	*/

	if(nDecimal == 1)
	{
		// Get the number of numbers after the decimal point in
		// the string if there is a decimal point present
		decPos = (txtLen - 1) - xTxt.value.indexOf(",");
		// Floating point cannot be more then two.
		// Valid format after decimal point.

		/**********************************/

		/*   $#.##, $#.#, $.#, $#., $.##  */

		/**********************************/
		if(decPos > 2)
		{
			//alert("ERROR! \n\nThe decimal point you entered is not in the correct position!");
			return false;
		} // end if
	} // end if

	if(nCommas == 0)
	{
		// If no commas are present value is a valid US
		// currency.
		return true;
	}
	else
	{
		// Get total number of dollar number(s), removing
		// floating point numbers or cents.
		nNum = nNum - decPos;
		// Determine if dollar sign is in string so to be 
		// removed.
		// After determining dollar sign, assign sDollarVal
		// numbers and comma(s)
		/*
		if(xTxt.value.indexOf("$", 0) == 0)
			sDollarVal = xTxt.value.substr(1, (nNum + nCommas));
		else
		*/
			sDollarVal = xTxt.value.substr(0, (nNum + nCommas));
		// Determine if a zero is the first number or if a
		// comma is the first or last character in the string.
		if(sDollarVal.lastIndexOf("0", 0) == 0 )
		{
			//alert("ERROR! \n\nYou cannot start the dollar amount out with a zero!");
			return false;
		}
		else if(sDollarVal.lastIndexOf(".", 0) == 0)
		{
			//alert("ERROR! \n\nYou cannot start the dollar amount out with a comma!");
			return false;
		}
		else if(sDollarVal.indexOf(".", (sDollarVal.length - 1)) == (sDollarVal.length - 1))
		{
			//alert("ERROR! \n\nYou cannot end the dollar amount with a comma!");
			return false;
		}
		else
		{
			// Initialize bComma indicating a comma has not been
			// occured yet.
			bComma = false;
			for(i = 0; i < sDollarVal.length; i++)
			{
				// Assign charater in substring to x.
				x = sDollarVal.substr(i, 1);
				if(parseInt(x) >= 0 || parseInt(x) <= 9)
				{
					// If x is a number add one to the number counter.
					nNumCount = nNumCount + 1;
					// Sense comma(s) are present number counter cannot
					// be more then three before the first or next comma.
					if(nNumCount > 3)
					{
						//alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;
					} // end if
				}
				else
				{
					// If the number counter is less then three and
					// the comma indicator is true the comma is either
					// mis-placed or there are not enough values.
					if(nNumCount != 3 && bComma)
					{
						//alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;
					} // end if
					// Reset the number counter back to zero.
					nNumCount = 0;
					// Set the comma indicator to true indicating
					// that the first comma has been found and that
					// there now MUST be three numbers after each
					// comma until the loop hits the end.
					bComma = true;
				} // end if
			} // end for
			// Determine if after the loop ended that there
			// was a total of three final numbers after the
			// last comma.
			if(nNumCount != 3 && bComma)
			{
				//alert("ERROR! \n\nYou have a mis-placed comma!");
				return false;
			} // end if
		} // end if
	} // end if
	// Return true indicating that the value is a valid
	// currency.
	return true;
}
	
