﻿// KGPublishOptionControl JScript File
var g_eventX;
var g_eventY;
var g_originalKgId;
var g_locationId;
var g_publishHolderId = 'Contents_LoginView_KGMemberControl_UserObjectSummary_KGPublishOptionControl_KGPublishOptionControl';
// For firefox
var g_splitter1DivScrollTop = -1;
var g_splitter1DivScrollLeft = -1;

// to store component art menu group divs
var g_KGPublishCatMenuGroupDivs = new Array();

function KGPublishOptionControl_CallbackTrigger_Wrapped(_action, 
                                                        _originalKgId, 
                                                        _publishedKgId, 
                                                        _locationId,
                                                        _knowdeShortcut,
                                                        _textVersion,
                                                        _lockData,
                                                        _newName,
                                                        e,
                                                        _sessionNameForPublishKG,
                                                        _callbackScript,
                                                        _isOnCommunityTab)
{
  // debugger;
  var args;


  // Construct the callback arguments
  if(_action.length > 0)
    args = 'action=' + _action;
  
  if(_originalKgId > 0)
    args += '|originalKgId=' + _originalKgId;

  if(_publishedKgId != null && _publishedKgId.length > 0)
    args += '|publishedKgId=' + _publishedKgId;

  if(_locationId != null && (_locationId > 0 || _locationId == -1))
    args += '|locationId=' + _locationId;
    
  if(_knowdeShortcut != null && _knowdeShortcut > 0)
    args += '|knowdeShortcut=' + _knowdeShortcut;
    
  if(_textVersion != null && _textVersion > 0)
    args += '|textVersion=' + _textVersion;
    
  if(_lockData != null && _lockData > 0)
    args += '|lockData=' + true;
    
  if(_newName != null && _newName != '')
    args += '|newName=' + _newName;
    
  // Test if we are dealing with Remove or Publish action
  // YES: use the coords saved from gen-menu (1st callback), 
  //      coz we don't want to move the menu to the new event location
  //  NO: we are dealing with gen-menu action, so used the event location
  //      also we need to save the coords for subsequent actions (2nd callback)
  if(_action.indexOf('gen_menu') == 0)
  {
    if(e != null)
    {
      g_originalKgId = _originalKgId;
      g_locationId = _locationId;
      if(_isOnCommunityTab.toLowerCase() == "true")
      {
        g_eventX = e.clientX;
        g_eventY = e.clientY;
        //alert('1-' + g_eventX + ' ' + g_eventY);
      }
      else
      {
        g_eventX = e.x || e.pageX;
        g_eventY = e.y || e.pageY;
        //alert('2-' + g_eventX + ' ' + g_eventY);
      }
    }
  }
  
  args += '|eventX=' + g_eventX;
  args += '|eventY=' + g_eventY;
  //alert('3-' + g_eventX + ' ' + g_eventY);
  
  
  if(args.length > 0)
  {      
    SetSessionProperty(_sessionNameForPublishKG, _originalKgId);
    CancelBubble(e);
    eval(_callbackScript);
  }
  
}

function KGPublishOptionControl_ReSetPublishingChoicesControl()
{
  // make sure the existing menus are hidden
  for (var mid in g_KGPublishCatMenuGroupDivs)
  {
    var menuGroupTable = document.getElementById(g_KGPublishCatMenuGroupDivs[mid]);
    if(menuGroupTable != null && menuGroupTable.parentNode != null)
    {
      var parentDiv = menuGroupTable.parentNode;
      parentDiv.parentNode.removeChild(parentDiv);
    }
  }
  g_KGPublishCatMenuGroupDivs = new Array();
  HideKGPublishingChoicesControl();
}
				  
