function validateForm() {
	var msgs = "";
    var allowSubmit = true;   

    if(document.the_form.Church.value.length < 1) {
    	if(document.the_form.NewChurch.value.length < 1) {      
	  		allowSubmit = false;
      		msgs += "- Please provide your church name.\n";
		}
    }
	
    if(document.the_form.Church.value.length >= 1) {
    	if(document.the_form.NewChurch.value.length >= 1) {      
	  		allowSubmit = false;
      		msgs += "- Please select a church from the list OR enter a new church name.\n";
		}
    }	

    if(document.the_form.FirstName.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide your first name.\n";
    }

    if(document.the_form.LastName.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide your last name.\n";
    }
    
    if (document.the_form.LastName.value.length > 1) {
    	if (document.the_form.FirstName.value.length > 1) {
    		if (document.the_form.FirstName.value == document.the_form.LastName.value) {
      			allowSubmit = false;
      			msgs += "- Please provide a valid name.\n";   			
    		}
    	}
    }
	
    if((document.the_form.FirstName.value.length < 1) && (document.the_form.LastName.value.length < 1)) {
    	if (document.the_form.FirstName.value == document.the_form.LastName.value) {
    		allowSubmit = false;
    		msgs += "- Please provide a valid first and last name.\n";
    	}
    }

    if(document.the_form.PhoneNumber.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide your phone number.\n";
    }
	
    if(document.the_form.EmailAddress.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please enter an email address.\n";
    } 	
	
    if(document.the_form.ChurchRole.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please enter your role at the church.\n";
    } 		
	
    if(document.the_form.ChurchAddress1.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide your church's street address.\n";
    }

    if(document.the_form.ChurchCity.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide your church's city.\n";
    }

    if(document.the_form.ChurchState.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide your church's state.\n";
    }

    if(document.the_form.ChurchZip.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide your church's zip code.\n";
    }

    if(document.the_form.Participants.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide the number of expected participants.\n";
    }

    if(document.the_form.PossibleGroups.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please provide the number of possible groups.\n";
    }
	
    if(document.the_form.Childrens.value.length < 1) {
      allowSubmit = false;
      msgs += "- Please let us know whether your 0-18 ministry will be participating.\n";
    }	
	
    for(i=1;i<=10;i++) {
        if( trim(document.getElementById("FirstName_" + i).value).length != 0 ||
            trim(document.getElementById("LastName_" + i).value).length != 0 ||
            trim(document.getElementById("PhoneNumber_" + i).value).length != 0 ||
            trim(document.getElementById("EmailAddress_" + i).value).length != 0 ||
            trim(document.getElementById("ChurchRole_" + i).value).length != 0
            ) 
            {
                if( trim(document.getElementById("FirstName_" + i).value).length == 0 ||
                    trim(document.getElementById("LastName_" + i).value).length == 0 ||
                    trim(document.getElementById("PhoneNumber_" + i).value).length == 0 ||
                    trim(document.getElementById("EmailAddress_" + i).value).length == 0 ||
                    trim(document.getElementById("ChurchRole_" + i).value).length == 0
                    )   {
                        alert(document.getElementById("ChurchRole_" + i).value);
		                allowSubmit = false;
		                msgs = msgs +  "- Please fill in all of the info for others in your church in row " + i + ".\n";
                    }
            }
    }

    if(allowSubmit) {
      document.the_form.action = "/journeypartners/actJourneySignup.php";
      document.the_form.submit();
    } else {
      msgs += "\nPlease correct the item(s) listed above to submit the form.";
      alert(msgs);
    }
    
  }
  
    function trim (str) {
	    str = str.replace(/^\s+/, '');
	    for (var i = str.length - 1; i >= 0; i--) {
	        if (/\S/.test(str.charAt(i))) {
	            str = str.substring(0, i + 1);
	            break;
	        }
	    }
	    return str;
    }
    
    function openwindow(fileName) {
        window.open(fileName, 'Message', 'toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, width=300, height=200');
        return false;
    }
    
    
  


