//==============================================================================
// CONSTANTS

var MszFloaterColor = 'yellow'; 
var MszFloaterWidth = 50;
var MszFloaterHeight = 20;
var MszDragHandle = "DragHandle";
var MnInsertWidth = 20;  // the sensitivity for inserting a dim tile.
var MnInsertHeight = 7;

//==============================================================================
// VARIABLES

var m_clDivContentsScroll = null;
var m_clFloater = null;
var m_bSwap = false;
var m_bInsertTop = false;
var m_bInsertLeft = false;
var m_bLeftButton = false;
var m_clOthersPanel = null;
//==============================================================================
// FUNCTIONS

//------------------------------------------------------------------------------
function M_UpdateBackGroundColor(
   )
{
   var clPrivate;
   var strActiveDimColor = ".ActiveDimension";
   var strOtherDimColor = ".DimensionOther";
   var strDDRowDimColor = ".DragNDropRow";
   var strDDOtherDimColor = ".DragNDropOther";
   var strDDColDimColor = ".DragNDropCol";

   clPrivate = M_clDragNDrop;
   if (clPrivate.m_clFlyOverElement)
   {      
      if (clPrivate.m_clFlyOverElement.id != "Oth-1") {
         if (clPrivate.m_clFlyOverElement.id.indexOf("Row") != -1) {
            clPrivate.m_clFlyOverElement.style.backgroundColor = getBackGroundColor(strDDRowDimColor);
         }
         else if (clPrivate.m_clFlyOverElement.id.indexOf("Oth") != -1) {
             clPrivate.m_clFlyOverElement.style.backgroundColor = "";

             //unhighlight other bar
             var clElement;
             var clToolbar;
             var clItems = new Array();
             var x;


            clToolbar = $find("ctl00_MainContent_RadToolBarOtherDims_" + clPrivate.m_clFlyOverElement.id.substr(3));
             clItems = clToolbar.get_allItems();
             for (x in clItems) {
                 clElement = clItems[x].get_element();
                 clElement.style.backgroundColor = "";
             }
                      
         }
         else if (clPrivate.m_clFlyOverElement.id.indexOf("Col") != -1) {
            clPrivate.m_clFlyOverElement.style.backgroundColor = getBackGroundColor(strDDColDimColor);  
         }
      }
      else {
         clPrivate.m_clFlyOverElement.style.backgroundColor =  "lightgrey";
      }
   }
}



