﻿function openRadWindow(Url, Window, ClientCloseFunction) {
    var oWnd = radopen(Url, Window);
    if (oWnd != null) {
        oWnd.SetSize(780, 550);
        oWnd.SetStatus(" ");
        //oWnd.GetStatusbar().parentNode.style.display = 'none';
        oWnd.SetModal(true);
        oWnd.Center();
        oWnd.OnClientClose = ClientCloseFunction;
        cleanWindow(oWnd);
        return false;
    }
}



function openRadWindowSizeDefined(Url, Window, ClientCloseFunction, Width, Height) {
   
    var oWnd = radopen(Url, Window);
    if (oWnd != null) {
        oWnd.SetSize(Width, Height);
        oWnd.SetStatus(" ");
        //oWnd.GetStatusbar().parentNode.style.display = 'none';
        oWnd.Center();
        oWnd.SetModal(true);
        oWnd.OnClientClose = ClientCloseFunction;
        cleanWindow(oWnd);
        return false;
    }
}
function openRadWindowSizeDefined2(Url, Window, ClientCloseFunction, Width, Height) {
    var oWnd = radopen(Url, Window);
    if (oWnd != null) {
        oWnd.SetSize(Width, Height);
        oWnd.SetStatus(" ");
        //oWnd.GetStatusbar().parentNode.style.display = 'none';
        oWnd.Center();
        oWnd.SetModal(true);
        applyCustomModality(oWnd);
        oWnd.OnClientClose = ClientCloseFunction;
        cleanWindow(oWnd);
        return false;
    }
}
function cleanWindow(radWindow) {
    var prefix = "TogglePinButton"
    var pin = document.getElementById(prefix + radWindow.Name);
    if (pin != null) {
        if (pin.parentNode != null) {
            pin.parentNode.removeChild(pin)
        }
    }
    var prefixReload = "ReloadButton"
    var Reload = document.getElementById(prefixReload + radWindow.Name);
    if (Reload != null) {
        if (Reload.parentNode != null) {
            Reload.parentNode.removeChild(Reload)
        }
    }
    var prefixMin = "MinimizeButton"
    var Min = document.getElementById(prefixMin + radWindow.Name);
    if (Min != null) {
        if (Min.parentNode != null) {
            Min.parentNode.removeChild(Min)
        }
    }
    radWindow.GetStatusbar().parentNode.style.display = 'none';
}