function KGPublishOptionControl_CallbackDone_Wrapped(_args, _context, _isOnCommunityTab)
{
  // Check for a session time out before completing the callback
  if (CheckSessionTimeout())
    return;
  
  window.setTimeout('KGPublishOptionControl_ReSetPublishingChoicesControl()', 500);
  
  // for firefox
  // set the current scroll position
  var tabScroller = GetTabScroller();
  if(tabScroller)
  {
    g_splitter1DivScrollTop = tabScroller.scrollTop;
    g_splitter1DivScrollLeft = tabScroller.scrollLeft;
  }


  var tokens = _args.split('|');
  if(tokens.length == 6)
  {
    var holder = document.getElementById(tokens[0]);
    g_publishHolderId = tokens[0];
    var action = tokens[1];
    var eventX = tokens[2];
    var eventY = tokens[3];
    var kgvalid = tokens[4];
    var content = tokens[5];
    
    if(holder != null)
    {
      holder.innerHTML = content;
      // eval javascripts
      var cdatas = _args.split('<![CDATA[');
      var z = 0;
      for(z = 1; z < cdatas.length; z++)
      {
	      var posStart = cdatas[z].indexOf('window');      
	      var posEnd = cdatas[z].lastIndexOf('}') + 1;
	      if(posStart > -1 && posEnd > -1)
	      {
	  	    if (posEnd < posStart)
	  	    {
	          posEnd = cdatas[z].lastIndexOf(']') + 1;
	          var jscript = cdatas[z].substring(posStart, posEnd);
		        if(jscript.length != 0)
		        {
		          eval(jscript);
		        }
	        }
	        else
	        {
		        var jscript = cdatas[z].substring(posStart, posEnd);
		        if(jscript.length != 0)
		        {
			        eval(jscript);
			        var posNameStart = jscript.indexOf('window');
			        var posNameEnd = jscript.indexOf('=');
			        if(posNameStart > -1 && posNameEnd > -1)
			        {
			          var functionName = jscript.substring(posNameStart, posNameEnd);
			          eval(functionName+'()');
			        }
		        }
		      }
	      }
      }
      // for firefox
      var tabScroller = GetTabScroller();
      if(tabScroller)
      {
        if(tabScroller.scrollTop != g_splitter1DivScrollTop)
          tabScroller.scrollTop = g_splitter1DivScrollTop;
        
        if(tabScroller.scrollLeft != g_splitter1DivScrollLeft)
          tabScroller.scrollLeft = g_splitter1DivScrollLeft;
      }


      // Use callback to update the KGUserObjectSummaryControl after remove and publish
      if(action == 'remove' || action == 'publish' || action == 'republish' ||action == 'republishall' || action == 'unpublishall')
      {
        window.setTimeout("RepopulateProfilePageKGLists()",100);

        // Refresh the KGs in your maps here
        if (IsPortletContentOpen('MyHK'))
          window.setTimeout("LeftPaneMyKnowledgeControl_CallbackTrigger('Action=repopulate');",100);
        
        
        if(action != 'gen_menu')
        {
          // kg might have been removed
          if(kgvalid.toLowerCase() == 'false')
            window.setTimeout("ClearActiveKG()",200);
        }
      }
      //else
      //{
        // Need this to make sure the control is displayed on the screen
        KGPublishOptionControl_ShowMenu(tokens[0]);  
      //}
      if (window.CloseUOSMessageBox)
       CloseUOSMessageBox();
      // Need to test for which page we are on to decided what co-ordinates to use:
      // MapTabbedView.aspx has an extra spliter pane which will mess up the normal event.x and event.y
      // so we have to use event.clientX and clientY to correctly position the popup relative to the 
      // extra spliter pane.
      // Options.aspx does not have the extra spliter pane so it can use the normal event.x and event.y
      // however, if we apply clientX and clientY the positioning is wrong for that page.
      // Hence, we need to detect where we are and apply the correct co-ordinates [PL05Mar2008]
      //debugger;
      if(_isOnCommunityTab.toLowerCase() == "true")
      {
        if(action == 'publish'|| action =='remove' || action == 'republish' ||action == 'republishall' || action == 'unpublishall')
          window.setTimeout("KGPublishOptionControl_ShowAndReposition('absolute', " + parseInt(g_eventX) + 2 + "," + (parseInt(g_eventY) - 5) + ",'" + tokens[0] + "')", 1000);
        else
        {
          UpdateKGPublishOptionControlPos('absolute', parseInt(eventX) + 2, parseInt(eventY) - 5);
          //alert('d2-' + parseInt(eventX) + ' ' + parseInt(eventY));
        }
      }
      else 
      { 
        if(action == 'publish'|| action =='remove' || action == 'republish' ||action == 'republishall' || action == 'unpublishall')
          window.setTimeout("KGPublishOptionControl_ShowAndReposition('absolute', " + parseInt(g_eventX) + "," + (parseInt(g_eventY) + 5) + ",'" + tokens[0] + "')", 1000);

        else
        {
          UpdateKGPublishOptionControlPos('absolute', parseInt(eventX), parseInt(eventY) + 5);
          //alert('d1-' + parseInt(eventX) + ' ' + parseInt(eventY));
        }
      }


    }
    else
      KGPublishOptionControl_CallbackError('Content Div element is missing.');
  }
}