//------------------------------------------------------------------------------
function M_GJsdnd_HighLightTarget(
   )
{
   var clPrivate;
   var clTargetElement;
   var nDivContentsScrollBottom;
   var nDivContentsScrollLeft;
   var nDivContentsScrollRight;
   var nDivContentsScrollTop;
   var unFloaterBottom;
   var unFloaterLeft;
   var unFloaterRight;
   var unFloaterTop;
   var unTargetLeft;
   var unTargetTop;
   var nScrollLeft = 0;
   var nScrollTop = 0;
   
   clPrivate = M_clDragNDrop;
 
   M_UpdateBackGroundColor();
   clTargetElement = clPrivate.GetTarget(m_clFloater);
   unFloaterLeft = m_clFloater.offsetLeft;
   unFloaterTop = m_clFloater.offsetTop;
   unFloaterRight = unFloaterLeft + m_clFloater.offsetWidth;
   unFloaterBottom = unFloaterTop + m_clFloater.offsetHeight;
   if (m_clDivContentsScroll != null) {
      nDivContentsScrollLeft = PJsdnd.prototype.GetAbsPos(m_clDivContentsScroll, "Left");
		nDivContentsScrollTop = PJsdnd.prototype.GetAbsPos(m_clDivContentsScroll, "Top");
      nDivContentsScrollRight = nDivContentsScrollLeft + m_clDivContentsScroll.offsetWidth;
      nDivContentsScrollBottom = nDivContentsScrollTop + m_clDivContentsScroll.offsetHeight;
      if (unFloaterRight >= nDivContentsScrollLeft 
            && unFloaterRight <= nDivContentsScrollRight
            && unFloaterBottom >= nDivContentsScrollTop 
            && unFloaterBottom <= nDivContentsScrollBottom) {
         nScrollLeft = m_clDivContentsScroll.scrollLeft;
         nScrollTop = m_clDivContentsScroll.scrollTop;
      }
 }


   

   if (clTargetElement != null && 
       clTargetElement.id != "Oth-1" &&
       clPrivate.m_clSourceElement != null && 
       clTargetElement.id != clPrivate.m_clSourceElement.id) {
       if (clTargetElement.id.indexOf("Oth") != -1) {
           //allow for scrolling in the Others panel
           unTargetLeft = clPrivate.GetAbsPos(clTargetElement, "Left") - m_clOthersPanel.scrollLeft;
       }
       else {
           unTargetLeft = clPrivate.GetAbsPos(clTargetElement, "Left") - nScrollLeft;
       }
       
       unTargetTop = clPrivate.GetAbsPos(clTargetElement, "Top") - nScrollTop;

      clPrivate.m_clFlyOverElement = clTargetElement;
      // As each table has at least one dimension along the row and one dimension along the
      // column. If the source dimension is the last one, the user should not be able to insert it.
      if (clPrivate.m_clSourceElement != null) {
         if (clPrivate.m_clSourceElement.getAttribute("count") == 1) {
            m_clFloater.innerHTML = "<img src='../Bmp/dragicon.gif' border=0 alt=''>";
            m_bSwap = true;
         }
         else {
            // If the target dimension is along the column and in case of inserting, the top
            // or the bottom side should be highlighted.
            if (clTargetElement.id.indexOf("Col") != -1) {
               if (Math.abs((unFloaterTop + MszFloaterHeight) 
                  - (unTargetTop + clTargetElement.offsetHeight)) <= MnInsertHeight)
               {
                  m_clFloater.innerHTML = "<img src='../Bmp/dragicon_bottom.gif' border=0 alt=''>";
                  m_bSwap = false;
                  m_bInsertTop = false;
                  m_bInsertLeft = false;
               }
               else if ((Math.abs((unFloaterTop + MszFloaterHeight) - unTargetTop) <= MnInsertHeight)
                        && (clPrivate.m_clSourceElement.getAttribute("count") != 1))
               {
                  m_clFloater.innerHTML = "<img src='../Bmp/dragicon_top.gif' border=0 alt=''>";
                  m_bSwap = false;
                  m_bInsertTop = true;
                  m_bInsertLeft = false;
               }
               else {
                  m_clFloater.innerHTML = "<img src='../Bmp/dragicon.gif' border=0 alt=''>";
                  m_bSwap = true;
               }
            }
            // Table view: If the target dimension is along the "rows" or the "other" areas 
            // and in case of inserting, the left or the right side should be highlighted.
            else {
               if (clTargetElement.id.indexOf("Row") != -1 ||
                   clTargetElement.id.indexOf("Oth") != -1)
               {

                  if (Math.abs((unFloaterLeft + MszFloaterWidth) 
                     - (unTargetLeft + clTargetElement.offsetWidth)) <= MnInsertWidth)
                  {                     
                        m_clFloater.innerHTML = "<img src='../Bmp/dragicon_right.gif' border=0 alt=''>";                      
                     
                     m_bSwap = false;
                     m_bInsertTop = false;
                     m_bInsertLeft = false;
                  }
                  else if ((Math.abs((unFloaterLeft + MszFloaterWidth) - unTargetLeft) <= MnInsertWidth)
                        && (clPrivate.m_clSourceElement.getAttribute("count") != 1))
                  {                     
                        m_clFloater.innerHTML = "<img src='../Bmp/dragicon_left.gif' border=0 alt=''>";
                        m_bSwap = false;
                        m_bInsertTop = false;
                        m_bInsertLeft = true;
                     
                  }
                  else {
                     m_clFloater.innerHTML = "<img src='../Bmp/dragicon.gif' border=0 alt=''>";
                    
                        m_bSwap = true;
                        m_bInsertTop = false;
                        m_bInsertLeft = false;
                    
                  }
               }
            }   
         }
        clTargetElement.style.backgroundColor = MszFloaterColor; //doesn't highlight the "other" dimension
        //find the way to highlight that toolbar
        if (clTargetElement.id.indexOf("Oth") != -1) {
            var clElement;
            var clToolbar;
            var clItems = new Array();
            var x;
            

//             clElement = clPrivate.m_clWindow.document.getElementById(clTargetElement.lastChild.id);
//             clElement.style.backgroundColor = MszFloaterColor;


//           clToolbar = $find(clTargetElement.lastChild.id);
//           clElement = clToolbar.get_element();
//           clElement.style.backgroundColor = MszFloaterColor;

            clToolbar = $find("ctl00_MainContent_RadToolBarOtherDims_" + clTargetElement.id.substr(3));
            clItems = clToolbar.get_allItems();
            for (x in clItems) {
                clElement = clItems[x].get_element();               
                clElement.style.backgroundColor = MszFloaterColor;
            }

        
        }

      }
   }
   // If there is no "other" dimension, the source should be inserted to the right
   // of "Other:".
   else if ((clTargetElement != null && 
            (clTargetElement.id == "Oth-1" )) && 
            (clPrivate.m_clSourceElement != null && clPrivate.m_clSourceElement.getAttribute("count") != 1))
   {
      clPrivate.m_clFlyOverElement = clTargetElement;
      clTargetElement.style.backgroundColor = MszFloaterColor;
      m_clFloater.innerHTML = "<img src='../Bmp/dragicon.gif' border=0 alt=''>";
      m_bSwap = false;
      m_bInsertTop = false;
      m_bInsertLeft = false;
   }
   else {
      m_clFloater.innerHTML = "<img src='../Bmp/dragicon_dis.gif' border=0 alt=''>";
      m_bSwap = true;
   }
   clPrivate.m_bHighLightInProgress = null;
}

