﻿
/*
    Computer Science Group, LLC
    225-766-2397 office
    225-205-0263 cell
    darrell@computersciencegroup.com
    Copyright © 2011 Computer Science Group, LLC, All rights reserved.
*/

var iINDEX_UniqueName = 0;
var iINDEX_dd = 1;
var iINDEX_isSelected = 2;

//07/29/2011 variables used by the drag and drop drag/move events are maintained outside of the class functions
var _dragApproved = false;
var _x;
var _y;
var _temp1;
var _temp2;

//csgDragAndDrop()
//11/16/2010
//07/29/2011 Made major modifications. Moved all drag and drop code out of csgPage.js. Created page specific
//javascript files. txei_dragAndDrop.js, help_dragAndDrop.js, etc. Solved major problem on drag and drop events by
//always referencing the top window when get or show is fired.
function csgDragAndDrop(spUniqueName)
{
    //07/29/2011 removed headerTitleSpan
    var oThis = this;
    //get ids from unique name
    this.outerDivId = "__dd" + spUniqueName + "OuterDiv";
    this.headerDivId = "__dd" + spUniqueName + "HeaderDiv";
    this.closeImgId = "__dd" + spUniqueName + "CloseImg";
    this.iframeId = "__dd" + spUniqueName + "IFrame";
    //get form elements - DIV, IFRAME
    this.outerDiv = top.$get(oThis.outerDivId);
    this.headerDiv = top.$get(oThis.headerDivId);
    this.closeImg = top.$get(oThis.closeImgId);
    this.iFrame = top.$get(oThis.iframeId);
    this.textBoxToSetFocus;
    this.childUniqueNames;
    //
    this.form = document.forms[0];
    //
    _dragApproved = false;
    //move()
    //11/21/2010
    //07/29/2011 removed drag and drop variables, _temp1, _x, _y, etc. from class.
    //07/30/2011 drag on header div
    this.move = function ()
    {
        if (window.event.srcElement.id == oThis.headerDiv.id)
        {
            if (window.event.button == 1 && _dragApproved)
            {
                oThis.outerDiv.style.pixelLeft = _temp1 + window.event.clientX - _x;
                oThis.outerDiv.style.pixelTop = _temp2 + window.event.clientY - _y;
                return false;
            }
        }
    }

    //drags()
    //11/16/2010
    //07/29/2011 major testing, clean up
    this.drags = function ()
    {
        if (!document.all) { return; }
        //07/26/2011
        if (!window.event) { return; }
        var oElement = window.event.srcElement;
        if (!window.event.srcElement) { return; }
        //07/28/2011 This method is fired in the document.onmousedown event. Ignore all elements that do not
        //have an id with the prefix "__dd". Only drag and drops have these ids.
        if (!oElement.id) { return; }
        //07/30/2011 must be a div
        if (oElement.tagName != "DIV") { return; }
        //07/28/2011 must be a drag and drop
        if (oElement.id.substr(0, 4) != "__dd") { return; }
        //07/24/2011
        if (oThis.headerDiv)
        {
            //----------------------------------------------------------------------------------------------------------
            //07/29/2011
            //This step is neccessary because when the header div is clicked
            //a different drag and drop div is referenced by oThis. This is corrected by getting a reference
            //to the same drag and drop where the clicked header div is.
            if (oElement.id != oThis.headerDiv.id) { oThis = dragAndDrop_getDragAndDrop(oElement, oThis); }
            //----------------------------------------------------------------------------------------------------------
                if (oElement.id == oThis.headerDiv.id)
                {
                _dragApproved = true;
                if (oThis.outerDiv)
                {
                    //07/30/2011 select this drag and drop
                    dragAndDrop_select(oThis);
                    dragAndDrop_bringToFront();
                    _temp1 = oThis.outerDiv.offsetLeft;
                    _temp2 = oThis.outerDiv.offsetTop;
                    _x = window.event.clientX;
                    _y = window.event.clientY;
                    document.onmousemove = oThis.move;
                }
            }
        }
    }
    document.onmousedown = oThis.drags;
    document.onmouseup = new Function("_dragApproved=false;")

    //setLocationProperties()
    //07/31/2011
    this.setLocationProperties = function ()
    {
        var oTop;
        var oLeft;
        var x = (screen.width / 2) - (oThis.outerDiv.style.pixelWidth / 2);
        var y = (screen.height / 3) - (oThis.outerDiv.style.pixelHeight / 2);
        oTop = y + "px";
        oLeft = x + "px";
        if (oTop) { oThis.outerDiv.style.top = oTop; }
        if (oLeft) { oThis.outerDiv.style.left = oLeft; }
    }

    //show()
    //07/31/2011
    this.show = function (opdd)
    {
        //07/30/2011 pass <opdd> as an argument when calling show() from outside the class so that oThis is updated.
        //For example, this is necessary in dragAndDrop_show()
        if (opdd) { oThis = opdd; }
        oThis.outerDiv.style.display = "block";
        dragAndDrop_select(oThis);
        dragAndDrop_bringToFront();
    }

    this.headerDivClick = function ()
    {
        //07/29/2011
        if (!window.event) { return; }
        var oElement = window.event.srcElement;
        if (!window.event.srcElement) { return; }
        //07/29/2011 This method is fired in the document.onmousedown event. Ignore all elements that do not
        //have an id with the prefix "__dd". Only drag and drops have these ids.
        if (!oElement.id) { return; }
        //07/30/2011 must be a div
        if (oElement.tagName != "DIV") { return; }
        //07/29/2011 must be a drag and drop
        if (oElement.id.substr(0, 4) != "__dd") { return; }
        //----------------------------------------------------------------------------------------------------------
        //07/30/2011
        //This step is neccessary because when the header div is clicked
        //a different drag and drop div is referenced by oThis. This is corrected by getting a reference
        //to the same drag and drop where the clicked header div is.
        if (oElement.id != oThis.headerDiv.id) { oThis = dragAndDrop_getDragAndDrop(oElement, oThis); }
        //----------------------------------------------------------------------------------------------------------
        //07/30/2011 select this drag and drop
        dragAndDrop_select(oThis);
        dragAndDrop_bringToFront();
        if (oThis.textBoxToSetFocus) { oThis.focusOnTextBox(oThis.textBoxToSetFocus); }
    }
    oThis.headerDiv.onclick = oThis.headerDivClick;

    //11/16/2010
    //isVisible()
    this.isVisible = function () { return (oThis.outerDiv.style.display == "block"); }

    //11/16/2010
    //setValueOfIFrameElement(<opElementId>, <oValue>)
    this.setValueOfIFrameElement = function (opElementId, oValue)
    {
        var oElement;
        if (oThis.iFrame)
        {
            oElement = oThis.iFrame.contentWindow.document.getElementById(opElementId);
            if (oElement) { oElement.value = oValue; }
        }
    }

    //11/16/2010
    //iFrameUpdatePanelPostBack()
    this.iFrameUpdatePanelPostBack = function ()
    {
        if (oThis.iFrame)
        {
            if (oThis.iFrame.contentWindow)
            {
                if (oThis.iFrame.contentWindow.gridTable)
                {
                    if (oThis.iFrame.contentWindow.gridTable.csgUpdatePanel) { oThis.iFrame.contentWindow.gridTable.csgUpdatePanel.doPostBack(); }
                }
            }
        }
    }

    if (oThis.closeImg)
    {
        oThis.closeImgMouseOver = function () { oThis.closeImg.src = __imagesPath + "csgDragAndDropCloseMouseOver.gif"; }
        oThis.closeImgMouseOut = function () { oThis.closeImg.src = __imagesPath + "csgDragAndDropClose.gif"; }
        oThis.closeImgClick = function ()
        {
            //07/29/2011
            if (window.event)
            {
                var oElement = window.event.srcElement;
                if (window.event.srcElement)
                {
                    var oElementInfo = dragAndDrop_ElementIdInfo(oElement);
                    if (oElementInfo.uniqueName)
                    {
                        var oOuterDivInfo = dragAndDrop_ElementIdInfo(oThis.outerDiv);
                        if (oOuterDivInfo.uniqueName)
                        {
                            //----------------------------------------------------------------------------------------------------------
                            //07/29/2011
                            //This step is neccessary because when the header div is clicked
                            //a different drag and drop div is referenced by oThis. This is corrected by getting a reference
                            //to the same drag and drop where the clicked header div is.
                            if (oElement.id != oThis.headerDiv.id) { oThis = dragAndDrop_getDragAndDrop(oElement, oThis); }
                            //----------------------------------------------------------------------------------------------------------
                        }
                    }
                }
            }
            oThis.outerDiv.style.display = "none";
            //08/24/2011
            pageHourGlassHide();
            oThis.hideChildDragAndDrops();
        }
        oThis.closeImg.onmouseover = oThis.closeImgMouseOver;
        oThis.closeImg.onmouseout = oThis.closeImgMouseOut;
        oThis.closeImg.onclick = oThis.closeImgClick;
    }

    //07/30/2011
    //hideChildDragAndDrops()
    this.hideChildDragAndDrops = function ()
    {
        if ((top.dragAndDropArray) && (oThis.childUniqueNames))
        {
            for (var j = 0; j < oThis.childUniqueNames.length; j++)
            {
                for (var i = 0; i < top.dragAndDropArray.length; i++)
                {
                    if (top.dragAndDropArray[i][iINDEX_UniqueName] == oThis.childUniqueNames[j])
                    {
                        //08/24/2011
                        pageHourGlassHide();
                        top.dragAndDropArray[i][iINDEX_dd].outerDiv.style.display = "none";
                        break;
                    }
                }
            }
        }
    }

    //pageFocusOnTextBox(<oObject>)
    //11/20/2010
    //<oObject> is either an array of textbox ids or it is the id of a textbox.
    //if it is an array, focus on the first empty textbox.
    //**** NOTICE ****
    //must have an iframe containing the textbox
    this.focusOnTextBox = function (oObject)
    {
        var ocontentWindow;
        this.textBoxToSetFocus = oObject;
        //07/29/2011
        //if no iframe do this, used for log in drag and drop
        var otextBox = oThis.outerDiv.document.getElementById(oObject);
        if (otextBox)
        {
            try { otextBox.focus(); } catch (e) { }
            return;
        }
        //if iframe, do this
        if (oThis.iFrame)
        {
            if (oThis.iFrame.contentWindow)
            {
                ocontentWindow = oThis.iFrame.contentWindow;
                //if we got an array, do this
                if (oObject instanceof Array)
                {
                    for (var i = 0; i < oObject.length; i++)
                    {
                        otextBox = ocontentWindow.$get(oObject[i]);
                        if (otextBox)
                        {
                            if (otextBox.value.length == 0)
                            {
                                //focus on first empty textbox then bail
                                try { otextBox.focus(); } catch (e) { }
                                break;
                            }
                        }
                    }
                    //if none are empty, focus on the first one
                    if (otextBox == null)
                    {
                        otextBox = ocontentWindow.$get(oObject[0]);
                        if (otextBox) { try { otextBox.focus(); } catch (e) { } }
                    }
                }
                else
                {
                    //no array, do this
                    otextBox = ocontentWindow.document.getElementById(oObject);
                    if (otextBox) { try { otextBox.focus(); } catch (e) { } }
                }
            }
        }
    }

    //getElementFromContentWindow(<opId>)
    //11/27/2010
    this.getElementFromContentWindow = function (opId)
    {
        var oElement = false;
        if (oThis.iFrame)
        {
            if (oThis.iFrame.contentWindow) { oElement = oThis.iFrame.contentWindow.$get(opId); }
        }
        return oElement;
    }
    
}

