
window.status = document.title;

if (window.top != window) {
    window.top.location.replace (window.location.href);
}

function popOpen (url, win, width, height) {
    var nWin = window.open (url, win, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height);
    nWin.moveTo (screen.availwidth/2 - (width / 2), screen.availheight/2 - (height / 2));
    nWin.focus ();
}

function popOpenS (url, win, width, height) {
    var nWin = window.open (url, win, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height);
    nWin.moveTo (screen.availwidth/2 - (width / 2), screen.availheight/2 - (height / 2));
    nWin.focus ();
}

function valChar (elmt) {
    var valid = " 0123456789";
    var rtn = true;
    var temp;
    for (var i = 0; i < elmt.value.length; i++) {
        temp = elmt.value.toLowerCase().substring (i, i+1);
        if (valid.indexOf (temp) == -1) {
            rtn = false;
        }
    }
    if (rtn == false) {
        alert (elmt.getAttribute ("errMsg"));
        elmt.focus ();
        elmt.select ();
    }
    return rtn;
}

function valEmail (elmt) {
    if (elmt.value.indexOf ("@") <= -1) {
        alert (elmt.getAttribute ("errMsg"));
        elmt.focus ();
        elmt.select ();
        return false;
    }
    return true;
}

function formValidate (form, fSubmit) {
    for (var i = 0; i < form.elements.length; i++) {
        elmt = form.elements[i];
        if (elmt.type != "button" &&
            elmt.type != "submit" &&
            elmt.type != "hidden" &&
            elmt.getAttribute ("mandatory") == "true") {
            if (elmt.type != "checkbox" &&
                elmt.value == "") {
                alert (elmt.getAttribute ("empMsg"));
                elmt.focus ();
                return false;
            }
            if (elmt.type == "checkbox") {
                if (elmt.checked == false) {
                    alert (elmt.getAttribute ("errMsg"));
                    elmt.focus ();
                    return false;
                }
            }
            if (elmt.getAttribute ("valType") == "number" &&
                valChar (elmt) == false) {
                return false;
            }
            if (elmt.getAttribute ("valType") == "email" &&
                valEmail (elmt) == false) {
                return false;
            }
        }
    }
    fSubmit.disabled = true;
    return true;
}