/* check sign up form */
function isReady(form) {
		if (isFilled(form.item_name) == false) {
		alert("Please choose a program.");
		form.item_name.focus();
		return false;
		}
		if (isFilled(form.parent) == false) {
		alert("Please enter the parent's name.");
		form.parent.focus();
		return false;
		}
		if (isFilled(form.child) == false) {
		alert("Please enter the child's name.");
		form.child.focus();
		return false;
		}
		if (isFilled(form.phone) == false) {
		alert("Please enter your phone number.");
		form.phone.focus();
		return false;
		}
		if (isEmail(form.email) == false) {
		alert("Please enter a valid email address.");
		form.email.focus();
		return false;
		}
		if (isChecked(form.terms) == false) {
		alert("You must agree to the terms before signing up for our services.");
		form.terms.focus();
		return false;
		}
	else {
	joinFields(form);
	calculateAmount(form);
		return true;
		}		
	}
function isEmail(elm) {
	if (elm.value.indexOf("@") != "-1" &&
		elm.value.indexOf(".") != "-1") {
		return true;
	}
	else {
		return false;
		}
	}
function isFilled(elm) {
	if (elm.value == "" || elm.value == null) {
		return false;
	}
	else {
		return true;
	}
}
function isChecked(elm) {
       if (!window.document.signUpForm.terms.checked) {
	   return false;
	   }
	   else {
		return true;
	   }
}
/* create custom field to attach to paypal form */
function joinFields(form){
    form.custom.value = 'Parent Name: ' + form.parent.value + ' --- Child Name: ' + form.child.value + ' --- Tel: ' +
              form.phone.value + ' --- Email: ' + form.email.value;
  }
  
 /* calculate amount to pass to paypal form */ 
function calculateAmount (form){ 
	if (form.item_name.value == "Developmental Playgroup - 1 day") {
        window.document.signUpForm.amount.value = "425";
    }
	else if 
	   (form.item_name.value == "Summer Camp") {
	    window.document.signUpForm.amount.value = "1495";
	}
	else if (form.item_name.value == "Dyads") {
        window.document.signUpForm.amount.value = "60";
    }
	else if 
	   (form.item_name.value == "Infant Massage Instruction - individual") {
	    window.document.signUpForm.amount.value = "135";
	}
	else if 
	   (form.item_name.value == "Infant Massage Instruction - per person rate for group") {
	    window.document.signUpForm.amount.value = "55";
	}	
	else if 
	   (form.item_name.value == "Global Developmental Evaluation") {
	    window.document.signUpForm.amount.value = "375";
	}
	else if 
	   (form.item_name.value == "Child Needs Assessment / Consultations") {
	    window.document.signUpForm.amount.value = "120";
	}
	else if 
	   (form.item_name.value == "Therapeutic Play Interactions initial") {
	    window.document.signUpForm.amount.value = "345";
	}
	else if 
	   (form.item_name.value == "Therapeutic Play Interactions renewal") {
	    window.document.signUpForm.amount.value = "210";
	}
	else if 
	   (form.item_name.value == "Preschool") {
	    window.document.signUpForm.amount.value = "";
	}
	else if 
	   (form.item_name.value == "Developmental Therapy") {
	    window.document.signUpForm.amount.value = "";
	}
	else if 
	   (form.item_name.value == "Behavioral Therapy") {
	    window.document.signUpForm.amount.value = "";
	}
	else if 
	   (form.item_name.value == "Music Therapy") {
	    window.document.signUpForm.amount.value = "";
	}
	else if 
	   (form.item_name.value == "Art Therapy") {
	    window.document.signUpForm.amount.value = "";
	}
	else if 
	   (form.item_name.value == "Speech Therapy") {
	    window.document.signUpForm.amount.value = "";
	}
	else if 
	   (form.item_name.value == "Family Counseling") {
	    window.document.signUpForm.amount.value = "";
	}
	else if 
	   (form.item_name.value == "Miscellaneous") {
	    window.document.signUpForm.amount.value = "";
	}
}
/* open browser window */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

