
/*
	purpose:
		used in the contact page
	page:
		/contactus/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactForm(theform)
{
	var temp_checkbox=0;
	
	if (!IsWordNumberSpecial(theform.contactfirstname.value))
	{
		alert("Please enter your first name.");
		theform.contactfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactlastname.value))
	{
		alert("Please enter your last name.");
		theform.contactlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactaddress.value))
	{
		alert("Please enter your address.");
		theform.contactaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactcity.value))
	{
		alert("Please enter your city.");
		theform.contactcity.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (theform.countryid[theform.countryid.selectedIndex].value == "")
	{
		alert("Please select a valid country.");
		theform.countryid.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.contactpostal.focus();
		return false;
	}

	if (!IsPhone(theform.contactphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contactphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactconfirmemail.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.contactconfirmemail.focus();
		return false;
	}
	
	if (theform.contactemail.value != theform.contactconfirmemail.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.contactconfirmemail.focus();
		return false;
	}
	
	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;
}



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

function CheckFaqForm(theform)
{
	if (!IsDescription(theform.faqquestion.value))
	{
		alert("Please enter a question.");
		theform.faqquestion.focus();
		return false;
	}

	if (!IsDescription(theform.faqanswer.value))
	{
		alert("Please enter an answer.");
		theform.faqanswer.focus();
		return false;
	}
						
	return true;
}


/*
	purpose:
		to make sure the password fields are the same and secret answer has been typed
	pages:
		/login/jobseekerforgotpass.cfm
		/login/employerforgotpass.cfm
	
*/

function CheckForgotpass(theform)
{

	/**/
	if (!IsPassword(theform.password.value))
	{
		alert("Please enter a valid password.");
		theform.password.focus();
		return false;
	}
	
	if (!IsPassword(theform.confirmpassword.value))
	{
		alert("Please enter a valid password confirmation password.");
		theform.confirmpassword.focus();
		return false;
	}
	
	if (theform.password.value != theform.confirmpassword.value)
	{
		alert ("You Password and Confirm Password do not match");
		theform.confirmpassword.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.secretanswer.value))
	{
		alert("Please enter your secret answer.");
		theform.secretanswer.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 control panel
	page:
		/admin/group/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckMonthlyTopicForm(theform)
{
	
	if (!IsWordNumberSpecial(theform.monthlytopictitle.value))
	{
		alert("Please enter a Title.");
		theform.monthlytopictitle.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.monthlytopicsource.value))
	{
		alert("Please enter a Source.");
		theform.monthlytopicsource.focus();
		return false;
	}
	
	
	if (theform.monthlytopiccheckiflink.checked == false && theform.monthlytopicdescription.innerHTML == '')
	{
		alert("Please enter a Full Article.");
		theform.monthlytopicdescription.focus();
		return false;
	}
	
	if (theform.monthlytopiccheckiflink.checked == true && theform.monthlytopicweblink.innerHTML == '') 
	{		
		
		alert("Please enter a link to article.");
		theform.monthlytopicweblink.focus();
		return false;	
	}
	
	
	if (theform.monthlytopicforumlink.innerHTML == '')
	{
		alert("Please enter a link to the forum.");
		theform.monthlytopicforumlink.focus();
		return false;
	}
	
	if (theform.monthlytopicfile.value != '') {
		
		attachment_value=theform.monthlytopicfile.value;
		
		if (!IsAttachmentExtension(attachment_value.substring(attachment_value.lastIndexOf("."),attachment_value.length)))
		{
			alert("Please select valid file to upload as an Attachment.");
			theform.monthlytopicfile.focus();
			return false;
		}	
	}
	
	
	
	if (theform.monthlytopicpicture1.value != "")
	{
	 	image_value=theform.monthlytopicpicture1.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.monthlytopicpicture1.focus();
			return false;
		}
	}
	
	if (theform.monthlytopicpicture2.value != "")
	{
	 	image_value=theform.monthlytopicpicture2.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.monthlytopicpicture2.focus();
			return false;
		}
	}
	
	if (theform.monthlytopicpicture3.value != "")
	{
	 	image_value=theform.monthlytopicpicture3.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.monthlytopicpicture3.focus();
			return false;
		}
	}
	
	if (theform.monthlytopicpicture4.value != "")
	{
	 	image_value=theform.monthlytopicpicture4.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.monthlytopicpicture4.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 (theform.groupinfoid.selectedIndex == -1)
	{
		alert("Please select at least one group.");
		theform.groupinfoid[0].focus();
		return false;
	}

	return true;
}
