// <script>


/*
  Wrapper function name with shorter name that calls SwitchImg
*/
function si(sImgID, sNewImg)
{
  SwitchImg(sImgID, sNewImg);
}

function PopupWin(sURL, sName, sFeatures, bReplace)
{
/*
  if (window.PopUpWindow && !window.PopUpWindow.close)
    window.PopUpWindow.close();

  window.PopUpWindow = window.open(sURL, sName, sFeatures, false);
  window.PopUpWindow.focus();
  return false;
*/
  return window.open(sURL, sName, sFeatures, false).focus();
}

var Is = new BrowserDetect() ;

function DoBrowserDetect()
{
  window.Is = new BrowserDetect() ;
}

function BrowserDetect()
{
  this.IE4 = ( document.all                        ? true : false) ;
  this.NN4 = (!this.IE4 && document.layers         ? true : false) ;
  this.IE5 = ( this.IE4 && document.getElementById ? true : false) ;
  this.NN6 = (!this.IE4 && document.getElementById ? true : false) ;
}

function IsEmpty(value)
{
  return (value == "" || value == null || value.search(/^\s*$/) != -1) ? true : false;
}

function Trim(sToTrim)
{
  if (typeof(sToTrim) != "string")
    sToTrim = new String(sToTrim);
  return RTrim(LTrim(sToTrim));
}

function LTrim(sToLTrim)
{
  if (typeof(sToLTrim) != "string")
    sToLTrim = new String(sToLTrim);
  
  return sToLTrim.replace(/\s*$/, "");
}

function RTrim(sToRTrim)
{
  if (typeof(sToRTrim) != "string")
    sToRTrim = new String(sToRTrim);
  
  return sToRTrim.replace(/^\s*/, "");
}

function ViewFile(sFileURL)
{
  location.href = sFileURL;
}

function DeleteFolder(iFolderID)
{
  if (confirm("Are you sure you want to delete this folder, all of its sub-folders and files?"))
    location.href="_DeleteFolder.asp?fid=" + iFolderID;
}

function DeleteFile(iFileID)
{
  if (confirm("Are you sure you want to delete this file?"))
    location.href="_DeleteFile.asp?file=" + iFileID;
}

function DeleteAccount(sUserID)
{
  if (confirm("Are you sure you want to delete this account?"))
    location.href="_DeleteAccount.asp?uid=" + sUserID;
}

function Toggle(iFolderID)
{
  var bChecked, i;
  for (i = 0, len = oForm._TheForm["fid"].length; i < len; ++i)
  {
    if (parseInt(oForm._TheForm["fid"][i].value) == parseInt(iFolderID))
    {
      bChecked = oForm._TheForm["fid"][i].checked;
      break;
    }
  }

//  ToggleChildren(bChecked, iFolderID);
  if (bChecked)
  {
    ToggleParents(bChecked, iFolderID);
  }
  else
  {
    ToggleChildren(bChecked, iFolderID);
    //oForm._TheForm["fid"][i].checked = false;
  }
}

function ToggleParents(bChecked, iFolderID)
{
  for (var item = oForm._TheForm["pid" + iFolderID]; item; item = oForm._TheForm["pid" + item.value])
  {
    for (var i = 0, len = oForm._TheForm["fid"].length; i < len; ++i)
      if (parseInt(oForm._TheForm["fid"][i].value) == parseInt(item.value))
        oForm._TheForm["fid"][i].checked = bChecked;
  }
}

function ToggleChildren(bChecked, iFolderID)
{
  var arrChildren = [];
  
  for (var i = 0, len = oForm._TheForm["fid"].length; i < len; ++i)
  {
    if (parseInt(oForm._TheForm["pid" + oForm._TheForm["fid"][i].value].value) == parseInt(iFolderID))
    {
      arrChildren[arrChildren.length] = oForm._TheForm["fid"][i].value;
      oForm._TheForm["fid"][i].checked = bChecked;
    }
  }

  for (var i = 0, len = arrChildren.length; i < len; ToggleChildren(bChecked, arrChildren[i++]));
}