// JavaScript Document

function valida(){
	usuario = document.forms[0].txt_usuario.value;
	password = document.forms[0].txt_password.value;
	usuario = allTrim(usuario);
	password = allTrim(password);
	if (usuario.length == 0){ 
		alert('El campo usuario no puede estar vacio');
		return false;
	}else{
		if (Simbolo(usuario) == true){
				alert("Los caracteres ' / \\ ; : no pueden ser introducidos en el campo usuario");
				return false;
		}
	}
	if (password.length == 0){ 
		alert('El campo clave no puede estar vacio');
		return false;
	}else{
		if (Simbolo(password) == true){
			alert("Los caracteres ' / \\ ; : no pueden ser introducidos en el campo clave");
			return false;
		}
	}
	
	document.forms[0].password2.value = hex_sha1(password);
	return true;
}
function Simbolo(aux){
	if (aux.indexOf("'") != -1){return true;}
	if (aux.indexOf(";") != -1){return true;}
	if (aux.indexOf("/") != -1){return true;}
	if (aux.indexOf("\\") != -1){return true;}
	if (aux.indexOf(":") != -1){return true;}
	return false;
}
function lTrim(sStr){ 
     while (sStr.charAt(0) == " ") 
     sStr = sStr.substr(1, sStr.length - 1); 
     return sStr; 
} 
function rTrim(sStr){ 
     while (sStr.charAt(sStr.length - 1) == " ") 
     sStr = sStr.substr(0, sStr.length - 1); 
     return sStr; 
} 
function allTrim(sStr){ 
     return rTrim(lTrim(sStr)); 
} 

