﻿/**
* @fileoverview 定义了客户端对象序列化代表图层列表的Tree类和图层列表功能的TOCPage类
* @version 1.0
*/
/** **************************************************************** */
/*                                                                 */
/* 参 数 */
/*                                                                 */
/** **************************************************************** */
var closedImgURL = "images/toc/icon_closed.gif";
var openedImgURL = "images/toc/icon_opened.gif";
var layerImgURL = "images/toc/icon_layer.gif";
var checkBoxVisibleImgURL = "images/toc/iconCheckAll.gif";
var checkBoxCurNotVisibleImgURL = "images/toc/icon_visscale.gif";
var checkBoxHiddenImgURL = "images/toc/iconUnCheckAll.gif";
var checkBoxTristateURL = "images/toc/icon_tristate.gif";
var radioSelectedImgURL = "images/toc/icon_active.gif";
var radioUnselectedImgURL = "images/toc/icon_inactive.gif";
var iconChild = "images/toc/icon_child.gif";
var iconChildLast = "images/toc/icon_childlast.gif";
var iconSibling = "images/toc/icon_sibling.gif";
var iconBlank = "images/toc/icon_blank.gif";
var legendFolder = "images/toc/legend/";
TOPTAG = "MAPDOCUMENT";
// MAPTAG = "DATAFRAME";
MAPTAG = "Toc";
LAYERGROUPTAG = "GROUPLAYER";
LAYERTAG = "Layer";
LEGENDGROUPTAG = "LEGENDGROUP";
LEGENDTAG = "LEGEND";

var lastDomObj;
var lastImgObj;
var lastTextObj;
//全局变量记录显示的图层id
var vLayerIds = new Array();
/** **************************************************************** */
/*                                                                 */
/* TOC 树 */
/*                                                                 */
/** **************************************************************** */

/**
* 创建Tree对象，Tree对象包括父节点和子节点，每个节点代表图层列表中的一个节点,读取Dom文档
* 
* @class
* @constructor
* @param {XMLNode}
*            node xml节点
* @param {Tree}
*            parent 父节点
* @param {bool}
*            isClosed 是否关闭
* @param {bool}
*            isSelected 是否被选中
*/
function Tree(node, parent, isClosed, isSelected) {
    this.node = node;
    this.childs = new Array();
    this.parent = parent;
    this.isClosed = isClosed;
    this.isSelected = isSelected;
    this.HtmlEntity = null;

    if (node.hasChildNodes()) {
        for (var i = 0; i < node.childNodes.length; i++) {
            if (node.childNodes.item(i).nodeName != "#text") {
                // if (node.childNodes.item(i).getAttribute("id") != null) {
                this.childs[i] = new Tree(node.childNodes.item(i), this, true,
						false);
                // }
            }
        }
    }
}

Tree.prototype.toHtmlElement = toHtmlElement;
Tree.prototype.openClose = openClose
Tree.prototype.getLayerVisibleStatusPic = getLayerVisibleStatusPic;
Tree.prototype.getGLayerVisibleStatusPic = getGLayerVisibleStatusPic;
Tree.prototype.getglyvisiblesta = getglyvisiblesta;
Tree.prototype.getlyvisible = getlyvisible;
Tree.prototype.setVisible = setVisible;
Tree.prototype.setSelected = setSelected;

Tree.prototype.refreshScale = refreshScale;