//07/31/2011
//dragAndDrop_maxZIndex()
function dragAndDrop_maxZIndex()
{
    var odd;
    var imaxIndex = 0;
    var icurrentIndex;
    // Compute the maximal z-index of other drag and drops
    if (top.dragAndDropArray)
    {
        for (var i = 0; i < top.dragAndDropArray.length; i++)
        {
            odd = top.dragAndDropArray[i][iINDEX_dd];
            if (odd.isVisible() == true)
            {
                if (odd.outerDiv.style.zIndex == '') { continue; }
                icurrentIndex = parseInt(odd.outerDiv.style.zIndex);
                if (imaxIndex < icurrentIndex) { imaxIndex = icurrentIndex; }
            }
        }
    }
    return imaxIndex;
}

//07/30/2011
//dragAndDrop_bringToFront()
function dragAndDrop_bringToFront()
{
    if (top.dragAndDropArray)
    {
        //get the max z-index
        var imaxIndex = dragAndDrop_maxZIndex();
        //set the max z-index
        for (var i = 0; i < top.dragAndDropArray.length; i++)
        {
            if (top.dragAndDropArray[i][iINDEX_isSelected] == true)
            {
                top.dragAndDropArray[i][iINDEX_dd].outerDiv.style.zIndex = imaxIndex + 1;
                break;
            }
        }
    }
}

