//
function SelectOneListBox(name) {
    var lst1 = window.document.getElementById("SourceListBox");
    var lstindex = lst1.selectedIndex;
    if (lstindex < 0)
        return;
    var v = lst1.options[lstindex].value;
    var t = lst1.options[lstindex].text;
    var lst2 = window.document.getElementById("DestinationListBox");
    lst2.options[lst2.options.length] = new Option(t, v, true, true);
    ListBoxText(name);
}

function DelOneListBox(name) {
    var lb = window.document.getElementById("" + name + "");
    var lstindex = lb.selectedIndex;
    if (lstindex >= 0) {
        var v = lb.options[lstindex].value + ";";
        lb.options[lstindex].parentNode.removeChild(lb.options[lstindex]);
    }
    ListBoxText(name);
}

function DelAllListBox(name) {
    var lb = window.document.getElementById("" + name + "");
    var len = lb.options.length;
    for (var i = len; i > 0; i--) {
        lb.options[i - 1].parentNode.removeChild(lb.options[i - 1]);
    }
    ListBoxText(name);
}

function EditOneListBox(app, name, css) {
    var lb = window.document.getElementById("" + name + "");
    var lstindex = lb.selectedIndex;
    if (lstindex >= 0) {
        var v = escape(lb.options[lstindex].value + "");
        WinOpenLhgDialog('修改选中文件', '' + app + '/common/BatchEditUrl.aspx?ControlId=' + name + '&url=' + v + '&index=' + lstindex + '', 600, 280, '' + css + '')
    }
    //ListBoxText(name);
}

function EditOneListBoxSoft(app, name, css) {
    var lb = window.document.getElementById("" + name + "");
    var lstindex = lb.selectedIndex;
    if (lstindex >= 0) {
        var v = escape(lb.options[lstindex].value + "");
        WinOpenLhgDialog('修改选中文件', '' + app + '/common/BatchEditUrlSoft.aspx?ControlId=' + name + '&url=' + v + '&index=' + lstindex + '', 600, 150, '' + css + '')
    }
    //ListBoxText(name);
}

function MoveListBox(name, move) {
    var lb = window.document.getElementById("" + name + "");
    var index = lb.selectedIndex;
    var v = lb.options[index].value;
    var _index;
    var _v;
    if (move == "up") {
        _index = index - 1;
        if (_index >= 0) {
            _v = lb.options[_index].value;
            lb.options[_index] = new Option(v, v, true, true);
            lb.options[index] = new Option(_v, _v, true, true);
        }
    }
    else {
        _index = index + 1;
        if (_index < lb.length) {
            _v = lb.options[_index].value;
            lb.options[_index] = new Option(v, v, true, true);
            lb.options[index] = new Option(_v, _v, true, true);
        }
    }

    ListBoxText(name);
}

function ListBoxText(name) {
    var _name = name + "_Text";
    var lb = window.document.getElementById("" + name + "");
    var _t = "";
    if (lb.length > 0) {
        for (var i = 0; i < lb.length; i++) {
            _t += lb.options[i].value + ",";
        }
    }
    document.getElementById(_name).value = _t;
    showmorepic(name);
}

function SelectFile(url, cssname) {
    var upload = DianCMS_$("FilePicPath").value.split("|")[0];
    WinOpenLhgDialog('从服务器上选择文件', '' + url + '&upload=' + upload + '', 650, 400, '' + cssname + '')
}

function showmorepic(name) {
    var objSelect = document.getElementById("" + name + "");
    var p = "";
    for (var i = 0; i < objSelect.options.length; i++) {
        p += objSelect.options[i].text + ",";
    }
    var picpath = document.getElementById("FilePicPath").value.split("|")[0];

    D.BLL.B_Common.ReturnShowMorePic(p, picpath, name, callshowmorepic);
}

function callshowmorepic(res) {
    if (res.value != null) {
        if (res.value.length > 0) {
            var name = res.value.split("☂")[0];
            document.getElementById("" + name + "_showpic").innerHTML = res.value.split("☂")[1];
        }
    }
}