<%@ Page Title="" Language="C#" AutoEventWireup="false" MasterPageFile="~/EmptyAjaxMaster.Master"
    CodeBehind="AmendItemsOrdersPage.aspx.cs" Inherits="MKInsight.Online.RRAM2.SystemConfiguration.AmendItemsOrdersPage" %>

<%@ Register Src="../UIControls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="h" runat="server">
    <script type="text/javascript" src="../scripts/jquery/jquery_min.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.highlightFade.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.tablednd_0_5.js"></script>
    <script type="text/javascript">

        function cb() {
            parent.$().colorbox.close();

		}

    </script>
    <style type="text/css">
        .list-grid {
            background-color: #fff;
            border: solid 2px #0099CC;
            font-size: 12px;
            font-family: Tahoma, Arial, Helvetica, Sans-Serif;
            width: 500px;
        }

            .list-grid .titlebar {
                border-bottom: solid 1px #0099CC;
                height: 28px;
                line-height: 28px;
                padding: 0px 5px;
                color: #fff;
                font-size: 15px;
                font-weight: bold;
                position: relative;
                display: block;
            }

            .list-grid .datatable {
                width: 100%;
                empty-cells: show;
                border-collapse: collapse;
            }

                .list-grid .datatable .header TH {
                    height: 24px;
                    line-height: 24px;
                    padding-left: 6px;
                    color: #666666;
                    text-align: left;
                    white-space: nowrap;
                }

                .list-grid .datatable .datarow TD {
                    padding: 6px 0 6px 6px;
                    color: #666666;
                    text-align: left;
                    white-space: nowrap;
                    border-bottom: 1px solid #0099CC;
                }
    </style>
    <script type="text/javascript">

        $(document).ready(function () {

            $("#tbl-reorder").tableDnD({
                onDrop: onDropItem
            });
        });

        function onDropItem(table, row) {

			// $("#status").html("Loading..");


            $(row).highlightFade({ color: 'rgb(255, 241, 168)', end: '#fff', speed: 1000, final: "" });

            var table = document.getElementById("tbl-reorder");
            var value="";
            for (var i = 0, row; row = table.rows[i]; i++) {
				//iterate through rows
				//rows would be accessed using the "row" variable assigned in the for loop

                var r = row.getAttribute('id');
                if (!isNaN(r) ) value = value + row.getAttribute('id').toString() +","


			}

            var saveValue = value.substring(0, value.lastIndexOf(","));
			document.getElementById("<%:hd_Value.ClientID%>").value = saveValue;


		}

        function onSucceeded(result) {
			//   $("#status").html("Reorder was a success!");
		}

        function onFailed(result) {
			//  $("#status").html("Reorder failed!");
		}

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cm" runat="server">
    <h3>
        <asp:Label ID="lbl_MS" runat="server" CssClass="msg" /></h3>
    <uc1:MessageBox ID="u_M" runat="server" />
    <h3>
        <asp:CheckBox runat="server" ID="mki_SetGlobal" />
    </h3>
    <hr class="ee" />
    <asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
        <ContentTemplate>

            <table style="width: 100%">
                <tr>
                    <td class="divfleft">
                        <asp:Button ID="btn_Save" runat="server" />
                        <asp:Button ID="btn_Cancel" runat="server" />
                        <asp:HiddenField ID="hd_Value" runat="server" />
                    </td>
                    <td class="divfright">
                        <asp:Button ID="btn_Reset" runat="server" ForeColor="Red" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <table>

        <tr>
            <td>
                <asp:ListView ID="lvReorder" runat="server">
                    <LayoutTemplate>
                        <div class="list-grid">
                            <table id="tbl-reorder" class="datatable" border="0" cellpadding="0" cellspacing="0">
                                <tr id="itemPlaceholder" runat="server" />
                            </table>
                        </div>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <tr id="<%#Eval("ID")%>" class="datarow">
                            <td>
                                <%#Eval("Name")%>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:ListView>
            </td>
        </tr>
    </table>
</asp:Content>