//dragAndDrop_selectedDragAndDrop()
//08/26/2011
function dragAndDrop_selectedDragAndDrop()
{
    if (top.dragAndDropArray)
    {
        for (var i = 0; i < top.dragAndDropArray.length; i++)
        {
            if (top.dragAndDropArray[i][iINDEX_isSelected] == true) { return top.dragAndDropArray[i][iINDEX_dd]; }
        } 
    }
    return false;
}

//dragAndDrop_ElementIdInfo(<opElement>)
//07/29/2011
//The naming convention for element ids in the drag and drop is <prefix><uniqueName><suffix>.
//<prefix> is always "__dd"
//<uniqueName> is some unique name like "LogIn" or "txeiAccountSiteForm40"
//<suffix> is either "OuterDiv", "HeaderDiv", "CloseImg", "IFrameDiv", or "IFrame"
function dragAndDrop_ElementIdInfo(opElement)
{
    if (!opElement) { return; }
    if (!opElement.id) { return; }
    var oPrefix = "__dd";
    var oSuffixes = new Array("OuterDiv", "HeaderDiv", "CloseImg", "IFrameDiv", "IFrame");
     var oId = opElement.id;
    var oInfo = new Object();
    //make sure this is either an outer div or a header div for a drag and drop
    if (oId)
    {
        if (oId.length > oPrefix.length)
        {
            //make sure the id begins with "__dd"
            if (oId.substr(0, oPrefix.length) == oPrefix)
            {
                for (var i = 0; i < oSuffixes.length; i++)
                {
                    if (oId.lastIndexOf(oSuffixes[i]) > -1)
                    {
                        oInfo.uniqueName = oId.substr(oPrefix.length, oId.length - oPrefix.length - oSuffixes[i].length);
                        oInfo.suffix = oSuffixes[i];
                        break;
                    }
                }
            }
        }
    }
    return oInfo;
}