/**
* 将 DOM对象序列化为HTML页面对象
*/
function toHtmlElement() {
    var obj = this;
    var type = this.node.tagName;

    if (type != null && type != "Legend") {
        var id = this.node.getAttribute("id");
        var e = document.createElement("div");
        e.setAttribute("id", id);
        e.setAttribute("type", type);
        var text1 = document.createElement("A");
        text1.style.margin = "0px 0px 0px 0px";
        text1.style.fontColor = "black";
        text1.style.height = "16px";
        text1.style.fontSize = "9pt";
        text1.style.cursor = "pointer";
        text1.target = "_blank";
        text1.style.position = "absolute";

        var imgCheckBox = document.createElement("img");
        var imgCloseorOpen = document.createElement("img");
        imgCloseorOpen.setAttribute("id", "closeopen");
        imgCloseorOpen.src = this.isClosed ? closedImgURL : openedImgURL;

        if (type == MAPTAG) {
            imgCloseorOpen.onclick = function() {
                G_TOC.tree.openClose(obj, this);
            };

            text1.innerHTML = this.node.getAttribute("name");
            text1.onclick = function() {
                G_TOC.tree.openClose(obj, imgCloseorOpen);
            };

            e.style.width = "100%";
            e.style.height = "100%";
            e.style.overflow = "auto";
            e.appendChild(imgCloseorOpen);
            e.appendChild(text1);

            for (var i = 0; i < obj.childs.length; i++) {
                e.appendChild(obj.childs[i].toHtmlElement());
            }
        } else if (type == LAYERGROUPTAG) {
            //imgCheckBox.src = this.getLayerVisibleStatusPic(G_Map, obj);
            var sta = this.getglyvisiblesta(obj.node);
            imgCheckBox.src = this.getGLayerVisibleStatusPic(sta);
            imgCheckBox.onclick = function() {
                G_TOC.tree.setVisible(obj, this);
            };
            imgCheckBox.setAttribute("id", "checkbox");

            imgCloseorOpen.onclick = function() {
                G_TOC.tree.openClose(obj, this);
            };

            text1.innerHTML = this.node.getAttribute("name");
            text1.onclick = function() {
                G_TOC.tree.openClose(obj, imgCloseorOpen);
            };

            e.appendChild(imgCloseorOpen);
            e.appendChild(imgCheckBox);
            e.appendChild(text1);
            for (var i = 0; i < obj.childs.length; i++) {
                var subdiv = obj.childs[i].toHtmlElement();
                if (this.isClosed) {
                    subdiv.style.display = "none";
                } else {
                    subdiv.style.display = "block";
                }
                e.appendChild(subdiv);
            }

            // 树状连接线
            var lastObj = imgCloseorOpen;
            var thisNode = obj;
            var pareNode = obj.parent;

            var level = 0;
            while (pareNode != null) {
                var imgLine = document.createElement("img");

                imgLine.src = iconChild;
                if (level == 0) {
                    if (thisNode == pareNode.childs[pareNode.childs.length - 1]) {
                        imgLine.src = iconChildLast;
                    }
                } else {
                    if (thisNode == pareNode.childs[pareNode.childs.length - 1]) {
                        imgLine.src = iconBlank;
                    } else {
                        imgLine.src = iconSibling;
                    }
                }

                e.insertBefore(imgLine, lastObj);
                lastObj = imgLine;

                thisNode = pareNode;
                pareNode = pareNode.parent;

                level++;
            }
        } else if (type == LAYERTAG) {
            // 表示图层的标签， 图层不能展开
            imgCloseorOpen.src = layerImgURL;
            imgCloseorOpen.onclick = null;

            // 显示图层是否可见的复选框
            //alert(obj.node.getAttribute("visibility"));
            imgCheckBox.src = this.getLayerVisibleStatusPic(obj);
            imgCheckBox.onclick = function() {
                G_TOC.tree.setVisible(obj, this);
            };
            imgCheckBox.setAttribute("id", "checkbox");


            // 图层名称显示值
            text1.innerHTML = this.node.getAttribute("name");
            text1.onclick = function() {
                G_TOC.tree.setSelected(obj, imgRatioBox, this);
            };

            e.appendChild(imgCloseorOpen);
            e.appendChild(imgCheckBox);
            e.appendChild(text1);

            // 树状连接线
            var lastObj = imgCloseorOpen;
            var thisNode = obj;
            var pareNode = obj.parent;

            var level = 0;
            while (pareNode != null) {
                var imgLine = document.createElement("img");

                imgLine.src = iconChild;
                if (level == 0) {
                    if (thisNode == pareNode.childs[pareNode.childs.length - 1]) {
                        imgLine.src = iconChildLast;
                    }
                } else {
                    if (thisNode == pareNode.childs[pareNode.childs.length - 1]) {
                        imgLine.src = iconBlank;
                    } else {
                        imgLine.src = iconSibling;
                    }
                }

                e.insertBefore(imgLine, lastObj);
                lastObj = imgLine;

                thisNode = pareNode;
                pareNode = pareNode.parent;

                level++;
            }

            // 只有一个图例，直接显示在图层名称前
            if (this.node.childNodes != null) {
                if (this.node.childNodes.length == 1) {
                    var legendImg = document.createElement("img");
                    legendImg.setAttribute("id", "legend");
                    var url = this.node.childNodes.item(0).getAttribute("url");
                    legendImg.setAttribute("src", url);
                    e.insertBefore(legendImg, imgRatioBox);
                } else if (this.node.childNodes.length > 1) {
                    // 判断当前图层所处的深度
                    imgCloseorOpen.onclick = function() {
                        for (var i = 0; i < obj.HtmlEntity.childNodes.length; i++) {
                            var subnode = obj.HtmlEntity.childNodes[i];
                            if (subnode.tagName == "DIV") {
                                subnode.style.display = subnode.style.display == "none"
										? "block"
										: "none";
                            }
                        }
                    }
                    var subdiv = document.createElement("div");
                    subdiv.setAttribute("id", id);
                    subdiv.style.display = "none";
                    for (var li = 0; li < this.node.childNodes.length; li++) {
                        var legdiv = document.createElement("div");
                        legdiv.style.display = "block";

                        var legendImg = document.createElement("img");
                        legendImg.setAttribute("id", "legend");
                        var url = legendFolder
								+ this.node.childNodes.item(li)
										.getAttribute("url");
                        legendImg.setAttribute("src", url);

                        var legendText = document.createElement("A");
                        legendText.innerHTML = this.node.childNodes.item(li)
								.getAttribute("label")
                        legendText.style.margin = "0px 0px 0px 0px";
                        legendText.style.fontColor = "black";
                        legendText.style.height = "16px";
                        legendText.style.fontSize = "9pt";
                        legendText.target = "_blank";
                        legendText.style.position = "absolute";

                        for (var lj = 0; lj < level + 1; lj++) {
                            var imgLine = document.createElement("img");
                            imgLine.src = iconBlank;
                            legdiv.appendChild(imgLine);
                        }

                        legdiv.appendChild(legendImg);
                        legdiv.appendChild(legendText);

                        subdiv.appendChild(legdiv);
                    }
                    e.appendChild(subdiv);
                }
            }
        }

        obj.HtmlEntity = e;
        return e;
    }

}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getGLayerVisibleStatusPic(vsta) {
    if (vsta == 1) {
        return checkBoxVisibleImgURL;
    }
    else if (vsta == 2) {
        return checkBoxTristateURL;
    }
    else {
        return checkBoxHiddenImgURL;
    }
}
function getglyvisiblesta(domobj) {
    var tsta;
    for (var i = 0; i < domobj.childNodes.length; i++) {
        if (i == 0) {
            if (domobj.childNodes.item(i).tagName == LAYERGROUPTAG) {
                //alert(domobj.childNodes.item(i).getAttribute("name"));
                var m = getglyvisiblesta(domobj.childNodes.item(i));
                if (m == 2) {
                    domobj.childNodes.item(i).setAttribute("visibility", "false");
                    domobj.setAttribute("visibility", "false");
                    return 2;
                }
                else if (m == 3) {
                    tsta = false;
                    domobj.childNodes.item(i).setAttribute("visibility", "false");
                }
                else if (m == 1) {
                    tsta = true;
                    domobj.childNodes.item(i).setAttribute("visibility", "true");
                }
            }
            else {
                tsta = this.getlyvisible(domobj.childNodes.item(i));
            }
        }
        else {
            if (domobj.childNodes.item(i).tagName == LAYERGROUPTAG) {
                var m = getglyvisiblesta(domobj.childNodes.item(i));
                if (m == 2) {
                    domobj.childNodes.item(i).setAttribute("visibility", "false");
                    domobj.setAttribute("visibility", "false");
                    return 2;
                }
                else if (m == 3) {
                    tsta = tsta && false;
                    domobj.childNodes.item(i).setAttribute("visibility", "false");
                }
                else if (m == 1) {
                    tsta = tsta && true;
                    domobj.childNodes.item(i).setAttribute("visibility", "true");
                }
            }
            else {
                tsta = tsta && this.getlyvisible(domobj.childNodes.item(i));
            }
        }
    }
    if (tsta) {
        domobj.setAttribute("visibility", "true");
        return 1;
    }
    else {
        var tsta1;
        for (var i = 0; i < domobj.childNodes.length; i++) {
            if (i == 0) {
                if (domobj.childNodes.item(i).tagName == LAYERGROUPTAG) {
                    var m = getglyvisiblesta(domobj.childNodes.item(i));
                    if (m == 2) {
                        domobj.childNodes.item(i).setAttribute("visibility", "false");
                        domobj.setAttribute("visibility", "false");
                        return 2;
                    }
                    else if (m == 3) {
                        domobj.childNodes.item(i).setAttribute("visibility", "false");
                        tsta1 = false;
                    }
                    else if (m == 1) {
                        domobj.childNodes.item(i).setAttribute("visibility", "true");
                        tsta1 = true;
                    }
                }
                else {
                    tsta1 = this.getlyvisible(domobj.childNodes.item(i));
                }
            }
            else {
                if (domobj.childNodes.item(i).tagName == LAYERGROUPTAG) {
                    var m = getglyvisiblesta(domobj.childNodes.item(i));
                    if (m == 2) {
                        domobj.childNodes.item(i).setAttribute("visibility", "false");
                        domobj.setAttribute("visibility", "false");
                        return 2;
                    }
                    else if (m == 3) {
                        domobj.childNodes.item(i).setAttribute("visibility", "false");
                        tsta1 = tsta1 || false;
                    }
                    else if (m == 1) {
                        domobj.childNodes.item(i).setAttribute("visibility", "true");
                        tsta1 = tsta1 || true;
                    }
                }
                else {
                    tsta1 = tsta1 || this.getlyvisible(domobj.childNodes.item(i));
                }

            }
        }
        if (tsta1) {
            domobj.setAttribute("visibility", "false");
            return 2;
        }
        else {
            domobj.setAttribute("visibility", "false");
            return 3;
        }
    }
}

