/**

* USAGE: To implement this script, simply create some
* <DIV> with a fixed width (in pixels) or a table cell
* and give it the following ID attribute:
*    id="passStrength"
* for example:
*    <td id="passStrength">
* Make sure no other elements of the page use this ID.
* Then add the following attribute to your password field:
*    onKeyUp="strongPass(this);"
* for example:
*    <input type="password" onKeyUp="strongPass(this)">
* Finally, add the following to the <HEAD> section of 
* your page:
*    <script language="javascript" src="strongPass.js"
*      type="text/javascript"></script>
* Then you're done!
* 
* @package	turnThePage
* @author	James Socol <me@jamessocol.com>
* @version	1.0
* @date		20 July 2006
*/

function strongPass (input)
{
	var text   = new Array('<div style="width:', '%; background: white; color:#006699; font-weight:bold; font-size:80%; font-family:Verdana">', '</div>');
	var weak   = new Array('25', 'Şifreniz güvensiz!');
	var ok     = new Array('40', 'Şifreniz normal.');
	var strong = new Array('65', 'Şifreniz güvenli.');
	var very   = new Array('100', 'Şifreniz çok güvenli!');
	var error  = '<div style="width:100%; background:#c00; color:#fff; font-weight:bold; font-size:65%; font-family:Tahoma">Error</div>';
	var password = input.value;
	var strength = 0;

	if (password.match(/[a-z]/)) { strength = strength + 10; }
	if (password.match(/[A-Z]/)) { strength = strength + 10; }
	if (password.match(/[0-9]/)) { strength = strength + 10; }
	if (password.match(/[^a-zA-Z0-9]/)) { strength = strength + 10; }
	if (password.length >= 7) { strength = strength + 5; }
	if (password.length >= 8) { strength = strength + 5; }
	if (password.length >= 14) { strength = strength + 10; }
	if (strength <= 25) {
		text = text[0] + weak[0] + text[1] + weak[1] + text[2];
	} else if (strength <= 40) {
		text = text[0] + ok[0] + text[1] + ok[1] + text[2];
	} else if (strength <= 50) {
		text = text[0] + strong[0] + text[1] + strong[1] + text[2];
	} else if (strength <= 60) {
		text = text[0] + very[0] + text[1] + very[1] + text[2];
	} else {
		text = error;
	}
	if (document.getElementById) {
		id = document.getElementById('passStrength');
		id.innerHTML = '';
		id.innerHTML = text;
	} else if (document.all) {
		id = document.all('passStrength');
		id.innerHTML = text;
	}
}
