function checkAll(listed)
{
for (i = 0; i < listed.length; i++)
	listed[i].checked = true;
}

function uncheckAll(listed)
{
for (i = 0; i < listed.length; i++)
	listed[i].checked = false;
}


function popitup(url)
{
	newwindow=window.open(url,'name','height=450,width=600,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;

}

function popitup2(url)
{
	newwindow=window.open(url,'name','height=450,width=400,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;

}

function popitup3(url)
{
	newwindow=window.open(url,'name','height=600,width=800,scrollbars=no');
	if (window.focus) {newwindow.focus()}
	return false;

}

function testPassword(password)
{
		var intScore   = 0
		var strVerdict = "weak"
		var strLog     = ""
		
		// PASSWORD LENGTH
		if ((password.length > 0) && (password.length <= 4))        // length 4 or less
  {
    intScore = 2;
    
  }
  else if ((password.length>=5) && (password.length<=7))      // length 5 to 7
  {
    intScore = password.length / 0.6;
  }
  else if ((password.length>=8) && (password.length<=10))     // length 8 to 10
  {
    intScore = (password.length * 1.5) / 0.6;
  }
  else if (password.length >= 11)                           
  {
    intScore = 25;
  } 
		// LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex)
		if (password.match(/[a-z]/))                              // [verified] at least one lower case letter
		{ intScore = (intScore+2) }
		if (password.match(/[A-Z]/))                              // [verified] at least one upper case letter
		{ intScore = (intScore+5) }
		// NUMBERS
		if (password.match(/\d+/))                                 // [verified] at least one number
		{ intScore = (intScore+5) }
		if (password.match(/(.*[0-9].*[0-9].*[0-9])/))             // [verified] at least three numbers
		{ intScore = (intScore+13) }
		// SPECIAL CHAR
		if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))            // [verified] at least one special character
		{ intScore = (intScore+5) }
		// [verified] at least two special characters
		if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
		{ intScore = (intScore+8) }		
		// COMBOS
		if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))        // [verified] both upper and lower case
		{ intScore = (intScore+8) }

		if (password.match(/(\d.*\D)|(\D.*\d)/))                    // [FAILED] both letters and numbers, almost works because an additional character is required
		{ intScore = (intScore+10) }
 
																  // [verified] letters, numbers, and special characters
		if (password.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
		{ intScore = (intScore+13) }
		
		if(intScore < 4)
		{ strVerdict = ""; percentage = 0; }
		if(intScore > 3 && intScore < 16)
		{ strVerdict = "very weak"; percentage = 20; }
		else if (intScore > 15 && intScore < 25)
		{ strVerdict = "weak"; percentage = 40;}
		else if (intScore > 24 && intScore < 35)
		{ strVerdict = "mediocre"; percentage = 60;}
		else if (intScore > 34 && intScore < 75)
		{ strVerdict = "strong";	percentage = 80;}
		else if (intScore > 74 )
		{ strVerdict = "Excellent"; percentage = 100;}
	
	
	//document.forms.passwordForm.score.value = (intScore)
	//document.forms.passwordForm.verdict.value = (strVerdict)
	BarWidth= 100 - percentage;
	document.getElementById("mask").style.left = percentage + "%";
	document.getElementById("mask").style.width = BarWidth + "%";
	document.getElementById("progressIndicator").style.zIndex  = 10;
	document.getElementById("mask").style.display = "block";
	document.getElementById("progressIndicator").innerHTML = strVerdict;
}

function showMatch() {
  strOne = document.getElementById("password").value;
  strTwo = document.getElementById("cpassword").value;

  if ((strOne == "") || (strTwo == "")) {
    document.getElementById("pwMatch").style.display = "none";
    document.getElementById("pwNoMatch").style.display = "none";
    return;
  }

  if (strOne != strTwo) {
    document.getElementById("pwMatch").style.display = "none";
    document.getElementById("pwNoMatch").style.display = "inline";
  } else {
    document.getElementById("pwMatch").style.display = "inline";
    document.getElementById("pwNoMatch").style.display = "none";
  }
}

function doSel(obj)
 {
     for (i = 0; i < obj.length; i++)
        if (obj[i].selected == true)
           eval(obj[i].value);
		 
}

function openPoker(cn,player,password) {pipwin=open("","pipwin","scrollbars=no,width=715,height=510").document.write("<html><title>Texas Holdem</title><frameset rows=* cols=* border=0 frameborder=0><frame noresize scrolling=no src=http://www.pluginpoker.com/popup/lobby.asp?c="+cn+"&phpu="+player+"&phpp="+password+"></frameset></html>");}

