//AJAX
function nuevoAjax()
{
	var xmlHttp;
	try
	{	// Firefox, Opera 8.0+, Safari 
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{	// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("¡Su navegador no soporta AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

//COMPROBACIÓN DISPONIBILIDAD DE NICK
function compruebaNick(tipo)
{
	//excepciones
	if( document.getElementById('nick').value == "" )
	{
		if (tipo == 'manual')
		{
			muestraErrores('<br /><br />Para comprobar la disponibilidad del nick es necesario que introduzcas tu nombre de usuario.', 'validacion');
		}
	}
	else
	{
		ajax = nuevoAjax();
		pagina = 'lib/nick.php?';
		param = 'nick='+ document.getElementById('nick').value;
		ajax.open("POST",pagina);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState == 1)
			{
				if (tipo == 'manual')
				{
					muestraErrores('<br /><br />Chequeando disponibilidad del nick "<b>'+ document.getElementById("nick").value+'</b>"...', 'validacion');
				}
				else if (tipo == 'auto')
				{
					document.getElementById('validacionNick').value = "";
				}
			}
			if (ajax.readyState == 4)
			{
				if (ajax.responseText == "TRUE")
				{
					if (tipo == 'manual')
					{
						muestraErrores('<br /><br />Lo sentimos, el nick que has elegido (<b>'+ document.getElementById("nick").value+'</b>) no está disponible. <br />Por favor escoge otro.', 'validacion');
					}
					else if (tipo == 'auto')
					{
						document.getElementById('validacionNick').value = false;
					}
				}
				else if (ajax.responseText == "FALSE")
				{
					if (tipo == 'manual')
					{
						muestraErrores('<br /><br />¡Perfecto! ,<br /> el nick que has elegido (<b>'+ document.getElementById("nick").value+'</b>) está disponible.', 'validacion');
					}
					else if (tipo == 'auto')
					{
						document.getElementById('validacionNick').value = true;
					}
				}
			}
		}
		ajax.send(param);
		return ;
	}
}

//COMPROBACIÓN DEL CODIGO DE SEGURIDAD Y EL CAPTCHA DE MANERA AUTOMÁTICA
function compruebaCaptcha()
{
	//excepciones
	if( document.getElementById('captcha').value != "" )
	{
		ajax = nuevoAjax();
		pagina = 'lib/captcha.php?';
		param = 'captcha='+ document.getElementById('captcha').value;
		ajax.open("POST",pagina);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById('validacionCaptcha').value = "";
			}
			if (ajax.readyState == 4)
			{
				if (ajax.responseText == "TRUE")
				{
					document.getElementById('validacionCaptcha').value = true;
				}
				else if (ajax.responseText == "FALSE")
				{
					document.getElementById('validacionCaptcha').value = false;
				}
			}
		}
		ajax.send(param);
		return ;
	}
}

//VALIDA EL CODIGO POSTAL CON EL CODIGO DE LA PROVINCIA
function cpValido(cp, codigo)
{
	var cod = cp.substring(0, 2);
	if (cod == codigo)
	{return true;}
	else
	{return false;}
}

//ELIMINA ESPACIOS DEL DNI Y OTROS CARACTERES
function formateaDNI(dni)
{
	var dniFormateado = "";
	dniFormateado = dni.replace("-", "");
	dniFormateado = dniFormateado.replace("_", "");
	dniFormateado = dniFormateado.replace(" ", "");
	dniFormateado = dniFormateado.replace(".", "");
	dniFormateado = dniFormateado.replace("*", "");
	dniFormateado = dniFormateado.toUpperCase();
	return dniFormateado;
}

