function LeapYear(intYear) 
{
     	if (intYear % 100 == 0) 
	{
      	  if (intYear % 400 == 0) 
	  { 
	  	return true; 
	  }
     	}
     else 
  {
        if ((intYear % 4) == 0) 
	 { 
	 	return true; 
	 }
     }
        return false;
     }

function checkdate(flag)
{
	var theday; 
	var	themonth; 
	var theyear; 
		
	if (flag == 'dateofbirth')
	{
		theday = document.form_edit.caregiverdateofbirth_day[document.form_edit.caregiverdateofbirth_day.selectedIndex].value;
		themonth = document.form_edit.caregiverdateofbirth_month[document.form_edit.caregiverdateofbirth_month.selectedIndex].value;
		theyear =  document.form_edit.caregiverdateofbirth_year[document.form_edit.caregiverdateofbirth_year.selectedIndex].value;
	}
	if (flag == 'availability')
	{
		theday = document.form_edit.caregiveravailabilitydate_day[document.form_edit.caregiveravailabilitydate_day.selectedIndex].value;
		themonth = document.form_edit.caregiveravailabilitydate_month[document.form_edit.caregiveravailabilitydate_month.selectedIndex].value;
		theyear =  document.form_edit.caregiveravailabilitydate_year[document.form_edit.caregiveravailabilitydate_year.selectedIndex].value;
	}
	if (flag == 'contractexpiry')
	{
		theday = document.form_edit.caregiverworkingcontractexpirydate_day[document.form_edit.caregiverworkingcontractexpirydate_day.selectedIndex].value;
		themonth = document.form_edit.caregiverworkingcontractexpirydate_month[document.form_edit.caregiverworkingcontractexpirydate_month.selectedIndex].value;
		theyear =  document.form_edit.caregiverworkingcontractexpirydate_year[document.form_edit.caregiverworkingcontractexpirydate_year.selectedIndex].value;
	}
	if (flag == 'employmentstart1')
	{
		theday = document.form_edit.caregiverapplicationemploymentstartdate_day_1[document.form_edit.caregiverapplicationemploymentstartdate_day_1.selectedIndex].value;
		themonth = document.form_edit.caregiverapplicationemploymentstartdate_month_1[document.form_edit.caregiverapplicationemploymentstartdate_month_1.selectedIndex].value;
		theyear =  document.form_edit.caregiverapplicationemploymentstartdate_year_1[document.form_edit.caregiverapplicationemploymentstartdate_year_1.selectedIndex].value;
	}
	if (flag == 'employmentstart2')
	{
		theday = document.form_edit.caregiverapplicationemploymentstartdate_day_2[document.form_edit.caregiverapplicationemploymentstartdate_day_2.selectedIndex].value;
		themonth = document.form_edit.caregiverapplicationemploymentstartdate_month_2[document.form_edit.caregiverapplicationemploymentstartdate_month_2.selectedIndex].value;
		theyear =  document.form_edit.caregiverapplicationemploymentstartdate_year_2[document.form_edit.caregiverapplicationemploymentstartdate_year_2.selectedIndex].value;
	}
	if (flag == 'employmentstart3')
	{
		theday = document.form_edit.caregiverapplicationemploymentstartdate_day_3[document.form_edit.caregiverapplicationemploymentstartdate_day_3.selectedIndex].value;
		themonth = document.form_edit.caregiverapplicationemploymentstartdate_month_3[document.form_edit.caregiverapplicationemploymentstartdate_month_3.selectedIndex].value;
		theyear =  document.form_edit.caregiverapplicationemploymentstartdate_year_3[document.form_edit.caregiverapplicationemploymentstartdate_year_3.selectedIndex].value;
	}
	if (flag == 'employmentend1')
	{
		theday = document.form_edit.caregiverapplicationemploymentenddate_day_1[document.form_edit.caregiverapplicationemploymentenddate_day_1.selectedIndex].value;
		themonth = document.form_edit.caregiverapplicationemploymentenddate_month_1[document.form_edit.caregiverapplicationemploymentenddate_month_1.selectedIndex].value;
		theyear =  document.form_edit.caregiverapplicationemploymentenddate_year_1[document.form_edit.caregiverapplicationemploymentenddate_year_1.selectedIndex].value;
	}
	if (flag == 'employmentend2')
	{
		theday = document.form_edit.caregiverapplicationemploymentenddate_day_2[document.form_edit.caregiverapplicationemploymentenddate_day_2.selectedIndex].value;
		themonth = document.form_edit.caregiverapplicationemploymentenddate_month_2[document.form_edit.caregiverapplicationemploymentenddate_month_2.selectedIndex].value;
		theyear =  document.form_edit.caregiverapplicationemploymentenddate_year_2[document.form_edit.caregiverapplicationemploymentenddate_year_2.selectedIndex].value;
	}
	if (flag == 'employmentend3')
	{
		theday = document.form_edit.caregiverapplicationemploymentenddate_day_3[document.form_edit.caregiverapplicationemploymentenddate_day_3.selectedIndex].value;
		themonth = document.form_edit.caregiverapplicationemploymentenddate_month_3[document.form_edit.caregiverapplicationemploymentenddate_month_3.selectedIndex].value;
		theyear =  document.form_edit.caregiverapplicationemploymentenddate_year_3[document.form_edit.caregiverapplicationemploymentenddate_year_3.selectedIndex].value;
	}
	if (flag == 'expecting')
	{
		theday = document.form_edit.parentexpectingday[document.form_edit.parentexpectingday.selectedIndex].value;
		themonth = document.form_edit.parentexpectingmonth[document.form_edit.parentexpectingmonth.selectedIndex].value;
		theyear =  document.form_edit.parentexpectingyear[document.form_edit.parentexpectingyear.selectedIndex].value;
	}

	if (themonth ==  2) 
	{
		if (theday > 28)
		{
			if (LeapYear(theyear))
			{
				if (theday > 29)
				{
					alert("February only has 29 days in a leap year.");
					if (flag == 'dateofbirth')
						document.form_edit.caregiverdateofbirth_day[0].focus();
					if (flag == 'availability')
						document.form_edit.caregiveravailabilitydate_day[0].focus();
					if (flag == 'contractexpiry')
						document.form_edit.caregiverworkingcontractexpirydate_day[0].focus();
					if (flag == 'employmentstart1')
						document.form_edit.caregiverapplicationemploymentstartdate_day_1[0].focus();
					if (flag == 'employmentstart2')
						document.form_edit.caregiverapplicationemploymentstartdate_day_2[0].focus();
					if (flag == 'employmentstart3')
						document.form_edit.caregiverapplicationemploymentstartdate_day_3[0].focus();
					if (flag == 'employmentend1')
							document.form_edit.caregiverapplicationemploymentenddate_day_1[0].focus();
					if (flag == 'employmentend2')
						document.form_edit.caregiverapplicationemploymentenddate_day_2[0].focus();
					if (flag == 'employmentend3')
						document.form_edit.caregiverapplicationemploymentenddate_day_3[0].focus();
					if (flag == 'expecting')						
						document.form_edit.parentexpectingday[0].focus();
					return false;
				}
			}
			else
			{
				alert("February only has 28 days.");	
				if (flag == 'dateofbirth')
					document.form_edit.caregiverdateofbirth_day[0].focus();
				if (flag == 'availability')
					document.form_edit.caregiveravailabilitydate_day[0].focus();
				if (flag == 'contractexpiry')
					document.form_edit.caregiverworkingcontractexpirydate_day[0].focus();
				if (flag == 'employmentstart1')
					document.form_edit.caregiverapplicationemploymentstartdate_day_1[0].focus();
				if (flag == 'employmentstart2')
					document.form_edit.caregiverapplicationemploymentstartdate_day_2[0].focus();
				if (flag == 'employmentstart3')
					document.form_edit.caregiverapplicationemploymentstartdate_day_3[0].focus();
				if (flag == 'employmentend1')
					document.form_edit.caregiverapplicationemploymentenddate_day_1[0].focus();
				if (flag == 'employmentend2')
					document.form_edit.caregiverapplicationemploymentenddate_day_2[0].focus();
				if (flag == 'employmentend3')
					document.form_edit.caregiverapplicationemploymentenddate_day_3[0].focus();
				if (flag == 'expecting')						
					document.form_edit.parentexpectingday[0].focus();					

				return false;
			}
		}
	}
	if ((themonth == 4) || (themonth == 6) || (themonth == 9) || (themonth == 11))
	{
		if (theday > 30)
		{
			alert("Please pick 30 or less days for this " + flag + " month.");
			if (flag == 'dateofbirth')
				document.form_edit.caregiverdateofbirth_day[0].focus();
			if (flag == 'availability')
				document.form_edit.caregiveravailabilitydate_day[0].focus();
			if (flag == 'contractexpiry')
				document.form_edit.caregiverworkingcontractexpirydate_day[0].focus();
			if (flag == 'employmentstart1')
				document.form_edit.caregiverapplicationemploymentstartdate_day_1[0].focus();
			if (flag == 'employmentstart2')
				document.form_edit.caregiverapplicationemploymentstartdate_day_2[0].focus();
			if (flag == 'employmentstart3')
				document.form_edit.caregiverapplicationemploymentstartdate_day_3[0].focus();
			if (flag == 'employmentend1')
				document.form_edit.caregiverapplicationemploymentenddate_day_1[0].focus();
			if (flag == 'employmentend2')
				document.form_edit.caregiverapplicationemploymentenddate_day_2[0].focus();
			if (flag == 'employmentend3')
				document.form_edit.caregiverapplicationemploymentenddate_day_3[0].focus();
			if (flag == 'expecting')						
				document.form_edit.parentexpectingday[0].focus();	
		
			return false;
		}
	}

return true;
}