function KGPublishOptionControl_ShowAndReposition(_positionType, _eventX, _eventY, _holderID)
{
  //debugger;
  KGPublishOptionControl_HideMenu(_holderID);
  //KGPublishOptionControl_CallbackTrigger('gen_menu', g_originalKgId, -1, g_locationId, null);
  //UpdateKGPublishOptionControlPos(_positionType, _eventX, _eventY);
}

function KGPublishOptionControl_ShowMessage_Wrapped(_resultDivId, _message)
{
  var resultDiv = document.getElementById(_resultDivId);
  if(resultDiv != null)
  {
    resultDiv.innerHTML = "<img src='Images/LoadingBar.gif' widht='12px' height='12px'>&nbsp;&nbsp;" + _message;
  }
}

  			
function KGPublishOptionControl_CallbackError(_args, _context)
{
  alert(_args);
}

function KGPublishOptionControl_PublishClick(_object, _action, 
                                                        _originalKgId, 
                                                        _publishedKgId, 
                                                        _locationId,
                                                        e)
{
  // show loading icon
  if(_object != null && _object.tagName.toLowerCase() == 'span')
  {
    _object.className = 'InProgressImage';
    _object.title = 'Please wait while we publish this Knowledge Gene...'
    _object.innerHTML = "<img src='Images/LoadingBar.gif' widht='12px' height='12px'>";
  }
  
  KGPublishOptionControl_ShowMessage('publishing...');

  // trigger callback
  KGPublishOptionControl_CallbackTrigger(_action, _originalKgId, _publishedKgId, _locationId, 0, 0, 0, null, e);

  if (_locationId == -1 && IsPortletContentOpen('MyHK'))
  {
		LeftPaneMyKnowledgeControl_CallbackTrigger('Action=repopulate');
  }
}

function KGPublishOptionControl_PublishClickWithOptions(_object, _action, 
                                                        _originalKgId, 
                                                        _publishedKgId, 
                                                        _locationId,
                                                        _knowdeShortcut,
                                                        _textVersion,
                                                        _lockData,
                                                        _newName,
                                                        e)
{
  // show loading icon
  if(_object != null && _object.tagName.toLowerCase() == 'div')
  {
    //_object.className = 'InProgressImage';
    _object.title = 'Please wait while we publish this Knowledge Gene...'
    _object.innerHTML = "<img src='Images/LoadingBar.gif' widht='12px' height='12px'>&nbsp;Publishing...&nbsp;&nbsp;";
  }
  
  // trigger callback
  KGPublishOptionControl_CallbackTrigger(_action, _originalKgId, _publishedKgId, _locationId, _knowdeShortcut, _textVersion, _lockData, _newName, e);
}

function KGPublishOptionControl_UnPublishClick(_object, _action, 
                                                        _originalKgId, 
                                                        _publishedKgId, 
                                                        _locationId,
                                                        e)
{
    if (_action == 'remove' || _action == 'unpublishall')
    {
        EnsureDeletePubKGMessage(_action, _originalKgId, _publishedKgId, _locationId, e);
        PositionUosMessageBox("SiteOverlays_LoginView1_KGPublishOptionControl1_KGPublishOptionTable", false, e);
    }
    else
    {
      var msg = 'unpublishing...';
      if(_action == 'republish')
        msg = 'republishing...';
      KGPublishOptionControl_ShowMessage(msg);

      // trigger callback
      KGPublishOptionControl_CallbackTrigger(_action, _originalKgId, _publishedKgId, _locationId, 0, 0, 0, null, e);
    }   
}

function KGPublishOptionControl_UnPublishClick_Confirm(_action, 
                                                        _originalKgId, 
                                                        _publishedKgId, 
                                                        _locationId,
                                                        e)
{
  m_UosMessageBox.innerHTML= '<div style=\"position:absolute;width:400px;height:120px;border:gray solid 1pt;background:white\"><table width=\"100%\"><tr><td align=\"center\" style=\"font-size: xx-small\"><br/><img src=\"Images/loadingbar.gif\" />Unpublishing....</td></tr></table></div>';

  // trigger callback
  KGPublishOptionControl_CallbackTrigger(_action, _originalKgId, _publishedKgId, _locationId, 0, 0, 0, null, e);
}



