////////////////////////////////////////////////////////////////////////////////
// JavaScript Document
// Copyright Mitey-Web Development 2007 all rights reserved
// AnimalZ
// Author: Michael Ford
/////////////////////////////////////////////////////////////////////////////////
// Alert functions
/////////////////////////////////////////////////////////////////////////////////
// Cattery Booking Form Vax Check
/////////////////////////////////////////////////////////////////////////////////
function vaxCheck() {
	alert ("VACCINATIONS AND YOUR CAT.\r\nYour cat needs to have a current Vaccination in order to board at an AnimalZ cattery. This is for it's own protection as well as that of other boarding cats.\r\nShould your cat not be vaccinated or you are unsure, then contact your local branch for advice as soon as possible.")
}
///////////////////////////////////////////////////////////////////////////////
// Cattery Booking Form Worm Check 
///////////////////////////////////////////////////////////////////////////////
function wormCheck() {
	alert ("WORMS AND YOUR CAT.\r\nYour cat needs to have current Worm Treatment in order to board at an AnimalZ cattery. This is for it's own protection as well as that of other boarding cats.\r\nShould your cat not be wormed or you are unsure, then contact your local branch for advice as soon as possible.\r\nA staff member will happily worm your cat for you whilst it boards at the cattery.")
}
////////////////////////////////////////////////////////////////////////////////
// Cattery Booking Form Flea Check
////////////////////////////////////////////////////////////////////////////////
function fleaCheck() {
	alert ("FLEAS AND YOUR CAT.\r\nYour cat needs to have current Flea Treatment in order to board at an AnimalZ cattery. This is for it's own protection as well as that of other boarding cats.\r\nShould your cat not be flead or you are unsure, then contact your local branch for advice as soon as possible.\r\nA staff member will happily Flea Treat your cat for you whilst it boards at the cattery.")
}
/////////////////////////////////////////////////////////////////////////////////
// Cattery Booking Form Medication Check
/////////////////////////////////////////////////////////////////////////////////
function medCheck() {
	alert ("MEDICATION AND YOUR CAT.\r\nPlease advise AnimalZ if your cat is currently taking any medication.\r\nEnsure you supply enough medication for the duration of your cats stay or ask a staff member to supply the medication.\r\nBe very clear with regards to how much, how often for each and every medication.")
}
///////////////////////////////////////////////////////////////////////////////////
// Username Check
//////////////////////////////////////////////////////////////////////////////////
function usernameCheck() {
	alert ("USERNAME.\r\nPlease select a username that you will remember easily. If it is already in use you will be prompted to select another.")
}
///////////////////////////////////////////////////////////////////////////////////
// Password Check
//////////////////////////////////////////////////////////////////////////////////
function passwordCheck() {
	alert ("PASSWORD.\r\nYour password can be any combination of letters and numbers. It is case sensitive and can be upto 10 digits long.\r\nIf you have forgotten your password please email webmaster@animalz.co.nz")
}
//////////////////////////////////////////////////////////////////////////////
// Validate Cattery Booking Form
/////////////////////////////////////////////////////////////////////////////
function validateForm() {
// Validate email address function
re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+)*(\.\w{2,3})+$/
// Validate numbers only
renum = /^\d+$/
// Check first name has been entered
	if (document.CatteryBookingForm.firstName.value == "") {
		alert ("Please enter your first name.")
		document.CatteryBookingForm.firstName.focus()
		return false;	
	}
// Check last name has been entered
	if (document.CatteryBookingForm.lastName.value == "") {
		alert ("Please enter your last name.")
		document.CatteryBookingForm.lastName.focus()
		return false;	
	}
// Check e-mail has been entered
	$email = document.CatteryBookingForm.email.value;
	if (document.CatteryBookingForm.email.value == "") {
		alert ("Please enter your e-mail address.")
		document.CatteryBookingForm.email.focus()
		return false;	
	} else if (re.test(document.CatteryBookingForm.email.value)){
	// If email validates do nothing
	} else {			
			alert ("Please enter a valid e-mail address.")
			document.CatteryBookingForm.email.value = ""
			document.CatteryBookingForm.email.focus()
			document.CatteryBookingForm.email.select()
			return false;
	}
