function esFecha(cadena){//Comprueba que el campo tiene formato dd/mm/aaaa
if (cadena.search(/^[0-3][0-9]\/[0-1][0-9]\/(19|20)[0-9][0-9]$/) !=-1)
	return true;
else
	return false;
}
function esExtension(cadena,extension){ //comprueba la extension de un archivo formato .xxx
	if(cadena!=""){
		cadena_extension=cadena.substring(cadena.length-extension.length,cadena.length);
		if(cadena_extension.toLowerCase()==extension.toLowerCase()){
			return true;
		}else{
			return false;
		}
	}
}
function esEmail(strEmail) { //Comprueba el formato de una dirección de email
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}
function esLetras(strLetras){ //Comprueba que un campo solo tenga letras
	if (strLetras.search(/^[a-zA-Z]+[a-zA-Z-_,\. ]+$/) != -1)
		return true;
	else
		return false;
}
function esNumero(strNumero){ //Comprueba que el campo tiene un valor numerico
	if (strNumero.search(/^[0-9]+$/) != -1)
		return true;
	else
		return false;
}
function noCorto(strCadena,maximo,minimo){//Comprueba la longitud de un campo para ver si está entre max y el minimo
	if (strCadena.length>=minimo && strCadena.length<=maximo)
		return true;
	else
		return false;
}
function esMovil(strNumero){
if (esNumero(strNumero)==true && parseInt(strNumero.charAt(0))==6 && noCorto(strNumero,9,9)==true)
	return true;
else 
	return false;
}
function esFijo(strNumero){
if (esNumero(strNumero)==true && (parseInt(strNumero.charAt(0))==9 || parseInt(strNumero.charAt(0))==8) && noCorto(strNumero,9,9)==true)
	return true;
else 
	return false;
}
function noVacio(strVacio){//Comprueba que un campo no esté vacio
	if (strVacio!="" && strVacio!=" ")
		return true;
	else
		return false;
}

function estaCheck(campo){//Comprueba el valor de un checkbox
	if (campo.checked==true)
		return true;
	else
		return false;
}
function calcularnif(dni) {
	letras = ["T", "R", "W", "A", "G", "M", "Y", "F", "P", "D", "X", "B", "N", "J", "Z", "S", "Q", "V", "H", "L", "C", "K", "E"];
	return letras[dni-(Math.floor(dni/23)*23)];
}
function esNif(miNum) {
	str = miNum;
	miNum = str.substr(0, str.length-1);
	miLetra = str.substr(-1);
	laLetra = calcularnif(miNum);
	if (miLetra.toUpperCase() != laLetra) {
		return false;
	} else {
		return true;
	}
}
function esMayorEdad(fecha) {
	if (esFecha(fecha)){
		bits = fecha.split("/");
		days = parseInt(bits[0]);
		month = parseInt(bits[1]);
		year = parseInt(bits[2]);
		hoy = new Date();
		nac = new Date(year, month, days);
		if (((hoy-nac)/(1000*60*60*24*365))<18) {
			return false;
		} else {
		return true;
		}
	} else {
		return false;
	}
}
function valorRadio(radio){
	aux_radio="";
	for (j=0;j<radio.length;j++){
		if (radio[j].checked==true) aux_radio=radio[j].value;
	}
	return aux_radio;
}
function valorCombo(combo){
	return combo[combo.selectedIndex].value;
}