var currentRow1, movedRow1 = null;
function GridRowCreated1(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow1) {
            currentRow1 = document.createElement("div");
            currentRow1.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow1);
            currentRow1.style.position = "absolute";
            currentRow1.style.display = "none";

            movedRow1 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow1) {
            if (movedRow1 && currentRow1.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows1(movedRow1.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow1);
            currentRow1 = null;
            movedRow1 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow1) {
            currentRow1.style.display = "";
            currentRow1.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow1.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton1");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 2ndGrid                

var currentRow2, movedRow2 = null;
function GridRowCreated2(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow2) {
            currentRow2 = document.createElement("div");
            currentRow2.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow2);
            currentRow2.style.position = "absolute";
            currentRow2.style.display = "none";

            movedRow2 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow2) {
            if (movedRow2 && currentRow2.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows2(movedRow2.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow2);
            currentRow2 = null;
            movedRow2 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow2) {
            currentRow2.style.display = "";
            currentRow2.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow2.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton2");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 3rd Grid

var currentRow3, movedRow3 = null;
function GridRowCreated3(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow3) {
            currentRow3 = document.createElement("div");
            currentRow3.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow3);
            currentRow3.style.position = "absolute";
            currentRow3.style.display = "none";

            movedRow3 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow3) {
            if (movedRow3 && currentRow3.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows3(movedRow3.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow3);
            currentRow3 = null;
            movedRow3 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow3) {
            currentRow3.style.display = "";
            currentRow3.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow3.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton3");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 4th Grid

var currentRow4, movedRow4 = null;
function GridRowCreated4(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow4) {
            currentRow4 = document.createElement("div");
            currentRow4.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow4);
            currentRow4.style.position = "absolute";
            currentRow4.style.display = "none";

            movedRow4 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow4) {
            if (movedRow4 && currentRow4.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows4(movedRow4.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow4);
            currentRow4 = null;
            movedRow4 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow4) {
            currentRow4.style.display = "";
            currentRow4.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow4.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton4");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 5th Grid

var currentRow5, movedRow5 = null;
function GridRowCreated5(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow5) {
            currentRow5 = document.createElement("div");
            currentRow5.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow5);
            currentRow5.style.position = "absolute";
            currentRow5.style.display = "none";

            movedRow5 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow5) {
            if (movedRow5 && currentRow5.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows5(movedRow5.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow5);
            currentRow5 = null;
            movedRow5 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow5) {
            currentRow5.style.display = "";
            currentRow5.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow5.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton5");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 6th Grid

var currentRow6, movedRow6 = null;
function GridRowCreated6(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow6) {
            currentRow6 = document.createElement("div");
            currentRow6.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow6);
            currentRow6.style.position = "absolute";
            currentRow6.style.display = "none";

            movedRow6 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow6) {
            if (movedRow6 && currentRow6.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows6(movedRow6.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow6);
            currentRow6 = null;
            movedRow6 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow6) {
            currentRow6.style.display = "";
            currentRow6.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow6.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton6");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 7th Grid

var currentRow7, movedRow7 = null;
function GridRowCreated7(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow7) {
            currentRow7 = document.createElement("div");
            currentRow7.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow7);
            currentRow7.style.position = "absolute";
            currentRow7.style.display = "none";

            movedRow7 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow7) {
            if (movedRow7 && currentRow7.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows7(movedRow7.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow7);
            currentRow7 = null;
            movedRow7 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow7) {
            currentRow7.style.display = "";
            currentRow7.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow7.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton7");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 8th Grid

var currentRow8, movedRow8 = null;
function GridRowCreated8(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow8) {
            currentRow8 = document.createElement("div");
            currentRow8.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow8);
            currentRow8.style.position = "absolute";
            currentRow8.style.display = "none";

            movedRow8 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow8) {
            if (movedRow8 && currentRow8.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows8(movedRow8.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow8);
            currentRow8 = null;
            movedRow8 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow8) {
            currentRow8.style.display = "";
            currentRow8.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow8.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton8");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

//function for the 13th Grid

var currentRow13, movedRow13 = null;
function GridRowCreated13(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow13) {
            currentRow13 = document.createElement("div");
            currentRow13.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow13);
            currentRow13.style.position = "absolute";
            currentRow13.style.display = "none";

            movedRow13 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow13) {
            if (movedRow13 && currentRow13.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows13(movedRow13.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow13);
            currentRow13 = null;
            movedRow13 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow13) {
            currentRow13.style.display = "";
            currentRow13.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow13.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton13");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}


//function for the 14th Grid

var currentRow14, movedRow14 = null;
function GridRowCreated14(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow14) {
            currentRow14 = document.createElement("div");
            currentRow14.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow14);
            currentRow14.style.position = "absolute";
            currentRow14.style.display = "none";

            movedRow14 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow14) {
            if (movedRow14 && currentRow14.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows14(movedRow14.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow14);
            currentRow14 = null;
            movedRow14 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow14) {
            currentRow14.style.display = "";
            currentRow14.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow14.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton14");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}


//function for the 15th Grid

var currentRow15, movedRow15 = null;
function GridRowCreated15(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow15) {
            currentRow15 = document.createElement("div");
            currentRow15.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow15);
            currentRow15.style.position = "absolute";
            currentRow15.style.display = "none";

            movedRow15 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow15) {
            if (movedRow15 && currentRow15.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows15(movedRow15.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow15);
            currentRow15 = null;
            movedRow15 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow15) {
            currentRow15.style.display = "";
            currentRow15.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow15.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton15");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}


//function for the 16th Grid

var currentRow16, movedRow16 = null;
function GridRowCreated16(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow16) {
            currentRow16 = document.createElement("div");
            currentRow16.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow16);
            currentRow16.style.position = "absolute";
            currentRow16.style.display = "none";

            movedRow16 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow16) {
            if (movedRow16 && currentRow16.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows16(movedRow16.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow16);
            currentRow16 = null;
            movedRow16 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow16) {
            currentRow16.style.display = "";
            currentRow16.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow16.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton16");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}


//function for the 17th Grid

var currentRow17, movedRow17 = null;
function GridRowCreated17(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow17) {
            currentRow17 = document.createElement("div");
            currentRow17.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow17);
            currentRow17.style.position = "absolute";
            currentRow17.style.display = "none";

            movedRow17 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow17) {
            if (movedRow17 && currentRow17.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows17(movedRow17.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow17);
            currentRow17 = null;
            movedRow17 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow17) {
            currentRow17.style.display = "";
            currentRow17.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow17.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton17");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}


function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 9th Grid

var currentRow9, movedRow9 = null;
function GridRowCreated9(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow9) {
            currentRow9 = document.createElement("div");
            currentRow9.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow9);
            currentRow9.style.position = "absolute";
            currentRow9.style.display = "none";

            movedRow9 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow9) {
            if (movedRow9 && currentRow9.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows9(movedRow9.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow9);
            currentRow9 = null;
            movedRow9 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow9) {
            currentRow9.style.display = "";
            currentRow9.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow9.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton9");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 10th Grid

var currentRow10, movedRow10 = null;
function GridRowCreated10(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow10) {
            currentRow10 = document.createElement("div");
            currentRow10.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow10);
            currentRow10.style.position = "absolute";
            currentRow10.style.display = "none";

            movedRow10 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow10) {
            if (movedRow10 && currentRow10.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows10(movedRow10.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow10);
            currentRow10 = null;
            movedRow10 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow10) {
            currentRow10.style.display = "";
            currentRow10.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow10.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton10");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 18th Grid

var currentRow18, movedRow18 = null;
function GridRowCreated18(row) {
  
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow18) {
            currentRow18 = document.createElement("div");
            currentRow18.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow18);
            currentRow18.style.position = "absolute";
            currentRow18.style.display = "none";

            movedRow18 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow18) {
            if (movedRow18 && currentRow18.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows18(movedRow18.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow18);
            currentRow18 = null;
            movedRow18 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow18) {
            currentRow18.style.display = "";
            currentRow18.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow18.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton18");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};




//function for the 19th Grid

var currentRow19, movedRow19 = null;
function GridRowCreated19(row) {

    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow19) {
            currentRow19 = document.createElement("div");
            currentRow19.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow19);
            currentRow19.style.position = "absolute";
            currentRow19.style.display = "none";

            movedRow19 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow19) {
            if (movedRow19 && currentRow19.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows19(movedRow19.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow19);
            currentRow19 = null;
            movedRow19 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow19) {
            currentRow19.style.display = "";
            currentRow19.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow19.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton19");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};




//function for the 20th Grid

var currentRow20, movedRow20 = null;
function GridRowCreated20(row) {

    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow20) {
            currentRow20 = document.createElement("div");
            currentRow20.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow20);
            currentRow20.style.position = "absolute";
            currentRow20.style.display = "none";

            movedRow20 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow20) {
            if (movedRow20 && currentRow20.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows20(movedRow20.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow20);
            currentRow20 = null;
            movedRow20 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow20) {
            currentRow20.style.display = "";
            currentRow20.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow20.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton20");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};



//function for the 21th Grid

var currentRow21, movedRow21 = null;
function GridRowCreated21(row) {    
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow21) {
            currentRow21 = document.createElement("div");
            currentRow21.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow21);
            currentRow21.style.position = "absolute";
            currentRow21.style.display = "none";

            movedRow21 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow21) {
            if (movedRow21 && currentRow21.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows21(movedRow21.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow21);
            currentRow21 = null;
            movedRow21 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow21) {
            currentRow21.style.display = "";
            currentRow21.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow21.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton21");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 22th Grid

var currentRow22, movedRow22 = null;
function GridRowCreated22(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow22) {
            currentRow22 = document.createElement("div");
            currentRow22.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow22);
            currentRow22.style.position = "absolute";
            currentRow22.style.display = "none";

            movedRow22 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow22) {
            if (movedRow22 && currentRow22.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows22(movedRow22.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow22);
            currentRow22 = null;
            movedRow22 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow22) {
            currentRow22.style.display = "";
            currentRow22.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow22.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton22");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};

//function for the 23th Grid

var currentRow23, movedRow23 = null;
function GridRowCreated23(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow23) {
            currentRow23 = document.createElement("div");
            currentRow23.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow23);
            currentRow23.style.position = "absolute";
            currentRow23.style.display = "none";

            movedRow23 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow23) {
            if (movedRow23 && currentRow23.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows23(movedRow23.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow23);
            currentRow23 = null;
            movedRow23 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow23) {
            currentRow23.style.display = "";
            currentRow23.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow23.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton23");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};













//function for the 24th Grid

var currentRow24, movedRow24 = null;
function GridRowCreated24(row) {    
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow24) {
            currentRow24 = document.createElement("div");
            currentRow24.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow24);
            currentRow24.style.position = "absolute";
            currentRow24.style.display = "none";

            movedRow24 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow24) {
            if (movedRow24 && currentRow24.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows24(movedRow24.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow24);
            currentRow24 = null;
            movedRow24 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow24) {
            currentRow24.style.display = "";
            currentRow24.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow24.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton24");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};





//function for the 25th Grid

var currentRow25, movedRow25 = null;
function GridRowCreated25(row) {    
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow25) {
            currentRow25 = document.createElement("div");
            currentRow25.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow25);
            currentRow25.style.position = "absolute";
            currentRow25.style.display = "none";

            movedRow25 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow25) {
            if (movedRow25 && currentRow25.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows25(movedRow25.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow25);
            currentRow25 = null;
            movedRow25 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow25) {
            currentRow25.style.display = "";
            currentRow25.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow25.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton25");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};




//function for the 11th Grid

var currentRow11, movedRow11 = null;
function GridRowCreated11(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow11) {
            currentRow11 = document.createElement("div");
            currentRow11.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow11);
            currentRow11.style.position = "absolute";
            currentRow11.style.display = "none";

            movedRow11 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow11) {
            if (movedRow11 && currentRow11.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows11(movedRow11.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow11);
            currentRow11 = null;
            movedRow11 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow11) {
            currentRow11.style.display = "";
            currentRow11.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow11.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton11");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};


//function for the 12th Grid

var currentRow12, movedRow12 = null;
function GridRowCreated12(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow12) {
            currentRow12 = document.createElement("div");
            currentRow12.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow12);
            currentRow12.style.position = "absolute";
            currentRow12.style.display = "none";

            movedRow12 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow12) {
            if (movedRow12 && currentRow12.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows12(movedRow12.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow12);
            currentRow12 = null;
            movedRow12 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow12) {
            currentRow12.style.display = "";
            currentRow12.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow12.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton12");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};

//function for the 28th Grid

var currentRow28, movedRow28 = null;
function GridRowCreated28(row) {
    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow28) {
            currentRow28 = document.createElement("div");
            currentRow28.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow28);
            currentRow28.style.position = "absolute";
            currentRow28.style.display = "none";

            movedRow28 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow28) {
            if (movedRow28 && currentRow28.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows28(movedRow28.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow28);
            currentRow28 = null;
            movedRow28 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow28) {
            currentRow28.style.display = "";
            currentRow28.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow28.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton28");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}

function ClearDocumentEvents() {
    if (document.onmousedown != this.mouseDownHandler) {
        this.documentOnMouseDown = document.onmousedown;
    }

    if (document.onselectstart != this.selectStartHandler) {
        this.documentOnSelectStart = document.onselectstart;
    }

    this.mouseDownHandler = function(e) { return false; };
    this.selectStartHandler = function() { return false; };

    document.onmousedown = this.mouseDownHandler;
    document.onselectstart = this.selectStartHandler;

};

function RestoreDocumentEvents() {
    if ((typeof (this.documentOnMouseDown) == "function") &&
			(document.onmousedown != this.mouseDownHandler)) {
        document.onmousedown = this.documentOnMouseDown;
    }
    else {
        document.onmousedown = "";
    }

    if ((typeof (this.documentOnSelectStart) == "function") &&
			(document.onselectstart != this.selectStartHandler)) {
        document.onselectstart = this.documentOnSelectStart;
    }
    else {
        document.onselectstart = "";
    }
};
//function for the 21th Grid Sub Categories

var currentRow21, movedRow21 = null;
function GridRowCreated21(row) {

    row.Control.RowIndex = row.RealIndex;

    var mouseDownHandler = function(e) {
        if (!e)
            var e = window.event;
        if (!currentRow21) {
            currentRow21 = document.createElement("div");
            currentRow21.innerHTML = "<table><tbody><tr style='font: normal 11px Arial, Verdana;'>" + row.Control.innerHTML + "</tr></tbody><table>";
            document.body.appendChild(currentRow21);
            currentRow21.style.position = "absolute";
            currentRow21.style.display = "none";

            movedRow21 = row;
        }

        ClearDocumentEvents();
    };
    var mouseUpHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow21) {
            if (movedRow21 && currentRow21.style.display != "none") {
                var targetElement = e.srcElement ? e.srcElement : e.target;
                var droppedRowIndex;
                var i = 0;
                while (typeof (droppedRowIndex) == "undefined") {
                    i++;
                    droppedRowIndex = targetElement.parentNode.RowIndex;
                    targetElement = targetElement.parentNode; //in case of controls in the row
                    if (i == 2) break;
                }
                if (typeof (droppedRowIndex) != "undefined")
                    ReorderGridRows21(movedRow21.RealIndex, droppedRowIndex);
            }
            document.body.removeChild(currentRow21);
            currentRow21 = null;
            movedRow21 = null;
        }
        RestoreDocumentEvents();
    };
    var mouseMoveHandler = function(e) {
        if (!e)
            var e = window.event;
        if (currentRow21) {
            currentRow21.style.display = "";
            currentRow21.style.top = e.clientY +
										document.documentElement.scrollTop +
										document.body.scrollTop + 3 + "px";

            currentRow21.style.left = e.clientX +
										document.documentElement.scrollLeft +
										document.body.scrollLeft + 3 + "px";
        }

    };

    var cell = this.GetCellByColumnUniqueName(row, "OrderButton21");
    if (cell != null) {
        var button;
        if (document.all) {
            button = cell.childNodes[0];
        }
        else {
            button = cell.childNodes[1];
        }

        if (button.attachEvent) {
            button.attachEvent("onmousedown", mouseDownHandler);
            document.body.attachEvent("onmouseup", mouseUpHandler);
            document.body.attachEvent("onmousemove", mouseMoveHandler);
        }

        if (button.addEventListener) {
            button.addEventListener("mousedown", mouseDownHandler, true);
            document.body.addEventListener("mouseup", mouseUpHandler, true);
            document.body.addEventListener("mousemove", mouseMoveHandler, true);
        }
    }
}


function Trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}



function VaildateCharacters(editor, limitNum) {
    var message = 'You are not able to type more than ' + limitNum + ' characters!';

    var oFun = function() {
        var oValue = editor.get_html(true);

        if (oValue.length > limitNum) {
            editor.set_html(oValue.substring(0, limitNum));
            alert(message);
            return true;
        }
        else {

        }
    };


    editor.attachEventHandler("onkeyup", oFun);
    editor.attachEventHandler("onkeydown", oFun);
}
function VaildateCharactersWithTestKey(editor, limitNum) {
    var message = 'You are not able to type more than ' + limitNum + ' characters!';

    var oFun = function(e) {
        var code = e.keyCode;
        var testkey = false;
        if (code != 38 && code != 40 && code != 37 && code != 39 && code != 33 && code != 34 && code != 36 && code != 35 && code != 13 && code != 9 && code != 27 && code != 16 && code != 17 && code != 18 && code != 20 && code != 8 && code != 46) {
            testkey = true;
        }

        var oValue = editor.get_html();
        if (oValue.lenght > limitNum && testkey) {
            alert(message);
            editor.set_html(oValue.substring(0, limitNum));
            oValue = editor.get_html(false);
            return true;
        }
        else {

        }
    };
    editor.attachEventHandler("onkeyup", oFun);
    editor.attachEventHandler("onkeydown", oFun);
}


function openRadWindowSizeDefinedT(URL, ClientCloseFunction, Width, Height) {
    
    
    var oWnd = radopen(URL, '');
    oWnd.SetSize(Width, Height);
    oWnd.SetModal(true);
    oWnd.Center();
    oWnd.GetStatusbar().parentNode.style.display = 'none';
    oWnd._behaviors = 52;
    if (ClientCloseFunction != '')
        oWnd.add_close(ClientCloseFunction);
    return false;
}
