<!--Data-entry Functions for WareFore Analysis
var promptEnterBgn='Enter ';
var promptEnterEnd=', please';
var promptEntryBad='Do not use these characters'+promptEnterEnd+': ';
var promptEntryTooLongBgn='Use fewer than ';
var promptEntryTooLongEnd=' characters'+promptEnterEnd
var defaultEmptyOK = false
// whitespace characters
var whitespace = " \t\n\r";
var ZIPCodeDelimiters = "-";
// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9
//
function personNameNOgud (fldINo, lenINn, needItINb)
{
var Bdebug = false
var badC = ''
//I cudn't get the RegExp stuff to work
if (Bdebug) alert('pnNg/bgn='+fldINo.value)
if (fldINo.value.length==0)
	{
	if (Bdebug) alert('pnNg/empty w/'+needItINb)
	if (needItINb)
		{
		alert(promptEnterBgn+fldINo.title+promptEnterEnd)
		return false
		}
	}
else
	{
	if (Bdebug) alert('pnNg/contents='+fldINo.value+' w/len='+fldINo.value.length)
	if (fldINo.value.length>lenINn)
		{
		alert(promptEntryTooLongBgn+lenINn+promptEntryTooLongEnd)
		return false
		}
	else
		{
		for (i = 0; i < fldINo.value.length; i++)
			{
// Check that current character is letter.
			var c = fldINo.value.charAt(i);
			if (!isLetter(c))
				{
// Check that current character is neither comma or period.
				if ((c!='.')&&(c!=',')&&(c!=' ')&&(c!='-'))
					{
					if (Bdebug) alert('pnNg/badC='+badC+' w/c='+c+'@'+i)
					if (badC.length>0) badC = badC + ' or '
					badC = badC + c
					}
				}
			}
		if (Bdebug) alert('pnNg/badC='+badC)
		if (badC.length>0)
			{
			if (Bdebug) alert('pnNg/badC=/'+badC+'/')
			alert(promptEntryBad+badC)
			return false
			}
		}
	}
if (Bdebug) alert('pnNg/end='+fldINo.value)
return true
}
function addressNOgud (fldINo, lenINn, needItINb)
{
var Bdebug = false
var badC = ''
//I cudn't get the RegExp stuff to work
if (Bdebug) alert('aNg/bgn='+fldINo.value)
if (fldINo.value.length==0)
	{
	if (Bdebug) alert('aNg/empty w/'+needItINb)
	if (needItINb)
		{
		alert(promptEnterBgn+fldINo.title+promptEnterEnd)
		return false
		}
	}
else
	{
	if (Bdebug) alert('aNg/contents='+fldINo.value+' w/len='+fldINo.value.length)
	if (fldINo.value.length>lenINn)
		{
		alert(promptEntryTooLongBgn+lenINn+promptEntryTooLongEnd)
		return false
		}
	else
		{
		if (Bdebug) alert('aNg/iter')
		for (i = 0; i < fldINo.value.length; i++)
			{
// Check that current character is letter.
			var c = fldINo.value.charAt(i);
			if (!isLetterOrDigit(c))
				{
// Check that current character is neither comma or period.
				if ((c!='.')&&(c!=',')&&(c!=' ')&&(c!='-')&&(c!='#'))
					{
					if (Bdebug) alert('aNg/badC='+badC+' w/c='+c+'@'+i)
					if (badC.length>0) badC = badC + ' or '
					badC = badC + c
					}
				}
			}
		if (Bdebug) alert('aNg/badC='+badC)
		if (badC.length>0)
			{
			if (Bdebug) alert('aNg/badC=/'+badC+'/')
			alert(promptEntryBad+badC)
			return false
			}
		}
	}
if (Bdebug) alert('aNg/end='+fldINo.value)
return true
}
function zipNOgud(fldINo, needItINb)
{
var Bdebug = false
if (Bdebug) alert('zNg/bgn='+fldINo.value)
if (fldINo.value.length==0)
	{
	if (Bdebug) alert('zNg/0len='+fldINo.value.length)
	if (needItINb)
		{
		alert(promptEnterBgn+fldINo.title+promptEnterEnd)
		return false
		}
	}
else
	{
	if (Bdebug) alert('zNg/strip')
	var normalizedZIP = stripCharsInBag(fldINo.value, ZIPCodeDelimiters)
	if (Bdebug) alert('zNg/normalizedZIP='+normalizedZIP)
	if (!isZIPCode(normalizedZIP, false)) 
		{
		alert('Invalid ZIPcode: '+fldINo.value)
		return false
		}
	else 
		{
		if (Bdebug) alert('zNg/OK')
		fldINo.value = reformatZIPCode(normalizedZIP)
		if (Bdebug) alert('zNg/reformatZIPCode='+fldINo.value)
		return true;
		}
	}
}
function eAddNOgud(fldINo, needItINb)
{
var Bdebug=false
//var emailexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/
//expression from http://tech.irt.org/articles/js049/
if (Bdebug) alert ('eANg/bgn='+fldINo.value)
if (fldINo.value.length==0)
	{
	if (Bdebug) alert ('eANg/len=0; needItINb='+needItINb)
	if (needItINb)
		{
		alert(promptEnterBgn+fldINo.title+promptEnterEnd)
		return false
		}
	}
else
	{
	if (Bdebug) alert ('eANg/chkAddr='+fldINo.value)
	if (!isEmail(fldINo.value,false))
		{
		alert('Invalid eAddress: '+fldINo.value)
		return false
		}
	}
if (Bdebug) alert ('eANg/end='+fldINo.value)
return true
//	if (!emailexp.test(fldINo.value))
}
// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{
   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}





