function openSpot() {
	//showLayer('spot');
}

function registerAjaxStuff() {
   ajaxEngine.registerAjaxElement('divMensaje');
   ajaxEngine.registerAjaxElement('divMensajeContacto');
   ajaxEngine.registerAjaxElement('divMensajeCicletada');
   ajaxEngine.registerAjaxElement('content4');
   ajaxEngine.registerAjaxElement('content13');
   ajaxEngine.registerRequest('inscribir', 'addVoluntario.php');
   ajaxEngine.registerRequest('contactar', 'contacto.php');
   ajaxEngine.registerRequest('verNoticias', 'noticias.php');
   ajaxEngine.registerRequest('cicletada', 'cicletada.php');
   ajaxEngine.registerRequest('loadNews', 'loadNewsContent.php');
   var doc = document.getElementById('idVoluntarioForm');
   Form.reset(doc);
   doc.recibir_info[0].checked = true;
   doc = document.getElementById('idContactoForm');
   Form.reset(doc);
   doc = document.getElementById('idCicletadaForm');
   Form.reset(doc);
   hideLayer('divMensajeContacto');
   hideLayer('divMensajeCicletada');
}

function enviar() {
	if (formularioValido()) {
		showLoading();
		params = Form.serialize('idVoluntarioForm');
		var options = {method:'post',onComplete:showMessage,parameters:params};
		ajaxEngine.sendRequest('inscribir',options);
	}
}

function formularioValido() {
	var doc = document.getElementById('idVoluntarioForm');
	var nombres = trim(doc.nombres.value); 
	if (nombres.length == 0) {
		window.alert('Ingresa tu nombre o nombres si tienes más de uno');
		doc.nombres.select();
		return false;
	}
	var apellidos = trim(doc.apellidos.value); 
	if (apellidos.length == 0) {
		window.alert('Ingresa por lo menos tu primer apellido');
		doc.apellidos.select();
		return false;
	}
	var email = trim(doc.email.value);
	var telefono = trim(doc.telefono.value);
	
	if ((email.length == 0) && (telefono.length == 0)) {
		window.alert('Debes ingresar un email válido o teléfono para poder contactarte');
		doc.email.select();
		return false;
	}
	
	if ((email.length != 0) && !isValidEmail(doc.email)) {
		return false;
	}
	
	var codigo = trim(doc.codigo.value);
	if ((telefono.length != 0) && (codigo == 0)) {
		window.alert('Ingrese código de área telefónico, 09 si es celular');
		doc.codigo.select();
		return false;
	}
	
	if ((telefono.length != 0) && (!isNumeric(telefono))) {
		window.alert('Teléfono ingresado no es numérico');
		doc.telefono.select();
		return false;
	}
	
	if ((telefono.length != 0) && (codigo.length != 0) && (!isNumeric(codigo))) {
		window.alert('Código Telefónico ingresado no es numérico');
		doc.codigo.select();
		return false;
	}
	
	return true;
}

function showMessage() {
	var load = document.getElementById('divLoading');
	load.style.visibility = 'hidden';
	var mensaje = document.getElementById('divMensaje');
	mensaje.style.visibility = 'visible';
}

function inicio() {
   var doc = document.getElementById('idVoluntarioForm');
   Form.reset(doc);
   doc.recibir_info[0].checked = true;
   doc = document.getElementById('idContactoForm');
   Form.reset(doc);
   doc = document.getElementById('idCicletadaForm');
   Form.reset(doc);
   hideLayer('divMensajeContacto');
   hideLayer('divMensajeCicletada');
   onClickMenu(1);
}

function showLoading() {
	var load = document.getElementById('divLoading');
	load.style.visibility = 'visible';
}