
	/*
		stringTool uServers: Checador de strings varias en JS
	*/
	
	// $URBANO_VERSION = "2.480";
	
	function stringTool() {
		this.Error = false;
		this.Error_History = Array();
	}
	
	stringTool.prototype = new uObject();
	
	stringTool.prototype.setError = function(error) {
		if(this.Error) { this.Error_History.push(this.Error); }
		this.Error = error;
		return false;
	}
	
	stringTool.prototype.Redondea = function(numero, digitos) {
		// #uDOC:TITLE Redondea
		// #uDOC:DESCR Redondea un numero a ciertos decimales
		
		if(digitos == undefined) { digitos = 2; }
		
		if (digitos > 0) {
			
			// Adicion cerdo: Si no vienen ceros. Agrega
			if(numero.toString().lastIndexOf(".") == -1) {
				numero = numero.toString() + ".";
				for(var i=0; i<digitos; i++) { numero = numero + "0"; }
				return numero;
			}
			
			if ((numero.toString().length - numero.toString().lastIndexOf(".")) > (digitos + 1)) {
				// Para redondear, sube el numero a la ^Digitos potencia, redondea y luego divdide
				
				var potencia = Math.pow(10, digitos);
				resultado = Math.round(numero * potencia) / potencia;
				
				// Verifica que tenga los digitos que pedimos:
				var adigitos = (resultado.toString().length - resultado.toString().lastIndexOf(".")) - 1;
				
				if(adigitos < digitos) {
					for(i=adigitos; i<digitos; i++) { resultado = resultado + "0"; }
				}
				
				return resultado;
				
				
			} else {
				
				adigitos = (numero.toString().length - numero.toString().lastIndexOf(".")) - 1;						
				for(i=adigitos; i<digitos; i++) { 
					numero = numero + "0";
				}
				
				return numero;
			}
		} else return Math.round(numero);
		
	}
	
	stringTool.prototype.esNombreCompleto = function(estringu) {
		//#uDOC:TITLE esNombreCompleto
		//#uDOC:DESCR Indica si una string es un nombre completo o no
		
		if(estringu.match(/\S+\s+\S+/)) { return true; }
		else { return false; }
	}
		
	stringTool.prototype.esTelefono = function(estringu) {
		//#uDOC:TITLE esTelefono
		//#uDOC:DESCR Indica si una string parece como un numero de telefono
		
		if(estringu.match(/^[-0-9\(\)\.\s+]+$/)) { return true; }
		else { return false; }
	}
		
	stringTool.prototype.esMailValido = function(estringu) {
		//#uDOC:TITLE esMailValido
		//#uDOC:DESCR Indica si una string es una direccion de mail valida
		
		if(estringu == undefined) { return false; }
		if(! estringu.match) { return false; }
		if(estringu.match(/^[-a-z0-9._]+@[-a-z0-9\.]+.[a-z]{2,8}$/i)) { return true; }
		else { return false; }
	}
	
	stringTool.prototype.checkPassword = function(passwdstring) {
		// #uDOC:TITLE checkPassword
		// #uDOC:DESCR Regresa true si es un password bueno
		if(passwdstring.match(/^\d+$/)) { alert("La clave de la cuenta no pueden ser solo numeros"); return false; }
		if(passwdstring.length <= 4) { alert("La clave de la cuenta tiene que ser mayor a 4 caracteres"); return false; }
	
		return true;
		
	}
	
	stringTool.prototype.checkMailAddress = function(mailstring) {
		// #uDOC:TITLE checkMailAddress
		// #uDOC:DESCR Verifica suna string es una direccion de mail correcta
		return this.esMailValido(mailstring);
	}
	
	stringTool.prototype.checkUserIdent = function(identificador) {
		// #uDOC:TITLE checkUserIdent
		// #uDOC:DESCR Checa si una string es un identificador de3 user valido
		
	}
	
	stringTool.prototype.checkDomainName = function(name) {
		// #uDOC:TITLE checkDomainName
		// #uDOC:DESCR Checasi una string es un dominio valido
		
		if(name.match(/^[-\.a-z0-9]+\.[a-z]{2,8}$/i)) { return true; }
		else { return false; }
	}
	
	
	
	
