//Funcion que Convierte una cadena a tipo titulo (Capitalize)
function obtener_tipo_titulo (cadena) {
	if (cadena.length>0)
		{
		var cadena_titulo = '';
		cadena = cadena.toLowerCase();

		cadena = cadena.split(' ');
		for(var c=0; c < cadena.length; c++)
			{
			cadena_titulo += cadena[c].substring(0,1).toUpperCase() + cadena[c].substring(1,cadena[c].length) + ' ';
			}
		return cadena_titulo;
		}
	else
		return "";
}

// Funcion que permite ingresar solo telefonos
function dejar_solo_telefono(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[0-9\s]/;
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Funcion que permite ingresar solo letras
function dejar_solo_letras(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-zàèéêîïôüç\s]/; // de la A a las Z
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Funcion que permite ingresar solo codigo postal
function dejar_solo_postal(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-z0-9\s]/; // de la A a las Z
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

function dejar_solo_numeros_letras_espacios(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-z0-9 \s]/; // de la A a las Z
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// FUNCIN PARA PERMITIR AL USERNAME
function dejar_solo_username(e) {
		tecla = (document.all) ? e.keyCode : e.which;
	 	if (tecla==8) return true;
 	 	if (tecla==0) return true;
		if (tecla==32) return false;
		
	 	patron = /[A-Za-z0-9-_.\s]/; //Numeros y letras
 	 	te = String.fromCharCode(tecla);
	 	return patron.test(te);
	}

// FUNCIN PARA PERMITIR EL PASSWORD
function dejar_solo_pass(e) {
		tecla = (document.all) ? e.keyCode : e.which;
	 	if (tecla==8) return true;
 	 	if (tecla==0) return true;
		if (tecla==32) return false;
	}

// FUNCIN PARA PERMITIR NUMEROS, LETRAS, ACENTOS, Y ALGUNOS SIGNOS y mas cosas
function dejar_solo_texto_especial(e) {
		tecla = (document.all) ? e.keyCode : e.which;
	 	if (tecla==8) return true;
 	 	if (tecla==0) return true;

	 	patron = /[A-Za-z!?.,:-;_0-9\s]/; //Numeros y letras
 	 	te = String.fromCharCode(tecla);
	 	return patron.test(te);
	}

function dejar_solo_numeros_y_letras(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-z0-9\s]/; //Numeros y letras
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

function dejar_solo_numeros_y_letras_coma(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-z0-9,\s]/; //Numeros y letras
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

function dejar_solo_numeros_y_letras_sin_acentos(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-z0-9\s]/; //Numeros y letras
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

function dejar_solo_numeros_y_letras_especial(e) {
  tecla = (document.all) ? e.keyCode : e.which;

  if (tecla==8) return true;
  if (tecla==0) return true;

  patron = /[A-Za-z0-9\s]/; //Numeros y letras
  te = String.fromCharCode(tecla);
  return patron.test(te);
}

function dejar_solo_password(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==32) return false;
	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-z0-9\s]/; //Numeros y letras
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Fncin para permitir solo los caracteres que se indiquen en ella misma

function dejar_solo_email_especial(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==32) return false;
	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[A-Za-z0-9-_.,@\s]/; //Numeros y letras
	//patron = new RegExp(expresion);
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Funcion que permite ingresar solo caracteres de correo
function dejar_caracteres_correo_electronico(e) {
	tecla = (document.all) ? e.keyCode : e.which;

	if (tecla==8) return true;
	if (tecla==32) return false; // Barra espaciadora
	if (tecla==0) return true;

	patron = /[a-z0-9-_.@\s]/; //Numeros y letras
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Deja solo numeros
function dejar_solo_numeros(e) {
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[\d\s]/;
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Deja solo numeros sin espacios
function dejar_solo_numeros_sin_espacios(e) {
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==32) return false;
	if (tecla==8) return true;
	if (tecla==0) return true;

	patron = /[\d\s]/;
	te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Verifica si un ano es bisiesto
function anyoBisiesto(anyo){
	if (anyo % 4 != 0)
		return false;
	else
		{
		if (anyo % 100 == 0)
			{
			if (anyo % 400 == 0)
				return true;
			else
				return false;
			}
		else
			return true;
		}
}