function getlyvisible(domobj) {
    var isVisible = domobj.getAttribute("visibility");

    if (isVisible == "true")

        return true;

    else

        return false;
}

/**
* 控制图层的关闭
* 
* @param {HtmlElement}
*            obj 页面元素
* @author wbz
*/

function openClose(domobj, imgobj) {
    domobj.isClosed = !domobj.isClosed;
    imgobj.src = domobj.isClosed ? closedImgURL : openedImgURL;

    for (var i = 0; i < domobj.HtmlEntity.childNodes.length; i++) {
        var subnode = domobj.HtmlEntity.childNodes[i];
        if (subnode.tagName == "DIV") {
            subnode.style.display = (!domobj.isClosed ? "block" : "none");
        }
    }
}

function setSelected(domobj, imgobj, textobj) {
    if (lastDomObj != null && lastDomObj != domobj) {
        lastDomObj.isSelected = false;
        lastImgObj.src = radioUnselectedImgURL;
        lastTextObj.style.backgroundColor = "white";
    }
    if (domobj.isSelected) {
        return;
    } else {
        domobj.isSelected = true;
    }

    if (imgobj != null) {
        imgobj.src = domobj.isSelected
				? radioSelectedImgURL
				: radioUnselectedImgURL;
        G_TOC.curNode = domobj.node.getAttribute("id");
        textobj.style.backgroundColor = domobj.isSelected
				? "lightblue"
				: "white";

        lastDomObj = domobj;
        lastImgObj = imgobj;
        lastTextObj = textobj;
    }
}

