function popform (ctro, curso)
{
	my_window= window.open ("formulario.php?centro=" + ctro + "&curso=" + curso,
	  "form","status=0,width=650,height=700"); 
}

function checkform() {

	var errores = 0;
	var mensaje = "Por favor, revise los siguientes campos:\n";

	var oApellidos = document.getElementById('apellidos');		
	var oNombre = document.getElementById('nombre');
	var oNIF = document.getElementById('NIF');
	var oDomicilio = document.getElementById('domicilio');
	var oPoblacion = document.getElementById('poblacion');
	var oCp = document.getElementById('cp');
	var oEmail = document.getElementById('email');
	var oTelefono = document.getElementById('telefono');
	var oSituacion = document.getElementById('situacion');
	var oEspecificar = document.getElementById('especificar');
	var oMatricula = document.getElementById('matricula');
	var oOtros = document.getElementById('otros');
	var oEspecificar = document.getElementById('especificar');
	
	if (oApellidos.value == "")
	{
		mensaje = mensaje + "- Apellidos\n";
		errores++;
	}
	if (oNombre.value == "")
	{
		mensaje = mensaje + "- Nombre\n";
		errores++;
	}
	if (oNombre.value == "")
	{
		mensaje = mensaje + "- NIF\n";
		errores++;
	}
	if (oDomicilio.value == "")
	{
		mensaje = mensaje + "- Domicilio\n";
		errores++;
	}
	if (oPoblacion.value == "")
	{
		mensaje = mensaje + "- Poblaci\u00F3n\n";
		errores++;
	}
	if (oCp.value == "")
	{
		mensaje = mensaje + "- C\u00F3digo Postal\n";
		errores++;
	}
	if (oEmail.value == "")
	{
		mensaje = mensaje + "- Direcci\u00F3n electr\u00F3nica\n";
		errores++;
	}
	if (oTelefono.value == "")
	{
		mensaje = mensaje + "- Tel\u00E9fono\n";
		errores++;
	}
	
	var esp_checked = 0;
	for (var i=0; i < document.form1.situacion.length; i++)
	{
		if (document.form1.situacion[i].checked)
		{
			var esp_val = i;
			esp_checked = esp_checked + 1;
		}
	}
	if (esp_checked != 1) {
		mensaje = mensaje + "- Escoja una situaci\u00F3n\n";
		errores++;
	}

	if (esp_val == 1 || esp_val == 2 || esp_val == 4) {
		if (oEspecificar.value == "") { mensaje = mensaje + "- Especifique si su situaci\u00F3n es estudiante, empleo u otros\n"; }
	}
	
	var mat_checked = 0;
	for (var i=0; i < document.form1.matricula.length; i++)
	{
		if (document.form1.matricula[i].checked)
		{
			var rad_val = document.form1.matricula[i].value;
			mat_checked = mat_checked + 1;
		}
	}
	if (mat_checked != 1) {
		mensaje = mensaje + "- Escoja una opci\u00F3n de matriculaci\u00F3n\n";
		errores++;
	}

	var otr_checked = 0;
	for (var i=0; i < document.form1.otros.length; i++)
	{
		if (document.form1.otros[i].checked)
		{
			var otr_val = document.form1.otros[i].value;
			otr_checked = otr_checked + 1;
		}
	}
	if (otr_checked != 1) {
		mensaje = mensaje + "- Escoja si desea recibir informaci\u00F3n\n";
		errores++;
	}
	
	if (document.form1.condiciones.checked == false) {
		mensaje = mensaje + "- Aceptaci\u00F3n de condiciones de Privacidad\n";
		errores++;
	}
	
	// comprueba telefono
	var oTelefono = document.getElementById("telefono");
	if (oTelefono.value.length < 9 && oTelefono.value !== "") { errores++; mensaje = mensaje + "- Cantidad de d\u00EDgitos en tel\u00E9fono inv\u00E1lidos\n"; } else 
	if (oTelefono.value.length >= 9 && oTelefono.value !== "")
	{
		var numeros = "0123456789";
		var bien = 0;
		
		for (i = 0; i < oTelefono.value.length; i++) {
			for (j = 0; j < numeros.length; j++) { 
				var checkNumber = oTelefono.value.charAt(i);
				if (numeros.charAt(j) == checkNumber) { bien++; } 
				}		
		}
		
		if (bien !== oTelefono.value.length) { 
			errores ++; 
			mensaje = mensaje + "- N\u00FAmero de tel\u00E9fono inv\u00E1lido\n"; 
			}
	}
	
	// comprueba email
		var oMail	=	document.getElementById("email").value;
		if (oMail !== "") {
			var arrobas = 0;
			var longitud = oMail.length;
			for (i = 0; i < longitud; i++) {
				if (oMail.charAt(i) == "@") { 
					arrobas++; 
					}
				}
			if (arrobas !== 1) {
				errores++;  
				mensaje = mensaje + "- Introduzca una direcci\u00F3n de email v\u00E1lida\n";
				}
		}
		
	if (errores >0)
	{
		alert(mensaje);
		return false;
	} else { 
			alert('Gracias por su inscripci\u00F3n que tendr\u00E1 car\u00E1cter definitivo con el abono de la cuota indicada'); 
			//window.close();
			}
	
}
