/*
	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;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/documentation/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckDocumentationForm(theform)
{
	
	if (!IsWordSpace(theform.tidcmoduledocumentationtitle.value))
	{
		alert("Please enter a valid documentation title.");
		theform.tidcmoduledocumentationtitle.focus();
		return false;
	}

	if (!IsDescription(theform.tidcmoduledocumentationshortdescription.value))
	{
		alert("Please enter some valid documenation short description.");
		theform.tidcmoduledocumentationshortdescription.focus();
		return false;
	}

	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/group/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckGroupForm(theform)
{
	var test=false;
	
	if (!IsWordSpace(theform.groupinfoname.value))
	{
		alert("Please enter a valid group name.");
		theform.groupinfoname.focus();
		return false;
	}

	if (!IsDescription(theform.groupinfodescription.value))
	{
		alert("Please enter a valid group description.");
		theform.groupinfodescription.focus();
		return false;
	}

						
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		main control panel login page
	Parameters:
		theform - object reference to the form being passed
*/
function CheckLoginForm(theform)
{

	if (!IsUsername(theform.username.value))
	{
		alert("Please enter a valid username. (MIN. 5 characters)");
		theform.username.focus();
		return false;
	}

	if (!IsPassword(theform.password.value))
	{
		alert("Please enter a valid password. (MIN. 5 characters)");
		theform.password.focus();
		return false;
	}

	return true;
}

