﻿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 openRadWindow2(Url, Window, ClientCloseFunction) {
    var oWnd = radopen(Url, Window);
    if (oWnd != null) {
        oWnd.SetSize(780, 550);
        oWnd.SetStatus(" ");
        oWnd.SetModal(true);

        applyCustomModality(oWnd);

        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 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 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 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.GetHtml(true);

        if (oValue.length > limitNum) {
            editor.SetHtml(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;
        }

        oValue = editor.GetHtml(false);
        if (oValue.length > limitNum && testkey) {
            alert(message);
            editor.SetHtml(oValue.substring(0, limitNum));
            oValue = editor.GetHtml(false);
            return true;
        }
        else {

        }
    };
    editor.AttachEventHandler("onkeyup", oFun);
    editor.AttachEventHandler("onkeydown", oFun);
}
