function MostrarTopicos()
{
		var	id_tiporegistro = "";
		//alert(id_Departamento);
		id_tiporegistro = document.form.cbTipoRegistro.options[document.form.cbTipoRegistro.selectedIndex].value
		if(id_tiporegistro == 2)
		{
			document.getElementById("topicos").style.display ="block";
		}
		else
		{
			document.getElementById("topicos").style.display ="none";
		}
}
function mostrarOpcionesUsuario()
	{
		
		if (jtrim(document.form.email.value) != "")
		{
			email=jtrim(window.document.form.email.value)
			arroba=etrim(email)
			if (!ValidarMail(email) && arroba != -1)
			{
				document.getElementById("errorEmailServidor").style.display="none";
				document.getElementById("errorMail").style.display = "none";
				document.getElementById("mensajeError").style.display="none";
				document.getElementById("mostraropcionusuario").style.display ="block";
				document.getElementById("mostraropcionusuario").innerText = "";
	
				var parametros = "";
				parametros = parametros + "mail=" + jtrim(document.form.email.value);
				
				var opcionesusuario = new Ajax('/includes/chequear_mail.php?' + parametros);
				
				opcionesusuario.addLoading("mostraropcionusuario"); // ID donde muestra Loading !
				opcionesusuario.setResponse("mostraropcionusuario"); // ID donde muestra Resp.
				opcionesusuario.setError("mostraropcionusuario"); // Error
	
				opcionesusuario.enviar();
			}
			else
			{
				document.getElementById("errorMail").style.display = "none";
				document.getElementById("mensajeError").style.display="none";
				document.getElementById("lblemail").style.display = 'none';
				document.getElementById("mostraropcionusuario").style.display ="none";
				document.getElementById("errorMail").style.display = "block";
				document.getElementById("errorMail").innerText = "Tu mail debe ser un mail valido.";
			}

		}
		
	}
	function copiarnick() 
	{
		if ('' == 'R') 
		{
			window.document.form.txtnick1.value = window.document.form.usuario.value
		}
	}

	function setearTexto(obj,campo) 
	{
		var elemento = eval("document.form."+campo);
		elemento.value = obj.options[obj.selectedIndex].text;
		return true;
	}

	function atrapar_enter()
	{
		if (window.event.keyCode==13) Ingresar();
	}


	function Continuar()
	{
		var error = 0;
		var control='';
		clave = jtrim(window.document.form.clave.value)
		if ( clave.length < 6)
		{
			document.getElementById("errorclave").style.display = "block";
			document.getElementById("lblclave").style.display = "none";	
			if (control=='')
				control = 'clave';
			error = 1;
		}else
		{
				document.getElementById("errorclave").style.display = "none";
				document.getElementById("lblclave").style.display = "block";
		}

		if (ValidarTexto(clave))
		{
			document.getElementById("errorclaveCarInvalid").style.display = "block";
			document.getElementById("lblclave").style.display = "none";
			if (control=='')
				control = 'clave';
			error = 1;
		}else
		{
			document.getElementById("errorclaveCarInvalid").style.display = "none";
			document.getElementById("lblclave").style.display = "block";
		}

		confirmaclave = jtrim(window.document.form.confirmaclave.value)
		if (clave != confirmaclave)
		{
			document.getElementById("errorclaveCoincidencia").style.display = "block";
			document.getElementById("lblclave").style.display = "none";
			document.getElementById("lblconfirma").style.display = "none";
			if (control=='')
				control = 'confirmaclave';
			error = 1;
		}else
		{
			document.getElementById("errorclaveCoincidencia").style.display = "none";
			document.getElementById("lblclave").style.display = "none";
			document.getElementById("lblconfirma").style.display = "block";
		}

		email=jtrim(window.document.form.email.value)
		arroba=etrim(email)
		if (arroba == -1)
		{
			return
		}
		else 
		{
			if (email == "")
			{
				document.getElementById("errorMail").style.display = "block";
				document.getElementById("errorEmailInvalido").style.display = "none";
				document.getElementById("lblemail").style.display = "none";
				if (control=='')
					control = 'email';
				error = 1;
			}
			else 
			{
				if (ValidarMail(email))
				{
					document.getElementById("errorEmailInvalido").style.display = "block";
					document.getElementById("errorMail").style.display = "none";
					document.getElementById("errorEmailServidor").style.display = "none";
					document.getElementById("lblemail").style.display = "none";
					if (control=='')
						control = 'email';
					error = 1;
				}else
				{
					document.getElementById("errorMail").style.display = "none";
					document.getElementById("errorEmailInvalido").style.display = "none";
					document.getElementById("errorEmailServidor").style.display = "none";
					document.getElementById("lblemail").style.display = "block";
				}
			}
		}


		

		nombre = jtrim(window.document.form.nombre.value)
		if (nombre == "")
		{
			document.getElementById("errorNombre").style.display = "block";
			document.getElementById("lblnombre").style.display = "none";
			if (control=='')
				control = 'nombre';
			error = 1;
		}else
		{
			document.getElementById("errorNombre").style.display = "none";
			document.getElementById("lblnombre").style.display = "block";
		}

		apellido = jtrim(window.document.form.apellido.value)
		if ( apellido == "")
		{
			document.getElementById("errorApellido").style.display = "block";
			document.getElementById("lblapellido").style.display = "none";
			if (control=='')
				control = 'apellido';
			error = 1;
		}else
		{
			document.getElementById("errorApellido").style.display = "none";
			document.getElementById("lblapellido").style.display = "block";
		}
		
		telefono = jtrim(window.document.form.telefono.value)
		if ( telefono == "")
		{
			document.getElementById("errortelefono").style.display = "block";
			document.getElementById("lbltelefono").style.display = "none";
			if (control=='')
				control = 'telefono';
			error = 1;
		}else
		{
			document.getElementById("errortelefono").style.display = "none";
			document.getElementById("lbltelefono").style.display = "block";
		}
		
		direccion = jtrim(window.document.form.direccion.value)
		if ( direccion == "")
		{
			document.getElementById("errordireccion").style.display = "block";
			document.getElementById("lbldireccion").style.display = "none";
			if (control=='')
				control = 'direccion';
			error = 1;
		}else
		{
			document.getElementById("errordireccion").style.display = "none";
			document.getElementById("lbldireccion").style.display = "block";
		}
		
		DNI = jtrim(window.document.form.DNI.value)
		if ( DNI == "")
		{
			document.getElementById("errorDNI").style.display = "block";
			document.getElementById("lblDNI").style.display = "none";
			if (control=='')
				control = 'DNI';
			error = 1;
		}else
		{
			document.getElementById("errorDNI").style.display = "none";
			document.getElementById("lblDNI").style.display = "block";
		}
		
		
		CP = jtrim(window.document.form.CP.value)
		if ( CP == "")
		{
			document.getElementById("errorCP").style.display = "block";
			document.getElementById("lblCP").style.display = "none";
			if (control=='')
				control = 'CP';
			error = 1;
		}else
		{
			document.getElementById("errorCP").style.display = "none";
			document.getElementById("lblCP").style.display = "block";
		}
		
		tiporegistro = document.form.cbPais.options[document.form.cbTipoRegistro.selectedIndex].value;
		if (tiporegistro=="")
		{
			document.getElementById("errortiporegistro").style.display = "block";
			if (control=='')
				control = 'cbTipoRegistro';
			error = 1;
		}else
			document.getElementById("errortiporegistro").style.display = "none";
		
		
		var	id_tiporegistro = "";
		//alert(id_Departamento);
		id_tiporegistro = document.form.cbTipoRegistro.options[document.form.cbTipoRegistro.selectedIndex].value
		if(id_tiporegistro == 2)
		{
			topico1 = document.form.cbTopico1.options[document.form.cbTopico1.selectedIndex].value;
			topico2 = document.form.cbTopico2.options[document.form.cbTopico2.selectedIndex].value;
			topico3 = document.form.cbTopico3.options[document.form.cbTopico3.selectedIndex].value;
			if (topico1=="")
			{
				document.getElementById("errortopico1").style.display = "block";
				if (control=='')
					control = 'cbTopico1';
				error = 1;
			}else
				document.getElementById("errortopico1").style.display = "none";
			
			
			if (topico2=="")
			{
				document.getElementById("errortopico2").style.display = "block";
				if (control=='')
					control = 'cbTopico2';
				error = 1;
			}else
				document.getElementById("errortopico2").style.display = "none";
			
			
			if (topico3=="")
			{
				document.getElementById("errortopico3").style.display = "block";
				if (control=='')
					control = 'cbTopico3';
				error = 1;
			}else
				document.getElementById("errortopico3").style.display = "none";
			
		
			if (topico1 == topico2 || topico1 == topico3 || topico3 == topico2)  
			{
					document.getElementById("errortopico1").style.display = "block";
					document.getElementById("errortopico2").style.display = "block";
					document.getElementById("errortopico3").style.display = "block";
			}
		}
		pais = document.form.cbPais.options[document.form.cbPais.selectedIndex].value;
		if (pais=="")
		{
			document.getElementById("errorpais").style.display = "block";
			if (control=='')
				control = 'cbPais';
			error = 1;
		}else
			document.getElementById("errorpais").style.display = "none";
		
		
		provincia = jtrim(window.document.form.provincia.value)
		if ( provincia == "")
		{
			document.getElementById("errorprovincia").style.display = "block";
			document.getElementById("lblprovincia").style.display = "none";
			if (control=='')
				control = 'provincia';
			error = 1;
		}else
		{
			document.getElementById("errorprovincia").style.display = "none";
			document.getElementById("lblprovincia").style.display = "block";
		}
		
		ciudad = jtrim(window.document.form.ciudad.value)
		if ( ciudad == "")
		{
			document.getElementById("errorciudad").style.display = "block";
			document.getElementById("lblciudad").style.display = "none";
			if (control=='')
				control = 'ciudad';
			error = 1;
		}else
		{
			document.getElementById("errorciudad").style.display = "none";
			document.getElementById("lblciudad").style.display = "block";
		}
		
		centro = jtrim(window.document.form.centro.value)
		if ( centro == "")
		{
			document.getElementById("errorcentro").style.display = "block";
			document.getElementById("lblcentro").style.display = "none";
			if (control=='')
				control = 'centro';
			error = 1;
		}else
		{
			document.getElementById("errorcentro").style.display = "none";
			document.getElementById("lblcentro").style.display = "block";
		}
		
		departamento = jtrim(window.document.form.departamento.value)
		if ( departamento == "")
		{
			document.getElementById("errordepartamento").style.display = "block";
			document.getElementById("lbldepartamento").style.display = "none";
			if (control=='')
				control = 'departamento';
			error = 1;
		}else
		{
			document.getElementById("errordepartamento").style.display = "none";
			document.getElementById("lbldepartamento").style.display = "block";
		}

		tyc = window.document.form.tyc.checked;
		if (!tyc)
		{
			document.getElementById("errorTyc").style.display = "block";
			if (control=='')
				control = 'tyc';
			error = 1;
		}else
			document.getElementById("errorTyc").style.display = "none";			
		
		captcha = document.form.codigo_seguro.value;
		if (captcha=="")
		{
			document.getElementById("errorCaptcha").style.display = "block";
			document.getElementById("errorCaptchaServidor").style.display = "none";
			document.getElementById("lblcaptcha").style.display = "none";
			if (control=='')
					control = 'codigo_seguro';
			error = 1;
		}else
		{
			document.getElementById("lblcaptcha").style.display = "block";
			document.getElementById("errorCaptcha").style.display = "none";
			document.getElementById("errorCaptchaServidor").style.display = "none";
		}

		
		window.document.form.action = "/procesarregistro.php";
		if (error==0)
		{
			document.getElementById("continuar").disabled=true;
			window.document.form.submit()
		}
		else
		{
			document.getElementById("mensajeError").style.display = "block";
			document.getElementById("mensajeError").innerText="Algunos campos estan vacios o incorrectos";
			document.getElementById("mensajeRegistracion").style.display = "none";
			document.getElementById(control).focus();
		}

	}

	function ValidarDNI(numero)
	{
		var exp = /[^\d]+/
		if (exp.test(numero))
			return 1
		else
			return 0
	}

	function ValidarTexto(cadena)
	{
		var exp = /[^A-Za-z0-9_]/

		if (exp.test(cadena))
			return 1
		else
			return 0
	}

	function Concatenar(checks)
	{
		var concatenados = ""
		var i=0;

		while ( i<document.form.elements.length)
		{
			if(document.form.elements[i].type=="checkbox")
				if(document.form.elements[i].name==checks)
					if (document.form.elements[i].checked)
						concatenados = concatenados + document.form.elements[i].value + ","
			i++
		}
		return concatenados
	}

	

	function Str2Sql(sParam)
	{
		var nuevo

		if (jtrim(sParam) == "")
			return "NULL"
		else
			nuevo = sParam.replace("'","")

		return "'" + nuevo + "'"
	}

	function Int2Sql(sParam)
	{
		if (jtrim(sParam) == "")
			return "NULL"
		else
			return sParam
	}

	function Date2Sql(sParam)
	{
		/*Formato DD/MM/YYYY a MM/DD/YYYY*/
		if (jtrim(sParam) == "")
			return "NULL"

		return "'" + sParam.slice(3,5) + "/" + sParam.slice(0,2) + "/" + sParam.slice(6,10) + "'"
	}
	function elegirUsuario(usuario)
	{
		window.alert(usuario);
	}