/*
	purpose:
		used in the front of the site
	page:
		/recruiting/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckPhysicianRecruitingForm(theform)
{
	if (!IsWordSpace(theform.recruitingfirstname.value))
	{
		alert("Please enter a valid first name value.");
		theform.recruitingfirstname.focus();
		return false;
	}

	if (!IsWordSpace(theform.recruitinglastname.value))
	{
		alert("Please enter a valid last name value.");
		theform.recruitinglastname.focus();
		return false;
	}

	//only if they filled in a company name do we check it
	if (theform.recruitingcompany.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.recruitingcompany.value))
		{
			alert("Please enter a valid company value.");
			theform.recruitingcompany.focus();
			return false;
		}
	}
	
	if (!IsWordSpecial(theform.recruitingcity.value))
	{
		alert("Please enter a valid city value.");
		theform.recruitingcity.focus();
		return false;
	}
	
	if (!IsPhone(theform.recruitingphone.value))
	{
		alert("Please enter a valid phone number value.");
		theform.recruitingphone.focus();
		return false;
	}	

	//only if they entered a fax number do we check it
	if (theform.recruitingfax.value.length > 0)
	{
		if (!IsPhone(theform.recruitingfax.value))
		{
			alert("Please enter a valid fax number value.");
			theform.recruitingfax.focus();
			return false;
		}	
	}
	
	if (!IsEmail(theform.recruitingemail.value))
	{
		alert("Please enter a valid email address value.");
		theform.recruitingemail.focus();
		return false;
	}	

	if (!IsDescription(theform.recruitingeducation.value))
	{
		alert("Please enter a valid medical education value.");
		theform.recruitingeducation.focus();
		return false;
	}	
	
	if (!IsDescription(theform.recruitingemploymenthistory.value))
	{
		alert("Please enter a valid employment history value.");
		theform.recruitingemploymenthistory.focus();
		return false;
	}	
	
	return true;
}

/*
	purpose:
		used in the front of the site
	page:
		/survey/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckQualitySurveyForm(theform)
{
	if (!IsPostalCode(theform.surveypostalcode.value))
	{
		alert("Please enter a valid postal code value.");
		theform.surveypostalcode.focus();
		return false;
	}

	//if they didn't choose
	if (theform.surveychildvisit[theform.surveychildvisit.selectedIndex].value == 0)
	{
		alert("Please select if this visit was for a child.");
		theform.surveychildvisit.focus();
		return false;
	}

	//if they person has answered that this visit was for a child
	if (theform.surveychildvisit[theform.surveychildvisit.selectedIndex].value == 1)
	{
		//make sure they choose a child age
		if (theform.surveychildage[theform.surveychildage.selectedIndex].value == 0)
		{
			alert("Please select the childs age.");
			theform.surveychildage.focus();
			return false;
		}
	}
	
	//if they didn't choose
	if (theform.surveywaitforservice[theform.surveywaitforservice.selectedIndex].value == 0)
	{
		alert("Please select your rating for how long you had to wait for service.");
		theform.surveywaitforservice.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveyparking[theform.surveyparking.selectedIndex].value == 0)
	{
		alert("Please select your rating for parking availability.");
		theform.surveyparking.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveylocation[theform.surveylocation.selectedIndex].value == 0)
	{
		alert("Please select your rating for the convenience of this location.");
		theform.surveylocation.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveycleanliness[theform.surveycleanliness.selectedIndex].value == 0)
	{
		alert("Please select your rating for cleanliness, comfort, lighting and temperature of the setting.");
		theform.surveycleanliness.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveycourtesy[theform.surveycourtesy.selectedIndex].value == 0)
	{
		alert("Please select your rating for courtesy, respect, friendliness, kindness of staff.");
		theform.surveycourtesy.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveyinformation[theform.surveyinformation.selectedIndex].value == 0)
	{
		alert("Please select your rating for how well we provided you with information about your concerns.");
		theform.surveyinformation.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveyprivacy[theform.surveyprivacy.selectedIndex].value == 0)
	{
		alert("Please select your rating for how well your privacy was protected.");
		theform.surveyprivacy.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveyreferral[theform.surveyreferral.selectedIndex].value == 0)
	{
		alert("Please select your rating for how well staff planned for referral to other services.");
		theform.surveyreferral.focus();
		return false;
	}
	
	
	//if they didn't choose
	if (theform.surveyservices[theform.surveyservices.selectedIndex].value == 0)
	{
		alert("Please select your rating for how helpful the services were that you received.");
		theform.surveyservices.focus();
		return false;
	}
	
	
	//if they didn't choose
	if (theform.surveycare[theform.surveycare.selectedIndex].value == 0)
	{
		alert("Please select your rating for overall, the rate of care and service you received.");
		theform.surveycare.focus();
		return false;
	}
	
	//if they didn't choose
	if (theform.surveyfindoutaboutus[theform.surveyfindoutaboutus.selectedIndex].value == 0)
	{
		alert("Please select how you heard about us.");
		theform.surveyfindoutaboutus.focus();
		return false;
	}
	
	
	//if they choose other
	if (theform.surveyfindoutaboutus[theform.surveyfindoutaboutus.selectedIndex].value == "Other")
	{	
		if (!IsDescription(theform.surveyfindoutaboutusother.value))
		{
			alert("Please enter a valid how you found out about us other value.");
			theform.surveyfindoutaboutusother.focus();
			return false;
		}	
	}
	
	//if they entered additional comments
	if (theform.surveycomments.value.length > 0)
	{
		if (!IsDescription(theform.surveycomments.value))
		{
			alert("Please enter a valid additional comments value.");
			theform.surveycomments.focus();
			return false;
		}	
	}
	
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/user/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckUserForm(theform)
{
	
	if (!IsWordSpace(theform.userinfofirstname.value))
	{
		alert("Please enter a valid first name.");
		theform.userinfofirstname.focus();
		return false;
	}
	
	if (!IsWordSpace(theform.userinfolastname.value))
	{
		alert("Please enter a valid last name.");
		theform.userinfolastname.focus();
		return false;
	}

	if (!IsUsername(theform.userinfousername.value))
	{
		alert("Please enter a valid username.");
		theform.userinfousername.focus();
		return false;
	}

	if ((theform.updatepassword.checked == 1) || (theform.submit_type.value == "add"))
	{
		if (!IsPassword(theform.userinfopassword.value))
		{
			alert("Please enter a valid password.");
			theform.userinfopassword.focus();
			return false;
		}
		
		if (!IsPassword(theform.userinfopasswordconfirm.value))
		{
			alert("Please enter a valid password confirmation password.");
			theform.userinfopasswordconfirm.focus();
			return false;
		}
	 	
		if (theform.userinfopassword.value != theform.userinfopasswordconfirm.value)
		{
		 	alert ("You Password and Confirm Password do not match");
			theform.userinfopasswordconfirm.focus();
			return false;
		}
	}

	if (!IsWordSpace(theform.userinfojobtitle.value))
	{
		alert("Please enter a valid job title.");
		theform.userinfojobtitle.focus();
		return false;
	}
	
	if (!IsEmail(theform.userinfoemailaddress.value))
	{
		alert("Please enter a valid email address.");
		theform.userinfoemailaddress.focus();
		return false;
	}

	//if we are supposed to upload an thumbnail
	if (theform.groupinfoid.selectedIndex == -1)
	{
		alert("Please select at least one group.");
		theform.groupinfoid[0].focus();
		return false;
	}

	return true;
}
