/*************************************************************
* Page: login.js v 1.0  
* Description: Login validation
* 
* Hospitality Recruitment - Online Strategies
* Copyright (C) 2005 Online Strategies, All rights reserved
* Email  info@hospitalityonline.co.uk
* 
*************************************************************/
function validate_login(e){
	if ((VALIDATE_LOGIN == 0 && JAVASCRIPT_ON == 1) || (VALIDATE_LOGIN == 0 && JAVASCRIPT_ON == 0)){ // override javascript
	
		return true; // Send the form through without Javascript DEBUG
	
	}
	else if ((VALIDATE_LOGIN == 1 && JAVASCRIPT_ON == 1) || (VALIDATE_LOGIN == 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 = '';
	
		// First Name is_empty
		e.username.value = e.username.value.trim();
		if (is_empty(e.username))
		{
			msg += "- Please enter your username.\n";
			focus_el = focus_el || e.username;
		}
		// Surname is empty
		e.password.value = e.password.value.trim();
		if (is_empty(e.password))
		{
			msg += "- Please enter your password\n";
			focus_el = focus_el || e.password;
		}	
		// If there is an error then send through an alert (var msg) and return false
		if (msg != '')
		{
			var prefix = "The Login form was not filled in correctly:\n\n";
			alert(prefix + msg);
			if (focus_el.focus)
			{
				focus_el.focus();
			}
			return false;
		}
		// If there are no errors send through the form and process it.
		if (CHANGE_PROCESS == 1){
			document.getElementById('show_login').style.display = "none";
			document.getElementById('hide_login').style.display = "block";
		}
		else {
			document.getElementbyId('sub_login').disabled = true;
		}
		return true;
	}
	else {
		// There has been an error
		alert ("Error reported to: " + ADMIN_EMAIL);
		return false;
	}
}