///////////////////////
// Ensures that the delete message box is on the page
function EnsureDeletePubKGMessage(_action, _originalKgId, _publishedKgId, _locationId, e)
{

  m_UosMessageBox = document.getElementById("DeleteKGMessageBox");

  if(m_UosMessageBox == null)
  {
    m_UosMessageBox = document.createElement("div");
    m_UosMessageBox.setAttribute("id", "DeleteKGMessageBox");
    m_UosMessageBox.style.display = "none";
    m_UosMessageBox.style.width = "400px"
    m_UosMessageBox.style.height = "160px";
    m_UosMessageBox.style.position = "absolute";
    m_UosMessageBox.style.zIndex = 1000;
    //m_UosMessageBox.style.zIndex = TopZIndex(); // this function does not work in FF, so have hard coded a z-index for a quick fix
    
    if (_action == 'unpublishall')
      m_UosMessageBox.innerHTML = "<div class='MessageBox'><table border='0' cellpadding='5' cellspacing='0'><tr><td colspan='2' class='MessageBoxHeader'>Are you sure you want to unpublish this Knowledge Gene<sup>&#174;</sup> from ALL groups?</td></tr><tr><td rowspan='2' valign='top'><img src='images/recycle.png' height='50' width='50'/></td><td style='font-size:x-small;'>It will be removed from ALL groups it has previously been published to and any links added by other users (e.g. in the 'Community' tab) will also be removed.</td></tr><tr><td align='right'><button type='button' onclick='KGPublishOptionControl_UnPublishClick_Confirm(\"" + _action + "\"," + _originalKgId + ",\"" + _publishedKgId + "\"," + _locationId + ")'>Yes</button><button id = defaultButton type='button' onclick='CloseUOSMessageBox()'>Cancel</button></td></tr></table></div>";
    else
      m_UosMessageBox.innerHTML = "<div class='MessageBox'><table border='0' cellpadding='5' cellspacing='0'><tr><td colspan='2' class='MessageBoxHeader'>Are you sure you want to unpublish this Knowledge Gene<sup>&#174;</sup>?</td></tr><tr><td rowspan='2' valign='top'><img src='images/recycle.png' height='50' width='50'/></td><td style='font-size:x-small;'>It will be removed from the group and any links added by other users (e.g. in the 'Community' tab) will also be removed.</td></tr><tr><td align='right'><button type='button' onclick='KGPublishOptionControl_UnPublishClick_Confirm(\"" + _action + "\"," + _originalKgId + ",\"" + _publishedKgId + "\"," + _locationId + ")'>Yes</button><button id = defaultButton type='button' onclick='CloseUOSMessageBox()'>Cancel</button></td></tr></table></div>";
    
    //var parentControlDiv = document.getElementById(_parentControlDivId);
    //InsertAdjacentElement(document.body,"afterBegin", m_UosMessageBox);
    document.body.appendChild(m_UosMessageBox);
  }
  else
  {
    if (_action == 'unpublishall')
        m_UosMessageBox.innerHTML = "<div class='MessageBox'><table border='0' cellpadding='5' cellspacing='0'><tr><td colspan='2' class='MessageBoxHeader'>Are you sure you want to unpublish this Knowledge Gene<sup>&#174;</sup> from ALL groups?</td></tr><tr><td rowspan='2' valign='top'><img src='images/recycle.png' height='50' width='50'/></td><td style='font-size:x-small;'>It will be removed from ALL groups it has previously been published to and any links added by other users (e.g. in the 'Community' tab) will also be removed.</td></tr><tr><td align='right'><button type='button' onclick='KGPublishOptionControl_UnPublishClick_Confirm(\"" + _action + "\"," + _originalKgId + ",\"" + _publishedKgId + "\"," + _locationId + ")'>Yes</button><button id = defaultButton type='button' onclick='CloseUOSMessageBox()'>Cancel</button></td></tr></table></div>";
    else
        m_UosMessageBox.innerHTML = "<div class='MessageBox'><table border='0' cellpadding='5' cellspacing='0'><tr><td colspan='2' class='MessageBoxHeader'>Are you sure you want to unpublish this Knowledge Gene<sup>&#174;</sup>?</td></tr><tr><td rowspan='2' valign='top'><img src='images/recycle.png' height='50' width='50'/></td><td style='font-size:x-small;'>It will be removed from the group and any links added by other users (e.g. in the 'Community' tab) will also be removed.</td></tr><tr><td align='right'><button type='button' onclick='KGPublishOptionControl_UnPublishClick_Confirm(\"" + _action + "\"," + _originalKgId + ",\"" + _publishedKgId + "\"," + _locationId + ")'>Yes</button><button id = defaultButton type='button' onclick='CloseUOSMessageBox()'>Cancel</button></td></tr></table></div>";

    m_UosMessageBox.style.zIndex = TopZIndex(); //Show on top of other items
  }
}