/*
	purpose:
		used in the login area
	page:
		/login/caregiver/popup_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckCaregiverImage(theform,thetype)
{
		
	if (thetype != "thumbnail")
	{
		
		//only check for image if the user intends to upload an image
		if (theform.uploadnewimage[theform.uploadnewimage.selectedIndex].value == 1)
		{
			if (theform.imagefile.value.length <= 2)
			{
				alert("Please select an image file for uploading.");
				theform.imagefile.focus();
				return false;
			}
	
			if (!IsImageExtension(image_value.substring(theform.imagefile.value.lastIndexOf("."),theform.imagefile.value.length)))
			{
				alert("Please select a valid image file for uploading.  Must be .jpg or .gif format.");
				theform.imagefile.focus();
				return false;
			}

		}
	}
	else
	{
		if (theform.imagefile.value.length <= 2)
		{
			alert("Please select an thumbnail file for uploading.");
			theform.imagefile.focus();
			return false;
		}
		

			if 	(!IsImageExtension(image_value.substring(theform.imagefile.value.lastIndexOf("."),theform.imagefile.value.length)))
			{
				alert("Please select a valid image file for uploading.  Must be .jpg or .gif format.");
				theform.imagefile.focus();
				return false;
			}

	}
	return true;
}


/*
	purpose:
		used in the login area
	page:
		/login/caregiver/popup_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckCaregiverLetter(theform)
{
	if (theform.imagefile.value.length <= 2)
	{
		alert("Please select an letter file for uploading.");
		theform.imagefile.focus();
		return false;
	}
	
	if (!IsImageExtension(image_value.substring(theform.imagefile.value.lastIndexOf("."),theform.imagefile.value.length)))
	{
		alert("Please select a valid image file for uploading.  Must be .jpg or .gif format.");
		theform.imagefile.focus();
		return false;
	}
	
	return true;
}

/*
	purpose:
		used in the login area
	page:
		/login/forgot_form.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckForgotForm(theform)
{
	
	if (!IsUsername(theform.username.value))
	{
		alert("Please enter a valid username.");
		theform.username.focus();
		return false;
	}

	return true;
}



/*
	purpose:
		used in the login area
	page:
		/login/login.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckLoginForm(theform)
{
	
	if (!IsUsername(theform.username.value))
	{
		alert("Please enter a valid username.");
		theform.username.focus();
		return false;
	}

	if (!IsPassword(theform.password.value))
	{
		alert("Please enter a valid password.");
		theform.password.focus();
		return false;
	}

	return true;
}

/*
	purpose:
		used in the login area
	page:
		/login/forum/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckPost(theform)
{
	if (theform.submit_type.value == "add")
	{
		if (theform.forumtopicname.value.length <= 2)
		{
			alert("Please enter a valid topic name.");
			theform.forumtopicname.focus();
			return false;
		}
		if (theform.forumtopicmessage.value.length <= 2)
		{
			alert("Please enter a valid message.");
			theform.forumtopicmessage.focus();
			return false;
		}
	}

	return true;
}


/*
	purpose:
		used in the login area
	page:
		/login/search/module_viewall.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSearchCaregiverForm(theform)
{
	if ((theform.caregiverlastname.value.length <= 2) && (theform.caregivercity.value.length <= 2) && (theform.religionid.value == 0))
	{
		alert("Please enter a caregiver last name or a caregiver city or select a caregiver religion.");
		theform.caregiverlastname.focus();
		return false;
	}
						
	return true;
}


/*
	purpose:
		used in the login area
	page:
		/login/search/module_viewall.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSearchFamilyForm(theform)
{
	if ((theform.familylastname.value.length <= 2) && (theform.familycity.value.length <= 2))
	{
		alert("Please enter a family last name or a family city.");
		theform.familylastname.focus();
		return false;
	}
						
	return true;
}

/*
	purpose:
		used in the login area
	page:
		/login/testimonial/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckTestimonial(theform)
{
	if (theform.testimonialpostedbyname.value.length <= 2)
	{
		alert("Please enter a submitted by value.");
		theform.testimonialpostedbyname.focus();
		return false;
	}

	if (theform.testimonialdescription.value.length <=4)
	{
		alert("Please enter a longer testimonial.");
		theform.testimonialdescription.focus();
		return false;
	}
						
	return true;
}

/*
	purpose:
		used in the login area
	page:
		/login/users/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckUser(theform)
{
	var family_user=true;
	
	if (theform.userinfousername.value.length <= 4)
	{
		alert("Please enter a valid username.  Must be at least 5 characters.");
		theform.userinfousername.focus();
		return false;
	}

	if (theform.userinfopasswordraw.value.length <=5)
	{
		alert("Please enter a longer password.  Must be at least 6 characters");
		theform.userinfopasswordraw.focus();
		return false;
	}
	
	//if the user has selected to create a useraccount in the group family, ensure they have selected a family id in the familyapplicationid select
	if (theform.groupinfoid[theform.groupinfoid.selectedIndex].value == 6)
	{
		if (theform.familyapplicationid[theform.familyapplicationid.selectedIndex].value == 0)
		{
			alert("Please select a family, as you are creating user account in the Family group.");
			theform.familyapplicationid[1].focus();
			return false;
		}
	}
	else
	
	// if this isn't a family user, we need to verify that there is a first name, last name and email address
	if (theform.groupinfoid[theform.groupinfoid.selectedIndex].value != 6)
	{	
		if (theform.userinfofirstname.value.length <=1)
		{
			alert("Please enter a user first name.");
			theform.userinfofirstname.focus();
			return false;
		}			
		
		if (theform.userinfolastname.value.length <=1)
		{
			alert("Please enter a user last name.");
			theform.userinfolastname.focus();
			return false;
		}			
		
		
		
		//check if they have selected to update the expiration date, tell them not to, as infinite expiratoin date for these groups
		if (theform.update_expiry_date.checked == 1)
		{
			alert("You do not need to update the expiration date for this user.");
			theform.update_expiry_date.checked = 0;
			return false;
		}
	}
	
	if (!IsEmail(theform.userinfoemailaddress.value))
	{
		alert("Please enter a valid email address.");
		theform.userinfoemailaddress.focus();
		return false;
	}
	
	return true;
}

/*
	purpose:
		used in the login area
	page:
		/login/caregiver/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckCaregiverForm(theform)
{
	var test=true;
	
	if (theform.caregiverfirstname.value.length <=1)
	{
		alert("Please enter caregiver first name.");
		theform.caregiverfirstname.focus();
		return false;
	}

	if (theform.caregiverlastname.value.length <=1)
	{
		alert("Please enter caregiver last name.");
		theform.caregiverlastname.focus();
		return false;
	}

	if (theform.caregiveraddress.value.length <=1)
	{
		alert("Please enter caregiver address.");
		theform.caregiveraddress.focus();
		return false;
	}
	
	if (theform.caregivercity.value.length <=1)
	{
		alert("Please enter caregiver city.");
		theform.caregivercity.focus();
		return false;
	}
	
	/*
	if (theform.caregiverpostal.value.length <=1)
	{
		alert("Please enter caregiver postal code.");
		theform.caregiverpostal.focus();
		return false;
	}
	*/
	
	if (theform.caregiverhomephone.value.length <=8)
	{
		alert("Please enter caregiver home phone number.");
		theform.caregiverhomephone.focus();
		return false;
	}

	/*
	if (theform.caregiverbesttimetocontact.value.length <=2)
	{
		alert("Please enter best time to contact.");
		theform.caregiverbesttimetocontact.focus();
		return false;
	}
	*/
	
	//check to make sure the date of birth is in proper form (i.e. no february 30th).
	if (!checkdate('dateofbirth'))
		return false;
	
	/*
	if (theform.caregiverheight.value.length <=0)
	{
		alert("Please enter caregiver height.");
		theform.caregiverheight.focus();
		return false;
	}

	if (theform.caregiverweight.value.length <=0)
	{
		alert("Please enter caregiver weight.");
		theform.caregiverweight.focus();
		return false;
	}
	*/
	
	/*
	//if the caregiver has children of their own, ensure they have entered their ages
	if (theform.caregivernumberownchildren[theform.caregivernumberownchildren.selectedIndex].value > 0)
	{
		if (theform.caregiveragesownchildren.value.length <=1)
		{
			alert("Please enter the age of the caregivers children.");
			theform.caregiveragesownchildren.focus();
			return false;
		}
	}
	*/
	
	//if the caregiver has said that they hvae brothers or sisters
	if (theform.caregiverhassiblings[theform.caregiverhassiblings.selectedIndex].value == 1)
	{
		if (theform.caregiversiblingsage.value.length <=1)
		{
			alert("Please enter the siblings ages.");
			theform.caregiversiblingsage.focus();
			return false;
		}
	
	}
	
	//if the caregiver has said that they have health problems
	if (theform.caregiverhealthconditions[theform.caregiverhealthconditions.selectedIndex].value == 1)
	{
		if (theform.caregiverhealthconditionsdescription.value.length <=2)
		{
			alert("Please enter the health problems the caregiver has.");
			theform.caregiverhealthconditionsdescription.focus();
			return false;
		}
	
	}
	
	//if the caregiver has said that they are on a special diet
	if (theform.caregiverspecialdiet[theform.caregiverspecialdiet.selectedIndex].value == 1)
	{
		if (theform.caregiverspecialdietdescription.value.length <=2)
		{
			alert("Please enter the caregiver's special diet.");
			theform.caregiverspecialdietdescription.focus();
			return false;
		}
	
	}

	//if the caregiver has said that they have seriuos allergies
	if (theform.caregiverseriousallergies[theform.caregiverseriousallergies.selectedIndex].value == 1)
	{
		if (theform.caregiverseriousallergiesdescription.value.length <=2)
		{
			alert("Please enter the caregiver's serious allergies.");
			theform.caregiverseriousallergiesdescription.focus();
			return false;
		}
	
	}
	
	//if the caregiver has said that they play musical instruments
	if (theform.caregiverplayinstrument[theform.caregiverplayinstrument.selectedIndex].value == 1)
	{
		if (theform.caregiverplayinstrumentdescription.value.length <=2)
		{
			alert("Please enter the musical instruments the caregiver can play.");
			theform.caregiverplayinstrumentdescription.focus();
			return false;
		}
	
	}
	
	if (theform.caregiverhobbies.value.length <=2)
	{
		alert("Please enter the caregivers hobbies.");
		theform.caregiverhobbies.focus();
		return false;
	}
	
	
		
	/*
	//check to make sure the date of availability in proper form (i.e. no february 30th).
	if (!checkdate('availability'))
		return false;
			
	//check to make sure the date of contract expiration in proper form (i.e. no february 30th).
	if (!checkdate('contractexpiry'))
		return false;
	*/
	
	//if they have filled out any of the previous job history 1 fields
	if ((theform.caregiverapplicationemploymentemployername_1.value.length > 0) || (theform.caregiverapplicationemploymentposition_1.value.length > 0) ||(theform.caregiverapplicationemploymentagechildren_1.value.length > 0) || (theform.caregiverapplicationemploymentresponsibility_1.value.length > 0))
	{
		if (theform.caregiverapplicationemploymentemployername_1.value.length <=2)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter an employer name.");
			theform.caregiverapplicationemploymentemployername_1.focus();
			return false;
		}	

		if (theform.caregiverapplicationemploymentposition_1.value.length <=2)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter a position title.");
			theform.caregiverapplicationemploymentposition_1.focus();
			return false;
		}			
	
		/*
		//check to make sure the date of job 1 start in proper form (i.e. no february 30th).
		if (!checkdate('employmentstart1'))
			return false;

		//check to make sure the date of job 1 end in proper form (i.e. no february 30th).
		if (!checkdate('employmentend1'))
			return false;
		*/
			
		/*
		if (theform.caregiverapplicationemploymentagechildren_1.value.length <=0)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter the age of the children when you started.");
			theform.caregiverapplicationemploymentagechildren_1.focus();
			return false;
		}	
		*/
		
		/* removed dec 12, 2008 By Alex Bacso
		if (theform.caregiverapplicationemploymentresponsibility_1.value.length <=1)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter your responsibilities.");
			theform.caregiverapplicationemploymentresponsibility_1.focus();
			return false;
		}	
		*/
	}
	
	//if they have filled out any of the previous job history 2 fields
	if ((theform.caregiverapplicationemploymentemployername_2.value.length >0) || (theform.caregiverapplicationemploymentposition_2.value.length > 0) ||(theform.caregiverapplicationemploymentagechildren_2.value.length > 0) || (theform.caregiverapplicationemploymentresponsibility_2.value.length > 0))
	{
		if (theform.caregiverapplicationemploymentemployername_2.value.length <=2)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter an employer name.");
			theform.caregiverapplicationemploymentemployername_2.focus();
			return false;
		}	

		if (theform.caregiverapplicationemploymentposition_2.value.length <=2)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter a position title.");
			theform.caregiverapplicationemploymentposition_2.focus();
			return false;
		}	
		
		/*
		//check to make sure the date of job 2 start in proper form (i.e. no february 30th).
		if (!checkdate('employmentstart2'))
			return false;

		//check to make sure the date of job 2 end in proper form (i.e. no february 30th).
		if (!checkdate('employmentend2'))
			return false;
		*/
		
		/*
		if (theform.caregiverapplicationemploymentagechildren_2.value.length <=0)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter the age of the children when you started.");
			theform.caregiverapplicationemploymentagechildren_2.focus();
			return false;
		}	
		*/
		
		/* removed dec 12, 2008 By Alex Bacso
		if (theform.caregiverapplicationemploymentresponsibility_2.value.length <=1)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter your responsibilities.");
			theform.caregiverapplicationemploymentresponsibility_2.focus();
			return false;
		}	
		*/
	}
	
	//if they have filled out any of the previous job history 3 fields
	if ((theform.caregiverapplicationemploymentemployername_3.value.length > 0) || (theform.caregiverapplicationemploymentposition_3.value.length > 0) ||(theform.caregiverapplicationemploymentagechildren_3.value.length > 0) || (theform.caregiverapplicationemploymentresponsibility_3.value.length > 0))
	{
		if (theform.caregiverapplicationemploymentemployername_3.value.length <=2)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter an employer name.");
			theform.caregiverapplicationemploymentemployername_3.focus();
			return false;
		}	

		if (theform.caregiverapplicationemploymentposition_3.value.length <=2)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter a position title.");
			theform.caregiverapplicationemploymentposition_3.focus();
			return false;
		}			
		
		/*
		//check to make sure the date of job 3 start in proper form (i.e. no february 30th).
		if (!checkdate('employmentstart3'))
			return false;

		//check to make sure the date of job 3 end in proper form (i.e. no february 30th).
		if (!checkdate('employmentend3'))
			return false;
		*/
	
		/*
		if (theform.caregiverapplicationemploymentagechildren_3.value.length <=0)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter the age of the children when you started.");
			theform.caregiverapplicationemploymentagechildren_3.focus();
			return false;
		}	
		*/
		
		/* removed dec 12, 2008 By Alex Bacso
		if (theform.caregiverapplicationemploymentresponsibility_3.value.length <=1)
		//make sure they have filled out all the relevant info
		{
			alert("Please enter your responsibilities.");
			theform.caregiverapplicationemploymentresponsibility_3.focus();
			return false;
		}	
		*/
	}
		
	//if the caregiver has said that they object to pets
	if (theform.caregiverobjectpets[theform.caregiverobjectpets.selectedIndex].value == 1)
	{
		if (theform.caregiverobjectpetsdescription.value.length <=2)
		{
			alert("Please explain the reason the caregiver objects to pets in the home.");
			theform.caregiverobjectpetsdescription.focus();
			return false;
		}
	
	} 
	
	//if the caregiver has said that they  have paid experience caring for the elderly
	if (theform.caregiverelderlycarepaid[theform.caregiverelderlycarepaid.selectedIndex].value == 1)
	{
		//make sure they have indicate the years experience being paid to care for the elderly
		if (theform.caregiverelderlycareexperience[theform.caregiverelderlycareexperience.selectedIndex].value == 0)
		{
			alert("Please select the years experience for paid elderly care.");
			theform.caregiverelderlycareexperience[0].focus();
			return false;
		}
	
	}

	
	return true;
}