// Check Phone has been entered
	if (document.CatteryBookingForm.telephone.value == "") {
		alert ("Please enter your phone number.")
		document.CatteryBookingForm.telephone.focus()
		return false;	
	} else if (renum.test(document.CatteryBookingForm.telephone.value)) {
	// Only numbers so do nothing
	} else {
		alert ("Please enter numbers only for your phone number, and include the area code.")
		document.CatteryBookingForm.telephone.focus()
		document.CatteryBookingForm.telephone.select()
		return false;
	}
// Check Cats name has been entered
	if (document.CatteryBookingForm.catsName.value == "") {
		alert ("Please enter your Cats name.")
		document.CatteryBookingForm.catsName.focus()
		return false;	
	}
// Check Cats description has been entered
	if (document.CatteryBookingForm.catsDescription.value == "") {
		alert ("Please enter a description of your Cat. For identification purposes.")
		document.CatteryBookingForm.catsDescription.focus()
		return false;	
	}
// Check cats years has been entered
	if (document.CatteryBookingForm.years.value == "") {
		alert ("Please enter your Cats age in years, enter 0 if less than one year old.")
		document.CatteryBookingForm.years.focus()
		return false;	
	} else if (renum.test(document.CatteryBookingForm.years.value)) {
	// Only numbers so do nothing
	} else {
		alert ("Please enter numbers only. 0 if under one year old.")
		document.CatteryBookingForm.years.focus()
		document.CatteryBookingForm.years.select()
		return false;
	}
// Check cats months has been entered
	if (document.CatteryBookingForm.months.value == "") {
		alert ("Please enter your Cats age in months.")
		document.CatteryBookingForm.months.focus()
		return false;	
	} else if (renum.test(document.CatteryBookingForm.months.value)) {
	// Only numbers so do nothing
	} else {
		alert ("Please enter numbers only.")
		document.CatteryBookingForm.months.focus()
		document.CatteryBookingForm.months.select()
		return false;
	}
// Check vax check has been selected
   if ((document.CatteryBookingForm.vax[0].checked) || (document.CatteryBookingForm.vax[1].checked)) {
	} else if ((!document.CatteryBookingForm.vax[0].checked) || (!document.CatteryBookingForm.vax[1].checked)) {
		alert ("Is your cat vaccinated?\r\nPlease select yes or no.")
				return false;
	}
// Check worm check has been selected
   if ((document.CatteryBookingForm.wormed[0].checked) || (document.CatteryBookingForm.wormed[1].checked)) {
	} else if ((!document.CatteryBookingForm.wormed[0].checked) || (!document.CatteryBookingForm.wormed[1].checked)) {
		alert ("Is your cats Worm Treatment current?\r\nPlease select yes or no.")
				return false;
	}
// Check worm check has been selected
   if ((document.CatteryBookingForm.flead[0].checked) || (document.CatteryBookingForm.flead[1].checked)) {
	} else if ((!document.CatteryBookingForm.flead[0].checked) || (!document.CatteryBookingForm.flead[1].checked)) {
		alert ("Is your cats Flea Treatment current?\r\nPlease select yes or no.")
				return false;
	}
// Check medication check has been selected
   if ((document.CatteryBookingForm.medication[0].checked) || (document.CatteryBookingForm.medication[1].checked)) {
	} else if ((!document.CatteryBookingForm.medication[0].checked) || (!document.CatteryBookingForm.medication[1].checked)) {
		alert ("Is your cat on medication?\r\nPlease select yes or no.")
				return false;
	}		
// Check if medication YES is selected then make sure something is entered into the how much, how often textfield
	if (document.CatteryBookingForm.medication[0].checked) {
		if (document.CatteryBookingForm.medDesc.value == "") {
			alert ("You have selected 'Yes, my cat is on medication' but you have not provided and details\r\nPlease enter what, how much and how often?");
			document.CatteryBookingForm.medDesc.focus();
			return false;
		}
	}
// Check arrival date has been entered
	if (document.CatteryBookingForm.arrival.value == "") {
		alert ("Please enter an arrival date.");
		javascript:cal1.popup();
		document.CatteryBookingForm.arrival.focus();
		return false;	
	}	
// Check departure date has been entered
	if (document.CatteryBookingForm.departure.value == "") {
		alert ("Please enter a departure date.");
		javascript:cal2.popup();
		document.CatteryBookingForm.departure.focus();
		return false;	
	}
// Check clinic has been selected
	if (document.CatteryBookingForm.branch.value == "none") {
		alert ("Please select which clinic you wish to board your cat at?");
		document.CatteryBookingForm.branch.focus();
		return false;	
	}
