﻿// Generic functions
// by WR may 2008


function LoginFormCheckFields(ln, pw) {
    var lntxt = strtrim(document.getElementById(ln).value);
    var pntxt = strtrim(document.getElementById(pw).value);
    var msg = '';
    if (lntxt.length == 0) {
        alert("Please enter your user name to login.");
        document.getElementById(ln).focus;
        return false;
    }
    
    if (pntxt.length == 0)  {
        alert("Please enter your password to login.");
        document.getElementById(pw).focus;
        return false;
    }
    return true;
}

function strtrim(string)
{
    //Remove leading spaces
    while(string.charAt(0) == " ")
        string = string.substring(1, string.length);
    //Remove trailing spaces
    while(string.charAt(string.length-1) == " ")
        string = string.substring(string, string.length-1);
    return string;
}

function cleartext(o, emptyval) {
    if (o.value == emptyval) {
        o.value="";
    }
}

function restoretext(o, emptyval) {
    if (o.value == "") {
        o.value=emptyval;
    }
}


