/*
<!--
NAME: formvalidation.js
DESC: this checks the fields of a form to see if there are any errors in user input.
USAGE NOTES: none
*/

var errorListMaxChars = "";			//	function isMaxLength(s, maxChars, friendlyName)
var errorNumItem = "";				//	function isNumItem(s, friendlyName)
var errorLetterItem = "";			//	function isLetterItem(s, friendlyName)
var errorListHTML = "";				//	function isHTML(s, friendlyName)
var errorListEmpty = "";			//	function isEmpty(s, friendlyName) & function isEmptyString(s, friendlyName)
var errorListBlank = "";			//	function isBlank(s, friendlyName)
var errorSelectedItem = "";			//	function isSelectedItem(m, friendlyName)
var errorInvalidEmail = "";			//	function isInvalidEmail(s, friendlyName)
var errorPassword = "";				//	function passwordTest(p1, p2a, p2b) & function NewpasswordTest(p2a, p2b)
var errorPasswordClue = "";			//	function passwordClue(p2a, p2c)
var errorPhone = "";				//	function isInvalidPhone(s, friendlyName)
var errorZipCode = "";				//	function isZipCode(s, friendlyName)
var urlTest = "";					//	function goForward(url)
var errorValidFile="";				//	function isValidFile(s,p,friendlyName)
var errorListInvalid  = "";			//	function isInvalidString(s, friendlyName)
var passedTest = "passed";			//	Local Variable
var showAlert = false;				//	Local Variable

/*
Names of Functions included in this file are the following:
FUNCTION: isMaxLength - checks for maximum number of chars entered in a field  -- function isMaxLength(s, maxChars, friendlyName)
FUNCTION: stripBlanks - removes blank characters at end of string (used by itself or with other fxns) -- function stripBlanks(aString)
FUNCTION: isBlank - checks for blank spaces beyond first space -- function isBlank(s, friendlyName)
FUNCTION: isEmptyString - checks for empty fields -- function isEmptyString(s, friendlyName)
FUNCTION: isEmpty - checks for empty fields -- function isEmpty(s, friendlyName)
FUNCTION: isSelectedItem - checks to see if a dropdown box has been selected from default option (m, friendlyName)
FUNCTION: isHTML - returns if html is present in the string -- function isHTML(s, friendlyName)
FUNCTION: isInvalidPhone - Vasu : for checking phone information -- function isInvalidPhone(s, friendlyName)
FUNCTION: isInvalidString - checks if there is an invalid character in the string -- function isInvalidString(s, friendlyName)
FUNCTION: isNumItem - checks if the entry has only numbers present -- function isNumItem(s, friendlyName)
FUNCTION: isLetterItem - checks if the entry has only letters present -- function isLetterItem(s, friendlyName)
FUNCTION: isZipCode - checks if zip code is at least a valid 5 digit zipcode -- function isZipCode(s, friendlyName)
FUNCTION: isInvalidEmail - checks to see if it appears that this is a valid email type of string -- function isInvalidEmail(s, friendlyName)
FUNCTION: passwordTest - checks to see if new password request fits what is required -- function passwordTest(p1, p2a, p2b)
FUNCTION: NewPasswordTest - checks to see if new password request fits what is required -- function NewPasswordTest(p2a, p2b)
FUNCTION: passwordClue - checks to see if pwd clue is same as pwd itself -- function passwordClue(p2a, p2c)
FUNCTION: listErrors - this will compile the list of errors present, if any -- function listErrors()
FUNCTION: goForward - this will assign a new url for the window -- function goForward(url)
FUNCTION: isValidFile - checks for valid file path and valid file type for file uploading-- function isValidFile(s,p,friendlyName)
*/



