/*************************************************************
* Page: contact_us.js v 1.0  
* Description: Contact us Validation
* 
* Hospitality Recruitment - Online Strategies
* Copyright (C) 2005 Online Strategies, All rights reserved
* Email  info@hospitalityonline.co.uk
* 
*************************************************************/
function validate(e){
		// Validate the form
	String.prototype.trim = function()
	{
		return this.replace(/^\s*|\s*$/g, '');
	}
	
	var grp, focus_el = null, msg = '';

	// Your Name is empty
	e.name.value = e.name.value.trim();
	if (is_empty(e.name))
	{
		msg += error[361];
		focus_el = focus_el || e.name;
	}
	// Your Name is empty
	e.company.value = e.company.value.trim();
	if (is_empty(e.company))
	{
		msg += error[371];
		focus_el = focus_el || e.company;
	}
	// Email address is empty
	e.email.value = e.email.value.trim();
	if (is_empty(e.email))
	{
		msg += error[362];
		focus_el = focus_el || e.email;
	}
	// Email address is empty
	e.email.value = e.email.value.trim();
	if (!is_empty(e.email))
	{
		if(!is_valid_email(e.email))
		{
			msg += error[363];
			focus_el = focus_el || e.email;
		}
	}
	// Your Name is empty
	e.address_line_1.value = e.address_line_1.value.trim();
	if (is_empty(e.address_line_1))
	{
		msg += error[364];
		focus_el = focus_el || e.address_line_1;
	}
	// Your Name is empty
	e.city.value = e.city.value.trim();
	if (is_empty(e.city))
	{
		msg += error[365];
		focus_el = focus_el || e.city;
	}
	// Your Name is empty
	e.postcode.value = e.postcode.value.trim();
	if (is_empty(e.postcode))
	{
		msg += error[366];
		focus_el = focus_el || e.postcode;
	}
	// Your Name is empty
	if (is_empty(e.country))
	{
		msg += error[367];
		focus_el = focus_el || e.country;
	}
	// if telephone field is filled in make sure its a number
	e.phone.value = e.phone.value.trim();
	if (is_empty(e.phone))
	{
		msg += error[368];
		focus_el = focus_el || e.phone;
	}
	e.phone.value = e.phone.value.trim();
	if (!is_empty(e.phone))
	{
		if (!is_valid_phone(e.phone))
			{
				msg += error[369];
				focus_el = focus_el || e.phone;
			}
	}
	if (e.occupation_list.selectedIndex == 0)
	{
		msg += error[370];
		focus_el = focus_el || e.phone;
	}
	// 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";
		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){
		showprocess('show','hide');
	}
	else {
		document.getElementbyId('sub').disabled = true;
	}
	return true;
}