//------------------------------------------------------------------------------
function M_RebuildOtherColRow(
   i_szDim,
   i_szVar
   )
{
   var unDim = parseInt(i_szDim.substr(3));
   return i_szVar + "+='" + unDim.toString() + "'+','";
}

//------------------------------------------------------------------------------
function GJsdnd(
   )
{
   this.m_clPrivate = new PJsdnd();
}

//------------------------------------------------------------------------------
function GJsdnd_Initialize(
   i_clWindow
   )
{
   var aszDim;
   var clDimTile;
   var clDoc;
   var clPrivate;
   var nIndex;
   var szDim;
   var unTarget = 0;

   clPrivate = this.m_clPrivate;
   clPrivate.m_clWindow = i_clWindow;
   m_clFloater = clPrivate.m_clWindow.document.getElementById("DnDFltr");
   m_clDivContentsScroll = clPrivate.m_clWindow.document.getElementById("DivContentsScroll");
   m_clOthersPanel = clPrivate.m_clWindow.document.getElementById("ctl00_MainContent_Others");
   if (m_clFloater != null) {
      M_clDragNDrop = clPrivate;
      clDoc = i_clWindow.document;
      clDoc.onmousedown = this.StartDrag;
      clDoc.onmouseup = this.EndDrag;
      clDoc.onmousemove = this.DragOver;
      
      clPrivate.m_clTargets = new Array();
      szDim = clPrivate.m_clWindow.document.aspnetForm.Rows.value;
      if (szDim.length > 0) {
         aszDim = szDim.split(",");
         for (nIndex = 0; nIndex < aszDim.length; nIndex++) {
            clDimTile = clPrivate.m_clWindow.document.getElementById("Row" + aszDim[nIndex]);
            if (clDimTile != null) {
               clPrivate.m_clTargets[unTarget++] = clDimTile;
            }
         }
      }
      szDim = clPrivate.m_clWindow.document.aspnetForm.Cols.value;
      if (szDim.length > 0) {
         aszDim = szDim.split(",");
         for (nIndex = 0; nIndex < aszDim.length; nIndex++) {
            clDimTile = clPrivate.m_clWindow.document.getElementById("Col" + aszDim[nIndex]);
            if (clDimTile != null) {
               clPrivate.m_clTargets[unTarget++] = clDimTile;
            }
         }
      }
      szDim = clPrivate.m_clWindow.document.aspnetForm.Others.value;      
      var clButton;
          if (szDim.length > 0) {
              aszDim = szDim.split(",");
              for (nIndex = 0; nIndex < aszDim.length; nIndex++) {                 
                  clDimTile = $find("ctl00_MainContent_RadToolBarOtherDims_" + aszDim[nIndex]);
                 if (clDimTile != null) {
                     clButton = clDimTile.get_element();
                     clButton.id = "Oth" + aszDim[nIndex];
                     clPrivate.m_clTargets[unTarget++] = clButton;
                  }
              }
         }
       
          // do the "other" dim area
              var clToolbar = $find("ctl00_MainContent_RadToolBarOtherDims");
              if (clToolbar != null) {
                  clDimTile = clToolbar.findItemByValue("Oth-1");
                  if (clDimTile != null) {
                      clButton = clDimTile.get_element();
                      clButton.style.backgroundColor = "lightgrey";
                      clButton.id = "Oth-1";
                      clPrivate.m_clTargets[unTarget++] = clButton;
                  }
              }

     
   }
}
GJsdnd.prototype.Initialize = GJsdnd_Initialize;