/*
	purpose:
		used in the login area
	page:
		/login/family/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckFamilyApplication(theform)
{
	var test=true;
	
	if (theform.parentfirstname.value.length <=1)
	{
		alert("Please enter your first name.");
		theform.parentfirstname.focus();
		return false;
	}

	if (theform.parentlastname.value.length <=1)
	{
		alert("Please enter your last name.");
		theform.parentlastname.focus();
		return false;
	}

	if (theform.parenthomephone.value.length <=7)
	{
		alert("Please enter your home phone number (please include area code). i.e. 9059882222");
		theform.parenthomephone.focus();
		return false;
	}

	/*
	if (theform.parentaddress.value.length <=2)
	{
		alert("Please enter your address.");
		theform.parentaddress.focus();
		return false;
	}

	if (theform.parentcity.value.length <=2)
	{
		alert("Please enter your city.");
		theform.parentcity.focus();
		return false;
	}

	if (theform.parentpostal.value.length <=2)
	{
		alert("Please enter your postal code.");
		theform.parentpostal.focus();
		return false;
	}
	
	if (theform.parenthomephone.value.length <=7)
	{
		alert("Please enter your home phone number (please include area code). i.e. 9059882222");
		theform.parenthomephone.focus();
		return false;
	}

	if (theform.parentbesttimetocontact.value.length <=2)
	{
		alert("Please enter the best time for us to contact you. i.e. evenings, mornings");
		theform.parentbesttimetocontact.focus();
		return false;
	}
	
	if (theform.parentemail.value.length < 4)
	{
		alert("Please enter your email address.");
		theform.parentemail.focus();
		return false;
	}
	
	if (theform.parentemail.value.indexOf("@") == -1)
	{
		alert("Please enter a valid email address.")
	 	theform.parentemail.focus();
		return false;
	}
 	
	if (theform.parentisexpecting[theform.parentisexpecting.selectedIndex].value == 1)
	{
		//check to make sure the expecting date is in proper form (i.e. no february 30th).
		if (!checkdate('expecting'))
			return false;
	}
	
	if (theform.childcarerequiredmedical[theform.childcarerequiredmedical.selectedIndex].value == 1)
	{
		if (theform.childcarerequiredmedicaldescription.value.length <=2)
		{
			alert("Please enter the medical reason for child care.");
			theform.childcarerequiredmedicaldescription.focus();
			return false;
		}
	
	}
	
	if (theform.householdisenglish[theform.householdisenglish.selectedIndex].value == 0)
	{
		if (theform.householdotherlanguages.value.length <=2)
		{
			alert("Please list the languages spoken in your home.");
			theform.householdotherlanguages.focus();
			return false;
		}
	
	}
	
	//ensure they have selected at least one item for the caregiver acomodation area
	if ((theform.accomodationprivatebedroom.checked == 0) && (theform.accomodationprivatebathroom.checked == 0) && (theform.accomodationprivatetv.checked == 0) && (theform.accomodationprivatecable.checked == 0) && (theform.accomodationprivatephone.checked == 0) && (theform.accomodationother.value.length <=0))
	{
		alert("Please select the details of the caregiver's accomodations.");
		theform.accomodationprivatebedroom.focus();
		return false;
	}
	
	if (theform.question1.value.length < 2)
	{
		alert("Please specify the need for a caregiver to live in your home on a full time basis.");
		theform.question1.focus();
		return false;
	}
	
	if (theform.question2.value.length < 2)
	{
		alert("What specific efforts hvae been made to recruit a caregiver up to now?");
		theform.question2.focus();
		return false;
	}
	
	if (theform.question3.value.length < 2)
	{
		alert("How did you hear about our agency?");
		theform.question3.focus();
		return false;
	}
	
	if (theform.question4.value.length < 2)
	{
		alert("Please, share any comments that you think would be helpful to us.");
		theform.question4.focus();
		return false;
	}
	
	*/
	
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/bin/popup_approval_process.cfm
	Parameters:
		theform - object reference to the form being passed
		theflag - 0|1 - used to tell us whether we are approving(0) or declining (1)
