function EncryptPass(Src1,Src2,Src3)
{
	if (Src2.value == "false" && Src1.value != "")
	{ 
		var tmp_pass = "";
		var tmp_char = "";
		for (var i = 0; i < Src1.value.length; i++) 
		{
			tmp_char = Src1.value.substr(i,1);
			tmp_pass += tmp_char.charCodeAt();
		}
		Src1.value = hex_md5(tmp_pass);
		Src2.value = "true";

		if(Src3 != null)
		{	
			Src3.value = Src1.value;
		}	
	}
}

function ClearPass(Src1,Src2) 
{
	Src1.value = "";
	Src2.value = "false";
}

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) 
{
	var extraChars, firstNumber, firstLower, firstUpper, firstOther;
	var latterNumber, latterLower, latterUpper, latterOther;
	var rc = "";

	extraChars = "";
	firstNumber = true;
	firstLower = true;
	firstUpper = true;
	firstOther = false;
	latterNumber = true;
	latterLower = true;
	latterUpper = true;
	latterOther = false;

	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;
}

function EncryptGeneratedPass(valor)
{
	var tmp_pass = "";
	var tmp_char = "";
	for (var i = 0; i < valor.length; i++) 
	{
		tmp_char = valor.substr(i,1);
		tmp_pass += tmp_char.charCodeAt();
	}
	valor = hex_md5(tmp_pass);
	
	return valor;
}

