function colorRow(elem, clr) {
    var theCells = null;
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = elem.getElementsByTagName('td');
    } else if (typeof(elem.cells) != 'undefined') {
        theCells = elem.cells;
    } else {
        return false;
    }
    var rowCellsCnt  = theCells.length;
    for (c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = clr;
    }
}
function elemOver(elem, clr, tclr) {
    elem.style.backgroundColor = clr;
    elem.style.cursor = 'pointer';
    elem.style.color = tclr;
}
function elemOut(elem, clr, tclr) {
    elem.style.backgroundColor = clr;
    elem.style.color = tclr;
}
function newWindow(mypage,myname,w,h,features) {
    if(screen.width){
        var winl = (screen.width-w)/2;
        var wint = (screen.height-h)/2;
    } else {
        winl = 0;
        wint =0;
    }
    if (winl < 0) winl = 0;
    if (wint < 0) wint = 0;
    var settings = 'height=' + h + ',';
    settings += 'width=' + w + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    settings += features;
    win = window.open(mypage,myname,settings);
    win.window.focus();
}

var req;
var div_name;
var div_display;
var post_script;
function load(url, d_name, form_name, d_display, p_script, div_loading) { // DOES NOT WORK WITH FILE UPLOADS
    div_name = d_name;
    div_display = d_display;
    post_script = p_script;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (req) {
        var p = '';
        if (form_name) {
            var myform = document[form_name];
            req.open("POST", url, true);
            req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            req.setRequestHeader("contenttype", "multipart/form-data");
            req.setRequestHeader("enctype", "multipart/form-data");
            req.setRequestHeader("postmode", "multipart form");
            var is_first = true;
            for (var i=0; i<myform.length; i++) {
                if (!is_first) p += '&';
                else is_first = false;
                p += myform[i].name + '=' + encodeURIComponent(myform[i].value);
            }
        }
        if (d_name) { // rewrite div AFTER loading values from the form, in case the form was inside the div!
            req.onreadystatechange = processReqChange;
            if (div_loading) {
                document.getElementById(d_name).style.display = 'block';
                document.getElementById(d_name).innerHTML = '<font class=notes>Loading...</font>';
            }
        }
        if (form_name) {
            req.send(p);
        } else {
            req.open("GET", url, true);
            req.send(null);
        }
    }
}

function processReqChange() {
    if (req.readyState == 4) {
        if (req.status == 200) {
            if (div_display) document.getElementById(div_name).style.display = 'block';
            document.getElementById(div_name).innerHTML = req.responseText;
            if (post_script) eval(post_script);
        } else {
            alert('There was a problem retrieving the XML data:\n' + req.statusText);
        }
    }
}