// this section includes the individual field tests which can be called to establish valid data entry 

// general purpose function to see if an input value has been entered at all
//  
function isEmpty(inputStr) 
    {
	if (inputStr==null || inputStr=="")
         {return true}
	else	 
         {return false}
    }
    
// general purpose function to see if a suspected numeric input is a positive integer
//  this has not been tested
function isPosInteger(inputVal) 
     {inputStr = inputVal.toString()
          for (var i = 0; i < inputStr.length; i++) 
                {var oneChar = inputStr.charAt(i)
                if (oneChar < "0" || oneChar > "9")
                      {return false} 
                }
     return true
     }

// general purpose function to see if numeric input  is an interger (positive or negative)
//  this has not been tested
function isInteger(inputVal) 
     {inputStr = inputVal.toString()
         for (var i = 0; i < inputStr.length; i++) 
               { var oneChar = inputStr.charAt(i)
               if (i == 0 && oneChar == "-") 
                    continue;
               if (oneChar < "0" || oneChar > "9") 
                    {return false}
               }
     return true
     }

// general purpose function to see if there is a decimal point in a string
// this has not been tested
function isDecimal(inputVal) 
     {
	 oneDecimal = false
     inputStr = inputVal.toString()
     for (var i = 0; i < inputStr.length; i++) 
            {   // begin for loop statements
			var oneChar = inputStr.charAt(i)
            if (i == 0 && oneChar == "-") 
                   {continue;}
            if (oneChar == "." && !oneDecimal) 
                   {oneDecimal = true
				    continue;}
            if (oneChar < "0" || oneChar > "9") 
                   {return false}
			}  // end for loop 
     return true
     }


// Password matching function
//
function isMatch(pw1,pw2)
     {
	  if (pw1 == pw2)
            {return true}
     else
            {alert ("Sorry, your passwords didn't match, please try again.")
		     return false
		     }
      }

// Alphanumeric testing function
function onlyAlphaNumeric(datum) 
       {
	  var valid = true   // assume that the data item is ok
       var GoodChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
       var i = 0
       for (i =0; i <= datum.length -1; i++) 
               {
			   if (GoodChars.indexOf(datum.charAt(i)) == -1) 
                        {
                        // Note: Remove the comments from the following line to see this
                        // for loop in action.
                        // alert(TheNumber.charAt(i) + " is no good.")
                        valid = false
                        } // End if instructions
                } // End for loop
        return valid
        }

// function to test for only valid hexidecimal characters
function onlyHexadecimal(datum) 
       {
	  var valid = true ;  // assume that the data item is ok
       var GoodChars = "ABCDEFabcdef1234567890";
       var i = 0
       for (i =0; i <= datum.length -1; i++) 
               {
			   if (GoodChars.indexOf(datum.charAt(i)) == -1) 
                        {
                        // Note: Remove the comments from the following line to see this
                        // for loop in action.
                        // alert(TheNumber.charAt(i) + " is no good.")
                        valid = false
                        } // End if instructions
                } // End for loop
        return valid
        }

	   
// Email characters are present
function EmailChars(datum)
{
     var valid = true   // assume that the data item is good
     if (datum.indexOf("@") < 0 || datum.indexOf(".") < 0)    //test for absence of '@' and '.'
		{valid = false}
	{return valid}
}

function onlyEmail(datum)
{
var valid = true   // assume that the data item is ok
       var GoodChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-@"
       var i = 0
       for (i =0; i <= datum.length -1; i++) 
               {
			   if (GoodChars.indexOf(datum.charAt(i)) == -1) 
                        {
                        // Note: Remove the comments from the following line to see this
                        // for loop in action.
                        // alert(TheNumber.charAt(i) + " is no good.")
                        valid = false
                        } // End if instructions
                } // End for loop
        return valid
}

function onlyNameChars(datum)
{
var valid = true   // assume that the data item is ok
       var GoodChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678 9."  // spaces and periods allowed
       var i = 0
       for (i =0; i <= datum.length -1; i++) 
               {
			   if (GoodChars.indexOf(datum.charAt(i)) == -1) 
                        {
                        // Note: Remove the comments from the following line to see this
                        // for loop in action.
                        // alert(TheNumber.charAt(i) + " is no good.")
                        valid = false
                        } // End if instructions
                } // End for loop
        return valid
}

function ZipCodeChars(datum)
{
var valid = true   // assume that the data item is ok
       var GoodChars = "012345678 9-"  // spaces and dashes allowed
       var i = 0
       for (i =0; i <= datum.length -1; i++) 
               {
			   if (GoodChars.indexOf(datum.charAt(i)) == -1) 
                        {
                        // Note: Remove the comments from the following line to see this
                        // for loop in action.
                        // alert(TheNumber.charAt(i) + " is no good.")
                        valid = false
                        } // End if instructions
                } // End for loop
        return valid
}