//COMPRUEBA QUE EL DNI INTRODUCIDO SEA VALIDO
function dniValido(dni)
{
	var numero = "";
	var let = "";
	var letra = "RWAGMYFPDXBNJZSQVHLCKET";

	dniFormateado = formateaDNI(dni);
	if ((dniFormateado == "000000000T")||(dniFormateado == "111111111T")||(dniFormateado == "222222222J"))
	{
		return false;
	}
	let2 = dniFormateado.substr(0,1);
	if (let2 == "X")
	{
		numero = dniFormateado.substr(1, dniFormateado.length-2);
	}
	else if (let2 == "Y")
	{
		numero = "1"+dniFormateado.substr(1, dniFormateado.length-2);
	}
	else if (let2 == "Z")
	{
		numero = "2"+dniFormateado.substr(1, dniFormateado.length-2);
	}
	else
	{
		numero = dniFormateado.substr(0, dniFormateado.length-1);
	}
	let = dniFormateado.substr(dniFormateado.length-1, 1);
	numero = numero % 23;
	if (numero == 0) numero = 23;
	letra = letra.charAt(numero-1);
	if (letra != let)
	{
		return false;
	}
	else
		return true;
}

//COMPRUEBA QUE SEA UN EMAIL VALIDO
function emailValido(address)
{
	if (address.indexOf('@') < 2)
		return false;
	var name = address.substring(0, address.indexOf('@'));
	var domain = address.substring(address.indexOf('@') + 1);
	var ext = address.substring(address.lastIndexOf('.') + 1);
	var serv = domain.substring(0,domain.indexOf('.'));
	
	if (name.indexOf('(') != -1 || name.indexOf(')') != -1 || name.indexOf('<') != -1 || name.indexOf('>') != -1 || name.indexOf(',') != -1 || name.indexOf(';') != -1 || name.indexOf(':') != -1 || name.indexOf('\\') != -1 || name.indexOf('"') != -1 || name.indexOf('[') != -1 || name.indexOf(']') != -1 || name.indexOf(' ') != -1)
		return false;
	if (domain == 'spam.la' || domain == 'mailinator.com' || domain == 'tempinbox.com' || domain == "" || domain.indexOf('(') != -1 || domain.indexOf(')') != -1 || domain.indexOf('<') != -1 || domain.indexOf('>') != -1 || domain.indexOf(',') != -1 || domain.indexOf('.') == -1 || domain.indexOf(';') != -1 || domain.indexOf(':') != -1 || domain.indexOf('\\') != -1 || domain.indexOf('"') != -1 || domain.indexOf('[') != -1 || domain.indexOf(']') != -1 || domain.indexOf(' ') != -1)
		return false;
	if (serv == "" || serv.length == 1)
		return false;
	
	if (ext == "" || ext.length == 1)
		return false;
	
	return true;
}

//COMPRUEBA SI LA FECHA DE NACIMIENTO PASADA ES MENOR QUE EL PARAMETRO AÑOS
function menorDe(anios, dia, mes, anyo)
{
	var now			= new Date();
	var now_mes		= now.getMonth()+1;
	var now_dia		= now.getDate();


	if (BrowserDetect.browser=="Explorer") var now_anyo = now.getYear();
	else var now_anyo = now.getFullYear();

	if(now_anyo - anyo < anios)
	{
		return true;
	}
	else if (now_anyo - anyo == anios)
	{
		if(now_mes < mes)
		{
			return true;
		}
		else if(now_mes == mes)
		{
			if(now_dia < dia)
			{
				return true;
			}
		}
	}
	return false;
}

//COMPRUEBA SI LA FECHA DE NACIMIENTO PASADA ES MAYOR QUE EL PARAMETRO AÑOS
function mayorDe(anios, dia, mes, anyo)
{
	var now			= new Date();
	var now_mes		= now.getMonth()+1;
	var now_dia		= now.getDate();

	if (BrowserDetect.browser=="Explorer") var now_anyo = now.getYear();
	else var now_anyo = now.getFullYear();

	if(now_anyo - anyo > anios)
	{
		return true;
	}
	else if (now_anyo - anyo == anios)
	{
		if(now_mes > mes)
		{
			return true;
		}
		else if(now_mes == mes)
		{
			if(now_dia > dia)
			{
				return true;
			}
		}
	}
	return false;
}

//COMPRUEBA QUE EL VALOR ENVIADO NO CONTENGA CARACTERES NO VALIDOS
function contieneCaracterInvalido(cadena)
{
	var caracteres = new Array("_","!","?","1","2","3","4","5","6","7","8","9","0", ",",";", "+", "=","/","¡"); 
	var encontrado = false;
	for (i = 0; i < caracteres.length; i++)
	{
		if(cadena.indexOf(caracteres[i]) != -1)
		{
			encontrado = true;
		}
	}
	return encontrado;
}