/*
FUNCTION: isMaxLength - checks for maximum number of chars entered in a field
INPUT:		s - string you are checking
					maxChars - maximum number of characters allowed in a field
RETURNS:	error message if length is greater than maxChars
*/
function isMaxLength(s, maxChars, friendlyName)
	{s=s+"";
		if (s.length > maxChars)
			{
				errorListMaxChars = errorListMaxChars + "    - " + friendlyName + " is restricted to " + maxChars + " characters\n";
			}
	}


/*
FUNCTION: stripBlanks - removes blank characters at end of string
INPUT:		s - string from form field that gets tested and modified
*/	
function stripBlanks(aString)
	{aString=aString + "";
		var newString;
		var i;
		var j;
		var blank;
		blank = " ";
		newString = "";
        
		if (aString.indexOf(blank) >= 0)
			{
				for (i=0; i<aString.length; i++)
					{
						if (aString.charAt(i) != blank)
							{
								break;
							}
					}
				for (j=aString.length-1; j>=0; j--)
					{
						if (aString.charAt(j) != blank)
							{
								break;
							}
					}
				if (i == aString.length && j == -1)
					{
						newString = "";
					}
				else if (i != 0 || j != aString.length-1)
					{
						newString = stripBlanks(aString.substring(i, j+1));
					}
				else 
				    {
						newString = aString;
					}
				return newString;
			}
		return aString;	
	}


/*
FUNCTION: 	isBlank - checks for blank spaces beyond first space
INPUT:		s - string you are checking
RETURNS:		false - if NO blank spaces are found
				true - if ANY blank spaces are found
*/
function isBlank(s, friendlyName)
	{s=s+"";
		if ((s.indexOf(" ") != -1) || (s.indexOf("\n") != -1) || (s.indexOf("\t") != -1))
			{
				errorListBlank = errorListBlank + "    - " + friendlyName + "\n";
         }
	}


/*
FUNCTION: 	isEmptyString - checks for empty fields
INPUT:		s - string you are checking
RETURNS:		false - if empty field IS NOT found
				true - if empty field IS found
*/
function isEmptyString(s, friendlyName)
	{s.value=s.value+"";
		if (s.value == "")
			{
				errorListEmpty += "    - " + friendlyName + "\n";
         }
	}


/*
FUNCTION: 	isEmpty - checks for empty fields
INPUT:		s - string you are checking
RETURNS:		false - if empty field IS NOT found
				true - if empty field IS found
*/
function isEmpty(s, friendlyName)
	{
		if (s == 0)
			{
				errorListEmpty += "    - " + friendlyName + "\n";
         }
	}


/*
FUNCTION: 	isSelectedItem - checks to see if a dropdown box has been selected from default option
INPUT:		m - select that you are checking
RETURNS:	true - if a selection is not chosen, or first item is chosen, adds friendlyname to errorSelectedItem error list
*/ 
function isSelectedItem(m, friendlyName)
 	{
 		if (m.selectedIndex == 0)
 			{
 				errorSelectedItem += "    - " + friendlyName + "\n";
 			}
	
	}