//------------------------------------------------------------------------------
function GJsdnd_StartDrag(i_clEvent) {
   var clElement;
   var clEvent;
   var clPrivate;
   var clHandle;
   var clTile;
   var szTileId;
   
   clPrivate = M_clDragNDrop;
   
   // Different DOM implementations.
   clEvent = (i_clEvent) ? i_clEvent : clPrivate.m_clWindow.event;
   clHandle = (clEvent.target) ? clEvent.target : clEvent.srcElement;
   if (clHandle && clHandle.id && clHandle.id.indexOf(MszDragHandle) != -1) {

       adjustTelerikButtonsHighlighting(false);
      
      // element is a valid drag and drop field.  start "drag"
      szTileId = clHandle.getAttribute("TileId")
      if (szTileId) {
         clTile = clPrivate.m_clWindow.document.getElementById(szTileId);
         clPrivate.m_clSourceElement = clTile;
         if (G_dIEVersion) {
            if (clEvent.button == 1) {
               m_bLeftButton = true;
            }
            m_clFloater.innerHTML = "<img src='../Bmp/dragicon_dis.gif' border=0 alt=''>";
            m_clFloater.style.width = MszFloaterWidth;
            m_clFloater.style.height = MszFloaterHeight;
            // When the floater is created, the mouse should be at the bottom of the floater.
            var strWidth = m_clFloater.style.width;
            var strHeight = m_clFloater.style.height;
            m_clFloater.style.left = clEvent.clientX - strWidth.substr(0, strWidth.length - 2);
            m_clFloater.style.top  = clEvent.clientY - strHeight.substr(0, strHeight.length - 2);

            var strLeft = m_clFloater.style.left;
            var nLeft = strLeft.substr(0, strLeft.length - 2)
            var strTop = m_clFloater.style.top;
            var nTop = strTop.substr(0, strTop.length - 2);
            m_clFloater.offsetX = clEvent.clientX - nLeft;
            m_clFloater.offsetY = clEvent.clientY - nTop;
         }
         else {
            if (clEvent.button == 0) {
               m_bLeftButton = true;
            }
            m_clFloater.innerHTML = "<img src='../Bmp/dragicon.gif' border=0 alt=''>";
            m_clFloater.style.width = MszFloaterWidth;
            m_clFloater.style.height = MszFloaterHeight;
            // When the floater is created, the mouse should be at the bottom of the floater.
            var strWidth = m_clFloater.style.width;
            var strHeight = m_clFloater.style.height;
            m_clFloater.style.left = clEvent.pageX - (strWidth.substr(0, strWidth.length - 2));
            m_clFloater.style.top  = clEvent.pageY - (strHeight.substr(0, strHeight.length - 2));
            var strLeft = m_clFloater.style.left;
            var strTop = m_clFloater.style.top;
            m_clFloater.offsetX = clEvent.clientX - strLeft.substr(0, strLeft.length - 2);
            m_clFloater.offsetY = clEvent.clientY - strTop.substr(0, strTop.length - 2);
         }   
         m_clFloater.style.visibility = 'visible';
         m_clFloater.style.zIndex = 99;
         m_clFloater.style.overflow = 'hidden';
         m_clFloater.style.textOverflow = 'ellipsis';
      }
   }
   else {
      return true;
   }
   return false;
}
GJsdnd.prototype.StartDrag = GJsdnd_StartDrag;