//SI HAY SOLO SE PUEDE REGISTRAR UN SEXO
//COMPRUEBA QUE EL USUARIO PERTENEZCA A ÉL
function compruebaSexo()
{
	mensaje = "";
	errorSexo = false;
	if (sexo_obligatorio != "")
	{
		mensaje = "<br />Recuerda que en esta promoci&oacute;n solo pueden participar ";
	
		if ((sexo_obligatorio == "M")&&(document.getElementById('sexoF').checked == true))
		{
			mensaje += "hombres.<br />";
			errorSexo = true;
			document.getElementById('sexoM').checked = true;
		}
		if ((sexo_obligatorio == "F")&&(document.getElementById('sexoM').checked == true))
		{
			mensaje += "mujeres.<br />";
			errorSexo = true;
			document.getElementById('sexoF').checked = true;
		}
		if ((mensaje == "")||(errorSexo == true))
		{
			muestraErrores(mensaje, 'validacion');
		}
	}
}

//COMPRUEBA SI HAY UNA EDAD TOPE O MÍNIMA
//Y LA COMPARA CON LA INTRODUCIDA POR EL USUARIO
function compruebaEdad()
{
	mensajeEdad = "";
	errorEdad = 1;
	if (edad_obligatoria == 1)
	{
		mensajeEdad = "<br />Recuerda que en esta promoci&oacute;n solo pueden participar personas que tengan ";
		if (menorDe(edad_min, document.getElementById('dia').value, document.getElementById('mes').value, document.getElementById('anio').value))
		{
			mensajeEdad += "mínimo "+ edad_min + " años.<br />";
			errorEdad = 2;
		}
		if (mayorDe(edad_max, document.getElementById('dia').value, document.getElementById('mes').value, document.getElementById('anio').value))
		{
			mensajeEdad += "máximo "+ edad_max + " años.<br />";
			errorEdad = 2;
		}
	}
	else
	{
		//NO SE PERMITE PARTICIPAR A MENORES DE 14 AÑOS
		if (menorDe(edad_min, document.getElementById('dia').value, document.getElementById('mes').value, document.getElementById('anio').value))
		{
			mensajeEdad =  "<br /><br />Para participar en esta promoción tienes que ser mayor<br /> de "+ edad_min +" años.<br />";
			errorEdad = 2;
		}
	}
	if (errorEdad == 1)
	{
		//LOS MENORES DE 18 AÑOS NECESITAN PERMISO PATERNO
		if (menorDe(18, document.getElementById('dia').value, document.getElementById('mes').value, document.getElementById('anio').value))
		{
			if (document.getElementById("confirmaPermiso").value != 500)
			{
				mensajeEdad =  "<br /><br />Al ser menor de 18 años, necesitas el permiso de tus padres <br />o tutores para poder participar:<br /><br />";
				mensajeEdad +=  "<form name='formPermiso' action='' method='post' onsubmit='return false;'><input type='checkbox' name='permiso' id='permiso' value='400'> Sí, tengo permiso paterno<br /><br />";
				mensajeEdad +=  "<input type='button' value='confirmar' id='botonEdad' onclick='if(document.getElementById(\"permiso\").checked){document.getElementById(\"confirmaPermiso\").value = 500;ocultaErrores(\"validacion\");}'></form><br />";
			
				errorEdad = 3;
			}
		}
	}
	
	return errorEdad;
}