/**
* 获得代表该图层显示状态的图片
* 
* @return 图片地址
* @author wbz
*/
function getLayerVisibleStatusPic(domobj) {
    var isVisible = domobj.node.getAttribute("visibility");
    var lyid=domobj.node.getAttribute("id");
    if (isVisible == null) {
        return;
    }
    if (isVisible == "True") {
//        vLayerIds.push(lyid);
        return checkBoxVisibleImgURL;
//        if (minScale == null && maxScale == null) {
//            return checkBoxVisibleImgURL;
//        } else if (minScale == null && maxScale != null) {
//            maxScale = parseFloat(maxScale);
//            if (curScale <= maxScale) {
//                return checkBoxVisibleImgURL;
//            } else {
//                return checkBoxCurNotVisibleImgURL;
//            }
//        } else if (minScale != null && maxScale == null) {
//            minScale = parseFloat(minScale);
//            if (curScale >= minScale) {
//                return checkBoxVisibleImgURL;
//            } else {
//                return checkBoxCurNotVisibleImgURL;
//            }
//        } else if (minScale != null && maxScale != null) {
//            minScale = parseFloat(minScale);
//            maxScacle = parseFloat(maxScale);
//            if (curScale > minScale && curScale < maxScale) {
//                return checkBoxVisibleImgURL;
//            } else {
//                return checkBoxCurNotVisibleImgURL;
//            }
//        }
    } else {
        //alert(domobj.node.getAttribute("name"));
        return checkBoxHiddenImgURL;
    }
}

