
function validateForm(event)
{	
	var nombre = $('nombre').value;
	
	
	var telefono = $('telefono').value;
	var email = $('email').value;
	
	var dia = $('dia').value;
	var hora = $('hora').value;
	var mes = $('mes').value;
	
	var observaciones = $('observaciones').value;
	
	var error = false;
	var errorText = '';
	
	if ('' == nombre)
	{	
		error = true;
		errorText = errorText + '\nEl campo nombre es obligatorio.';
	}
	/*
	if ('' == apellidos)
	{	
		error = true;
		errorText = errorText + '\nEl campo apellidos es obligatorio.';
	}	
	
	
	if ('' == empresa)
	{	
		error = true;
		errorText = errorText + '\nEl campo empresa es obligatorio.';
	}		
	*/
	if ('' == telefono)
	{	
		error = true;
		errorText = errorText + '\nEl campo teléfono es obligatorio.';
	}
	
	if ('' == email)
	{	
		error = true;
		errorText = errorText + '\nEl campo email es obligatorio.';
	}
		
	if (!isValidEmailAddress(email))
	{	
		error = true;
		errorText = errorText + '\nLa dirección de email debe ser correcta.';
	}
	
	if ('' == dia)
	{	
		error = true;
		errorText = errorText + '\nEl campo dia es obligatorio.';
	}
	if ('' == hora)
	{	
		error = true;
		errorText = errorText + '\nEl campo hora es obligatorio.';
	}
	if ('' == mes)
	{	
		error = true;
		errorText = errorText + '\nEl campo mes es obligatorio.';
	}	
		

	if (error)
	{
		alert('Debe rellenar todos los campos del formulario.' + errorText);
		Event.stop(event);
		return false;
	}
	else	
	{
		return true;
	}
}

function isValidEmailAddress(email) 
{
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
    {
	return true;
    }
    else
    {
	return false;
    }
}	

Event.observe(window, 'load', function() {	
	Event.observe('reservasForm', 'submit', validateForm);
});
