﻿

//------------------------------------------------------------------------------------------
function listVaultShow(owner)
{
   var div, mainFrm, w;
   
   // Make sure Sourcing List tab is active.
   top.miscSetView(2);
   
   // See if window is already open.
   mainFrm = $get('mainForm');
   div = $get('lvDiv');
   if(mainFrm && !div) {
      div = document.createElement('div');
      div.className = 'lvDiv';
      div.id = 'lvDiv';
      div.cellSpacing = '0px';
      div.cellPadding = '0px';
      div.style.overflow = 'hidden';
      div.style.zIndex = 1000;
      if(owner) {
         owner.appendChild(div);
      }  
   }
   div.innerHTML = '<iframe name="listVaultFrame" scrolling="no" frameborder="0" marginheight="3px" marginwidth="3px" src="listVault.aspx" width="100%" height="100%" >';
   div.style.left = owner.getClientRects()[0].left + 'px';
   div.style.top = owner.getClientRects()[0].bottom + 'px';
   div.style.display = '';
   
   // Make sure it fits.
   if(parseInt(div.style.left) + parseInt(div.offsetWidth) + 10 > top.miscClientWidth()) {
      div.style.left = (top.miscClientWidth() - div.offsetWidth - 10) + 'px';
   }
   if(parseInt(div.style.top) + parseInt(div.offsetHeight) + 30 > top.miscClientHeight()) {
      div.style.height = (top.miscClientHeight() - parseInt(div.style.top) - 30) + 'px';
   }
}

var lvCloseTimer = null;
//------------------------------------------------------------------------------------------
function listVaultStartHide()
{
   lvCloseTimer = window.setTimeout('top.listVaultHide()', 1000);
}
//------------------------------------------------------------------------------------------
function listVaultHide()
{
   var div;
   
   div = $get('lvDiv');
   if(div) {
      div.style.display = 'none';
   }
}
//------------------------------------------------------------------------------------------
function listVaultResetHide()
{
   if(lvCloseTimer) {
      window.clearTimeout(lvCloseTimer);
      lvCloseTimer = null;
   }
}

//------------------------------------------------------------------------------------------
function listVaultUpdate(context, ar)
{
   if(ar) {
      ar.evaluateJs();
   }
   
   // If not open then open it, else update.
   if($get('listVaultFrame')) {
      top.miscOpenWindow('listVault.aspx?' + top.miscCreateRandomRefresh(), 'listVaultFrame');
   }
   else {
      listVaultShow($get('btnLv'));
   }
}

//------------------------------------------------------------------------------------------
function listVaultDelFolder(pname)
{
   top.popupAskQuestion(resource.promptToDeleteFolder, 'listVaultDelFolderCont("' + pname + '");');
}
function listVaultDelFolderCont(pname)
{
   var ar = new ajaxRequest('listVault.aspx', null, listVaultUpdate);
   
   ar.addParameter('mode', 'df');
   ar.addParameter('pid', pname);
   ar.execute();
}
//------------------------------------------------------------------------------------------
function listVaultOpen(lid)
{
   var ar = new ajaxRequest('listVault.aspx', null, listVaultUpdate);
   
   ar.addParameter('mode', 'ol');
   ar.addParameter('lid', lid);
   ar.execute();
}
//------------------------------------------------------------------------------------------
function listVaultDel(lid)
{
   top.popupAskQuestion(resource.promptToDeleteList, 'listVaultDelCont("' + lid + '");');
}
function listVaultDelCont(lid)
{
   var ar = new ajaxRequest('listVault.aspx', null, listVaultUpdate);
   
   ar.addParameter('mode', 'dl');
   ar.addParameter('lid', lid);
   ar.execute();
}
//------------------------------------------------------------------------------------------
function listVaultAddList(pname)
{
   top.miscLoadList((pname ? pname : "Miscellaneous"));
}
//------------------------------------------------------------------------------------------
function listVaultListProps(lid)
{
   var u;
   
   u = "./listVaultProperties.aspx?" + top.miscCreateRandomRefresh();
   if(lid) {
      u += "&lid=" + lid;
   }
   top.popupBox("listProps", u, null, "300px", "200px", "none")
}