/**
* 关闭被当前节点的可视状态
* 
* @param {DOMElement}
*            改页面对象所对应的在Tree中的dom对象
* @param {HtmlElement}
*            obj 被点击的页面对象
*/
function setVisible(domobj, obj) {
    // 如果不在比例尺范围内，则让其不可用
    // if(obj.src.indexOf(checkBoxCurNotVisibleImgURL) != -1){
    // return false;
    // }

    var id = obj.parentNode.getAttribute("id");

    // 遍历Dom文档，改变属性
    if (domobj != null) {

        // 改变按钮选中的图片
        var isVisible = domobj.node.getAttribute("visibility") == "True"
				? true
				: false;
        domobj.node.setAttribute("visibility", isVisible ? "False" : "True");

        obj.src = this.getLayerVisibleStatusPic(G_Map, domobj);

        // 更新父元素的checkbox
        refreshParentGroup(domobj);

        // 判断当前node是否是Layer，如果是Layer，直接设定该图层不可见
        if (domobj.node.tagName == LAYERTAG) {
            var layerIdArray = id.split(".");
            var length = layerIdArray.length;
            var layerId = layerIdArray[length - 1];
            G_TOC.SetVisible(layerId, domobj.node.getAttribute("visibility"));
        }

        else if (domobj.node.tagName == LAYERGROUPTAG) {
            // 如果是设定该GroupLayer不可见，则设定下面所有的图层都不可见，包括GroupLayer下面的GroupLayer
            if (domobj.node.getAttribute("visibility") == "False") {
                refreshGroupChild(domobj, obj.parentNode, "False");
                // 获取该GroupLayer下面的所有Layer的ID
                var layerIdArray = getSubLayerIDs(domobj.childs);
                var layerIdVisible = "";
                var temp = layerIdArray.split(",");
                for (var i = 0; i < temp.length; i++) {
                    if (temp[i] != "") {
                        layerIdVisible += "False" + ",";
                    }
                }
                G_TOC.SetVisible(layerIdArray, layerIdVisible);
            }
            // 如果设定改GroupLayer可见，则设定下面所有的图层可见，但有些图层可能不在比例尺范围内，则设定图层前的图标为比例尺不可见图标
            else if (domobj.node.getAttribute("visibility") == "True") {
            refreshGroupChild(domobj, obj.parentNode, "True");
                // 获取该GroupLayer下面的所有Layer的ID
                var layerIdArray = getSubLayerIDs(domobj.childs);
                var layerIdVisible = "";
                var temp = layerIdArray.split(",");
                for (var i = 0; i < temp.length; i++) {
                    if (temp[i] != "") {
                        layerIdVisible += "True" + ",";
                    }
                }
                G_TOC.SetVisible(layerIdArray, layerIdVisible);
            }
        }
        return false;
    }
}

/**
* 更新GroupLayer下面的对象，在点击GroupLayer的CheckBox时调用该函数
*/
function refreshGroupChild(domobj, obj, strVis) {
    for (var i = 0; i < domobj.childs.length; i++) {
        var childdomobj = domobj.childs[i];
        childdomobj.node.setAttribute("visibility", strVis);

        // 因为Layer和表示这个Layer的DIV的ID是对应的，所以可以根据这个ID找到该Layer对应的Div，从而改变CheckBox
        // 的图像
        var layerdiv = document.getElementById(childdomobj.node
				.getAttribute("id"));
        if (layerdiv != null) {
            for (var j = 0; j < layerdiv.childNodes.length; j++) {
                if (layerdiv.childNodes[j].id == "checkbox") {
                    layerdiv.childNodes[j].src = this.getLayerVisibleStatusPic(
							G_Map, childdomobj);
                    break;
                }
            }
        }

        if (childdomobj.node.tagName == LAYERGROUPTAG) {
            refreshGroupChild(childdomobj, layerdiv, strVis);
        }
    }
}

