function tieneDato(campo,leyendaCampo){
	if ((campo.value == null) || (campo.value == "")){
           alert("" + leyendaCampo + " es necesario");
           campo.selected = true;
           campo.focus();
           return false;
        }
    else return true;
}

function cumpleLongitud(campo,leyendaCampo,longitud){
    if (campo.value.length != longitud){
           alert("El campo " + leyendaCampo + " debe ser de longitud " + longitud );
           campo.selected = true;
           campo.focus();
           return false;
        }
    else return true;
}

function validaLongitudPass(campo,leyendaCampo,longitudmin, longitudmax){
    if ((campo.value.length < longitudmin) || (campo.value.length > longitudmax)){
           alert("El campo " + leyendaCampo + " debe ser de minimo " + longitudmin + " y maximo " + longitudmax + " caracteres");
           campo.selected = true;
           campo.focus();
           return false;
        }
    else return true;
}

function soloNumeros(campo,leyendaCampo){
    var checkOK = "0123456789"; 
    var checkStr = campo.value; 
    var allValid = true; 
    var decPoints = 0; 
    var allNum = ""; 
    for (i = 0; i < checkStr.length; i++) 
    { 
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++) 
            if (ch == checkOK.charAt(j))
                break; 
            if (j == checkOK.length)
            { 
                allValid = false; 
                break; 
            } 
            allNum += ch; 
        }
        if (!allValid) { 
            alert("Solo se aceptan numeros en \""+leyendaCampo+"\".");
        campo.focus(); 
        return false; 
    }
    return true;
}

function checaCero(campo,leyendaCampo){
    if (campo.value == 0){
           alert(""+leyendaCampo+" es necesario");
           campo.focus();
           return false;
        }
    else return true;
}

function echeck(str,leyendaCampo) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert(""+leyendaCampo+" incorrecto");
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(""+leyendaCampo+" incorrecto");
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(""+leyendaCampo+" incorrecto");
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(""+leyendaCampo+" incorrecto");
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(""+leyendaCampo+" incorrecto");
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(""+leyendaCampo+" incorrecto");
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(""+leyendaCampo+" incorrecto");
		    return false
		 }

 		 return true					
	}

function checaEmail(campo,leyendaCampo){
	var emailID=campo
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert(""+leyendaCampo+" incorrecto");
		emailID.focus()
		return false
	}
	if (echeck(emailID.value,leyendaCampo)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