//------------------------------------------------------------------------------
function GJsdnd_EndDrag(
   )
{
   var bKeepSort = true;
   var clDest;
   var clElement; 
   var clPrivate;
   var clSrce;
   var clForm;
   var szCol = "";
   var szRow = "";
   var szOth = "";
   var szVarDest;
   var szVarSrce;
   var unTempDim;
   var nFlag = 0;

   clPrivate = M_clDragNDrop;
   adjustTelerikButtonsHighlighting(true);
   M_UpdateBackGroundColor();
   if (clPrivate.m_clSourceElement != null) {
      clSrce = clPrivate.m_clSourceElement.id;
   }
   else {
      return true;
   }
   
   if (clPrivate.GetTarget(m_clFloater) != null) {
      clDest = clPrivate.GetTarget(m_clFloater).id;
   }
   
   if ((clSrce != null) && (clDest != null)) {
      szVarSrce = 'sz' + clSrce.substr(0,3);
      szVarDest = 'sz' + clDest.substr(0,3);
      unSourceDim = eval(clSrce.substr(3));
      unTargetDim = eval(clDest.substr(3));
      if ((unSourceDim != null) && (unTargetDim != null) 
            && (unTargetDim != unSourceDim) 
            && (clPrivate.m_clSourceElement.getAttribute("count") != 1 || (clDest != "Oth-1"))) 
      {
         // Loop through all the dimensions from the left along the "other", then 
         // from the top along the column, and from the left along the row.
         for (unTarget = 0; unTarget < clPrivate.m_clTargets.length; unTarget++) {
            clElement = clPrivate.m_clTargets[unTarget].id;
            // If the element is the different to the target and the source, just leave it
            // in the same position.
            if (clElement != clDest && clElement != clSrce && clElement != "Oth-1" ) {
               szVarName = 'sz' + clElement.substr(0,3);
               eval(M_RebuildOtherColRow(clElement, szVarName));
            } else {
               // Insert a dimension
               if (!m_bSwap) {
                  // In this case of inserting a dimension on the left or on the top of the
                  // target, the source should be insert first.
                  // Otherwise, the target should be insert first.
                  if ((clElement == clDest) && (clDest != "Oth-1")) {
                     if (m_bInsertTop || m_bInsertLeft) {
                        eval(M_RebuildOtherColRow(clSrce, szVarDest));
                        eval(M_RebuildOtherColRow(clDest, szVarDest));
                     }
                     else {
                        eval(M_RebuildOtherColRow(clDest, szVarDest));
                        eval(M_RebuildOtherColRow(clSrce, szVarDest));
                     }
                  }
                  // In this case the "other" area is empty and we are dragging another dimension
                  // to it.
                  else if (clElement != clSrce && (clDest == "Oth-1" )) {
                     if (nFlag == 0 ) {
                        eval(M_RebuildOtherColRow(clSrce, szVarDest));
                        nFlag = 1;
                      }
                  }
               }
               // Swap dimensions
               else {
                  // In case of swaping dimensions and the element: 
                  // If the element equal to the target, the source should be inserted in 
                  // the target position.
                  // If the element equal to the source, the target should be inserted in 
                  // the source position.
                  if (clElement == clDest) {
                     eval(M_RebuildOtherColRow(clSrce, szVarDest));
                  }
                  else if (clElement == clSrce){
                     eval(M_RebuildOtherColRow(clDest, szVarSrce));
                  }
               }
            } 
            // Record the last Col Dimension's DimNum, it will be used for checking
            // if the inner most column is dragged.
            szVarTemp = 'sz' + clElement.substr(0,3);
            if (szVarTemp == "szCol") {
               unTempDim = eval(clElement.substr(3));
            }
         }

         if (szVarSrce == "szCol" && unSourceDim == unTempDim) {
            bKeepSort = false;
         }
         // When dragging and dropping dimensions from other dimensions to a Row or 
         // column dimension (not to other dimension) or vice versa (from row/column to 
         // other dimensions), the sorting order should be reset and also other dimension's 
         // active item id should be reset as well.
         if ( (szVarSrce == "szOth" || szVarDest == "szOth") && szVarDest != szVarSrce) {
            bKeepSort = false;
            clForm = clPrivate.m_clWindow.document.aspnetForm;
         }
         if (szCol.charAt(szCol.length - 1) == ',') {
            szCol = szCol.substr(0, szCol.length - 1);
         }
         if (szRow.charAt(szRow.length - 1) == ',') {
            szRow = szRow.substr(0, szRow.length - 1);
         }
         if (szOth.charAt(szOth.length - 1) == ',') {
            szOth = szOth.substr(0, szOth.length - 1);
         }
         
         clPrivate.m_clWindow.document.aspnetForm.Cols.value = szCol;
         clPrivate.m_clWindow.document.aspnetForm.Rows.value = szRow;
         clPrivate.m_clWindow.document.aspnetForm.Others.value = szOth;
         clPrivate.m_clWindow.document.aspnetForm.FirstRow.value = 0;
         clPrivate.m_clWindow.document.aspnetForm.FirstCol.value = 0;
         clPrivate.m_clWindow.document.aspnetForm.ChartStartRow.value = 0;
         clPrivate.m_clWindow.document.aspnetForm.ChartStartCol.value = 0;
         //if enlarged chart was displayed - switch back to chart preview after pivoting
         if (clPrivate.m_clWindow.document.aspnetForm.FullChartRequest.value == "True" ) {
             clPrivate.m_clWindow.document.aspnetForm.FullChartRequest.value = "False";
         }
         executeWait(clPrivate.m_clWindow.document.aspnetForm);
      }
   }
   if (clSrce != null) {
      m_clFloater.style.visibility = 'hidden';
      clPrivate.m_clSourceElement.style.visibility = 'visible';
      clPrivate.m_clSourceElement = null;
   }
   
   return false;
}
GJsdnd.prototype.EndDrag = GJsdnd_EndDrag;