//dragAndDrop_getDragAndDrop(<opElement>, <opThis>)
//07/28/2011 see if either an outer div or header div is clicked
function dragAndDrop_getDragAndDrop(opElement, opThis)
{
    if (top.dragAndDropArray)
    {
        var oInfo = dragAndDrop_ElementIdInfo(opElement);
        //if oInfo.uniqueName and oInfo.suffix are defined then we have a drag and drop
        if ((oInfo.uniqueName) && (oInfo.suffix))
        {
            for (var i = 0; i < top.dragAndDropArray.length; i++)
            {
                if (top.dragAndDropArray[i][iINDEX_UniqueName] == oInfo.uniqueName) { return top.dragAndDropArray[i][iINDEX_dd]; }
            }
        }
    }
    //if we get here, return what we started with
    return opThis;
}

//----------------------------------------------------------------------------------------------------------------
//dragAndDrop_get(<opUniqueName>, <opChildUniqueNames>) and dragAndDrop_show(<opFunction>, <opTextBox>) are used in
//page specific javascript files, help_dragAndDrop.js, txei_dragAndDrop.js, etc.
//
// NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE ** NOTICE
//
//All drag and drops should be instantiated with dragAndDrop_get(<opUniqueName>, <opChildUniqueNames>) so that the
//drag and drop is included in top.dragAndDropArray. This will avoid instability with drag and drops, especially
//those with child drag and drops.
//----------------------------------------------------------------------------------------------------------------

//dragAndDrop_get(<opUniqueName>, <opChildUniqueNames>)
//07/29/2011
//07/30/2011 used unique names to locate/hide/show drag and drops
function dragAndDrop_get(opUniqueName, opChildUniqueNames)
{
    //see if we have this drag and drop already
    if (top.dragAndDropArray)
    {
        for (var i = 0; i < top.dragAndDropArray.length; i++)
        {
            if (top.dragAndDropArray[i][iINDEX_UniqueName] == opUniqueName) { return top.dragAndDropArray[i][iINDEX_dd]; }
        }
    }
    //if we get here we don't have the drag and drop
    var odd = new csgDragAndDrop(opUniqueName);
    if (odd) { if (opChildUniqueNames) { odd.childUniqueNames = opChildUniqueNames } }
    return odd;
}