// Check security code has been selected
	if (document.CatteryBookingForm.code.value == "") {
		alert ("Please enter the security code.");
		document.CatteryBookingForm.code.focus();
		return false;	
	}
// Send form to process page
document.CatteryBookingForm.submit();
// End of Vaidate order form function	
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// validateAddTopic
////////////////////////////////////////////////////////////////////////////////////////////////////
function validateAddTopic() {
// Validate email address function
re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+)*(\.\w{2,3})+$/
//alert("in function");
// Check name has been entered
	if (document.addTopicForm.topic_owner.value == "") {
		document.addTopicForm.topic_owner.value = "Please enter your name."
		document.addTopicForm.topic_owner.focus()
		document.addTopicForm.topic_owner.select()
		return false;	
	} else if (document.addTopicForm.topic_owner.value == "Please enter your name.") {
		document.addTopicForm.topic_owner.value = "Please enter your name."
		document.addTopicForm.topic_owner.focus()
		document.addTopicForm.topic_owner.select()
		return false;
	}
//alert("after name check");
// Check e-mail has been entered
	if ((document.addTopicForm.topic_email.value == "") || (document.addTopicForm.topic_email.value == "Please enter your e-mail address.")) {
		document.addTopicForm.topic_email.value = "Please enter your e-mail address."
		document.addTopicForm.topic_email.focus()
		return false;	
	} else if (re.test(document.addTopicForm.topic_email.value)){
	// If email validates do nothing
	} else {			
		document.addTopicForm.topic_email.value = "Please enter a valid e-mail address."
		document.addTopicForm.topic_email.focus()
		document.addTopicForm.topic_email.select()
		return false;
	}
//alert("after email check");
// Check forum has been entered
var btnCheck = 0;
for (var i=0; i<document.addTopicForm.topic_category.length; i++)  {
	if (document.addTopicForm.topic_category[i].checked)  {
	var btnCheck = 1;
	} 
}
if (btnCheck == 0) {
	alert("You MUST select a forum to post a new topic in!");
	document.addTopicForm.topic_category[0].focus();
	document.addTopicForm.topic_category[0].select();
	return false;
}
//alert("after category check");
// Check topic title has been entered
	if (document.addTopicForm.topic_title.value == "") {
		document.addTopicForm.topic_title.value = "Please enter the topic title."
		document.addTopicForm.topic_title.focus()
		return false;	
	} else if (document.addTopicForm.topic_title.value == "Please enter the topic title.") {
		document.addTopicForm.topic_title.value = "Please enter the topic title."
		document.addTopicForm.topic_title.focus()
		return false;
	}
//alert("after title check");
// Check message has been entered
	if (document.addTopicForm.post_text.value == "") {
		document.addTopicForm.post_text.value = "Please enter your message / comments."
		document.addTopicForm.post_text.focus()
		return false;	
	} else if (document.addTopicForm.post_text.value == "Please enter your message / comments.") {
		document.addTopicForm.post_text.value = "Please enter your message / comments."
		document.addTopicForm.post_text.focus()
		return false;
	}
//alert("after message check");
// Check security code has been selected
	if (document.addTopicForm.code.value == "") {
		alert ("Please enter the security code.");
		document.addTopicForm.code.focus();
		document.addTopicForm.code.select();
		return false;	
	}