function KGPublishOptionControl_RePublishAllClick(_object, _action, 
                                                        _originalKgId,
                                                        e)
{
  // show loading icon
  if(_object != null && _object.tagName.toLowerCase() == 'span')
  {
    _object.className = 'InProgressImage';
    _object.title = 'Please wait while we re-publishing...'
    _object.innerHTML = "<img src='Images/LoadingBar.gif' widht='12px' height='12px'>";
  }
  
  KGPublishOptionControl_ShowMessage('republishing...');
  
  // trigger callback
  KGPublishOptionControl_CallbackTrigger(_action, _originalKgId, null, null, 0, null, e);
}

function KGPublishOptionControl_UnPublishAllClick(_object, _action, 
                                                        _originalKgId,
                                                        e)
{

  if (_action == 'remove' || _action == 'unpublishall')
  {
        EnsureDeletePubKGMessage(_action, _originalKgId, null, null, e);
        PositionUosMessageBox("SiteOverlays_LoginView1_KGPublishOptionControl1_KGPublishOptionTable", false, e);
  }
  else
  {
  
    KGPublishOptionControl_ShowMessage('unpublishing...');
    
    // trigger callback
    KGPublishOptionControl_CallbackTrigger(_action, _originalKgId, null, null, 0, null, e);
  }
}

function KGPublishOptionControl_MenuItemMouseOver(_sender, _eventArgs)
{
  var menuItem = _eventArgs.get_item();
  var menuGroupID = KGPublishOptionControl_GetMenuItemElementID(menuItem);
  // store into the array
  g_KGPublishCatMenuGroupDivs.push(menuGroupID);
  if (menuItem.getItems().length > 0)//if the item has children to show
  {
    KGPublishOptionControl_ShowMenuGroup(menuGroupID, null, menuItem.ParentIndex);
  }
}


function KGPublishOptionControl_MenuItemMouseOut(_sender, _eventArgs)
{
}

// finds the DOM element id for a component art menuItem object
function KGPublishOptionControl_GetMenuItemElementID(_menuItem)
{
  var indexArray = new Array();
  indexArray.push(_menuItem.get_index());
  
  while(_menuItem.ParentItem != null)
  {
    _menuItem = _menuItem.ParentItem;
    indexArray.push(_menuItem.get_index());
  }
  
  var groupId = _menuItem.ParentMenu.MenuId;
	var menuGroup = document.getElementById(groupId);
  var menuitems = menuGroup.getElementsByTagName("td");
  
  var menuItemElement = menuitems[indexArray[indexArray.length-1]];// get the menuItemElement at the index position given by the last array item
  groupId = "G" + menuItemElement.id;// get the id for the menuGroup that belongs to this menuItem
  indexArray.pop();// remove the last array item    

  while (indexArray.length > 0)
  {
  	var menuGroup = document.getElementById(groupId);// get the menuGroup
    var menuitems = menuGroup.getElementsByTagName("nobr");// only one of these tags per menuitem (there are additional tds if a menu item has children)

    var menuItemElement = menuitems[indexArray[indexArray.length-1]];// get the menuItemElement at the index position given by the last array item
    
    // the dom nesting is different for items with children an those without.
    // first check the parentNode for the item id, then check higher up.
    menuItemId = menuItemElement.parentNode.id || menuItemElement.parentNode.parentNode.parentNode.parentNode.id
    groupId = "G" + menuItemId;// get the id for the menuGroup that belongs to this menuItem
    indexArray.pop();// remove the last array item    
  }

  return groupId;
}

