<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SpecialType.ascx.cs"
    Inherits="PowerEasy.Module.General.WebSite.Admin.Controls.FieldControl.SpecialType" %>
<asp:HiddenField ID="HdnSpecial" runat="server" />
<div style="margin: 0; padding: 0; float: left;" id="UlSpecial" runat="server">
</div>
<pec:FloatingDialog ID="FDAddSpecial" runat="server" ShowType="1" Width="250" Height="400" Name="<%$ Res: Controls_FieldControl_SpecialType_AddSpecial , 添加到专题 %>"
        Skin="inputbutton" Title="<%$ Res: Controls_FieldControl_SpecialType_AddSpecial , 添加到专题 %>" onclick="AddSpecial()"/>

<script type="text/javascript">
<!--
    function AddSpecial() {
        var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
        var arr = null;

        if (arr != null) {
            UpdateSpecial(arr);
        }
    }

    function UpdateSpecial(arr) {
        var arrNodes = arr.split('$$$');
        var HdnSpecial = document.getElementById("<%= HdnSpecial.ClientID %>");
        var SelectedSpecial = HdnSpecial.value.split(",");
        var isExist = false;
        for (i = 0; i < SelectedSpecial.length; i++) {
            if (SelectedSpecial[i] == arrNodes[0])
            { isExist = true; }
        }

        if (!isExist) {
            if (HdnSpecial.value != '')
            { HdnSpecial.value = HdnSpecial.value + ','; }

            HdnSpecial.value = HdnSpecial.value + arrNodes[0];

            var newli = document.createElement("SPAN");  
            newli.setAttribute("id","SpecialSpanId" + arrNodes[0]);
            var newinput = document.createElement("INPUT"); 
            newinput.className = "inputtext"; 
            newinput.setAttribute("type", "text");
            newinput.setAttribute("disabled", "disabled");
            newinput.setAttribute("size", "50");
            newinput.value = arrNodes[1] + " ";
            newli.appendChild(newinput);
            var newlink = document.createElement("INPUT");
            newlink.onclick = function() { DelSpecial(arrNodes[0]);};
            newlink.setAttribute("type", "button");
            newlink.className = "inputbutton";
            newlink.setAttribute("value", "<%= Resources.DynamicPageResources.Controls_FieldControl_SpecialType_JS %>");
            newli.appendChild(newlink);
            var newbr = document.createElement("BR");  
            newli.appendChild(newbr);
            var links = document.getElementById("<%= UlSpecial.ClientID %>");
            links.appendChild(newli);
            DelSpecial('0');
        }
    }

    function DelSpecial(specialId){
        var li = document.getElementById("SpecialSpanId" + specialId);
        if(li != null)
        {
            li.parentNode.removeChild(li);
        }

        var hdnSpecial = document.getElementById("<%= HdnSpecial.ClientID %>");
        var SelectedSpecial = hdnSpecial.value.split(",");
        var newselected = '';
        for (i = 0; i < SelectedSpecial.length; i++) {
            if (SelectedSpecial[i] != specialId) {
                if (newselected != '') { newselected = newselected + ','; }
                newselected = newselected + SelectedSpecial[i];
            }
        }
        hdnSpecial.value = newselected;
    }
//-->
</script>

