var minLength = 6;
var maxLength = 20;
var noSpecialChars = true;
var isPasswordRequired = true;
var showTip = true;

var strRequired = "Gerekli Alan!";
var strTooShort = "Kısa Şifre!";
var strTooLong = "Uzun Şifre!";
var strSpecialChars = "Güçlü Şifre!";
var strWeak = "Uygun Şifre!";
var strMedium = "Çok Uzun";
var strStrong = "Güçlü Şifre!";

var BackgroundColor = "#141414";
var TextColor = "#FFFFFF"; 
var Width = "81px;"; 
var TextFontFamily = "Verdana";
var TextSize = "10px;";
var TextBold = true;

var tip = 'Şifrenizin '+minLength+' ile '+maxLength+' karakter arasında olması uygundur.';

function SifreDurumGoster(elementToValidate, colortb)
	{	

var validatorStyle = '<style type="text/css"> .pwdvalid { background-color:'+colortb+'; color:'+TextColor+'; width:'+Width+'; font-family:'+TextFontFamily+'; font-size:'+TextSize+';';
if(TextBold)
validatorStyle += 'font-weight: bold;';
validatorStyle +='}</style>';
document.write(validatorStyle);
		
var elm;
if(!(elm = document.getElementById(elementToValidate)))
{
alert('Password Validator could not find your password field identified by id='+elementToValidate);
return;
}
		
var output = '<div align="center" id="_pwdvalid'+elementToValidate+'" class="pwdvalid">&nbsp;</div>';
document.write(output);
		
var oldEventCode = (elm.onkeyup) ? elm.onkeyup : function () {};
elm.onkeyup = function () {oldEventCode(); validatePassword(elm.id)};

oldEventCode = (elm.onmouseout) ? elm.onmouseout : function () {};
elm.onmouseout = function() {oldEventCode(); validatePassword(elm.id)};		
}
	
function validatePassword(elementToValidate) 
{
var elm;
if(!(elm = document.getElementById(elementToValidate)))
{
return;
}
var passwordDiv = document.getElementById("_pwdvalid"+elementToValidate);
var passwordString = elm.value;
if(passwordString.length == 0)
{
passwordDiv.innerHTML = strRequired;
return;
}
if(passwordString.length < minLength)
{
passwordDiv.innerHTML = strTooShort;
return;
}
if(passwordString.length > maxLength)
{
passwordDiv.innerHTML = strTooLong;
return;
}
if(passwordString.match(/\W/))
{
passwordDiv.innerHTML = strSpecialChars;
return;
}			
var strength = 0;
if(passwordString.match(/[a-z]/))
{
strength++;
}
if(passwordString.match(/[A-Z]/))
{
strength++;
}
if(passwordString.match(/\d/))
{
strength++;
}		
switch(strength)
{
case 1: passwordDiv.innerHTML = strWeak;
		displayTip(passwordDiv);
		break;
case 2: passwordDiv.innerHTML = strMedium;
		displayTip(passwordDiv);
		break;
case 3: passwordDiv.innerHTML = strStrong;
		break;
	}				
}
		
function displayTip(div)
{		
	if(showTip)		
	div.innerHTML += '';
}