/**
* 更新Layer的父元素checkbox地址
*/
function refreshParentGroup(domobj) {
    if (domobj != null) {
        var parentdom = domobj.parent;
        if (parentdom != null) {
            // 根据childnode的可见性判断是否全部可见还是全部不可见还是部分可见
            var allvis = true; // 全部可见
            var nonevis = true; // 全部不可见
            for (var i = 0; i < parentdom.childs.length; i++) {
                var childdomobj = parentdom.childs[i];
                var isvis = childdomobj.node.getAttribute("visibility") == "True"
						? true
						: false;
                allvis = allvis && isvis;
                nonevis = nonevis && (!isvis);
            }

            var layerdiv = document.getElementById(parentdom.node
					.getAttribute("id"));
            if (layerdiv != null) {
                for (var j = 0; j < layerdiv.childNodes.length; j++) {
                    if (layerdiv.childNodes[j].id == "checkbox") {
                        if (allvis) {
                            layerdiv.childNodes[j].src = checkBoxVisibleImgURL;
                            parentdom.node.setAttribute("visibility", "True");
                        } else if (nonevis) {
                            layerdiv.childNodes[j].src = checkBoxHiddenImgURL;
                            parentdom.node.setAttribute("visibility", "False");
                        } else {
                            layerdiv.childNodes[j].src = checkBoxTristateURL;
                        }
                        break;
                    }
                }
            }

            refreshParentGroup(parentdom);
        }
    }

}

function getSubLayerIDs(childNodes) {
    var layerIDs = "";
    for (var i = 0; i < childNodes.length; i++) {
        var node = childNodes[i];
        if (node.node.tagName == LAYERTAG) {
            layerIDs += node.node.getAttribute("id") + ",";
        } else if (node.node.tagName == LAYERGROUPTAG) {
            layerIDs += getSubLayerIDs(node.childs)
        }
    }
    return layerIDs;
}
/**
* 选中TOC中的页面元素
* 
* @param {HtmlElement}
*            obj 被点击的页面对象
* @author wbz
*/

/**
* 地图比例尺发生变化时，刷新树
* 
* @author wbz
*/

function refreshScale() {
    var domobj = this;
    var type = this.node.tagName;
    // if(type == LAYERTAG || type == LAYERGROUPTAG) {
    if (type == LAYERTAG) {
        var childList = this.HtmlEntity.childNodes;
        var curElement;
        for (var i = 0; i < childList.length; i++) {
            var e = childList.item(i);
            if (e.getAttribute("id") == "checkbox") {
                curElement = e;
                break;
            }
        }
        curElement.src = this.getLayerVisibleStatusPic(G_Map, domobj);
    }
    if (type == TOPTAG || type == MAPTAG || type == LAYERGROUPTAG) {
        if (this.childs.length > 0) {
            for (var i = 0; i < this.childs.length; i++) {
                this.childs[i].refreshScale();
            }
        }
    }
}

/** **************************************************************** */
/*                                                                 */
/* TOC 页面类 */
/*                                                                 */
/** **************************************************************** */
/**
* TOCPage类构造函数 实例化之后必须设置Map成员变量
* 
* @author wbz
*/
function TOCPage(tocContainer) {
    // this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    this.xmlDoc = createXmlObject();
    this.Map;
    this.tree;
    this.curMenu;
    this.curNode;
    this.focusElement;
    this.TOCContainer = tocContainer;
}

/**
* TOCPage类方法 初始化TOC
* 
* @param {string}
*            xml 代表树的xml字符串
* @author wbz
*/
TOCPage.prototype.InitTOC = function(xml) {
    
    this.xmlDoc = loadFromXml(xml);

    var root = this.xmlDoc.documentElement.childNodes.item(0);
    this.tree = new Tree(root, null, false, null);
    this.tree.toHtmlElement();
    this.TOCContainer.appendChild(this.tree.HtmlEntity);
    return;
}

/**
* TOCPage类方法 控制图层显示
* 
* @param {string}
*            mapName 地图名称
* @param {string}
*            layerId 图层ID
* @param {bool}
*            是否显示
* @author wbz
*/
TOCPage.prototype.SetVisible = function(layerId, isVisible) {
    G_Requester.ReqSetLayerVisibility(layerId, isVisible);
}