//CHEQUEA TODO EL FORMULARIO
function validaRegistro()
{
	var fechaNacimientoCompleta = true;
	var fechaNacimientoValida = false;
	var necesitaPermiso = false;
	var datosPersonales = false;
	var mensaje = "<strong>Por favor, revisa el formulario.</strong><br /> Los siguientes campos están vacíos o no son correctos:<br />";

	//VALIDACIONES DE PROMOCIONES
	//SOLO SE EJECUTA SI LA PROMOCIÓN NO PERMITEN PARTICIPAR A LOS HOMBRES O A LAS MUJERES
	//SEXO
	compruebaSexo();

	//EDAD
	if(document.getElementById('dia').selectedIndex < 1)
	{
		mensaje += "· Mes de tu fecha de nacimiento<br />";
		fechaNacimientoCompleta = false;
	}

	if(document.getElementById('mes').selectedIndex < 1)
	{
		mensaje += "· Mes de tu fecha de nacimiento<br />";
		fechaNacimientoCompleta = false;
	}

	if(document.getElementById('anio').selectedIndex < 1)
	{
		mensaje += "· A&ntilde;o de tu fecha de nacimiento<br />";
		fechaNacimientoCompleta = false;
	}
	//SI LOS CAMPOS DIA MES Y AÑO ESTAN COMPLETADOS COMPRUEBA FECHA
	if (fechaNacimientoCompleta)
	{
		fechaNacimientoValida = compruebaEdad();
	}
		
	if(fechaNacimientoValida == 2)
	{
		muestraErrores(mensajeEdad, 'validacion');
	}
	else if (fechaNacimientoValida == 3)
	{
		necesitaPermiso = true;
		muestraErrores(mensajeEdad, 'validacion');
		return false;
	}
	//SI LA EDAD ESTÁ BIEN CONTINUA CON EL RESTO DE CAMPOS
	else if (fechaNacimientoValida == 1)
	{
		if((document.getElementById('nombre').value == '')||(contieneCaracterInvalido(document.getElementById('nombre').value)))
		{
			mensaje += "· Nombre<br />";
		}

		if((document.getElementById('apellido1').value == '')||(contieneCaracterInvalido(document.getElementById('apellido1').value)))
		{
			mensaje += "· Primer apellido<br />";
		}

		if ((!document.getElementById('sexoM').checked)&&(!document.getElementById('sexoF').checked))
		{	
			mensaje += "· Sexo<br />";
		}

		if(document.getElementById('dni').value != '')
		{
			if(dniValido( document.getElementById('dni').value ) == false)
			{
				mensaje += "· DNI<br />";
			}
		}
		else
		{
			mensaje += "· DNI<br />";
		}

		if(document.getElementById('tipo_via').value == "")
		{
			mensaje += "· Tipo de v&iacute;a<br />";
		}

		if(document.getElementById('via').value == '')
		{
			mensaje += "· Nombre de la v&iacute;a<br />";
		}

		if(document.getElementById('numero').value == '')
		{
			mensaje += "· N&uacute;mero de tu vivienda<br />";
		}
		if (document.getElementById('cp').value == '')
		{
			mensaje += "· C&oacute;digo postal<br />";
		}
		else
		{
			if (document.getElementById('cp').value.length == 4)
			{
				document.getElementById('cp').value = '0'+ document.getElementById('cp').value;
			}
			if((document.getElementById('cp').value.substring(0, 2) > 52)|| (document.getElementById('cp').value < 1000))
			{
				mensaje += "· C&oacute;digo postal no es correcto<br />";
			}
		}
		if(document.getElementById('ciudad').value == '')
		{
			mensaje += "· Ciudad / Poblaci&oacute;n<br />";
		}

		if(document.getElementById('provincia').value == '')
		{
			mensaje += "· Provincia<br />";
		}
		
		if(!cpValido(document.getElementById('cp').value, document.getElementById('provincia').value))
		{
			mensaje += "· C&oacute;digo postal no se corresponde con tu provincia<br />";
		}

		if((document.getElementById('telefono').value == '')&&(document.getElementById('movil').value == ''))
		{
			mensaje += "· Indica al menos uno de los dos  tel&eacute;fonos (fijo o m&oacute;vil)<br />";
		}
		
		if(document.getElementById('telefono').value != '')
		if((isNaN(document.getElementById('telefono').value)) || (document.getElementById('telefono').value.length < 9) || (document.getElementById('telefono').value.substring(0, 1) != 9))
		{
			mensaje += "· Tel&eacute;fono, el formato no es correcto <br />";
		}
		
		if(document.getElementById('movil').value != '')
		if((isNaN(document.getElementById('movil').value)) || (document.getElementById('movil').value.length < 9) || (document.getElementById('movil').value.substring(0, 1) != 6))
		{
			mensaje += "· M&oacute;vil, el formato no es correcto<br /><br />";
		}
		if (document.getElementById('email').value != '')
		{
			if (!emailValido(document.getElementById('email').value))
			{
				mensaje += "· Email, no es una cuenta de correo válida<br />";
			}
			else
			{
				if (document.getElementById('email').value != document.getElementById('conf_email').value)
				{
					mensaje += "· El email y su confirmación no coinciden<br />";
				}
			}
		}
		else
		{
			mensaje += "· Email<br />";
		}

		if (document.getElementById('nick').value == '')
		{
			mensaje += "· Nick<br />";
		}
		else
		{
			if (document.getElementById('validacionNick').value == 'false')
			{
				mensaje += "· El Nick elegido <b>no está disponible</b>, por favor escoge otro y comprueba su disponibilidad<br />";
			}
		}

		if (document.getElementById('password').value != '')
		{
			if (document.getElementById('password').value.length < 6)
			{
				mensaje += "· Contraseña, debe tener al menos 6 caracteres<br />";
			}
			else
			{
				if (document.getElementById('conf_password').value != '')
				{
					if (document.getElementById('password').value != document.getElementById('conf_password').value)
					{
						mensaje += "· Las contraseñas no coinciden<br />";
					}
				}
				else
				{
					mensaje += "· Confirma la contraseña<br />";
				}
			}
		}
		else
		{
			mensaje += "· Contraseña<br />";
		}

		if (document.getElementById('captcha').value == '')
		{
			mensaje += "· Clave de seguridad<br />";
		}
		else
		{
			if (document.getElementById('validacionCaptcha').value == 'false')
			{
				mensaje += "· La <b>clave de seguridad</b> no se corresponde con el texto de la imagen.<br />";
			}
		}

		if(!document.getElementById('aviso').checked )
		{
			mensaje += "<br /><strong> Para registrarse es necesario aceptar el aviso legal</strong><br />";
		}
	}
	if (mensaje != "<strong>Por favor, revisa el formulario.</strong><br /> Los siguientes campos están vacíos o no son correctos:<br />")
	{
		muestraErrores(mensaje, 'validacion');
		return false;
	}
	else
	{
		if (fechaNacimientoValida == 1)
		{
			datosPersonales = true;
		}
		else if (fechaNacimientoValida == 3)
		{
			if (document.getElementById('confirmaPermiso').value == 500)
			{
				datosPersonales = true;
			}
		}
	}

	if (datosPersonales)
	{
		mensajeCuestionario = validaCuestionario();
		if (mensajeCuestionario)
		{
			muestraErrores("<br />Por favor, comprueba que las preguntas indicadas abajo estén contestadas correctamente: <br />"+mensajeCuestionario, 'validacion')
		}
		else
		{
			document.getElementById('registro').submit();
		}
	}
}