// isYear (STRING s [, BOOLEAN emptyOK])
// 
// isYear returns true if string s is a valid 
// Year number.  Must be 2 or 4 digits only.
// 
// For Year 2000 compliance, you are advised
// to use 4-digit year numbers everywhere.
//
// And yes, this function is not Year 10000 compliant, but 
// because I am giving you 8003 years of advance notice,
// I don't feel very guilty about this ...
//
// For B.C. compliance, write your own function. ;->
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}
// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
// Returns true if character c is an English letter 
// (A .. Z, a..z).
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}
// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}
// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}
// Returns true if character c is a digit 
// (0 .. 9).
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
// Returns true if character c is a letter or digit.
function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}
// isZIPCode (STRING s [, BOOLEAN emptyOK])
// 
// isZIPCode returns true if string s is a valid 
// U.S. ZIP code.  Must be 5 or 9 digits only.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.  
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function isZIPCode (s)
{  if (isEmpty(s)) 
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) && 
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}
// takes ZIPString, a string of 5 or 9 digits;
// if 9 digits, inserts separator hyphen
function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}
function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}
// reformat (TARGETSTRING, STRING, INTEGER, STRING, INTEGER ... )       
//
// Handy function for arbitrarily inserting formatting characters
// or delimiters of various kinds within TARGETSTRING.
//
// reformat takes one named argument, a string s, and any number
// of other arguments.  The other arguments must be integers or
// strings.  These other arguments specify how string s is to be
// reformatted and how and where other strings are to be inserted
// into it.
//
// reformat processes the other arguments in order one by one.
// * If the argument is an integer, reformat appends that number 
//   of sequential characters from s to the resultString.
// * If the argument is a string, reformat appends the string
//   to the resultString.
//
// NOTE: The first argument after TARGETSTRING must be a string.
// (It can be empty.)  The second argument must be an integer.
// Thereafter, integers and strings must alternate.  This is to
// provide backward compatibility to Navigator 2.0.2 JavaScript
// by avoiding use of the typeof operator.
//
// It is the caller's responsibility to make sure that we do not
// try to copy more characters from s than s.length.
//
// EXAMPLES:
//
// * To reformat a 10-digit U.S. phone number from "1234567890"
//   to "(123) 456-7890" make this function call:
//   reformat("1234567890", "(", 3, ") ", 3, "-", 4)
//
// * To reformat a 9-digit U.S. Social Security number from
//   "123456789" to "123-45-6789" make this function call:
//   reformat("123456789", "", 3, "-", 2, "-", 4)
//
// HINT:
//
// If you have a string which is already delimited in one way
// (example: a phone number delimited with spaces as "123 456 7890")
// and you want to delimit it in another way using function reformat,
// call function stripCharsNotInBag to remove the unwanted 
// characters, THEN call function reformat to delimit as desired.
//
// EXAMPLE:
//
// reformat (stripCharsNotInBag ("123 456 7890", digits),
//           "(", 3, ") ", 3, "-", 4)

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}
// End-->