/**************************************************************************
* Jelszó Elemző - passwordanalyzer.js                                     *
* ======================================================================= *
* Megállapítja a begépelt jelszó erősségét, biztonságát.                  *
* ----------------------------------------------------------------------- *
* Analyzes the strenght and security of the typed password.               *
* ======================================================================= *
* Ezt a programot a PHP Studio fejlesztette, a szerzők: / This program    *
* was developed by the PHP Studio, the authors:                           *
* Warner                                                                  *
* ----------------------------------------------------------------------- *
* Weboldalunk / Our webpage: http://www.phpstudio.hu                      *
* Segítségnyújtás / HelpDesk: http://forum.phpstudio.hu                   *
* Kapcsolat / Contact: support@phpstudio.hu                               *
* ======================================================================= *
* Ez a program license alatt áll, amit itt tekinthetsz meg: / This        *
* program is under a license, which you can see here:                     *
* http://license.phpstudio.hu                                             *
* ----------------------------------------------------------------------- *
* A license-szel kapcsolatos észrevételeid, megjegyzéseid, kérdéseid  a   *
* license@phpstudio.hu e-mail címen várjuk.                               *
* ----------------------------------------------------------------------- *
* You can send your remarks, opinions, questions to the following e-mail  *
* address: license@phpstudio.hu                                           *
* ======================================================================= *
* Dátum / Date: 2008. 02. 20.                                             *
**************************************************************************/

function analyzePassword(passwdfield, strengthdiv)
	{
	var div;
	if((div = document.getElementById(strengthdiv)) != null)
		{
		var level = 0;
		var length = passwdfield.value.length;
		var lowletters = false;
		var upletters = false;
		var digits = false;
		var specials = false;
		var abc = "aábcdeéfghiíjklmnoóöőpqrstuúüűvwxyz";
		var numbers = "0123456789";	
		if(length > 0)
			{			
			for(var i = 0; i < length; i++)
				{
				if(abc.indexOf(passwdfield.value.charAt(i)) >= 0)
					lowletters = true;
				else if(abc.toUpperCase().indexOf(passwdfield.value.charAt(i)) >= 0)
					upletters = true;
				else if(numbers.indexOf(passwdfield.value.charAt(i)) >= 0)
					digits = true;
				else
					specials = true;
				}
			level = lowletters + upletters + digits + specials;
			if(length >= 4)
				{
				level++;
				if(length >= 8)
					level++;
				}
			}
			switch(level)
				{
				case 1:
					var strengthtxt = '<span style="color: #33CC33; font-weight: bold; font-size: 11px;">Katasztrófális</span>';
					break;
				case 2:
					var strengthtxt = '<span style="color: #339933; font-weight: bold; font-size: 11px;">Egyszerű</span>';
					break;
				case 3:
					var strengthtxt = '<span style="color: #336633; font-weight: bold; font-size: 11px;">Gyenge</span>';
					break;
				case 4:
					var strengthtxt = '<span style="color: #336699; font-weight: bold; font-size: 11px;">Átlagos</span>';
					break;
				case 5:
					var strengthtxt = '<span style="color: #FF6633; font-weight: bold; font-size: 11px;">Erős</span>';
					break;
				case 6:
					var strengthtxt = '<span style="color: #CC3333; font-weight: bold; font-size: 11px;">Biztonságos</span>';
					break;
				default:
					var strengthtxt = '<span style="color: #000000; font-weight: bold; font-size: 11px;">Jelszóerősség</span>';
					break;
				}
			div.innerHTML = strengthtxt;
		}
	}