//CHEQUEA EL FORMULARIO DE MODIFICACION
function validaModificacion()
{
	var fechaNacimientoCompleta = true;
	var fechaNacimientoValida = false;
	var necesitaPermiso = false;
	var datosPersonales = false;
	var mensaje = "<strong>Por favor, revisa el formulario.</strong><br /> Los siguientes campos no son correctos:<br />";

		if((document.getElementById('nombre').value == '')||(contieneCaracterInvalido(document.getElementById('nombre').value)))
		{
			mensaje += "· El nombre no puede estar vacío, o contener caracteres inválidos<br />";
		}

		if((document.getElementById('apellido1').value == '')||(contieneCaracterInvalido(document.getElementById('apellido1').value)))
		{
			mensaje += "· El primer apellido no puede estar vacío, o contener caracteres inválidos<br />";
		}

	//EDAD
	if ((document.getElementById('dia').value != "")||(document.getElementById('mes').value != "")||(document.getElementById('dia').value != ""))
	{
		if ((document.getElementById('dia').value != "")&&(document.getElementById('mes').value != "")&&(document.getElementById('dia').value != ""))
		{
			fechaNacimientoCompleta = true;
		}
		else
		{
			fechaNacimientoCompleta = false;
			mensaje += "· Si queres cambiar tu fecha de nacimiento tienes que introducir día, mes y año<br />";
		}
	}

	//SI LOS CAMPOS DIA MES Y AÑO ESTAN COMPLETADOS COMPRUEBA FECHA
	if (fechaNacimientoCompleta)
	{
		fechaNacimientoValida = compruebaEdad();
	}
		
	if(fechaNacimientoValida == 2)
	{
		muestraErrores(mensajeEdad, 'validacion');
	}
	else if (fechaNacimientoValida == 3)
	{
		necesitaPermiso = true;
		muestraErrores(mensajeEdad, 'validacion');
		return false;
	}
	//SI LA EDAD ESTÁ BIEN CONTINUA CON EL RESTO DE CAMPOS
	else if (fechaNacimientoValida == 1)
	{
		if(document.getElementById('dni').value != '')
		{
			if(dniValido( document.getElementById('dni').value ) == false)
			{
				mensaje += "· DNI<br />";
			}
		}

		if (document.getElementById('cp').value != '')
		{
			if (document.getElementById('cp').value.length == 4)
			{
				document.getElementById('cp').value = '0'+ document.getElementById('cp').value;
			}
			if((document.getElementById('cp').value.substring(0, 2) > 52)|| (document.getElementById('cp').value < 1000))
			{
				mensaje += "· C&oacute;digo postal no es correcto<br />";
			}

			if(document.getElementById('provincia').value == '')
			{
				mensaje += "· Si indicas el código postal es necesario que selecciones la provincia<br />";
			}
			else
			{
				if(!cpValido(document.getElementById('cp').value, document.getElementById('provincia').value))
				{
					mensaje += "· C&oacute;digo postal no se corresponde con tu provincia<br />";
				}
			}
		}

		if (document.getElementById('provincia').value != '')
		{
			if(document.getElementById('cp').value == '')
			{
				mensaje += "· Si indicas la provincia es necesario que selecciones el código postal<br />";
			}
			else
			{
				if (document.getElementById('cp').value.length == 4)
				{
					document.getElementById('cp').value = '0'+ document.getElementById('cp').value;
				}
				if((document.getElementById('cp').value.substring(0, 2) > 52)|| (document.getElementById('cp').value < 1000))
				{
					mensaje += "· C&oacute;digo postal no es correcto<br />";
				}
			}
			if(!cpValido(document.getElementById('cp').value, document.getElementById('provincia').value))
			{
				mensaje += "· C&oacute;digo postal no se corresponde con tu provincia<br />";
			}
		}

		if(document.getElementById('telefono').value != '')
		if((isNaN(document.getElementById('telefono').value)) || (document.getElementById('telefono').value.length < 9) || (document.getElementById('telefono').value.substring(0, 1) != 9))
		{
			mensaje += "· Tel&eacute;fono, el formato no es correcto <br />";
		}
		
		if(document.getElementById('movil').value != '')
		if((isNaN(document.getElementById('movil').value)) || (document.getElementById('movil').value.length < 9) || (document.getElementById('movil').value.substring(0, 1) != 6))
		{
			mensaje += "· M&oacute;vil, el formato no es correcto<br /><br />";
		}
		if (document.getElementById('email').value != '')
		{
			if (!emailValido(document.getElementById('email').value))
			{
				mensaje += "· Email, no es una cuenta de correo válida<br />";
			}
		}

		if (document.getElementById('password').value != '')
		{
			if (document.getElementById('password').value.length < 6)
			{
				mensaje += "· Contraseña, debe tener al menos 6 caracteres<br />";
			}
			else
			{
				if (document.getElementById('conf_password').value != '')
				{
					if (document.getElementById('password').value != document.getElementById('conf_password').value)
					{
						mensaje += "· Las contraseñas no coinciden<br />";
					}
				}
				else
				{
					mensaje += "· Confirma la contraseña<br />";
				}
			}
		}
	}
	if (mensaje != "<strong>Por favor, revisa el formulario.</strong><br /> Los siguientes campos no son correctos:<br />")
	{
		muestraErrores(mensaje, 'validacion');
		return false;
	}
	else
	{
		if (fechaNacimientoValida == 1)
		{
			datosPersonales = true;
		}
		else if (fechaNacimientoValida == 3)
		{
			if (document.getElementById('confirmaPermiso').value == 500)
			{
				datosPersonales = true;
			}
		}
	}

	if (datosPersonales)
	{
			document.getElementById('formModificacion').submit();
	}
}