// recorre el array de checks o radios que se le pasa y devuelve un booleano
// indicando si hay alguno chequeado
function algunoChequeado(ar) {

	var alguno = false

	for(var i=0; i< ar.length;i++) {
		if (ar[i].checked) {
			alguno = true
			break
		}
	}
	
	return alguno
} 

// Chequea si la fecha es válida segun el formato dd/mm/yyyy
function fechaCorrecta(indate) {
	
	if ( indate.length != 10 ) return false
	
    var sdate = indate.split("/")
  
    var chkDate = new Date(Math.abs(sdate[2]),(Math.abs(sdate[1])-1),Math.abs(sdate[0]))

    var cmpDate = (chkDate.getDate())+"/"+(chkDate.getMonth()+1)+"/"+(chkDate.getFullYear())
    var indate2 = (Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]))
    
    if (indate2 != cmpDate || cmpDate == "NaN/NaN/NaN") return false
    else return true;
}


// Función que comprueba si el email es correcto
String.prototype.isEmail = function(){	
	
	if (this.length < 5)	{	return false;	}	
	var iChars = "*|,\":<>[]{}`';()&$#%";	
	var eLength = this.length;	
	for (var i=0; i < eLength; i++)	
	{		
		if (iChars.indexOf(this.charAt(i)) != -1)		
		{			
			return false;		
		}	
	}	
	var atIndex = this.lastIndexOf("@");	
	if(atIndex < 1 || (atIndex == eLength - 1))	{		
		return false;	
	}	
	
	var pIndex = this.lastIndexOf(".");	
	if(pIndex < 4 || (pIndex == eLength - 1))	
	{		
		return false;	
	}	
	if(atIndex > pIndex)	{		
		return false;	
	}	
	return true;

}

// Función que comprueba que no haya @
String.prototype.isARROBA = function(){	
		
	var iChars = "*|,\":<>[]{}`';()&$#%@.";	
	var eLength = this.length;	
	for (var i=0; i < eLength; i++)	
	{		
		if (iChars.indexOf(this.charAt(i)) != -1)		
		{			
			return false;		
		}	
	}	
	return true;

}

String.prototype.isName = function(){	
		
	var iChars = "!*|,\":<>[]{}`';()&$#%@._-0123456789";	
	var eLength = this.length;	
	for (var i=0; i < eLength; i++)	
	{		
		if (iChars.indexOf(this.charAt(i)) != -1)		
		{			
			return false;		
		}	
	}	
	return true;

}

String.prototype.isNumero = function(){	
		
	var iNumero = "qwertyuiopasdfghjklñzxcvbnm_!$%&/()=?¿Ç*^¨ñ;:_:;QWERTYUIOPASDFGHJKLÑZXCVBNM";	
	var eLength = this.length;	
	for (var i=0; i < eLength; i++)	
	{		
		if (iNumero.indexOf(this.charAt(i)) != -1)		
		{			
			return false;		
		}	
	}	
	return true;

}