//------------------------------------------------------------------------------
function GJsdnd_DragOver(i_clEvent) {

   var clEvent;
   var clPrivate;
   
   clPrivate = M_clDragNDrop;
   clEvent = (i_clEvent) ? i_clEvent : clPrivate.m_clWindow.event;
   
	// Spr 008800: When you drag a dimension tile and then release the mouse outside the 
	// Table area, nothing happens.
   if (!m_bLeftButton && clPrivate.m_clSourceElement != null) {
      adjustTelerikButtonsHighlighting(true);
      M_UpdateBackGroundColor();
		m_clFloater.style.visibility = 'hidden';
		clPrivate.m_clSourceElement.style.visibility = 'visible';
		clPrivate.m_clSourceElement = null;

		return false;
	}		
   if (clPrivate.m_clSourceElement != null && clEvent != null)  {
      var strWidth = m_clFloater.style.width;
      var strHeight = m_clFloater.style.height;
      switch (G_nBrowser) {
         case IE:
            // When we start moving the floater, the mouse should be at the bottom of the floater.
            m_clFloater.style.left = clEvent.clientX - (strWidth.substr(0, strWidth.length - 2));
            m_clFloater.style.top = clEvent.clientY - (strHeight.substr(0, strHeight.length - 2));
            break;
         default : //(NS and others)
            // When we start moving the floater, the mouse should be in the middle of the floater.
            m_clFloater.style.left = clEvent.pageX - (strWidth.substr(0, strWidth.length - 2));
            m_clFloater.style.top  = clEvent.pageY - (strHeight.substr(0, strHeight.length - 2));
            break;
      }
      if (!clPrivate.m_bHighLightInProgress) {
         clPrivate.m_bHighLightInProgress = true;
         // setTimeout to create a new thread;
         setTimeout('M_GJsdnd_HighLightTarget()',1);
      }
   }
   else {
      return true;
   }
 
   return false;
}
GJsdnd.prototype.DragOver = GJsdnd_DragOver;

//------------------------------------------------------------------------------
function PJsdnd(
   )
{
   this.m_clSourceElement = null;
   this.m_clWindow = null;
   this.m_clTargets = null;
}