//dragAndDrop_show(<opFunction>, <opTextBox>)
//07/28/2011
//<opFunction> is the function to get the drag and drop
//<opTextBox> is either the id of a textbox page element or an array of ids
function dragAndDrop_show(opFunction, opTextBox)
{
    if (document.readyState == "complete")
    {
        if (opFunction)
        {
            var odd = opFunction();
            if (odd)
            {
                //07/31/2011 - if the drag and drop is at screen(0,0), center it on the screen
                if ((odd.outerDiv.style.pixelTop == 0) && (odd.outerDiv.style.pixelLeft == 0)) { odd.setLocationProperties(); }
                //update the array info and show the drag and drop
                var oInfo = dragAndDrop_ElementIdInfo(odd.outerDiv);
                dragAndDrop_updateDragAndDropArray(oInfo.uniqueName, odd, false);
                odd.show(odd);
                //07/31/2011
                dragAndDrop_select(odd);
                //select the textbox/textbox array
                if (opTextBox) { odd.focusOnTextBox(opTextBox); }
            }
        }
    }
}

//07/30/2011
//dragAndDrop_select(<opdd>)
//sets top.dragAndDropArray[i][iINDEX_isSelected] = true
function dragAndDrop_select(opdd)
{
    var oInfo = dragAndDrop_ElementIdInfo(opdd.outerDiv);
    if (oInfo.uniqueName)
    {
        if (top.dragAndDropArray)
        {
            for (var i = 0; i < top.dragAndDropArray.length; i++)
            {
                if (top.dragAndDropArray[i][iINDEX_UniqueName] == oInfo.uniqueName) { top.dragAndDropArray[i][iINDEX_isSelected] = true; }
                else { top.dragAndDropArray[i][iINDEX_isSelected] = false; }
            }
        } 
    }
}

//dragAndDrop_updateDragAndDropArray(<opUniqueName>, <opdd>)
//07/29/2011
//<opUniqueName> is the drag and drop unique name
//<opdd> is the drag and drop
function dragAndDrop_updateDragAndDropArray(opUniqueName, opdd)
{
    //if no top.dragAndDropArray, create one
    if (!top.dragAndDropArray) { top.dragAndDropArray = new Array(new Array(opUniqueName, opdd, false)); }
    else
    {
        //if we got this drag and drop already, bail out
        for (var i = 0; i < top.dragAndDropArray.length; i++)
        {
            if (top.dragAndDropArray[i][iINDEX_UniqueName] == opUniqueName) { return; }
        }
        //if we get here, we don't have the drag and drop so add it
        top.dragAndDropArray[top.dragAndDropArray.length] = new Array(opUniqueName, opdd, false);
    }
}

//07/31/2011
//dragAndDrop_changeHeaderDivInnerText(<opdd>, <opNewText>)
//The Header div has the form <div>Title Text<img></div>
//When changing the innerText, the img is wiped out. this is prevented using removeChild()/appendChild()
function dragAndDrop_changeHeaderDivInnerText(opdd, opNewText)
{
    var oChild = opdd.headerDiv.children[0];
    if (oChild)
    {
        opdd.headerDiv.removeChild(oChild);
        opdd.headerDiv.innerText = opNewText;
        opdd.headerDiv.appendChild(oChild);
    }
}

//07/31/2011
//dragAndDrop_showPickGridTable(<opddPickGridTable>, <opddForm>, <opddPickGridTableDisplay>)
//<opddPickGridTable> - double click this to select FIN, EPN, Contaminant, etc.
//<opddForm> - place data from double click on this form
//<opddPickGridTableDisplay> - display the grid dd to double click
function dragAndDrop_showPickGridTable(opddPickGridTable, opddForm, opddPickGridTableDisplay)
{
    if (opddPickGridTable)
    {
        if (opddPickGridTable.iFrame)
        {
            if (opddPickGridTable.iFrame.contentWindow)
            {
                //07/20/2011 used by window.gridTableOnDblClickTR() in pickGridTable pages
                opddPickGridTable.iFrame.contentWindow.dd = opddForm;
                opddPickGridTableDisplay();
            }
        }
    }
}

