/**
* For use on strategic-service page at northpoint.org (northpoint.org/site/get_involved)
*
* adapted from Josh Daws script written in 2007
*
* @author: Russell Todd - 2008.01.25
*/
/*************************
updateEmail was already on the page, I just put it in a seperate .js
no author or (c) information.
*************************/
var recipientsArray = Array();
recipientsArray["Administration"] = "admin@brownsbridge.org";	
recipientsArray["Care Team"] = "care@brownsbridge.org";	
recipientsArray["Host Team"] = "hostteam@brownsbridge.org";	
recipientsArray["GroupLink Team"] = "communitygroups@brownsbridge.org";	
recipientsArray["KidStuf"] = "kidstuf@brownsbridge.org";	
recipientsArray["Middle School"] = "xtreme@brownsbridge.org";	
recipientsArray["Production"] = "production@brownsbridge.org";	
recipientsArray["Resources"] = "resources@brownsbridge.org";	
recipientsArray["UpStreet"] = "upstreet@brownsbridge.org";	
recipientsArray["Waumba Land"] = "waumbaland@brownsbridge.org";	
recipientsArray["High School"] = "insideout@brownsbridge.org";
function updateEmail(theForm){
	var recipients = "info@brownsbridge.org;";
	var ministry = theForm["fhscol_ministry"].value;
        if (ministry != "")
		recipients = recipients + recipientsArray[ministry];

// !!!!! TESTING ONLY !!!!!!
//alert("Recipients: "+ recipients);
	//recipients = "russell.todd@northpoint.org";
// !!!!! TESTING ONLY !!!!!!
	theForm["fhs_recipients"].value = recipients;

}
	
function formCheck(theForm){
        updateEmail(theForm);
	message = "";
	if (theForm["fhscol_firstName"].value == ""){message += "  -- First Name\n";}
	if (theForm["fhscol_lastName"].value == ""){message += "  -- Last Name\n";}
	
	if (theForm["fhscol_address"].value == ""){message += "  -- Home Address\n";}
	if (theForm["fhscol_city"].value == ""){message += "  -- City\n";}
	if (theForm["fhscol_state"].value == ""){message += "  -- State\n";}
	if (theForm["fhscol_zip"].value == ""){message += "  -- Zip\n";}


	if (theForm["fhscol_phone"].value == ""){message += "  -- Home Phone\n";}
	if (theForm["fhscol_email"].value == ""){message += "  -- Email\n";}

	if (theForm["fhs_recipients"].value == ""){message += "  -- Preferred Service Opportunities\n";}

	if (message != ""){
		message = "You must enter the following information:\n\n" + message + "\nPlease click OK, enter the required information,\nand re-submit your request.";
		alert(message);
		return false;
	}
	
	// consolidate the service areas
	var cb = theForm["serviceteam"];
	if (cb) {
          var teams = "";
          for (i=0;i<cb.length;i++) {
	    if (cb[i].checked) 
                teams += cb[i].value + ", "; 
          }
          theForm["fhscol_service_area"].value = teams.substr(0,teams.length - 2);
        } else {
          theForm["fhscol_service_area"].value = theForm["serviceteam_hardcode"].value;
        } 

	// consolidate the service hours
	var cb2 = theForm["servicehour"];
	if (cb2) {
          var hours = "";
          for (i=0;i<cb2.length;i++) {
	    if (cb2[i].checked) 
                hours += cb2[i].value + ", "; 
          }
          theForm["fhscol_service_hour"].value = hours.substr(0,hours.length - 2);
        } else {
          theForm["fhscol_service_hour"].value = theForm["servicehour_hardcode"].value;
        } 
 
        
	//var theForm = document.getElementById('strategicForm');
	//theForm.submit();
	//theForm.submit();
	return true;

}
