    function validatePwd() {
        var invalid = " "; // Invalid character is a space
        var minLength = 3; // Minimum length
        var pw1 = document.myForm.newpassword.value;
        var pw2 = document.myForm.newpassword2.value;

        if (pw1 == '' || pw2 == '') {
            alert('Please enter your password twice.');
           return false;
        }
// check for minimum length
        if (document.myForm.newpassword.value.length < minLength) {
            alert('Your password must be at least ' + minLength + ' characters long. Try again.');
        return false;
        }
// check for spaces
        if (document.myForm.newpassword.value.indexOf(invalid) > -1) {
            alert("Sorry, spaces are not allowed.");
            return false;
        }
        else {
            if (pw1 != pw2) {
            alert ("You did not enter the same new password twice. Please re-enter your password.");
            return false;
            }
            else {
            return true;
            }
        }
    }


    function confirmDelete(name,id,url){
        if (confirm("Are you sure you want to remove " + name + " from the database. This is not undoable!"))
         {
             document.location=(url + "?action=delete&id=" + id  );

         }
         else {}
    }


rnd.today=new Date()
rnd.seed=rnd.today.getTime()

function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280
	return rnd.seed/(233280.0);
};

function rand(number) {
	return Math.ceil(rnd()*number);
};

function encrypt_email(address) {
	address = address.toLowerCase()
	coded = ""

	unmixedkey = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
	inprogresskey = unmixedkey
	mixedkey=""
	unshuffled = 62
	for (i = 0; i <= 62; i++) {
		ranpos = rand(unshuffled) - 1
		nextchar = inprogresskey.charAt(ranpos)
		mixedkey += nextchar
		before = inprogresskey.substring(0,ranpos)
		after = inprogresskey.substring(ranpos+1,unshuffled)
		inprogresskey = before+after
		unshuffled -= 1
	}
	cipher = mixedkey

	shift = address.length

    for (j=0; j<address.length; j++) {
			if (cipher.indexOf(address.charAt(j)) == -1 ) {
				chr = address.charAt(j)
				coded += address.charAt(j)
			}
			else {
				chr = (cipher.indexOf(address.charAt(j)) + shift) % cipher.length
				coded += cipher.charAt(chr)
			}
    }

    document.contact.email.value=coded
    document.contact.email_cipher.value=cipher
    }
    
function decrypt_email (coded,key){ 

  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {     
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.contact.email_plaintext.value=link

}

function decrypt_email_aslink (coded,key){ 

  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {     
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.write("<a href='mailto:" + link + "'>" + link + "</a>")

}