*/
function CheckApprovalProcess(theform,theflag)
{
	//declined
	if (theflag == 1)
	{
		if (theform.approvaldescription.value.length <= 2)
		{
			alert("Please enter a reason for declining this listing.");
			theform.approvaldescription.focus();
			return false;
		}	
	}

	return true;
}



/*
	purpose:
		used in the control panel
	page:
		/admin/photo/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckPhotoForm(theform)
{
	var thumbnail_value="";
	var image_value="";
	var gallery_checked=false;
	
	if (!IsWordNumberSpecial(theform.photoname.value))
	{
		alert("Please enter a valid Photo Name.");
		theform.photoname.focus();
		return false;
	}
	
	if (!IsDescription(theform.photodescription.value))
	{
		alert("Please enter some valid Photo Description.");
		theform.photodescription.focus();
		return false;
	}

	
	//if we are supposed to upload an thumbnail
	if (theform.uploadthumbnail.value == 1)
	{
		thumbnail_value=theform.photothumbnailfile_file.value;
		
		if (!IsImageExtension(thumbnail_value.substring(thumbnail_value.lastIndexOf("."),thumbnail_value.length)))
		{
			alert("Please select an thumbnail file for uploading (must be .jpg or .gif).");
			theform.photothumbnailfile_file.focus();
			return false;
		}
	}
						
	//if we are supposed to upload an image
	if (theform.uploadimage.value == 1)
	{
	 	image_value=theform.photoimagefile_file.value;
		
		if (!IsImageExtension(image_value.substring(image_value.lastIndexOf("."),image_value.length)))
		{
			alert("Please select an image file for uploading (must be .jpg or .gif).");
			theform.photoimagefile_file.focus();
			return false;
		}
	}
						
	return true;
}


/*
	purpose:
		used in the login area
	page:
		/login/placement/popup_edit_item.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckPlacementEditForm(theform)
{
	var the_step=theform.stepid.value;
	var check_the_date=false;
	
	if (theform.is_scheduled)
	{
		if (theform.is_scheduled[theform.is_scheduled.selectedIndex].value == 1)
			check_the_date=true;
	}
	
	switch (the_step)
	{
		case "1" :
			if (theform.placementnumber.value.length <= 2)
			{
				alert("Please enter a placement number.")
				theform.placementnumber.focus()
				return false
			}
			break
		case "4" :
			break
		
		case "6" :
			if (theform.placementcaregiverfrom.value.length <= 2)
			{
				alert("Please enter the caregiver from value.")
				theform.placementcaregiverfrom.focus()
				return false
			}
			break
		case "9" :
			if (theform.placementhrdcoffice.value.length <= 2)
			{
				alert("Please enter the Service Canada Office value.")
				theform.placementhrdcoffice.focus()
				return false
			}
			break
		case "14" :
			if (theform.placementinterviewresults.value.length <= 2)
			{
				alert("Please enter the Interview Results.")
				theform.placementinterviewresults.focus()
				return false
			}
			break
		case "17" :
			if (theform.placementflightinformation.value.length <= 2)
			{
				alert("Please enter the Flight information.")
				theform.placementflightinformation.focus()
				return false
			}
			break
		case "20" :
			if (theform.placementpaymentreceived.value.length <= 2)
			{
				alert("Please enter the payment received information.")
				theform.placementpaymentreceived.focus()
				return false
			}
			break
		case "23" :
			if (theform.placementagencycommission.value.length <= 2)
			{
				alert("Please enter the placement agency commision value.")
				theform.placementagencycommission.focus()
				return false
			}
		case "25" :
			if (theform.placementcomments.value.length <= 2)
			{
				alert("Please enter some comments.")
				theform.placementcomments.focus()
				return false
			}
			break
	}

	return true;
}

/*
	purpose:
		used in the control panel
	page:
		all /module_setorder.cfm pages
	Parameters:
		theform - object reference to the form being passed
*/
function CheckDisplayOrderForm(theform)
{
	if (theform.orderlist.value <= 0)
	{
		alert("The order has not changed, no update required.");
		return false;
	}

	return true;
}