/*
FUNCTION:	isHTML - returns if html is present in the string
INPUT:		s - string you are checking
RETURNS:	false - if HTML IS NOT found
					true - if HTML IS found
*/
function isHTML(s, friendlyName)
{s=s+"";
	s = s.toUpperCase( );
//	if( (s.indexOf("<IMG") != -1) )
//		errorListHTML += "    - " + friendlyName + "\n";
	if( (s.indexOf("<A") != -1) || (s.indexOf("</A>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<HTML") != -1) || (s.indexOf("</HTML>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<HEAD") != -1) || (s.indexOf("</head>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<BODY") != -1) || (s.indexOf("</BODY>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<FORM") != -1) || (s.indexOf("</FORM>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<INPUT") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<TABLE") != -1) || (s.indexOf("</TABLE>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<TR") != -1) || (s.indexOf("</TR>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<TD") != -1) || (s.indexOf("</TD>") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";
	else if( (s.indexOf("<!--") != -1) || (s.indexOf("-->") != -1) )
		errorListHTML += "    - " + friendlyName + "\n";		
	else if(s.indexOf("<!") != -1)
		errorListHTML += "    - " + friendlyName + "\n";		
}


/*
FUNCTION: isInvalidPhone - Vasu : for checking phone information
INPUT:		s - string you are checking
Returns  false - if any of the characters being checked for is NOT found
Returns true - if any of the characters being checked for is  found
*/

function isInvalidPhone(s, friendlyName)
	{s=s+"";
		if (s.length !=0)
		{
		
		if ( (s.indexOf("\n") != -1) || (s.indexOf("\t") != -1) || 
				(s.indexOf("<") != -1) || (s.indexOf(">") != -1) || (s.indexOf("&") != -1) || 
				(s.indexOf("*") != -1) || (s.indexOf("\|") != -1) || (s.indexOf("\!") != -1) || 
				(s.indexOf("\#") != -1) || (s.indexOf("\$") != -1) || (s.indexOf("\"") != -1) || 
				(s.indexOf("\%") != -1) || (s.indexOf("\^") != -1) ||  
				(s.indexOf("\+") != -1) || (s.indexOf("\=") != -1) || 
				(s.indexOf("\?") != -1) || (s.indexOf("\:") != -1) ||
				(s.indexOf("\~") != -1) || (s.indexOf("\`") != -1) || (s.indexOf("\'") != -1) || 
				(s.indexOf("\;") != -1) || (s.indexOf("\@") != -1))
			{
				errorListInvalid += "    - " + friendlyName + "\n";
				return;
			}

		if (s.length !=0)
		   if ( s.length < 10)
		   	{
		   				errorPhone += "The phone number you enter must have 10 numbers.\nPlease make sure to include the area code with your phone number.\n";
		   				return;
   		  	}

		var intNumberCnt = 0
		         
		for ( var i=0; i<s.length; i++ )
			{
				if ( (s.charAt(i) == '1') || (s.charAt(i) == '2') || (s.charAt(i) == '3') ||
					(s.charAt(i) == '4') || (s.charAt(i) == '5') || (s.charAt(i) == '6') ||
					(s.charAt(i) == '7') || (s.charAt(i) == '8') || (s.charAt(i) == '9') || 
					(s.charAt(i) == '0'))
					{
						intNumberCnt++;
					}
			}   		  
   		  
		if ( intNumberCnt < 10)
					{
						errorPhone += "The phone number you enter must have 10 numbers.\n Please make sure to include area code with your phone number.\n";
						return;
   		   }	  
   		}  
	}


/*
FUNCTION: isInvalidString - checks if there is an invalid character in the string
INPUT:		s - string you are checking
RETURNS:	false - if string IS NOT found
					true - if string IS found
*/
function isInvalidString(s, friendlyName)
	{s=s+"";
		if ( (s.indexOf("\n") != -1) || (s.indexOf("\t") != -1) || 
				(s.indexOf("<") != -1) || (s.indexOf(">") != -1) || (s.indexOf("&") != -1) || (s.indexOf("'") != -1) || 
				(s.indexOf("*") != -1) || (s.indexOf("\|") != -1) || (s.indexOf("\!") != -1) || 
				(s.indexOf("\#") != -1) || (s.indexOf("\$") != -1) || (s.indexOf("\"") != -1) || 
				(s.indexOf("\%") != -1) || (s.indexOf("\^") != -1) || (s.indexOf("\(") != -1) || 
				(s.indexOf("\)") != -1) || (s.indexOf("\+") != -1) || (s.indexOf("\=") != -1) || 
				(s.indexOf("\?") != -1) || (s.indexOf("\:") != -1) ||
				(s.indexOf("\~") != -1) || (s.indexOf("\`") != -1) || 
				(s.indexOf("\;") != -1) )
			{
				errorListInvalid += "    - " + friendlyName + "\n";
         }
	}


/*
FUNCTION: isLetterItem - checks if the entry has only letters present
INPUT:		s - string you are checking
RETURNS:	false - if only letters are found
					true - if any non-letter is found
*/
function isLetterItem(s, friendlyName)
	{s=s+"";
		for ( var i=0; i<s.length; i++ )
			{
				if ( (s.charAt(i) != 'a') && (s.charAt(i) != 'b') && (s.charAt(i) != 'c') && 
					(s.charAt(i) != 'd') && (s.charAt(i) != 'e') && (s.charAt(i) != 'f') && 
					(s.charAt(i) != 'g') && (s.charAt(i) != 'h') && (s.charAt(i) != 'i') && 
					(s.charAt(i) != 'j') && (s.charAt(i) != 'k') && (s.charAt(i) != 'l') && 
					(s.charAt(i) != 'm') && (s.charAt(i) != 'n') && (s.charAt(i) != 'o') && 
					(s.charAt(i) != 'p') && (s.charAt(i) != 'q') && (s.charAt(i) != 'r') && 
					(s.charAt(i) != 's') && (s.charAt(i) != 't') && (s.charAt(i) != 'u') && 
					(s.charAt(i) != 'v') && (s.charAt(i) != 'w') && (s.charAt(i) != 'x') && 
					(s.charAt(i) != 'y') && (s.charAt(i) != 'z') && 
					(s.charAt(i) != 'A') && (s.charAt(i) != 'B') && (s.charAt(i) != 'C') && 
					(s.charAt(i) != 'D') && (s.charAt(i) != 'E') && (s.charAt(i) != 'F') && 
					(s.charAt(i) != 'G') && (s.charAt(i) != 'H') && (s.charAt(i) != 'I') && 
					(s.charAt(i) != 'J') && (s.charAt(i) != 'K') && (s.charAt(i) != 'L') && 
					(s.charAt(i) != 'M') && (s.charAt(i) != 'N') && (s.charAt(i) != 'O') && 
					(s.charAt(i) != 'P') && (s.charAt(i) != 'Q') && (s.charAt(i) != 'R') && 
					(s.charAt(i) != 'S') && (s.charAt(i) != 'T') && (s.charAt(i) != 'U') && 
					(s.charAt(i) != 'V') && (s.charAt(i) != 'W') && (s.charAt(i) != 'X') && 
					(s.charAt(i) != 'Y') && (s.charAt(i) != 'Z') && (s.charAt(i) != ' ')) 
						{
							errorLetterItem += friendlyName + "\n";
							break;
						}
			}
	}


/*
FUNCTION: isNumItem - checks if the entry has only numbers present
INPUT:		s - string you are checking
RETURNS:	false - if no letters are found
					true - if any letter are found
*/
function isNumItem(s, friendlyName)
	{s=s+"";
		for ( var i=0; i<s.length; i++ )
			{
				if ( (s.charAt(i) != '1') && (s.charAt(i) != '2') && (s.charAt(i) != '3') && 
					(s.charAt(i) != '4') && (s.charAt(i) != '5') && (s.charAt(i) != '6') && 
					(s.charAt(i) != '7') && (s.charAt(i) != '8') && (s.charAt(i) != '9') && 
					(s.charAt(i) != '0') && (s.charAt(i) != '-') && (s.charAt(i) != '(' && (s.charAt(i) != ')') && (s.charAt(i) != ' ') ) )
						{
							errorNumItem += friendlyName + "\n";
							break;
						}
			}
	}


/*
FUNCTION: isZipCode - checks if zip code is at least a valid 5 digit zipcode
INPUT:		s - string you are checking - does same thing as isNumItem
RETURNS:	false - if no letters are found
					true - if any letter are found
*/
function isZipCode(s, friendlyName)
	{s=s+"";
		for ( var i=0; i<s.length; i++ )
			{
				if ( (s.charAt(i) != '1') && (s.charAt(i) != '2') && (s.charAt(i) != '3') && 
					(s.charAt(i) != '4') && (s.charAt(i) != '5') && (s.charAt(i) != '6') && 
					(s.charAt(i) != '7') && (s.charAt(i) != '8') && (s.charAt(i) != '9') && 
					(s.charAt(i) != '0') && (s.charAt(i) != '-') )
					{
						errorZipCode += "Some of the characters you have used are NOT\n"; 
						errorZipCode += "allowed in " + friendlyName + " zip code!\n";
						break;
					}
			}
		 if (s.length !=0){	
			if ( s.length < 5)
						{
							errorZipCode += "There MUST be five numbers in your " + friendlyName + " zip code!\n";
   		   	  }
   		  }			
	}


/*
FUNCTION: isInvalidEmail - checks to see if it appears that this is a valid email type of string
INPUT:		s - string you are checking
RETURNS:		error - 	if no "." or "@" symbol is found
							if the "." is found to be one of the last two chars of the string
							if the "@" is found to be one of the last 4 characters of the string
							if "@" is found to be the first char of the string
*/
function isInvalidEmail(s, friendlyName)
	{s=s+"";
		var errorFound = 0;
		var foundAt = 0;
		var foundDot = 0;
		var numAts = 0;
		var numDots = 0;
		var email;
		email = s;		

email = stripBlanks(email);
		
//checks for regular invalid chars		
		if ( (email.indexOf(" ") != -1) || (email.indexOf("<") != -1) || (email.indexOf(">") != -1) || 
			(email.indexOf("&") != -1) || (email.indexOf("*") != -1) || (email.indexOf("\|") != -1) || 
			(email.indexOf("\!") != -1) || (email.indexOf("\#") != -1) || (email.indexOf("\$") != -1) || 
			(email.indexOf("\%") != -1) || (email.indexOf("\^") != -1) || (email.indexOf("\(") != -1) || 
			(email.indexOf("\)") != -1) || (email.indexOf("\+") != -1) || (email.indexOf("\=") != -1) || 
			(email.indexOf("\?") != -1) || (email.indexOf("\,") != -1) || (email.indexOf("\~") != -1) || 
			(email.indexOf("\`") != -1) || (email.indexOf("\'") != -1) || (email.indexOf("\"") != -1) || 
			(email.indexOf("\;") != -1) || (email.indexOf("\:") != -1) )
			{
				errorFound += 1;
         }
//checks the location of the "@" or "." symbols, and records how many it finds of each
      for ( var i=0; i<=email.length-1; i++ )
      	{
      		if ( email.charAt(i) == "\@" )
      			{
      				foundAt = i;
      				numAts = numAts + 1;
      			}
      		if ( email.charAt(i) == "\." )
      			{
      				foundDot = i;
      				numDots = numDots + 1;
      			}
      	}
//if the number of "@" symbols does NOT equal 1, error recorded
      if ( numAts != 1 )
      	{
				errorFound += 1;
      	}
//if the number of "." symbols equals 0, error recorded.
      if ( numDots == 0 )
      	{
				errorFound += 1;
      	}
//if "@" symbol is first in string or one of the last 4 chars in the string, error recorded
      if ( (foundAt < 1) || (foundAt > email.length-5) )
      	{
				errorFound += 1;
      	}
//if "." symbol is one of the last 2 chars of the string, error recorded
      if ( foundDot > email.length-3 )
      	{
				errorFound += 1;
      	}
//checks to see that "@" and "." are not next to each other
		if ( Math.abs(foundDot - foundAt) == 1 )
			{
				errorFound += 1;
			}
//checks to make sure that the "@" symbol comes BEFORE the "."
		if ( foundAt > foundDot )
			{
				errorFound += 1;
			}
		if ( errorFound != 0 )
			{
				errorInvalidEmail += friendlyName + "\n";
   		}
	}


/*
FUNCTION: passwordTest and NewpasswordTest - checks to see if new password request fits what is required
INPUT:		p1 - the old password
					p2a - the first new password input
					p2b - the second new password input
RETURNS:	  error - If the new password is the same as the old password, or if the the retyping of the second 
						new password field does not match the first one.
*/
function passwordTest(p1, p2a, p2b)
	{
	 p1=p1+"";
	 p2a=p2a+"";
	 p2b=p2b+"";
		if ( p2a != p2b )
			{
				errorPassword += "The passwords you entered did not match.\n";
				errorPassword += "Please re-enter your passwords.\n";
			}
		else if ( p2a == p2b )
			{
				if ( p1 == p2a )
					{
						errorPassword += "You have selected the same password as your previous one.\n";
						errorPassword += "You MUST select a different password.  Please re-enter your password.\n";
					}
				if ( (p2a.length < 5) || (p2a.length > 20) )
					{
						errorPassword += "Your new password must have no less than 5 characters\n";
						errorPassword += "and be no more than 20 characters in length.\n";
						errorPassword += "Please re-enter your password.\n";
					}
			}
	}

function NewPasswordTest(p2a, p2b)
	{
	 p2a=p2a+"";
	 p2b=p2b+"";
	 if (p2a != ""){
		if ( p2a != p2b )
			{
				errorPassword += "The passwords you entered did not match.\n";
				errorPassword += "Please re-enter your passwords.\n";
			}
		else if ( p2a == p2b )
			{
				if ( (p2a.length < 5) || (p2a.length > 20) )
					{
						errorPassword += "Your new password must have no less than 5 characters\n";
						errorPassword += "and be no more than 20 characters in length.\n";
						errorPassword += "Please re-enter your password.\n";
					}
			}
    }
	}
	

/*
FUNCTION:	passwordClue - checks to see if pwd clue is same as pwd itself
INPUT:		p2a - the  new password input
					p2c - the new password clue
RETURNS:	error - If the new password is the same as the password clue
*/
function passwordClue(p2a, p2c)
  {p2a=p2a+"";
	 p2c=p2c+"";
	if (p2a !="" && p2c !=""){ 
    if (p2a==p2c)
        {
            errorPasswordClue += "You have selected the same password clue as your new password.\n";
						errorPasswordClue += "You MUST select a different password clue.\n";
        }
     }   
  }


/*
FUNCTION:	listErrors - this will compile the list of errors present, if any.
INPUT:		nothing
RETURNS:		a list of any errors user has made on the form it is checking
 */
function listErrors()
	{
		passedTest = "passed";
		var msg = "Please correct the following problems:\n\n";
		
		if ( errorInvalidEmail.length > 0 )
			{
				msg += "\n";
				msg += "------------------------------------------------------\n";
				msg += "Please enter a valid email for " + errorInvalidEmail + "\n";
				showAlert = true
			}
		if ( errorPassword.length > 0 )
			{
				msg += "------------------------------------------------------\n"
				msg += errorPassword;
				showAlert = true
			}
		if (errorPasswordClue.length > 0)
		   {
		        msg += "------------------------------------------------------\n"
				msg += errorPasswordClue;
				showAlert = true
		   }	
			
		if ( errorListInvalid.length > 0 )
			{
				msg += "\n";
				msg += "There are unusable characters in these fields:\n";
				msg += "------------------------------------------------------\n";
				msg += errorListInvalid;
				showAlert = true
			}
		if ( errorLetterItem.length > 0 )
			{
				msg += "\n";
				msg += "The following fields must have letters only:\n";
				msg += "------------------------------------------------------\n";
				msg += errorLetterItem;
				msg += "\n"
				showAlert = true
			}
		if ( errorNumItem.length > 0 )
			{
				msg += "\n";
				msg += "The following fields must have numbers only:\n";
				msg += "------------------------------------------------------\n";
				msg += errorNumItem;
				msg += "\n"
				showAlert = true
			}
		if ( errorZipCode.length > 0 )
			{
				msg += "------------------------------------------------------\n";
				msg += errorZipCode;
				msg += "\n"
				showAlert = true
			}
		if ( errorListEmpty.length > 0 )
			{
				msg += "\n";
				msg += "You must fill out the following required field(s):\n";
				msg += "------------------------------------------------------\n";
				msg += errorListEmpty;
				msg += "\n";
				showAlert = true
			}
		if ( errorSelectedItem.length > 0 )
			{
				msg += "\n";
				msg += "You must make selections in the following menus:\n";
				msg += "------------------------------------------------------\n";
				msg += errorSelectedItem;
				msg += "\n";
				showAlert = true
			}
		if (errorListMaxChars.length > 0)
			{
				msg += "\n";
				msg += "You have too many characters in the following fields:\n";
				msg += "------------------------------------------------------\n";
				msg += errorListMaxChars;
				msg += "\n";
				showAlert = true
			}
		if ( errorListBlank.length > 0 )
			{
				msg += "\n";
				msg += "Please remove blank space from these fields:\n";
				msg += "------------------------------------------------------\n";
				msg += errorListBlank;
				msg += "\n";
				showAlert = true
			}
		if ( errorListHTML.length > 0 )
			{
				msg += "\n";
				msg += "You can't use these HTML tags in these fields:\n";
				msg += "------------------------------------------------------\n";
				msg += errorListHTML;
				msg += "\n";
				showAlert = true
			}
		if ( errorPhone.length > 0 )
			{
				msg += "------------------------------------------------------\n";
				msg += errorPhone;
				msg += "\n";
				showAlert = true				
			}
		if ( errorValidFile.length > 0 )
			{
				msg += "\n";
				msg += "File path or type is not valid. Please choose a valid file path or type for the following fields :\n";
				msg += "------------------------------------------------------\n";
				msg += errorValidFile;
				msg += "\n";
				showAlert = true
			}				
		if (showAlert)
			{
				passedTest = "notPassed";
				alert(msg);
			}
			
		//reset these already existing variables to nothing so that the error message will appear only once in the error alert box.
		errorListMaxChars = "";
		errorNumItem = "";
		errorLetterItem = "";
		errorListEmpty = "";
		errorListBlank = "";
		errorSelectedItem = "";
		errorListHTML = "";
		errorInvalidEmail = "";
		errorPassword = "";
		errorPasswordClue = "";
		errorPhone = "";
		errorZipCode = "";
		urlTest = "";
		errorValidFile = "";
		errorListInvalid  = "";
		showAlert = false;		//	Local Variable
	}		
	
//*******************************************************************************************
//*************************Other Functions not requiring validation string*******************
//*******************************************************************************************

/*
FUNCTION:	goForward - this will assign a new url for the window
INPUT:		url - the page to continue on.
RETURNS:	if no errors, then url/page is loaded.
 */
function goForward(url)
	{url=url+"";
		if ( urlTest.length < 75 )
			{
   			window.location.assign(url);
   		}
	}


/*FUNCTION: 	isValidFile - checks for valid file path and valid file type for file uploading
INPUT:		s - string with valid extensions
			p - file path
*/
				
function isValidFile(s,p,friendlyName){
s=s+"";
p=p+"";
var ext;
var flag=0;
var i=0;
ext=s.split(".");

if (p.indexOf(".")!=-1){

for(i=0;i<ext.length;i++)
  {
	if ((eval("p.indexOf('." + ext[i] + "')")!=-1)&& (ext[i].length==p.length-p.indexOf(".")-1))
	{
		
		flag=1;
		break;
		
	}
	
   }	
 
}
if (flag !=1)
 {
 
 errorValidFile = errorValidFile + "    -" + friendlyName + "\n";

 }
}

// -->