//------------------------------------------------------------------------------
function PJsdndGetAbsPos(
   i_clElement, 
   i_szPos
   ) 
{
   var unPos = 0;

   while (i_clElement != null) {
      unPos += i_clElement["offset" + i_szPos];
      i_clElement = i_clElement.offsetParent;
   }

   return unPos;
}
PJsdnd.prototype.GetAbsPos = PJsdndGetAbsPos;



function adjustTelerikButtonsHighlighting(enable) {

    var arStyles = new Array();
    var clItems = new Array();
    var clToolbar;
    arStyles = ["noHover"];
   
    var nIndex;

    var szDim = document.aspnetForm.Others.value;
   if (szDim.length > 0) {
        var aszDim = szDim.split(",");

        for (nIndex = 0; nIndex < aszDim.length; nIndex++) {

            clToolbar = $find("ctl00_MainContent_RadToolBarOtherDims_" + aszDim[nIndex]);
            if (clToolbar != null) {
                clItems = clToolbar.get_allItems();
                for (y in clItems) {
                    clElement = clItems[y].get_element();
                    if (enable == false) {
                        $telerik.addCssClasses(clElement, arStyles);
                    }
                    else {
                        $telerik.removeCssClasses(clElement, arStyles);
                    }
                }
            }
        }
    }

}

//------------------------------------------------------------------------------
function PJsdndGetTarget(
   )
{
   var clTargetElement;
   var clPrivate;
   var nDivContentsScrollBottom;
   var nDivContentsScrollLeft;
   var nDivContentsScrollRight;
   var nDivContentsScrollTop;
   var unArea; 
   var unElementBottom;
   var unElementLeft;
   var unElementRight;
   var unElementTop;
   var unFloaterBottom;
   var unFloaterLeft;
   var unFloaterRight;
   var unFloaterTop;
   var nScrollLeft = 0;
   var nScrollTop = 0;
   var unTarget;
  
   clPrivate = M_clDragNDrop;
   unFloaterLeft = m_clFloater.offsetLeft;
   unFloaterTop = m_clFloater.offsetTop;
   unFloaterRight = unFloaterLeft + m_clFloater.offsetWidth;
   unFloaterBottom = unFloaterTop + m_clFloater.offsetHeight;
   if (m_clDivContentsScroll != null) {
      nDivContentsScrollLeft = this.GetAbsPos(m_clDivContentsScroll, "Left");
		nDivContentsScrollTop = this.GetAbsPos(m_clDivContentsScroll, "Top");
      nDivContentsScrollRight = nDivContentsScrollLeft + m_clDivContentsScroll.offsetWidth;
      nDivContentsScrollBottom = nDivContentsScrollTop + m_clDivContentsScroll.offsetHeight;
      if (unFloaterRight >= nDivContentsScrollLeft 
            && unFloaterRight <= nDivContentsScrollRight
            && unFloaterBottom >= nDivContentsScrollTop
            && unFloaterBottom <= nDivContentsScrollBottom) {

          nScrollLeft = m_clDivContentsScroll.scrollLeft;
         nScrollTop = m_clDivContentsScroll.scrollTop;
      }
   }
   clTargetElement = null;
   for (unTarget = 0; unTarget < clPrivate.m_clTargets.length; unTarget++) {
       clElement = clPrivate.m_clTargets[unTarget];
       if (clElement.id.indexOf("Oth") != -1) {
       //allow for scrolling in the Others panel
           unElementLeft = this.GetAbsPos(clElement, "Left") - m_clOthersPanel.scrollLeft;
       }
       else {
           unElementLeft = this.GetAbsPos(clElement, "Left") - nScrollLeft;
       }
		unElementTop = this.GetAbsPos(clElement, "Top") - nScrollTop;
      unElementRight = unElementLeft + clElement.offsetWidth;
      unElementBottom = unElementTop + clElement.offsetHeight;
      if (unFloaterRight >= unElementLeft && unFloaterRight <= unElementRight
            && unFloaterBottom >= unElementTop && unFloaterBottom <= unElementBottom) {
         clTargetElement = clElement;
         break;
      }
   }
   
   

   
   return clTargetElement;
}
PJsdnd.prototype.GetTarget = PJsdndGetTarget;

function InitializeFloater() {
   var clJsdnd = new GJsdnd();

   clJsdnd.Initialize(this);
}





