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

function CheckAdminPortfolioPhotoForm(theform)
{
	var thumbnail_value="";
	var image_value="";
	
	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 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/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/portfolio_category/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckPortfolioCategoryForm(theform)
{
				
	if (!IsWordNumberSpecial(theform.portfoliocategoryname.value))
	{
		alert("Please enter a portfolio category name.");
		theform.portfoliocategoryname.focus();
		return false;
	}

	
	return true;
}



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

function CheckMailingListForm(theform)
{
	var is_checked=false;
	var checked_value="";
	
	if (!IsWordNumberSpecial(theform.mailinglistfirstname.value))
	{
		alert("Please enter your first name.");
		theform.mailinglistfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistlastname.value))
	{
		alert("Please enter your last name.");
		theform.mailinglistlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistaddress.value))
	{
		alert("Please enter your address.");
		theform.mailinglistaddress.focus();
		return false;
	}

	if (theform.mailinglistaddress2.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.mailinglistaddress2.value))
		{
			alert("Please enter a valid address 2 value.");
			theform.mailinglistaddress2.focus();
			return false;
		}
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistcity.value))
	{
		alert("Please enter your city.");
		theform.mailinglistcity.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.mailinglistpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.mailinglistpostal.focus();
		return false;
	}

	if (!IsPhone(theform.mailinglistphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.mailinglistphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.mailinglistemail.value))
	{
		alert("Please enter a valid email address.");
		theform.mailinglistemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.mailinglistemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.mailinglistemailconfirm.focus();
		return false;
	}
	
	if (theform.mailinglistemail.value != theform.mailinglistemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.mailinglistemailconfirm.focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the send to a friend page
	page:
		/sent_to_a_friend/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSendToAFriendForm(theform)
{
	if (!IsWordNumberSpecial(theform.recipientfirstname.value))
	{
		alert("Please enter your friends first name.");
		theform.recipientfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.recipientlastname.value))
	{
		alert("Please enter your friends last name.");
		theform.recipientlastname.focus();
		return false;
	}
		
	if (!IsEmail(theform.recipientemail.value))
	{
		alert("Please enter your friends email address.");
		theform.recipientemail.focus();
		return false;
	}
	
	if (theform.message.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.message.value))
		{
			alert("Please enter your message to your friend.");
			theform.message.focus();
			return false;
		}
	}
	
	if (!IsWordNumberSpecial(theform.senderfirstname.value))
	{
		alert("Please enter your first name.");
		theform.senderfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.senderlastname.value))
	{
		alert("Please enter your last name.");
		theform.senderlastname.focus();
		return false;
	}
	
	if (!IsEmail(theform.senderemail.value))
	{
		alert("Please enter your email address.");
		theform.senderemail.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;
}
