function validate_apply_online()
{
	var parsed = true;
	
	if (document.eapp.first_name.value == "") 
	{
		alert("Please enter your first name.");
		parsed=false;
	}
		else if (allValidChars(document.eapp.first_name.value)) // check to make sure all characters are valid
		{  
				alert("You have made an invalid entry in the FIRST NAME field.");  	
        			parsed=false;
    			}
		else if (! webcheck(document.eapp.first_name.value))
		{  
				alert("You have made an invalid entry in the FIRST NAME field.");
        			parsed=false;
    			}	
	
	else if (document.eapp.last_name.value == "") 
	{
		alert("Please enter your last name.");
		parsed=false;
	}
		else if (allValidChars(document.eapp.last_name.value)) // check to make sure all characters are valid
			{  
				alert("You have made an invalid entry in the LAST NAME field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp.last_name.value))
		{  
				alert("You have made an invalid entry in the LAST NAME field.");
        			parsed=false;
    			}
	else if (document.eapp.company.value == "") 
	{
		alert("Please enter your company's name.");
		parsed=false;
	}
		else if (allValidChars(document.eapp.company.value)) // check to make sure all characters are valid
			{  
				alert("You have made an invalid entry in the BUSINESS NAME field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp.company.value))
		{  
				alert("You have made an invalid entry in the BUSINESS NAME field.");
        			parsed=false;
    			}
	else if (document.eapp.street.value == "") 
	{
		alert("Please enter a street address.");
		parsed=false;
	}
		else if (allValidChars(document.eapp.street.value)) // check to make sure all characters are valid
			{  
				alert("You have made an invalid entry in the BUSINESS ADDRESS field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp.street.value))
		{  
				alert("You have made an invalid entry in the BUSINESS ADDRESS field.");
        			parsed=false;
    			}
	else if (document.eapp.city.value == "") 
	{
		alert("Please enter your city.");
		parsed=false;
	}
		else if (allValidChars(document.eapp.city.value)) // check to make sure all characters are valid
			{  
				alert("You have made an invalid entry in the CITY field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp.city.value))
		{  
				alert("You have made an invalid entry in the CITY field.");
        			parsed=false;
    			}
	else if (document.eapp.state.value == "" || document.eapp.state.value == "Select a State") 
	{
		alert("Please select your state.");
		parsed=false;
	}
		else if (allValidChars(document.eapp.state.value)) // check to make sure all characters are valid
			{  
				alert("You have made an invalid entry in the STATE field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp.state.value))
		{  
				alert("You have made an invalid entry in the STATE field.");
        			parsed=false;
    			}
	else if (document.eapp.zip.value == "") 
	{
		alert("Please enter your zip code.");
		parsed=false;
	}
	else if (! Validzip(document.eapp.zip.value)) 
	{
		alert("Please enter a valid zip code.");
		parsed=false;
	}
	else if (document.eapp.phone.value == "") 
	{
		alert("Please enter your phone number.");
		parsed=false;
	}
	else if (! ValidPhone(document.eapp.phone.value)) 
	{
		alert("Please enter numeric data in the phone field.");
		parsed=false;
	}
	else if(document.eapp.phone.value.length < 12 || document.eapp.phone.value.length > 12)
	{
		alert("Please provide your area code and phone number in the following format: xxx-xxx-xxxx.");
		parsed=false;
	}	
	else if (document.eapp.email.value == "") 
	{
        	alert("Please enter your email address.");
        	parsed=false;
        }
    	else if (allValidChars(document.eapp.email.value)) // check to make sure all characters are valid
		{  
			alert("You have made an invalid entry in the EMAIL field");
        	parsed=false;
    	}
		else if (! ValidateAtCount(document.eapp.email.value)) // check to make sure there is not more than one "@" in the field
		{  
			alert("You have entered an invalid email address. 01");
        	parsed=false;
    	}
    	else if (document.eapp.email.value.indexOf("@") < 1) //  must contain @, and it must not be the first character
		{ 
			alert("You have entered an invalid email address. 02");
        	parsed=false;
    	} 
		else if (document.eapp.email.value.lastIndexOf(".") <= document.eapp.email.value.indexOf("@")) // last dot must be after the @
		{ 
			alert("You have entered an invalid email address. 03");
        		parsed=false;
    		}		 
		else if (document.eapp.email.value.indexOf("..") >=0) // two periods in a row is not valid
		{ 
			alert("You have entered an invalid email address. 04");
			parsed=false;
    		} 
		
		else if (document.eapp.email.value.indexOf(".") +1 == document.eapp.email.value.length) // . must not be the last character
		{  
			alert("You have entered an invalid email address. 05");
			parsed=false;
    		}
    				
return parsed;
}



function validate_help_desk()
{	
	var parsed=true;

	if (document.eapp1.first_name.value == "") 
	{
		alert("Please enter your first name.");
		parsed=false;
	}
	else if (allValidChars(document.eapp1.first_name.value)) // check to make sure all characters are valid
		{  
				alert("You have entered an invalid character in the FIRST NAME field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp1.first_name.value))
		{  
				alert("Please put the URLs in the WEBSITE field.");
        			parsed=false;
    			}
	else if (document.eapp1.company.value == "") 
	{
		alert("Please enter your company's name.");
		parsed=false;
	}
	else if (allValidChars(document.eapp1.company.value)) // check to make sure all characters are valid
		{  
				alert("You have entered an invalid character in the COMPANY field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp1.company.value))
		{  
				alert("Please put the URLs in the WEBSITE field.");
        			parsed=false;
    			}
	else if (document.eapp1.phone.value == "") 
	{
		alert("Please enter your phone number.");
		parsed=false;
	}
	else if (! ValidPhone(document.eapp1.phone.value)) 
	{
		alert("Please enter numeric data in the phone field.");
		parsed=false;
	}
	else if (document.eapp1.phone.value.length < 12 || document.eapp1.phone.value.length > 12)
	{
		alert("Please provide your area code and phone number in the following format: xxx-xxx-xxxx.");
		parsed=false;
	}
	else if (document.eapp1.email.value == "") 
	{
		alert("Please enter your email address.");
        parsed=false;
	}
		else if (allValidChars(document.eapp1.email.value)) // check to make sure all characters are valid
		{  
			alert("You have entered an invalid character in the email field");
			parsed=false;
		}
		else if (! ValidateAtCount(document.eapp1.email.value)) // check to make sure there is not more than one "@" in the field
		{  
			alert("You have entered an invalid email address. 01");
			parsed=false;
		}
		else if (document.eapp1.email.value.indexOf("@") < 1) //  must contain @, and it must not be the first character
		{ 
			alert("You have entered an invalid email address. 02");
			parsed=false;
		} 
		else if (document.eapp1.email.value.lastIndexOf(".") <= document.eapp1.email.value.indexOf("@")) // last dot must be after the @
		{ 
			alert("You have entered an invalid email address. 03");
			parsed=false;
    		}		 
		else if (document.eapp1.email.value.indexOf("..") >=0) // two periods in a row is not valid
		{ 
			alert("You have entered an invalid email address. 04");
			parsed=false;
    		} 
		
		else if (document.eapp1.email.value.indexOf(".") +1 == document.eapp1.email.value.length) // . must not be the last character
		{  
			alert("You have entered an invalid email address. 05");
			parsed=false;
    		}
	else if (document.eapp1.reason.options[document.eapp1.reason.selectedIndex].value == '--None--') // user must choose a Support Issue
	{  
		alert("Please choose a support issue.");
        parsed=false;
	}
	else if (ValidateDescription(document.eapp1.description.value)) // check to make sure no profanity is submitted in the description field.
	{  
		alert("You have entered invalid data in the description field.");
        parsed=false;
	}   
		    		
return parsed;
}


function validate_questions()
{
	var parsed=true;
	
	if (document.eapp2.first_name.value == "") 
	{
		alert("Please enter your first name.");
		parsed=false;
	}
	else if (allValidChars(document.eapp2.first_name.value)) // check to make sure all characters are valid
		{  
				alert("You have entered an invalid character in the FIRST NAME field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp2.first_name.value))
		{  
				alert("Please put the URLs in the WEBSITE field.");
        			parsed=false;
    			}
	else if (document.eapp2.last_name.value == "") 
	{
		alert("Please enter your last name.");
		parsed=false;
	}
	else if (allValidChars(document.eapp2.last_name.value)) // check to make sure all characters are valid
		{  
				alert("You have entered an invalid character in the LAST NAME field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp2.last_name.value))
		{  
				alert("Please put the URLs in the WEBSITE field.");
        			parsed=false;
    			}
	else if (document.eapp2.company.value == "") 
	{
		alert("Please enter your company's name.");
		parsed=false;
	}
	else if (allValidChars(document.eapp2.company.value)) // check to make sure all characters are valid
		{  
				alert("You have entered an invalid character in the COMPANY field.");
        			parsed=false;
    			}
		else if (! webcheck(document.eapp2.company.value))
		{  
				alert("Please put the URLs in the WEBSITE field.");
        			parsed=false;
    			}
	else if (document.eapp2.phone.value == "") 
	{
		alert("Please enter your phone number.");
		parsed=false;
	}
	else if (! ValidPhone(document.eapp2.phone.value)) 
	{
		alert("Please enter numeric data in the phone field.");
		parsed=false;
	}
	else if (document.eapp2.phone.value.length < 12 || document.eapp2.phone.value.length > 12)
	{
		alert("Please provide your area code and phone number in the following format: xxx-xxx-xxxx.");
		parsed=false;
	}
	else if (document.eapp2.email.value == "") 
	{
        	alert("Please enter your email address.");
        	parsed=false;
        }
    	else if (allValidChars(document.eapp2.email.value)) // check to make sure all characters are valid
		{  
			alert("You have entered an invalid character in the email field.");
        	parsed=false;
    	}
		else if (! ValidateAtCount(document.eapp2.email.value)) // check to make sure there is not more than one "@" in the field
		{  
			alert("You have entered an invalid email address. 01");
        	parsed=false;
    	}
    	else if (document.eapp2.email.value.indexOf("@") < 1) //  must contain @, and it must not be the first character
		{ 
			alert("You have entered an invalid email address. 02");
        	parsed=false;
    	} 
		else if (document.eapp2.email.value.lastIndexOf(".") <= document.eapp2.email.value.indexOf("@")) // last dot must be after the @
		{ 
			alert("You have entered an invalid email address. 03");
        		parsed=false;
    		}		 
		else if (document.eapp2.email.value.indexOf("..") >=0) // two periods in a row is not valid
		{ 
			alert("You have entered an invalid email address. 04");
			parsed=false;
    		} 
		
		else if (document.eapp2.email.value.indexOf(".") +1 == document.eapp2.email.value.length) // . must not be the last character
		{  
			alert("You have entered an invalid email address. 05");
			parsed=false;
    		}
    		
return parsed;
}


function webcheck(input) //makes sure websites are not place in inappropriate fields
{
	var parsed = true;
  	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_ ";
	var Getvalue = "";
	var webExt = new Array()
		webExt[0] = "www."
		webExt[1] = "http"
		webExt[2] = ".a"
		webExt[3] = ".b"
		webExt[4] = ".c"
		webExt[5] = ".d"
		webExt[6] = ".e"
		webExt[7] = ".f"
		webExt[8] = ".g"
		webExt[9] = ".h"
		webExt[10] = ".i"
		webExt[11] = ".j"
		webExt[12] = ".k"
		webExt[13] = ".l"
		webExt[14] = ".m"
		webExt[15] = ".n"
		webExt[16] = ".o"
		webExt[17] = ".p"
		webExt[18] = ".q"
		webExt[19] = ".r"
		webExt[20] = ".s"
		webExt[21] = ".t"
		webExt[22] = ".u"
		webExt[23] = ".v"
		webExt[24] = ".w"
		webExt[25] = ".x"
		webExt[26] = ".y"
		webExt[27] = ".z"
					
	for (var i=0; i < input.length; i++) 
  	{
		var letter = input.charAt(i).toLowerCase();
		Getvalue += letter;			    		
		if (validchars.indexOf(letter) != -1)
			continue;
    		parsed = false;
   			break;   			
	}
				
	for (var y=0; y < 29; y++) 
  	{
  		var getWebExt = webExt[y];
    	
    	for (var i=0; i < input.length; i++) 
    	{	
    		if (Getvalue.lastIndexOf(getWebExt) == i)
			alert("Please place URLs in the WEBSITE field.");   							 		
	    }
	}
				
	return parsed;
}

function allValidChars(input) 
{
	var parsed = false;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_ ";
  	var Getvalue = "";
	var badwords = new Array()
		badwords[0] = "porn"
		badwords[1] = "fuck"
		badwords[2] = "cunt"
		badwords[3] = "slut"
		badwords[4] = "whore"
		badwords[5] = "bitch"
		badwords[6] = "lesbian"
		badwords[7] = "cock"
		badwords[8] = "pussy"
		badwords[9] = "asshole"
		badwords[10] = "shit"
		badwords[11] = "horny"
		badwords[12] = "adult"
		badwords[13] = "nude"
		badwords[14] = "girl"
		badwords[15] = "sex"
		badwords[16] = "anal"
		badwords[17] = "beastiality"
		badwords[18] = "lolita"
		badwords[19] = "cum"
		badwords[20] = "viagra"		
		badwords[21] = "cialis"
		badwords[22] = "levitra"
		badwords[23] = "sblog.cz"
		badwords[24] = "tramadol"
		badwords[25] = "casino"		
		
				for (var i=0; i < input.length; i++) 
  				{
    					var letter = input.charAt(i).toLowerCase();
			    		Getvalue += letter;
			    		
					if (validchars.indexOf(letter) != -1)
						continue;
    					parsed = true;
   					break;   			
   							 		
				}
								
				for (var x=0; x < 27; x++) 
  				{
  					var getBadwords = badwords[x];
    				
    				for (var y=0; y < input.length; y++) 
    				{	
    					if (Getvalue.lastIndexOf(getBadwords) == y)
						parsed = true;						 		
				    }
				}
				
		return parsed;
}

function ValidateDescription(input) 
{
	var parsed = false;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_,;:'!#$%&*() ";  	
	var Getvalue = "";
	var badwords = new Array()
		badwords[0] = "porn"
		badwords[1] = "fuck"
		badwords[2] = "cunt"
		badwords[3] = "slut"
		badwords[4] = "whore"
		badwords[5] = "bitch"
		badwords[6] = "lesbian"
		badwords[7] = "cock"
		badwords[8] = "pussy"
		badwords[9] = "asshole"
		badwords[10] = "shit"
		badwords[11] = "horny"
		badwords[12] = "adult"
		badwords[13] = "nude"
		badwords[14] = "girl"
		badwords[15] = "sex"
		badwords[16] = "anal"
		badwords[17] = "beastiality"
		badwords[18] = "lolita"
		badwords[19] = "cum"	
		badwords[20] = "viagra"						
		badwords[21] = "cialis"
		badwords[22] = "levitra"
		badwords[23] = "sblog.cz"
		badwords[24] = "tramadol"
		badwords[25] = "casino"
		badwords[26] = "http"
		
				for (var i=0; i < input.length; i++) 
  				{
    					var letter = input.charAt(i).toLowerCase();
			    		Getvalue += letter;
			    		
					if (validchars.indexOf(letter) != -1)
						continue;
    					parsed = true;
   					break;   			
   							 		
				}
								
				for (var x=0; x < 28; x++) 
  				{
  					var getBadwords = badwords[x];
    				
    				for (var y=0; y < input.length; y++) 
    				{	
    					if (Getvalue.lastIndexOf(getBadwords) == y)
						parsed = true;						 		
				    }
				}
				
		return parsed;
}

function ValidateAtCount(email) 
{
  	var parsed = true;
  	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  	var AtFound = "";

	for (var i=0; i < email.length; i++) 
  	{
    		var letter = email.charAt(i).toLowerCase();
    				
    		if (validchars.indexOf(letter) == 36)
		AtFound += "@";
 		continue;
    		parsed = false;		
	}

	if (AtFound.length > 1)
	parsed = false;

	return parsed;
}

function ValidPhone(phone) 
{
  	var parsed = true;
  	var validchars = "0123456789+-";
  	
	for (var i=0; i < phone.length; i++) 
  	{
    		var number = phone.charAt(i);    		

		if (validchars.indexOf(number) != -1)
	        continue;
    		parsed = false;
   		break;  		
	}

	return parsed;
}

function Validzip(zip) 
{
  	var parsed = true;
  	var validchars = "0123456789-";
  	
	for (var i=0; i < zip.length; i++) 
  	{
    		var number = zip.charAt(i);    		

		if (validchars.indexOf(number) != -1)
	        continue;
    		parsed = false;
   		break;  		
	}

	return parsed;
}