// Send form to process page
document.addTopicForm.submit();
// End of Vaidate order form function	
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// validatePost()
////////////////////////////////////////////////////////////////////////////////////////////////////
function validatePost() {
// Check name has been entered
	if (document.postForm.post_owner.value == "") {
		document.postForm.post_owner.value = "Please enter your name.";
		document.postForm.post_owner.focus();
		document.postForm.post_owner.select();
		return false;	
	} else if (document.postForm.post_owner.value == "Please enter your name.") {
		document.postForm.post_owner.value = "Please enter your name.";
		document.postForm.post_owner.focus();
		document.postForm.post_owner.select();
		return false;
	}
// Check e-mail has been entered
	if (document.postForm.post_email.value == "") {
		document.postForm.post_email.value = "Please enter your e-mail address.";
		document.postForm.post_email.focus();
		document.postForm.post_email.select();
		return false;	
	} else if (document.postForm.post_email.value == "Please enter your e-mail address.") {
		document.postForm.post_email.value = "Please enter your e-mail address.";
		document.postForm.post_email.focus();
		document.postForm.post_email.select();
		return false;
	}
// Check message has been entered
	if (document.postForm.post_text.value == "") {
		document.postForm.post_text.value = "Please enter your message / comments.";
		document.postForm.post_text.focus();
		document.postForm.post_text.select();
		return false;	
	} else if (document.postForm.post_text.value == "Please enter your message / comments.") {
		document.postForm.post_text.value = "Please enter your message / comments.";
		document.postForm.post_text.focus();
		document.postForm.post_text.select();
		return false;
	}
// Check security code has been selected
	if (document.postForm.code.value == "") {
		alert ("Please enter the security code.");
		document.postForm.code.focus();
		document.postForm.code.select();
		return false;	
	}
// Send form to process page
document.postForm.submit();
// End of Vaidate order form function	
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// VALIDATE ASK THE VET FORM
////////////////////////////////////////////////////////////////////////////////////////////////////
function validateQuestionForm() {
// Validate email address function
re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+)*(\.\w{2,3})+$/
// Check name has been entered
	if ((document.questionForm.name.value == "") || (document.questionForm.name.value == "Please enter your name.")) {
		document.questionForm.name.value = "Please enter your name.";
		document.questionForm.name.focus();
		document.questionForm.name.select();
		return false;	
	}
// Check e-mail has been entered
	$email = document.questionForm.email.value;
	if ((document.questionForm.email.value == "") || (document.questionForm.email.value == "Please enter your e-mail address.")) {
		document.questionForm.email.value = "Please enter your e-mail address.";
		document.questionForm.email.focus();
		document.questionForm.email.select();
		return false;	
	} else if (re.test(document.questionForm.email.value)){
	// If email validates do nothing
	} else {			
		document.questionForm.email.value = "Please enter a valid e-mail address.";
		document.questionForm.email.focus();
		document.questionForm.email.select();
		return false;
	}	
// Check topic has been entered
	if ((document.questionForm.topic.value == "") || (document.questionForm.topic.value == "Please enter the topic for your question.")) {
		document.questionForm.topic.value = "Please enter the topic for your question."
		document.questionForm.topic.focus();
		document.questionForm.topic.select();
		return false;	
	}
// Check question has been entered
	if ((document.questionForm.question.value == "") || (document.questionForm.question.value == "Please enter the topic for your question.")) {
		document.questionForm.question.value = "Please enter the topic for your question.";
		document.questionForm.question.focus();
		document.questionForm.question.select();
		return false;	
	}
// Check security code has been selected
	if (document.questionForm.code.value == "") {
		alert ("Please enter the security code.");
		document.questionForm.code.focus();
		document.questionForm.code.select();
		return false;	
	}
// Send form to process page
document.questionForm.submit();
// End of Validate Question form function	
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO LOG IN USER
///////////////////////////////////////////////////////////////////////////////////////////////
function logIn() {
// Validate email address function
re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+)*(\.\w{2,3})+$/
// Check username has been entered
// Check e-mail has been entered
	$email = document.loginForm.email.value;
	if ((document.loginForm.email.value == "") || (document.loginForm.email.value == "Please enter your e-mail address.")) {
		document.loginForm.email.value = "Please enter your e-mail address.";
		document.loginForm.email.focus();
		document.loginForm.email.select();
		return false;	
	} else if (re.test(document.loginForm.email.value)){
	// If email validates do nothing
	} else {			
		document.loginForm.email.value = "Please enter a valid e-mail address.";
		document.loginForm.email.focus();
		document.loginForm.email.select();
		return false;
	}	
// Check password has been entered
	if (document.loginForm.password.value == "") {
		document.loginForm.password.value = ""
		document.loginForm.password.focus()
		document.loginForm.password.select()
		return false;	
	}
// Send form to process page
	document.loginForm.submit();
// End of logIn function	
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO REGISTER NEW USER
///////////////////////////////////////////////////////////////////////////////////////////////
function registerUser() {
// Validate email address function
re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+)*(\.\w{2,3})+$/
// Validate numbers only
renum = /^\d+$/
// Check First Name has been entered
	if ((document.registrationForm.firstName.value == "") || (document.registrationForm.firstName.value == "Please enter your first name.")) {
		document.registrationForm.firstName.value = "Please enter your first name."
		document.registrationForm.firstName.focus()
		document.registrationForm.firstName.select()
		return false;	
	}
// Check Last Name has been entered
if ((document.registrationForm.lastName.value == "") || (document.registrationForm.lastName.value == "Please enter your last name.")) {
	document.registrationForm.lastName.value = "Please enter your last name."
	document.registrationForm.lastName.focus()
	document.registrationForm.lastName.select()
	return false;	
}
// Check e-mail has been entered
	$email = document.registrationForm.email.value;
	if ((document.registrationForm.email.value == "") || (document.registrationForm.email.value == "Please enter your email address.")){
		document.registrationForm.email.value = "Please enter your email address."
		document.registrationForm.email.focus()
		document.registrationForm.email.select()
		return false;	
	} else if (re.test(document.registrationForm.email.value)){
// If email validates do nothing
	} else {			
			document.registrationForm.email.value = "Please enter a valid e-mail address."
			document.registrationForm.email.focus()
			document.registrationForm.email.select()
			return false;
	}
// Check region has been entered
	if ((document.registrationForm.region.value == "") || (document.registrationForm.name.value == "Please enter your region.")) {
		document.registrationForm.region.value = "Please enter your region."
		document.registrationForm.region.focus()
		document.registrationForm.region.select()
		return false;	
	}
// Check password1 has been entered
	if (document.registrationForm.password1.value == "") {
		alert ("You must select a password!");
		document.registrationForm.password1.focus()
		document.registrationForm.password1.select()
		return false;	
	}
// Check password2 has been entered
	if (document.registrationForm.password2.value == "") {
		alert ("You must confirm the password!");
		document.registrationForm.password2.focus()
		document.registrationForm.password2.select()
		return false;	
	}
// Check passwords match
	if (document.registrationForm.password1.value == document.registrationForm.password2.value) {
// Passwords match so do nothing
	} else {
// Passwords don't match, so warn user
		alert ("Passwords don't match!\r\nPlease try to enter your password again and confirm.");
		document.registrationForm.password1.value = ""
		document.registrationForm.password2.value = ""
		document.registrationForm.password1.focus()
		document.registrationForm.password1.select()
		return false;	
	}
// Check security code has been entered
	if (document.registrationForm.code.value == "") {
		alert ("You must enter the security code!");
		document.registrationForm.code.focus()
		document.registrationForm.code.select()
		return false;	
	}
// Send form to process page
document.registrationForm.submit();
// End of logIn function	
}
//////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO CONFIRM USER WANTS TO DELETE
/////////////////////////////////////////////////////////////////////////////////////////////
function confirmDeleteNews() {
	//confirm ("Are you sure you want to delete this item?")
	alert ("Working?")
	// NOW SEND TO PROCESSDELETEVETLIBRARY.PHP PAGE
	return false;
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO VALIDATE EMAIL HAS BEEN ENTERED, BEFORE EDIT DETAILS CAN BE DONE
///////////////////////////////////////////////////////////////////////////////////////////////
function checkEditEmail() {
// Validate email address function
re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+)*(\.\w{2,3})+$/
// Check e-mail has been entered
	if ((document.editEmailForm.email.value == "") || (document.editEmailForm.email.value == "Please enter your email address.")) {
		document.editEmailForm.email.value = "Please enter your email address."
		document.editEmailForm.email.focus()
		document.editEmailForm.email.select()
		return false;	
	} else if (re.test(document.editEmailForm.email.value)) {
	// If email validates do nothing
	} else {			
			document.editEmailForm.email.value = "Please enter a valid e-mail address."
			document.editEmailForm.email.focus()
			document.editEmailForm.email.select()
			return false;
	}
	if (document.editEmailForm.password.value == "") {
		alert ("Please enter your password.");
		document.editEmailForm.password.focus()
		document.editEmailForm.password.select()
		return false;		
	}
	document.editEmailForm.submit();
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO EDIT DETAILS
///////////////////////////////////////////////////////////////////////////////////////////////
function editDetails() {
// Validate email address function
re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+)*(\.\w{2,3})+$/
// Validate numbers only
renum = /^\d+$/
// Check name has been entered
	if ((document.editDetailsForm.name.value == "") || (document.editDetailsForm.name.value == "Please enter your name.")) {
		document.editDetailsForm.name.value = "Please enter your name."
		document.editDetailsForm.name.focus()
		document.editDetailsForm.name.select()
		return false;	
	}
// Check e-mail has been entered
	$email = document.editDetailsForm.email.value;
	if ((document.editDetailsForm.email.value == "") || (document.editDetailsForm.email.value == "Please enter your email address.")){
		document.editDetailsForm.email.value = "Please enter your email address."
		document.editDetailsForm.email.focus()
		document.editDetailsForm.email.select()
		return false;	
	} else if (re.test(document.editDetailsForm.email.value)){
// If email validates do nothing
	} else {			
			document.editDetailsForm.email.value = "Please enter a valid e-mail address."
			document.editDetailsForm.email.focus()
			document.editDetailsForm.email.select()
			return false;
	}
// Check password1 has been entered
	if (document.editDetailsForm.password1.value == "") {
		alert ("You must select a password!");
		document.editDetailsForm.password1.focus()
		document.editDetailsForm.password1.select()
		return false;	
	}
// Check password2 has been entered
	if (document.editDetailsForm.password2.value == "") {
		alert ("You must confirm the password!");
		document.editDetailsForm.password2.focus()
		document.editDetailsForm.password2.select()
		return false;	
	}
// Check passwords match
	if (document.editDetailsForm.password1.value == document.editDetailsForm.password2.value) {
// Passwords match so do nothing
	} else {
// Passwords don't match, so warn user
		alert ("Passwords don't match!\r\nPlease try to enter your password again and confirm.");
		document.editDetailsForm.password1.value = ""
		document.editDetailsForm.password2.value = ""
		document.editDetailsForm.password1.focus()
		document.editDetailsForm.password1.select()
		return false;	
	}
// Send form to process page
document.editDetailsForm.submit();
// End of logIn function	
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO VALIDATE CMS (NEWS)
///////////////////////////////////////////////////////////////////////////////////////////////
function validateNews() {
	var errors=''
	// Check form fields have been entered, display common error alert if any are empty.
	if (document.addNewsForm.Title.value == '') errors+="TITLE: Empty.\n";
	if (document.addNewsForm.Message.value == '') errors+="MESSAGE: Empty.\n";
	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
	// Send form to process page
	document.addNewsForm.submit();
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO VALIDATE CMS (NEWSLETTERS)
///////////////////////////////////////////////////////////////////////////////////////////////
function validateNewsletters() {
	var errors=''
	// Check form fields have been entered, display common error alert if any are empty.
	if (document.addNewsletterForm.month.value == '') errors+="MONTH: Empty.\n";
	if (document.addNewsletterForm.year.value == '') errors+="YEAR: Empty.\n";
	if (document.addNewsletterForm.Topic1.value == '') errors+="TOPIC #1: Empty.\n";
	if (document.addNewsletterForm.Topic2.value == '') errors+="TOPIC #2: Empty.\n";
	if (document.addNewsletterForm.Topic3.value == '') errors+="TOPIC #3: Empty.\n";
	if (document.addNewsletterForm.fileName.value == '') errors+="FILE: Empty.\n";
	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
	// Send form to process page
	document.addVetLibraryForm.submit();
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO VALIDATE CMS (VET LIBRARY)
///////////////////////////////////////////////////////////////////////////////////////////////
function validateVetLibrary() {
	var errors=''
	// Check form fields have been entered, display common error alert if any are empty.
	if (document.addVetLibraryForm.title.value == '') errors+="TITLE: Empty.\n";
	if (document.addVetLibraryForm.description.value == '') errors+="DESCRIPTION: Empty.\n";
	if (document.addVetLibraryForm.keywords.value == '') errors+="KEYWORDS: Empty.\n";
	if (document.addVetLibraryForm.fileName.value == '') errors+="FILE: Empty.\n";
	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
	// Send form to process page
	document.addVetLibraryForm.submit();
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO VALIDATE CMS (LINKS)
///////////////////////////////////////////////////////////////////////////////////////////////
function validateLinks() {
	var errors=''
	// Check form fields have been entered, display common error alert if any are empty.
	if (document.addLinkForm.title.value == '') errors+="TITLE: Empty.\n";
	if (document.addLinkForm.url.value == '') errors+="URL: Empty.\n";
	if (document.addLinkForm.description.value == '') errors+="DESCRIPTION: Empty.\n";
	if (document.addLinkForm.image.value == '') errors+="IMAGE: Empty.\n";
	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
	// Send form to process page
	document.addLinkForm.submit();
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
// OPEN VET LIBRARY ITEM IN A NEW PAGE
///////////////////////////////////////////////////////////////////////////////////////////////
function openLibraryItem (itemId) {
	libraryItem = itemId;
	newPage = "http://animalz.co.nz/library_items.php?item="+libraryItem;
	window.open(newPage,'mywindow','width=600,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes')
	/*return libraryItem;*/
}