/*comment*/
function passwordMeter()
{
return {

	init : function( txtOBJ, grOBJ, s0, s1, s2, s3, s4, s5 )
	{
		this.textOBJ = txtOBJ;
		this.graphOBJ = grOBJ;
		this.str0 = s0;
		this.str1 = s1;
		this.str2 = s2;
		this.str3 = s3;
		this.str4 = s4;
		this.str5 = s5;
	},
	
	testPassword : function( passwd )
	{
		this.score   = 0
		this.realScore = 0;
		this.short = false;
		this.textOBJ.innerHTML = this.str1;
		
		// PASSWORD LENGTH
		if (passwd.length<6)                         // length 4 or less
		{
			this.score = (this.score+3)
			this.short = true;
		}
		else if (passwd.length>4 && passwd.length<8) // length between 5 and 7
		{
			this.score = (this.score+6)
		}
		else if (passwd.length>7 && passwd.length<16)// length between 8 and 15
		{
			this.score = (this.score+12)
		}
		else if (passwd.length>15)                    // length 16 or more
		{
			this.score = (this.score+18)
		}
		
		
		// LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex)
		if (passwd.match(/[a-z]/))                              // [verified] at least one lower case letter
		{
			this.score = (this.score+1)
		}
		
		if (passwd.match(/[A-Z]/))                              // [verified] at least one upper case letter
		{
			this.score = (this.score+5)
		}
		
		// NUMBERS
		if (passwd.match(/\d+/))                                 // [verified] at least one number
		{
			this.score = (this.score+5)
		}
		
		if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))             // [verified] at least three numbers
		{
			this.score = (this.score+5)
		}
		
		
		// SPECIAL CHAR
		if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))            // [verified] at least one special character
		{
			this.score = (this.score+5)
		}
		
									 // [verified] at least two special characters
		if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
		{
			this.score = (this.score+5)
		}
	
		
		// COMBOS
		if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))        // [verified] both upper and lower case
		{
			this.score = (this.score+2)
		}

		if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers
		{
			this.score = (this.score+2)
		}
 
									// [verified] letters, numbers, and special characters
		if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
		{
			this.score = (this.score+2)
		}
	
		if ( this.short == true )
		{
			this.realScore = 0;
			this.textOBJ.innerHTML = this.str0;
		}
		else if(this.score < 16)
		{
			this.realScore = 20;
			this.textOBJ.innerHTML = this.str1;
		}
		else if (this.score > 15 && this.score < 25)
		{
			this.realScore = 40;
			this.textOBJ.innerHTML = this.str2;
		}
		else if (this.score > 24 && this.score < 35)
		{
			this.realScore = 60;
			this.textOBJ.innerHTML = this.str3;
		}
		else if (this.score > 34 && this.score < 45)
		{
			this.realScore = 80;
			this.textOBJ.innerHTML = this.str4;
		}
		else
		{
			this.realScore = 100;
			this.textOBJ.innerHTML = this.str5;
		}
		//
		var px = this.realScore * 2;
		if ( px > 200 ) px = 200;
		//
		this.graphOBJ.display = px >= 200 ? 'none' : '';
		this.graphOBJ.style.paddingLeft = px + 'px';
		this.graphOBJ.style.width = (200-px) + 'px';
		//
	}
};
}

