function highlightTableRows(tableId) {
    var previousClass = null;
    var table = document.getElementById(tableId);
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i = 0; i < rows.length; i++) {
        rows[i].onmouseover = function() {
            previousClass = this.className;
            this.className += ' over'
        };
        rows[i].onmouseout = function() {
            this.className = previousClass
        };
        rows[i].onclick = function() {
            var cell = this.getElementsByTagName("td")[0];
            if (cell.getElementsByTagName("a").length > 0) {
                var link = cell.getElementsByTagName("a")[0];
                if (link.onclick) {
                    call = link.getAttributeValue("onclick");
                    // this will not work for links with onclick handlers that return false
                    eval(call);
                } else {
                    location.href = link.getAttribute("href");
                }
                this.style.cursor = "wait";
            }
        }
    }
}

// Show the document's title on the status bar
window.defaultStatus = document.title;

// script for dropdowns on queue/assignments pages //
function doSel(obj)
{
    for (i = 1; i < obj.length; i++)
        if (obj[i].selected)
            eval(obj[i].value);
}

// script for popup pages //
var win = null;

function NewWindow(mypage, myname, w, h, scroll) {
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings =
    'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'
    win = window.open(mypage, myname, settings)
}

function selectAllOptions(list) {
    for (var i = 1; i < list.options.length; i++) {
        list.options[i].selected = true;
    }
    list.options[i].selected = false;
    return false;
}

function checkTextAreaSize(input, maxlength) {
    if (input.value.length > maxlength) {
        input.value = input.value.substring(0, maxlength);
    }
}

function acceptDigit(e) {
    var keynum;
    var keychar;
    var numcheck;
    if (window.event) {
        keynum = e.keyCode;
    } else if (e.which) {
        keynum = e.which;
    }
    keychar = String.fromCharCode(keynum);
    numcheck = /\d/;
    return numcheck.test(keychar);
}

function acceptPhoneChar(e) {
    var keynum;
    var keychar;
    var numcheck;
    if (window.event) {
        keynum = e.keyCode;
    } else if (e.which) {
        keynum = e.which;
    }
    keychar = String.fromCharCode(keynum);
    numcheck = /\d/;
    var a = numcheck.test(keychar);
    a = a || keychar == '(';
    a = a || keychar == ')';
    a = a || keychar == '-';
    a = a || keychar == 'x';
    a = a || keychar == '.';
    a = a || keynum < 32;
    a = a || (keynum == null);
    return a;
}
function toggle(item) {
	var target;
	target = document.getElementById(item);
	if (target.style.display == "none") {target.style.display = "block";}
	else {target.style.display="none";}
}
function popnfresh(URL) {
	eval("page" + " = window.open(URL, '" + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 75,top = 75');");
}
function popnfreshExp(URL) {
	eval("page" + " = window.open(URL, '" + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 75,top = 75');");
}