function KGPublishOptionControl_ShowMenuGroup(_menuGroupID, _iteration, _parentIndex)
{
  if (_iteration == null)
    _iteration = 0;
  else
    _iteration++;
  
  // get the menu group container
  var menuGroup = document.getElementById(_menuGroupID);
  if (menuGroup == null && _iteration <= 10)
  {
    // wait until it gets shown
    setTimeout("KGPublishOptionControl_ShowMenuGroup('" + _menuGroupID + "', " + _iteration + ", " + _parentIndex + ")", 100);
  }
  else if (_iteration > 10)
  {
    // this prevents the timeout from looping indefinitely if something goes wrong
    return;
  }
  else
  {
    // ensure the container is the correct size
    if(navigator.appName == "Opera") 
    {
      // this will causing templates sometimes become more than one lines (left icon, text in the middle and right icon)
      // but this is required for Opera, so have to assign a fix width which is wide enough for the moment.
      menuGroup.parentNode.style.height = menuGroup.clientHeight + 2 + 'px';
      //alert(menuGroup.clientWidth);
      menuGroup.parentNode.style.width = (menuGroup.clientWidth + 40) + 'px';
    }
    var divScrollTop = 0; // $('#MapPane').scrollTop;
    var divScrollLeft = 0; // $('#MapPane').scrollLeft;
    //alert(MySplitter.scrollTop);
    var parentDiv = menuGroup.parentNode;
    
    if (_parentIndex == -1) // if it's top level sub group 
    {
    //debugger;
      if(parentDiv != null && parentDiv.tagName && parentDiv.tagName.toLowerCase() == 'div' 
           && parentDiv.style.top && parentDiv.style.top != '' && parentDiv.style.left && parentDiv.style.left != '')
      {
        // if the menu group just get created, or already exists but position been reset
        if(!menuGroup.getAttribute("moved"))
        {
          var currentScrollTop = parseInt(parentDiv.style.top.replace('px',''));
          var currentScrollLeft = parseInt(parentDiv.style.left.replace('px',''));
          
          if(divScrollTop > 0 || navigator.appName == 'Netscape')
          {
            // reposition the div
            currentScrollTop = currentScrollTop - divScrollTop;
            if (navigator.appName == 'Netscape') 
              currentScrollTop -= 10;
            if(currentScrollTop < 0)
              currentScrollTop = 0;
            parentDiv.style.top = currentScrollTop + 'px';
          }
          
          if(divScrollLeft > 0)
          {
            // reposition the div
            currentScrollLeft = currentScrollLeft - divScrollLeft;
            if(currentScrollLeft < 0)
              currentScrollLeft = 0;
            parentDiv.style.left = currentScrollLeft + 'px';
          }
          menuGroup.setAttribute("moved", true);
        }
        else // check whether need to update position if the container div has been scroll
        {

          var oldScrollTop = parentDiv.getAttribute("containerScrollTop");
          var oldScrollLeft = parentDiv.getAttribute("containerScrollLeft");
          
          var currentScrollTop = parseInt(parentDiv.style.top.replace('px',''));
          var currentScrollLeft = parseInt(parentDiv.style.left.replace('px',''));
          
          // if the outer splitter pane scrollable div scroll position has been changed
          if(oldScrollTop != null && oldScrollLeft != null)
          {
            if(oldScrollTop != divScrollTop)
            {
              // verticle scroll position changed
              var vdiff = divScrollTop - oldScrollTop;
              currentScrollTop = currentScrollTop - vdiff;
              if (navigator.appName == 'Netscape')
                currentScrollTop += 100;
              if(currentScrollTop < 0)
                currentScrollTop = 0;
              parentDiv.style.top = currentScrollTop + 'px';
            }
            if(oldScrollLeft!= divScrollLeft)
            {
              // verticle scroll position changed
              var hdiff = divScrollLeft - oldScrollLeft;
              currentScrollLeft = currentScrollLeft - hdiff;
              if(currentScrollLeft < 0)
                currentScrollLeft = 0;
              parentDiv.style.left = currentScrollLeft + 'px';
            }
          }
        }
        
        // store the current scrollable position
        parentDiv.setAttribute("containerScrollTop", divScrollTop)
        parentDiv.setAttribute("containerScrollLeft", divScrollLeft)
        
        
      } // end if parentDiv != null
    }
  }
}



