	function runPassword(str,strfId) {
		var password = str;
		// Get controls
		var ctlBar = document.getElementById(strfId + "_bar"); 
		var ctlText = document.getElementById(strfId + "_text");
		if (!ctlBar || !ctlText)
			return;
		
		var strength = 0;

		// easy_guesses: strings that should not be used in password
		var easy_guesses = new Array();
		easy_guesses.push('password'); // does this need to be localized?
		easy_guesses.push('youtube');

		locase_matches = password.match(/[a-z_]/g); // lowercase and '_' matches
		digit_matches = password.match(/[0-9]/g);   // numeric matches
		upcase_matches = password.match(/[A-Z]/g);  // uppercase matches
		special_matches = password.match(/\W/g);    // special matches (not in a-z, A-Z, 0-9, _)

		if (password.length>5) {
			// for less than 5, leave strength at 0 since password too short

			// 1 point for each character more than 5
			strength += password.length - 5;

			// 1 point for each upcase character mixed with lowercase
			if (locase_matches && upcase_matches)
				strength += upcase_matches.length;

			// 1 point for each numeric character mixed with lowercase
			if (locase_matches && digit_matches)
				strength += digit_matches.length;

			// 1 point for each special characters
			if (special_matches)
				strength += special_matches.length;

			// 2 bonus points if mix of letters, numbers and special
			if ((locase_matches || upcase_matches) && special_matches && digit_matches)
				strength += 2;
		}

		// Reset strength to 0 if any easy guess in password (easy guess should be more than 3 chars)
		for (var i=0; i < easy_guesses.length; ++i) {
			if (easy_guesses[i].length>3 && (password.indexOf(easy_guesses[i])!=-1)) {
				strength=0;
				break;
			}
		}
		
		var nPerc = strength / 15;
		
		var nRound = Math.round(nPerc * 100);
		if (nRound < (str.length * 5)) 
		{ 
			nRound += str.length * 5; 
		}
		if (nRound > 100)
			nRound = 100;
			ctlBar.style.width = nRound + "%";

		// Color and text
		if (strength > 10)
		{
			strText = "Nagyon erős";
			strColor = "#3bce08";
		}
		else if (strength > 7)
		{
			strText = "Erős";
			strColor = "orange";
		}
		else if (strength > 3)
		{
			strText = "Közepes";
			strColor = "#BA9E01";
		}
		else
		{
			strColor = "red";
			strText = "Gyenge";
		}
		ctlBar.style.backgroundColor = strColor;
		ctlText.innerHTML = "<span style='color: " + strColor + ";'>" + strText + "</span>";
		
/*		var pstrength_elem = document.getElementById('password_strength');
		var pstrength_text = document.getElementById('password_strength_text');
		if (password.length==0) {
			pstrength_elem.className = 'password_empty';
			pstrength_text.innerHTML = 'None';
		}
		else if (strength<3) {
			pstrength_elem.className = 'password_weak';
			pstrength_text.innerHTML = 'Weak';
		}
		else if (strength<7) {
			pstrength_elem.className = 'password_fair';
			pstrength_text.innerHTML = 'Fair';
		}
		else if (strength<10) {
			pstrength_elem.className = 'password_good';
			pstrength_text.innerHTML = 'Good';
		}
		else {
			pstrength_elem.className = 'password_strong';
			pstrength_text.innerHTML = 'Strong';
		}*/
	}


// Settings
// -- Toggle to true or false, if you want to change what is checked in the password
var bCheckNumbers = true;
var bCheckUpperCase = true;
var bCheckLowerCase = true;
var bCheckPunctuation = true;
var nPasswordLifetime = 365;

// Check password
function checkPassword(strPassword)
{
	// Reset combination count
	nCombinations = 0;
	
	// Check numbers
	if (bCheckNumbers)
	{
		strCheck = "0123456789";
		if (doesContain(strPassword, strCheck) > 0) 
		{ 
        		nCombinations += strCheck.length; 
    		}
	}
	
	// Check upper case
	if (bCheckUpperCase)
	{
		strCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		if (doesContain(strPassword, strCheck) > 0) 
		{ 
        		nCombinations += strCheck.length; 
    		}
	}
	
	// Check lower case
	if (bCheckLowerCase)
	{
		strCheck = "abcdefghijklmnopqrstuvwxyz";
		if (doesContain(strPassword, strCheck) > 0) 
		{ 
        		nCombinations += strCheck.length; 
    		}
	}
	
	// Check punctuation
	if (bCheckPunctuation)
	{
		strCheck = ";:-_=+\|//?^&!.@$#*()%~<>{}[]";
		if (doesContain(strPassword, strCheck) > 0) 
		{ 
        		nCombinations += strCheck.length; 
    		}
	}
	
	// Calculate
	// -- 500 tries per second => minutes 
    	var nDays = ((Math.pow(nCombinations, strPassword.length) / 500) / 2) / 86400;
 
	// Number of days out of password lifetime setting
	var nPerc = nDays / nPasswordLifetime;
	
	return nPerc;
}
 
// Runs password through check and then updates GUI 
function runPassword2(strPassword, strFieldID) 
{
	// Check password
	nPerc = chkpw(strPassword);
	
	 // Get controls
	var ctlBar = document.getElementById(strFieldID + "_bar"); 
	var ctlText = document.getElementById(strFieldID + "_text");
	if (!ctlBar || !ctlText)
		return;
	
	// Set new width
	var nRound = Math.round(nPerc * 100);
	if (nRound < (strPassword.length * 5)) 
	{ 
		nRound += strPassword.length * 5; 
	}
	if (nRound > 100)
		nRound = 100;
    	ctlBar.style.width = nRound + "%";
 

 	// Color and text
 	if (nRound > 95)
 	{
 		strText = "Nagyon erős";
 		strColor = "#3bce08";
 	}
 	else if (nRound > 75)
 	{
 		strText = "Erős";
 		strColor = "orange";
	}
 	else if (nRound > 50)
 	{
 		strText = "Közepes";
 		strColor = "#BA9E01";
 	}
 	else
 	{
 		strColor = "red";
 		strText = "Gyenge";
 	}
	ctlBar.style.backgroundColor = strColor;
	ctlText.innerHTML = "<span style='color: " + strColor + ";'>" + strText + "</span>";
}
 
// Checks a string for a list of characters
function doesContain(strPassword, strCheck)
 {
    	nCount = 0; 
 
	for (i = 0; i < strPassword.length; i++) 
	{
		if (strCheck.indexOf(strPassword.charAt(i)) > -1) 
		{ 
	        	nCount++; 
		} 
	} 
 
	return nCount; 
} 
 
 
 
 
 


