	var requiredFields = new Array("txtName", "txtEmail", "txtPhone", "txtComments");
    	var fieldNames = new Array("Your Name", "Your Email", "Your Phone", "Your Comments");   
	var FormOK = NameOK = EmailOK = PhoneOK = CommentsOK = true;

function checkFields(input) {
	
	if (document.theForm.Topic.value==null){
		if (document.theForm.Topic[0].checked==false){
			if (document.theForm.Topic[1].checked==false){
				if (document.theForm.Topic[2].checked==false){
						alert("The Topic field requires valid input"); return false;
				}		
			}	
		}	
	}

	if (document.theForm.txtComments.value.length > 500){
		alert ("The Comments field can not exceed 500 characters."); return false;
	}
		
	if (!(checkRequiredFields2(input))) {return false;}	
	if (!(NameOK)) { alert("The Name field requires valid input"); return false; }
	if (!(EmailOK)) { alert("The Email field requires valid input"); return false; }
	if (!(PhoneOK)) { alert("The Phone Again field requires valid input"); return false; }		
	if (!(CommentsOK)) { alert("The Comments field requires valid input"); return false; }	
	else {
	return true; 
	}	
}	
		
function checkRequiredFields2(input)
{             
   
    var fieldCheck   = true;
    var fieldsNeeded = "\nA value must be entered in the following field(s):\n\n\t";

    for(var fieldNum=0; fieldNum < requiredFields.length; fieldNum++) {
        if ((input.elements[requiredFields[fieldNum]].value == "") ||
            (input.elements[requiredFields[fieldNum]].value == " ")) {

            fieldsNeeded += fieldNames[fieldNum] + "\n\t";
            fieldCheck = false;
        }
    }
  
    if (fieldCheck == true)
    {
		FormOK = true
        return true;
    }

    else
    {
		FormOK = false
        alert(fieldsNeeded);
        return false;
    }
}
	
function ifEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{   
	var i;
	var whitespace = " \t\n\r";
	
    if (ifEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   

	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

function isEmail (s)
{   
	if (ifEmpty(s)) 
       if (isEmail.arguments.length == 1) return alert('Please Enter Email Address');
       else return (isEmail.arguments[1] == true);
   
    if (isWhitespace(s)) return alert('invalid email1');
    
    var i = 1;
    var sLength = s.length;

    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return alert('Invalid Email Address without  "@" ');
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return alert('Invalid Email Address without  "." ');
    else return true;
}		

function toNumber(checkString)
{
			newString = ""; 	  

			for (i = 0; i < checkString.length; i++) {
				ch = checkString.substring(i, i+1);

				if ((ch >="0"  && ch <= "9"))
				{
				 newString += ch;
				 }
				}
	
				return newString;
}
		
function isPhoneFax(checkString) {

    for (i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i+1);

		if (!((ch >="0"  && ch <= "9") || (ch==" ") || (ch=="-") || (ch=="(") || (ch==")") || (ch=="x") ))
			{
				alert('This Phone number contains incompatable characters');
				return(false);
			}
	}
	if (checkString.length >= 10 && checkString.length <=25)
		{
		return (true);
		}
	else 
		{ 
		alert('This Phone number is invalid'); 
		return (false);
		}
}		
