/*************************************************************
* Page: search.js v 1.0  
* Description: To validate the search engine to make sure they fill
* in a keyword.
* 
* Hospitality Recruitment - Online Strategies
* Copyright (C) 2005 Online Strategies, All rights reserved
* Email  info@hospitalityonline.co.uk
* 
*************************************************************/
function validate_basic_search(e){	
	if ((VALIDATE_BASIC_SEARCH == 0 && JAVASCRIPT_ON == 1) || (VALIDATE_BASIC_SEARCH == 0 && JAVASCRIPT_ON == 0)){ // override javascript
		return true; // Send the form through without Javascript DEBUG
	}
	else if ((VALIDATE_BASIC_SEARCH == 1 && JAVASCRIPT_ON == 1) || (VALIDATE_BASIC_SEARCH == 1 && JAVASCRIPT_ON == 0)){ // Validate the form
		// Trim the data to make sure there is no white space
		String.prototype.trim = function()
		{
			return this.replace(/^\s*|\s*$/g, '');
		}
		
		var focus_el = null, msg = '';
		
		// title must be filled in
		e.keywords.value = e.keywords.value.trim();
		if (is_empty(e.keywords))
		{
			msg += error[301];
			focus_el = focus_el || e.keywords;
		}
		// If there is an error then send through an alert (var msg) and return false
		if (msg != '')
		{
			var prefix = "The search form has been completed incorrectly:\n\n";
			alert(prefix + msg);
			if (focus_el.focus)
			{
				focus_el.focus();
			}
			return false;
		}
		if (CHANGE_PROCESS == 1){
			show_searching_div();
		}
		else {
			document.getElementbyId('sub').disabled = true;
		}
		return true;
	}
	else {
		// There has been an error
		alert ("Error reported to: " + ADMIN_EMAIL);
		return false;
	}
}

// Valiate the Advanced Search facilities
function validate_basic_search(e){	
	if ((VALIDATE_ADVANCED_SEARCH == 0 && JAVASCRIPT_ON == 1) || (VALIDATE_ADVANCED_SEARCH == 0 && JAVASCRIPT_ON == 0)){ // override javascript
		return true; // Send the form through without Javascript DEBUG
	}
	else if ((VALIDATE_ADVANCED_SEARCH == 1 && JAVASCRIPT_ON == 1) || (VALIDATE_ADVANCED_SEARCH == 1 && JAVASCRIPT_ON == 0)){ // Validate the form
		// Trim the data to make sure there is no white space
		String.prototype.trim = function()
		{
			return this.replace(/^\s*|\s*$/g, '');
		}
		
		var focus_el = null, msg = '';
		
		// title must be filled in
		e.keywords.value = e.keywords.value.trim();
		if (is_empty(e.keywords))
		{
			msg += error[301];
			focus_el = focus_el || e.keywords;
		}
		
		// If there is an error then send through an alert (var msg) and return false
		if (msg != '')
		{
			var prefix = "The search form has been completed incorrectly:\n\n";
			alert(prefix + msg);
			if (focus_el.focus)
			{
				focus_el.focus();
			}
			return false;
		}
		if (CHANGE_PROCESS == 1){
			show_searching_div();
		}
		else {
			document.getElementbyId('sub').disabled = true;
		}
		return true;
	}
	else {
		// There has been an error
		alert ("Error reported to: " + ADMIN_EMAIL);
		return false;
	}
}