//07/31/2011
//dragAndDrop_pagePostBackChild(<opdd>)
function dragAndDrop_pagePostBackChild(opdd)
{
    var ocontentWindow;
    var oIFrame;
    if (opdd)
    {
        if (opdd.isVisible())
        {
            oIFrame = opdd.iFrame;
            if (oIFrame)
            {
                ocontentWindow = oIFrame.contentWindow;
                if (ocontentWindow)
                {
                    if (ocontentWindow.postBack)
                    {
                        //08/20/2011 this is the case of a content window that is not a pick gridtable,
                        // like FIN Characteristics. In this case postback each time a new FIN row is selected
                        ocontentWindow.postBack();
                    }
                    else
                    {
                        //06/14/2011 do this to postback pick gridtable
                        if (ocontentWindow.gridTable)
                        {
                            //08/20/2011 don't posback every time with the pick gridtables
                            if (opdd.didPostBack) { return; }
                            opdd.didPostBack = true;
                            ocontentWindow.gridTable.csgUpdatePanel.doPostBack();
                        }
                    }
                }
            }
        }
    }
}

//09/08/2011
//dragAndDrop_getElementValue(<opdd>, <opElementId>)
function dragAndDrop_getElementValue(opdd, opElementId)
{
    var oValue = false;
    if (opdd.iFrame)
    {
        if (opdd.iFrame.contentWindow)
        {
            var oElement = opdd.iFrame.contentWindow.document.getElementById(opElementId);
            if (oElement) { oValue = oElement.value; }
        }
    }
    return oValue;
}
//09/07/2011
//dragAndDrop_setElementValue(<opdd>, <opElementId>, <opValue>)
function dragAndDrop_setElementValue(opdd, opElementId, opValue)
{
    if (opdd.iFrame)
    {
        if (opdd.iFrame.contentWindow)
        {
            var oElement = opdd.iFrame.contentWindow.document.getElementById(opElementId);
            if (oElement) { oElement.value = opValue; }
        }
    }
}

//09/15/2011
//dragAndDrop_getElementInnerText(<opdd>, <opElementId>)
function dragAndDrop_getElementInnerText(opdd, opElementId)
{
    var oInnerText = false;
    if (opdd.iFrame)
    {
        if (opdd.iFrame.contentWindow)
        {
            var oElement = opdd.iFrame.contentWindow.document.getElementById(opElementId);
            if (oElement) { oInnerText = oElement.innerText; }
        }
    }
    return oInnerText;
}
//09/15/2011
//dragAndDrop_setElementInnerText(<opdd>, <opElementId>, <opInnerText>)
function dragAndDrop_setElementInnerText(opdd, opElementId, opInnerText)
{
    if (opdd.iFrame)
    {
        if (opdd.iFrame.contentWindow)
        {
            var oElement = opdd.iFrame.contentWindow.document.getElementById(opElementId);
            if (oElement) { oElement.innerText = opInnerText; }
        }
    }
}
//09/15/2011
//dragAndDrop_setElementInnerHTML(<opdd>, <opElementId>, <opInnerHTML>)
function dragAndDrop_setElementInnerHTML(opdd, opElementId, opInnerHTML)
{
    if (opdd.iFrame)
    {
        if (opdd.iFrame.contentWindow)
        {
            var oElement = opdd.iFrame.contentWindow.document.getElementById(opElementId);
            if (oElement) { oElement.innerHTML = opInnerHTML; }
        }
    }
}
//10/22/2011
//dragAndDrop_dropDownListSetValue(<opdd>, <opDropDownListId>, <opInnerHTML>)
function dragAndDrop_dropDownListSetValue(opdd, opDropDownListId, opInnerHTML)
{
    if (opdd)
    {
        if (opdd.iFrame)
        {
            if (opdd.iFrame.contentWindow)
            {
                //notice that this gets the dropdownlist DOM element not the csgDropDownList
                var odropDownList = opdd.iFrame.contentWindow.document.getElementById(opDropDownListId);
                if (odropDownList) { dropDownListSelectFromInnerText(odropDownList, opInnerHTML); }
            }
        }
    }
}



//01/15/2012
//dragAndDrop_gridTable(<opdd>)
function dragAndDrop_gridTable(opdd)
{
    var oReturn = false;
    if (opdd)
    {
        if (opdd.iFrame)
        {
            if (opdd.iFrame.contentWindow)
            {
                if (opdd.iFrame.contentWindow.gridTable) { oReturn = opdd.iFrame.contentWindow.gridTable; }
            }
        }
    }
    return oReturn;
}
