function validatePwd(pass1,pass2) {
    var invalid = " "; // Invalid character is a space
    var minLength = 6; // Minimum length
    var pw1 = document.getElementById(pass1).value;
    var pw2 = document.getElementById(pass2).value;
    // check for a value in both fields.
    if (pw1 == '' || pw2 == '') {
        alert('Please enter your password twice.');
        return false;
    }
    // check for minimum length
    if (pw1.length < minLength) {
        alert('Your password must be at least ' + minLength + ' characters long. Try again.');
        return false;
    }
    // check for spaces
    if (pw1.indexOf(invalid) > -1) {
        alert("Sorry, spaces are not allowed.");
        return false;
    }

    if (pw1 != pw2) {
        alert ("Passwords do not match.");
        return false;
    }
    return true;

}

function writeSystemMessage(message,level){
    $(document).ready(function(){
   var minHeight = 60;
        $('#system-messages').css('display','block');
        $('#system-messages').css('opacity',1);
        $('#system-messages').append('<p class="level-' + level + '">' + message + '</p>');
        $('body').css('margin-top',minHeight + 'px');
    });
}


function toggleSystemMessages(){
   var minHeight = 60;
   var fullHeight = 200;
   var height = $('#system-messages').css('height');
    height = height.replace(/px/,'',height);

    if (height == minHeight){
        $('#system-messages').css('height',fullHeight + 'px');
        $('body').css('margin-top',fullHeight + 'px');
    }
    else {
        $('#system-messages').css('height',minHeight + 'px');
        $('body').css('margin-top',minHeight + 'px');
    }
}