function validateSearch()
{
	fv = new formValidator();
	
	if (fv.isEmpty("keyword"))
		fv.raiseError("Please enter a word or phrase to search on.");
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
		return true;
}

function bookmarkUs() 
{
	window.external.AddFavorite('http://www.healthmart.co.za', 'HealthMart - Naturally we care for you!');
}

function validateContactForm()
{
	fs =  new formValidator();
	
	if (fs.isEmpty("fullname"))
		fs.raiseError("Your fullname must be specified.");
		
	if (fs.isEmpty("email"))
		fs.raiseError("An email address must be specified");
		
  	if (!fs.isEmailAddress("email"))
		fs.raiseError("A valid email address must be specified");
				
	if (fs.isEmpty("message"))
		fs.raiseError("Comment(s)/ Question(s) must be specified.");
		
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateAccount()
{

	fv = new formValidator();
	
	if (fv.isEmpty("last_name"))
		fv.raiseError("Please specify your last name");
	
	if (fv.isEmpty("first_name"))
		fv.raiseError("Please specify your first name");
			
	if (fv.isEmpty("username"))
		fv.raiseError("Please specify a username");	
		
	if (fv.isEmpty("address_1"))
		fv.raiseError("Please specify an address");	
		
	if (fv.isEmpty("city"))
		fv.raiseError("Please specify an city");	
		
	if (fv.isEmpty("state"))
		fv.raiseError("Please specify an province");	

	if (fv.isEmpty("zip"))
		fv.raiseError("Please specify an zip code");	
		
	if (fv.isEmpty("phone_1"))
		fv.raiseError("Please specify telephone number");	
		
	if (fv.isEmpty("user_email"))
		fv.raiseError("Please specify an email address");
	else
	{
		if (!fv.isEmailAddress("user_email"))
			fv.raiseError("Please specify a valid email address");
	}

	password1 = fv.findObj("password_1");
	password2 = fv.findObj("password_2");
	
	if (password1.value != password2.value)
		fv.raiseError("The passwords specified do not match.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateRegistration()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("last_name"))
		fv.raiseError("Please specify your last name");
	
	if (fv.isEmpty("first_name"))
		fv.raiseError("Please specify your first name");
			
	if (fv.isEmpty("username"))
		fv.raiseError("Please specify a username");
	
	if (fv.isEmpty("password_1"))
		fv.raiseError("Please specify a password");
	
	if (fv.isEmpty("address_1"))
		fv.raiseError("Please specify your address");
		
	if (fv.isEmpty("city"))
		fv.raiseError("Please specify a city");
		
	if (fv.isEmpty("state"))
		fv.raiseError("Please specify a province");
		
	if (fv.isEmpty("zip"))
		fv.raiseError("Please specify a zip code");
		
	if (fv.isEmpty("phone_1"))
		fv.raiseError("Please specify a phone number");
		
	if (fv.isEmpty("user_email"))
		fv.raiseError("Please specify an email address");
	else
	{
		if (!fv.isEmailAddress("user_email"))
			fv.raiseError("Please specify a valid email address");
	}

	password1 = fv.findObj("password_1");
	password2 = fv.findObj("password_2");
	
	if (password1.value != password2.value)
		fv.raiseError("The passwords specified do not match.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateLogin()
{
	fv = new formValidator();
	
	if (fv.isEmpty("login_username"))
		fv.raiseError("Please specify a username");
		
	if (fv.isEmpty("login_password"))
		fv.raiseError("Please specify a password");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateRecommendForm()
{
	fs = new formValidator();
	
	if (fs.isEmpty("your_name"))
		fs.raiseError("Your name must be specified.");
		
	if (!fs.isEmpty("your_email"))
	{
		if (!fs.isEmailAddress("your_email"))
			fs.raiseError("Your email address must be a valid email address.");
	}
	else
		fs.raiseError("Your email address must be specified.");
		
	if (fs.isEmpty("friend_name"))
		fs.raiseError("Your friend's name must be specified.");
	if (fs.isEmpty("friend_email"))
		fs.raiseError("Your friend's email address must be specified.");
	if (!fs.isEmailAddress("friend_email"))
		fs.raiseError("Your friends email address must be a valid email address.");
	
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
		return true;
}

function checkTerms()
{
	fs = new formValidator();
	
	if (!fs.isChecked("terms_read"))
		fs.raiseError("Please read our Terms & Conditions, Thank You");
	
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
		return true;
}

function termsAndConditions()
{
	window.open('terms-and-conditions.php', '', 'resizable=no,scrollbars=yes,width=575,height=580');
}

function validateCheckoutFields()
{
	fs = new formValidator();
	
	if (fs.isEmpty("order_payment_name"))
		fs.raiseError("Please provide the Name on The Card.");

	if (fs.isEmpty("payment_method_id"))
		fs.raiseError("Please select a method of payment.");
		
	if (fs.isEmpty("order_payment_number"))
		fs.raiseError("Please provide the credit card number.");
	
	monthExpIdx = document.Checkout.order_payment_expire_month.selectedIndex;
	yearExp = document.Checkout.order_payment_expire_year.value;

	if (monthExpIdx == 0)
		fs.raiseError("Please provide the expiry-month of the credit card.");
		
	//check card dates!
	
	
	if (fs.numErrors() > 0)
	{
		fs.displayErrors();
		return false;
	}
	else
		return true;
}
