<!--

// checkArray is original JavaScript code by Chirp Internet: www.chirp.com.au 
// Please acknowledge use of this code by including this header. 

function checkArray(form, arrayName) 
	{ var retval = new Array(); 
	for(var i=0; i < form.elements.length; i++) {
	 var el = form.elements[i]; if(el.type == "checkbox" && el.name == arrayName && el.checked) { retval.push(el.value); } } return retval; } 


function validate(frm) {

	//
    // Check the name field to see if any characters were entered
    //
    if (frm.name.value.length == 0)
    {
        alert("Please enter your name.")
        frm.name.focus()
        return false
    }
    
    //
    // Check the street address field to see if any characters were entered
    //
    if (frm.streetaddress.value.length == 0)
    {
        alert("Please enter your street address.")
        frm.streetaddress.focus()
        return false
    }
    
    //
    // Check the city field to see if any characters were entered
    //
    if (frm.city.value.length == 0)
    {
        alert("Please enter your city.")
        frm.city.focus()
        return false
    }
    
    //
    // Check the state field to see if any characters were entered
    //
    if (frm.state.value.length == 0)
    {
        alert("Please enter your state.")
        frm.state.focus()
        return false
    }
    
    //
    // Check the Zip code field to see if any characters were entered
    //
    if (frm.zip.value.length == 0)
    {
        alert("Please enter your ZIP code.")
        frm.zip.focus()
        return false
    }
    
    //
    // Check the phone 1 field to see if any characters were entered
    //
    if (frm.phone1.value.length == 0)
    {
        alert("Please enter your phone number.")
        frm.phone1.focus()
        return false
    }
	
	var phone = frm.phone1.value;
	
	// phone number - strip out delimiters and check for 10 digits

	var stripped = phone.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
  	  if (isNaN(parseInt(stripped))) {
 	      alert("The phone number contains illegal characters.")
 	      frm.phone1.focus()
 	      return false
  	  }
 	
 	   if (!(stripped.length == 10)) {
		  alert("The phone number is the wrong length. Make sure you included an area code.")
		  frm.phone1.focus()
 	      return false
 	   } 


    
    //
    // Check the Email field to see if any characters were entered
    //
    if (frm.email.value.length == 0)
    {
        alert("Please enter an e-mail address.")
        frm.email.focus()
        return false
    }
    
    // Check that the email address is valid.

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(frm.email.value))) { 
       alert("Please enter a valid email address.")
       frm.email.focus();
       return false;
    }
    
    // Make sure that at least one "get involved" checkbox is checked - no longer needed but left in to be safe

    //var itemsChecked = checkArray(frm, "involvement[]"); 
    //if(itemsChecked.length < 1) { 
    //	alert("You must check off at least one way that you want to get involved.")  
  	 // return false; 
	//}



    
}
//-->

