function validateForm(event)
{	
	var nombre = $('nombre').value;
	var apellidos = $('apellidos').value;
	var empresa = $('empresa').value;
	var direccion = $('direccion').value;
	var codigopostal = $('codigopostal').value;
	var poblacion = $('poblacion').value;
	var provincia = $('provincia').value;
	var pais = $('telefono').value;	
	var telefono = $('telefono').value;
	var email = $('email').value;
	var sector = $('sector').options[$('sector').selectedIndex].value;
	var sectorotro = $('sectorotro').value;
	var actividad = $('actividad').options[$('actividad').selectedIndex].value;	
	var actividadotro = $('actividadotro').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 ('' == direccion)
	{	
		error = true;
		errorText = errorText + '\nEl campo dirección es obligatorio.';
	}
	
	if ('' == codigopostal)
	{	
		error = true;
		errorText = errorText + '\nEl campo código postal es obligatorio.';
	}	
	
	
	if ('' == poblacion)
	{	
		error = true;
		errorText = errorText + '\nEl campo ciudad es obligatorio.';
	}	
	
	
	if ('' == provincia)
	{	
		error = true;
		errorText = errorText + '\nEl campo provincia es obligatorio.';
	}	
	
	
	if ('' == pais)
	{	
		error = true;
		errorText = errorText + '\nEl campo país 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 ('' == sector)
	{	
		error = true;
		errorText = errorText + '\nEl campo sector es obligatorio.';
	}	

	if ('otro' == sector && '' == sectorotro)
	{	
		error = true;
		errorText = errorText + '\nEl campo sector es obligatorio.';
	}	
	
	if ('' == actividad)
	{	
		error = true;
		errorText = errorText + '\nEl campo actividad es obligatorio.';
	}

	
	if ('otro' == actividad && '' == actividadotro)
	{	
		error = true;
		errorText = errorText + '\nEl campo actividad es obligatorio.';
	}

	if (error)
	{
		alert('Debe rellenar todos los campos del formulario.' + errorText);
		Event.stop(event);
		return false;
	}
	else	
	{
		return true;
	}
}

Event.observe(window, 'load', function() {
	Event.observe('sector', 'change', function() {
		var sector = $('sector').options[$('sector').selectedIndex].value;	
		if (sector == 'otro')
			$('contenedorso').show();
		else		
			$('contenedorso').hide();
	});	
	
	Event.observe('actividad', 'change', function() {
		var actividad = $('actividad').options[$('actividad').selectedIndex].value;	
		if (actividad == 'otro')
			$('contenedorao').show();
		else		
			$('contenedorao').hide();
	});
	

	Event.observe('preacreditacionForm', 'submit', validateForm);
});