// Each string in array == "id","image_file"
var pictParams = new Array(
        "login_over", "img/login_btn_02.gif",
        "login_out", "img/login_btn_01.gif",
        "search_01_over", "img/search_btn_02.gif",
        "search_01_out", "img/search_btn_01.gif",
        "search_02_over", "img/search_btn_04.gif",
        "search_02_out", "img/search_btn_03.gif"
        );

function PreloadImg(params) {
    /* Формирует массив картинок pictArr для анимации меню */
    var doc = document;
    if ((doc.images) && (params)) {
        if (!doc.pictArr) doc.pictArr = new Array();
        for (i = 0; i < (params.length - 1); i += 2) {
            doc.pictArr[params[i]] = new Image;
            doc.pictArr[params[i]].src = params[i + 1];
        }
    }
}

function ChangeImg(obj, id) {
    /* Заменяет картинку в изображении obj на картинку изображения id */
    var doc = document;
    if ((doc.images[obj]) && (doc.pictArr[id])) {
        doc.images[obj].src = doc.pictArr[id].src;
    }
}

function treeExpand(oObj, trname) {
    tr = document.getElementById(trname);
    var d;
    if (tr.style.display == '') {
        d = 'none';
    } else {
        d = '';
    }
    tr.style.display = d;
    return true;
}

function treeExpandImg(oObj, trname) {
    tr = document.getElementById(trname);
    var d, s;
    img = document.getElementById('img_' + trname);
    if (tr.style.display == '') {
        d = 'none';
        s = 'img/submenu_ico_plus.gif';
    } else {
        d = '';
        s = 'img/submenu_ico_minus.gif';
    }
    tr.style.display = d;
    img.src = s;
    return true;
}

function showOnMap(id) {
    var param = '';
    var flag = 0;
    if (id != '') {
        param = id + ';';
        flag++;
    }
    if (flag != 0) {
        window.top.document.frame.jBox.boxoff();
        window.top.document.frame.mapserv.zoomdir.value = 0;
        window.open('map/draw.jsp?id=' + param, null, 'height=600,width=200,status=yes,toolbar=yes,menubar=yes,location=no,left=' + window.screen.availWidth + ',top=' + window.screen.availHeight);
    }
    else {
        alert('Select at least 1 resource');
    }
}

// Adds onmouseover, onmouseout, and onclick handlers to each table row.  The onmouseover handler changes the row's class attribute to
// rowMouseOver.  The onmouseout handler changes it back.  The onclick function makes a request for the specified url, including the
// innerHTML of the specified column as a request parameter.
function addRowHandlers(tableId, rowClassName, paramName, columnIndex) {
    var previousClass = null;
    var table = document.getElementById(tableId);
    var rows = table.getElementsByTagName("tr");
    for (i = 1; i < rows.length; i++) {
        rows[i].onmouseover = function () {
            previousClass = this.className;
            this.className = this.className + " " + rowClassName;
        };

        rows[i].onmouseout = function () {
            if (i%2 == 1)
                this.className = "odd";
            if (i%2 == 0)
                this.className = "even";

        };

        //        rows[i].onclick = function () {
        //            var cell = this.getElementsByTagName("td")[columnIndex];
        //            var paramValue = cell.innerHTML;
        //            location.href = url + "?" + paramName + "=" + paramValue;
        //        };
    }
}

