/*************************************************************
* Page: forgotpass.js v 1.0  
* Description: Forgotpassword Validation
* 
* Hospitality Recruitment - Online Strategies
* Copyright (C) 2005 Online Strategies, All rights reserved
* Email  info@hospitalityonline.co.uk
* 
*************************************************************/
function validate_f(e){
	if ((VALIDATE_PASSWORD == 0 && JAVASCRIPT_ON == 1) || (VALIDATE_PASSWORD == 0 && JAVASCRIPT_ON == 0)){ // override javascript
		
		return true; // Send the form through without Javascript DEBUG
		
	}
	else if ((VALIDATE_PASSWORD == 1 && JAVASCRIPT_ON == 1) || (VALIDATE_PASSWORD == 1 && JAVASCRIPT_ON == 0)){  // Validate the form

		// Validate the form
		String.prototype.trim = function()
		{
			return this.replace(/^\s*|\s*$/g, '');
		}
		
		var grp, focus_el = null, msg = '';

		// If the username is on the form, then make sure the user fills it in
		e.username.value = e.username.value.trim();
		if (e.username)
		{
			if (is_empty(e.username))
			{
				msg += "- Please provide your username.\n";
				focus_el = focus_el || e.username;
			}		
		}
		
		// If there is a secret question box make sure you enter something.
		if (e.secret_question)
		{
			if (is_empty(e.secret_question))
			{
				msg += "- Please enter your "+ document.getElementById('sq').value +".\n";
				focus_el = focus_el || e.secret_question;
			}
		}

		// If there is an error then send through an alert (var msg) and return false
		if (msg != '')
		{
			var prefix = "The form has been incorrectly completed:\n\n";
			alert(prefix + msg);
			if (focus_el.focus)
			{
				focus_el.focus();
			}
			return false;
		}
		return true;
	}
	else {
		// There has been an error
		alert ("Error reported to: " + ADMIN_EMAIL);
		return false;
	}
}
