<%@ Page Language="C#"  AutoEventWireup="true"
    Inherits="PowerEasy.Module.General.WebSite.Admin.Vote.VoteTreeIndex" Title="选择信息" CodeBehind="VoteTreeIndex.aspx.cs" %>
        
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>信息选择</title>
</head>
<body>
    <form id="form1" runat="server">
        <div style="width:100%">
            <table style="width: 100%; height: 90%;" border="0" cellpadding="2" cellspacing="0"
                class="border">
                <tr>
                    <td colspan="2" style="height:30px; text-align: right;" class="title" >
                        选择的信息：
                        <input id="TxtItemName"  size="40" style="height: 22px;text-align: left; width: 80%;" type="text" />&nbsp;<br />
                        <input id="BtnDelLast" type="button" value="删除最后" onclick="DeleteLast()" />
                        <input id="BtnDelAll" type="button" value="删除全部" onclick="DeleteAll()" />
                        <input id="Button1" type="button" value="确认并返回 " onclick="ReturnValueToOpener()" />
                    </td>
                </tr>
                <tr>
                    <td runat="server" id="TdLeft" class="tdbg" align="center" valign="top" style="width: 20%;">
                        <iframe runat="server" id="shoplist" name="shoplist" scrolling="auto" style="width: 100%; height: 450px"
                            src="VoteTree.aspx" frameborder="0"></iframe>
                    </td>
                    <td runat="server" id="TdRight" class="tdbg" align="left" valign="top" style="width: 80%;">
                        <iframe runat="server" id="voteTree_main_right" name="voteTree_main_right" scrolling="auto" style="width:100%; height: 450px"
                            src="VoteTreeManage.aspx" frameborder="0" marginheight="0" marginwidth="1"></iframe>
                    </td>
                </tr>
            </table>
        </div>
    </form>
        <script type="text/javascript">
            Array.prototype.isContain = function(value) {
                for (var i in this) {
                    if (this[i] === value) {
                        return true;
                    }
                }
                return false;
            }

            var itemList = new Array();
            var itemIdList = new Array();
            var txtItemName = document.getElementById('TxtItemName');

            var loaditemName = parent.document.getElementById('<%=m_BackControlId %>').value;
            if (loaditemName != '') {
                if (loaditemName.indexOf("$")) {
                    var arrstr = loaditemName.split("$");
                    for (i = 0; i < arrstr.length; i++) {
                        var arrstritem = arrstr[i].split(",");
                        itemIdList.push(arrstritem[0]);
                        itemList.push(new Array(arrstritem[0], arrstritem[1]));
                    }
                    txtItemName.value = itemIdList.join(',');
                } else {
                    var arrstritem = loaditemName.split(",");
                    itemIdList.push(arrstritem[0]);
                    txtItemName.value = arrstritem[1];
                    itemList.push(new Array(arrstritem[0], arrstritem[1]));
                }
            }

            //返回Opener
            function ReturnValueToOpener() {
                if (txtItemName.value == '') {
                    alert('请选择信息！');
                    return;
                }
                try {
                    var returnJs = '<%=m_ReturnJsFunction %>';
                    if (returnJs == '') {
                        parent.DoProductPickerPostBack(itemList.join('$'));
                    } else {
                        var js = "parent." + returnJs + "('" + itemList.join('$') + "')";
                        eval(js);
                    }
                }
                catch (e) {
                    alert(e.message);
                }
                parent.document.getElementById('jqDnrFloatDivBg').style.display = "none";
                parent.document.getElementById('<%=m_FloatingDialog %>').style.display = "none";

            }


            function AddItem(generalId, title) {
                if (itemIdList.isContain(generalId)) {
                    alert("此信息已被选择！");
                    return;
                } else {
                    itemIdList.push(generalId);
                }
                txtItemName.value = itemIdList.join(',');
                itemList.push(new Array(generalId, title));
            }
            
            function DeleteLast() {
                itemIdList.pop();
                itemList.pop();
                txtItemName.value = itemIdList.join(',');
            }

            function DeleteAll() {
                txtItemName.value = '';
                itemIdList.length = itemList.length = 0;
            }
        </script>
</body>
</html>

