//add to Favourites
function bookmarksite(title, url)
{
	if (document.all)
		window.external.AddFavorite(url, title);
	else 
		if (window.sidebar)
			window.sidebar.addPanel(title, url, "");
}

//validateSearch
function validateSearch()
{
	fv =  new formValidator();
		
	if (fv.isEmpty("search"))
		fv.raiseError("Please enter your search term.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

//validateLogin
function validateNewsletter()
{
	fv =  new formValidator();
		
	if (fv.isEmpty("username"))
		fv.raiseError("Please enter your username.");
		
	if (fv.isEmpty("password"))
		fv.raiseError("Please enter your password.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

//validateNewsletter
function validateNewsletter()
{
	fv =  new formValidator();
		
	if (fv.isEmpty("newsletter_email"))
		fv.raiseError("Please enter your email address.");
	else
	{	
  		if (!fv.isEmailAddress("newsletter_email"))
			fv.raiseError("Please enter a valid email address.");
	}
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

//validateContact
function validateContact()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("your_name"))
		fv.raiseError("Please enter your Name.");
		
	if (fv.isEmpty("your_surname"))
		fv.raiseError("Please enter your Surname.");
		
	if (fv.isEmpty("your_email_address"))
		fv.raiseError("Please enter your Email Address.");
	else
	{	
  		if (!fv.isEmailAddress("your_email_address"))
			fv.raiseError("Please enter a valid Email Address.");
	}
	
	if (fv.isEmpty("your_message"))
		fv.raiseError("Please enter your Message.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateLogin()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("username") || fv.findObj("username").value == "Username")
		fv.raiseError("Please enter your username.");

	if (fv.isEmpty("password") || fv.findObj("password").value == "Password")
		fv.raiseError("Please enter your password.");
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateForgottenPassword()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("email_address"))
		fv.raiseError("Please enter your email address.");
	else
	if (!fv.isEmailAddress("email_address"))
		fv.raiseError("Please enter a valid email address.");
	
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateRegister()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("your_name"))
		fv.raiseError("Please enter your name.");
	
	if (fv.isEmpty("your_surname"))
		fv.raiseError("Please enter a your surname.");
		
	if (fv.isEmpty("your_email"))
		fv.raiseError("Please enter your email address.");
	else
	if (!fv.isEmailAddress("your_email"))
		fv.raiseError("Please enter a valid email address.");
		
	if (fv.isEmpty("your_telephone"))
		fv.raiseError("Please enter at your contact number.");
		
	if (fv.isEmpty("your_mobile"))
		fv.raiseError("Please specify who referred you to Valana.");

	if (fv.isEmpty("your_password"))
		fv.raiseError("Please enter a your password.");
	else
	if (fv.valueLength("your_password") < 5)
		fv.raiseError("Please enter a password that is equal to or longer than 5 characters.");

	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

function validateCC()
{
	fv =  new formValidator();
	
	if (fv.isEmpty("Ecom_Payment_Card_Number"))
		fv.raiseError("Please enter your name.");
	
	if (fv.isEmpty("Ecom_Payment_Card_ExpDate_Month"))
		fv.raiseError("Please enter your credit card's expiry date.");
		
	if (fv.isEmpty("Ecom_Payment_Card_ExpDate_Year"))
		fv.raiseError("Please enter your credit card's year of expiry.");
		
	if (fv.isEmpty("Ecom_Payment_Card_Type"))
		fv.raiseError("Please specify your credit card type.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}
