function passwordLevel (p){
	level = 0;
	v1 = 'aeioubcdfghjklmnpqrstvwxyz';
	v2 = 'AEIOU1234567890';
	v3 = 'BCDFGHJKLMNPQRSTVWXYZ';
	v4 = '$@#';
	for (i=0; i < p.length; i++){
		if (v1.indexOf(p.substring(i,i+1)) != -1) level += 1;
		else if (v2.indexOf(p.substring(i,i+1)) != -1) level += 2;
		else if (v3.indexOf(p.substring(i,i+1)) != -1) level += 3;
		else if (v4.indexOf(p.substring(i,i+1)) != -1) level += 9;
		else level += 15;
	}
	level *= 2;
	weight1 = 0;
	weight2 = 0;
	weight3 = 0;
	weight4 = 0;
	for (i=0; i < p.length; i++){
		if (v1.indexOf(p.substring(i,i+1)) != -1) weight1 = 1;
		else if (v2.indexOf(p.substring(i,i+1)) != -1) weight2 = 1;
		else if (v3.indexOf(p.substring(i,i+1)) != -1) weight3 = 1;
		else if (v4.indexOf(p.substring(i,i+1)) != -1) weight4 = 1;
	}
	if((weight1+weight2+weight3+weight4) > 2)
		level *= 2;
	if(level > 100) level = 100;
	return level;
}
	

function passwordLevelTd(password,tdLow,tdMedium,tdHigh,arrayLowSecWords){
	level = passwordLevel(password.value);
	if(arrayLowSecWords.compareNotAllowedArray(password.value))
		level = 40;
		
	if(password.value.length < 6){
		tdLow.style.background = '#fafafa';
		tdLow.style.color = '#cccccc';
		tdMedium.style.background = '#fafafa';
		tdMedium.style.color = '#cccccc';
		tdHigh.style.background = '#fafafa';
		tdHigh.style.color = '#cccccc';		
	}
	else if(level <= 40){
		tdLow.style.background = '#ff0000';
		tdLow.style.color = '#ffffff';
		tdMedium.style.background = '#fafafa';
		tdMedium.style.color = '#cccccc';
		tdHigh.style.background = '#fafafa';
		tdHigh.style.color = '#cccccc';
	}
	else if(level <= 70){
		tdLow.style.background = "#fafafa";
		tdLow.style.color = '#cccccc';
		tdMedium.style.background = "#feb900";
		tdMedium.style.color = '#ffffff';
		tdHigh.style.background = "#fafafa";
		tdHigh.style.color = '#cccccc';
		
	}
	else if(level <= 100){
		tdLow.style.background = "#fafafa";
		tdLow.style.color = '#cccccc';
		tdMedium.style.background = "#fafafa";
		tdMedium.style.color = '#cccccc';
		tdHigh.style.background = "#51a957";
		tdHigh.style.color = '#ffffff';
		
	}
}


Array.prototype.compareNotAllowedArray = function (value){
    var i;
		var regValue = new RegExp(value.toLowerCase()); 

    for (i=0; i < this.length; i++) {
			var regArray = new RegExp(this[i].toLowerCase()); 
        if( (regArray.test(value.toLowerCase()) || regValue.test(this[i].toLowerCase())) && (this[i].length > 5)) {
            return true;
        }
    }
    return false;
};


/* <!-- 
------------------------------------------
xxxxx USAR EN LA HOJA DE ESILOS CSS xxxxx
------------------------------------------
td.passwordSecurity{
	background:#fafafa;
	border:#CCCCCC 1px solid;
	color:#CCCCCC;
	font-family: Tahoma, Arial, sans-serif;
	font-size: 10px;
	font-weight:bold;
}





------------------------------------------
xxxxx USAR EN LA TABLA HTML xxxxx
------------------------------------------
<tr>
	<td><span class="red">*</span><label>Password: </label><br /><br /></td>
	<td>
		{formcat check="notEmpty" field="password" message="The access password must have six characters or more. \\nPlease enter the access password."}
		{formcat check="isLength" field="password" min="6" max="25" message="The access password must have six characters or more. \\nPlease enter the access password."}
		{literal}
		<input type="password" value="" name="password" class="text" maxlength="25" 
		 onkeyup="passwordLevelTd(password,
														 document.getElementById('psl'),
														 document.getElementById('psm'),
														 document.getElementById('psh'),
														 new Array(firstName.value,lastName.value,email.value,
																			 'password'));" />
		{/literal}
		<br />
		<span class="help">Six characters or more; capitalization matters!</span>
	</td>
</tr>	
<tr>
	<td><label>Security Level: </label></td>
	<td>
		<table width="250px" cellpadding="0" cellspacing="0" align="left">
			<tr>
				<td id="psl" width="80px" align="center" class="passwordSecurity">Low</td>
				<td id="psm" width="90px" align="center" class="passwordSecurity">Medium</td>	
				<td id="psh" width="80px" align="center" class="passwordSecurity">High</td>
			</tr>
		</table>
	</td>
</tr>
<tr>
	<td><span class="red">*</span><label>Re-enter password: </label></td>
	<td>
		{formcat check="isEqual" field="retypePassword" field2="password" message="The access password and confirmation are different. Please re-type them"}
		<input type="password" value="" name="retypePassword" class="text" maxlength="25" />
	</td>
</tr>
 -->  */					
