<!--
	//SCRIPT PARA GERAR SENHA ALEATÓRIA
	//Exemplo de chamada para gerar senha com 10 caracteres: getPassword(10);	
	
	function setAutoSenha(campoSenha,campoConfSenha,numChars){
		objSenha = document.getElementById(campoSenha);
		objConfSenha = document.getElementById(campoConfSenha);
		if (objSenha != null && objConfSenha != null){
			novaSenha = getPassword(numChars);	
			//alert(novaSenha);
			objSenha.value = novaSenha;
			objConfSenha.value = novaSenha;
		}
	}
	
	function getRandomNum(lbound, ubound) {
		return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
	}
	
	function getRandomChar(number, lower, upper, other, extra) {
		var numberChars = "0123456789";
		var lowerChars = "abcdefghijklmnopqrstuvwxyz";
		var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
		var charSet = extra;
		if (number == true)
		charSet += numberChars;
		if (lower == true)
		charSet += lowerChars;
		if (upper == true)
		charSet += upperChars;
		if (other == true)
		charSet += otherChars;
		return charSet.charAt(getRandomNum(0, charSet.length));
	}
	
	function getPassword(length) {
		extraChars = false;
		firstLower = false;
		firstUpper = true;
		firstOther = false;
		firstNumber = true;//primeiro caractere deve ser numérico
		latterNumber = true;//pode conter outros números
		latterLower = false;//não deve conter letra minúscula
		latterUpper = false;//não deve conter letra maiúscula
		latterOther = false;//não deve conter caracteres especiais		
		var rc = "";
		if (length > 0)
		rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
		for (var idx = 1; idx < length; ++idx) {
			rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
		}
		return rc;
	}
	
// -->
