function Folder(folderDescription, hreference, OpenImg, CloseImg) //constructor
{
  //constant data
  this.desc = folderDescription
  this.hreference = hreference
  this.id = -1
  this.navObj = 0
  this.iconImg = 0
  this.nodeImg = 0
  this.isLastNode = 0

  //dynamic data
  this.isOpen = true
  //this.iconSrc = "ftv2folderopen.gif" -- Original Code
  //Added new open and closed image compatibility, 06/15/2005.
  this.iconSrc= OpenImg;
  this.closeIcon= CloseImg;
  this.children = new Array
  this.nChildren = 0

  //methods
  this.initialize = initializeFolder
  this.setState = setStateFolder
  this.addChild = addChild
  this.createIndex = createEntryIndex
  this.hide = hideFolder
  this.display = display
  this.renderOb = drawFolder
  this.totalHeight = totalHeight
  this.subEntries = folderSubEntries
  this.outputLink = outputFolderLink
}

function setStateFolder(isOpen)
{
  var subEntries
  var totalHeight
  var fIt = 0
  var i=0

  if (isOpen == this.isOpen)
    return

  if (browserVersion == 2)
  {
    totalHeight = 0
    for (i=0; i < this.nChildren; i++)
      totalHeight = totalHeight + this.children[i].navObj.clip.height
      subEntries = this.subEntries()
    if (this.isOpen)
      totalHeight = 0 - totalHeight
    for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++)
      indexOfEntries[fIt].navObj.moveBy(0, totalHeight)
  }
  this.isOpen = isOpen
  propagateChangesInState(this)
}

function propagateChangesInState(folder)
{
  var i=0

  if (folder.isOpen)
  {
    if (folder.nodeImg)
      if (folder.isLastNode)
        folder.nodeImg.src = "/images/trees/ftv2mlastnode.gif"
      else
          folder.nodeImg.src = "/images/trees/ftv2mnode.gif"
          //folder.iconImg.src= "ftv2blank.gif"
          //Original Code: folder.iconImg.src = "/images/trees/ftv2folderopen.gif"
		  folder.iconImg.src = "/images/trees/" + folder.iconSrc;
    for (i=0; i<folder.nChildren; i++)
      folder.children[i].display()
  }
  else
  {
    if (folder.nodeImg)
      if (folder.isLastNode)
        folder.nodeImg.src = "/images/trees/ftv2plastnode.gif"
      else
          folder.nodeImg.src = "/images/trees/ftv2pnode.gif"
          //Original Code:--folder.iconImg.src = "/images/trees/ftv2folderclosed.gif"
		  folder.iconImg.src = "/images/trees/" + folder.closeIcon;
    for (i=0; i<folder.nChildren; i++)
      folder.children[i].hide()
  }
}

function hideFolder()
{
  if (browserVersion == 1) {
    if (this.navObj.style.display == "none")
      return
    this.navObj.style.display = "none"
  } else {
    if (this.navObj.visibility == "hiden")
      return
    this.navObj.visibility = "hiden"
  }

  this.setState(0)
}

function initializeFolder(level, lastNode, leftSide)
{
var j=0
var i=0
var numberOfFolders
var numberOfDocs
var nc

  nc = this.nChildren

  this.createIndex()

  var auxEv = ""
  
  //Flag all level one folders, so you can close them by default.
  //Modified on 06/22/2005. The Ids are generated dynamically based on the number of files and folders.
  if (level==1)
   { 
      //Add level 1 Ids to global array.
      Level1FolderIds[IdCntr]= this.id; 
	  IdCntr+=1; //Increment global counter
   }
   
  if (browserVersion > 0)
    auxEv = "<a href='javascript:OnClickNodeId("+this.id+")'>"
  else
    auxEv = "<a>"

  if (level>0)
    if (lastNode) //the last 'brother' in the children array
    {
      this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='/images/trees/ftv2mlastnode.gif' width=16 height=22 border=0></a>")
      leftSide = leftSide + "<img src='/images/trees/ftv2blank.gif' width=16 height=22>"
      this.isLastNode = 1
    }
    else
    {
      this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='/images/trees/ftv2mnode.gif' width=16 height=22 border=0></a>")
      leftSide = leftSide + "<img src='/images/trees/ftv2vertline.gif' width=16 height=22>"
      this.isLastNode = 0
    }
  else
    this.renderOb("")

  if (nc > 0)
  {
    level = level + 1
    for (i=0 ; i < this.nChildren; i++)
    {
      if (i == this.nChildren-1)
        this.children[i].initialize(level, 1, leftSide)
      else
        this.children[i].initialize(level, 0, leftSide)
      }
  }
}

function drawFolder(leftSide)
{
  if (browserVersion == 2) {
    if (!doc.yPos)
      doc.yPos=8
    doc.write("<layer id='folder" + this.id + "' top=" + doc.yPos + " visibility=hiden>")
  }

  doc.write("<table ")
  if (browserVersion == 1)
  doc.write(" id='folder" + this.id + "' style='position:block;' ")
  doc.write(" border=0 cellspacing=0 cellpadding=0>")
  doc.write("<tr><td>&nbsp;</td><td>")
  doc.write(leftSide)
  this.outputLink()
  doc.write("<img name='folderIcon" + this.id + "' ")
  doc.write("src='/images/trees/" + this.iconSrc+"' border=0></a>")
  doc.write("</td><td valign=middle nowrap>")
  if (HYPERLINKS)
  {
    this.outputLink()
    doc.write(this.desc + "</a>")
  }
  else
    doc.write(this.desc)
  doc.write("</td>")
  doc.write("</table>")

  if (browserVersion == 2) {
    doc.write("</layer>")
  }

  if (browserVersion == 1) {
    this.navObj = doc.all["folder"+this.id]
    this.iconImg = doc.all["folderIcon"+this.id]
    this.nodeImg = doc.all["nodeIcon"+this.id]
  } else if (browserVersion == 2) {
    this.navObj = doc.layers["folder"+this.id]
    this.iconImg = this.navObj.document.images["folderIcon"+this.id]
    this.nodeImg = this.navObj.document.images["nodeIcon"+this.id]
    doc.yPos=doc.yPos+this.navObj.clip.height
  }
}

//folder and Link separater
function outputFolderLink()
{
  if (this.hreference)
  {
    doc.write("<a href='" + this.hreference + "' TARGET='" + FrmName + "'")
    if (browserVersion > 0)
      doc.write("onClick='javascript:clickOnFolder("+this.id+")'")
    doc.write(">")
  }
  else
    doc.write("<a>")
//  doc.write("<a href='javascript:clickOnFolder("+this.id+")'>")
}

function addChild(childNode)
{
  this.children[this.nChildren] = childNode
  this.nChildren++
  return childNode
}

function folderSubEntries()
{
  var i = 0
  var se = this.nChildren

  for (i=0; i < this.nChildren; i++){
    if (this.children[i].children) //is a folder
      se = se + this.children[i].subEntries()
  }

  return se
}


// Definition of class Item (a document or link inside a Folder)
// *************************************************************

function Item(itemDescription, itemLink) // Constructor
{
  // constant data
  this.desc = itemDescription
  this.link = itemLink
  this.id = -1 //initialized in initalize()
  this.navObj = 0 //initialized in render()
  this.iconImg = 0 //initialized in render()

  //Determine if the Browser is Netscape or MSIE
  if(navigator.appVersion.lastIndexOf("MSIE") == -1) //Its a Netscape Browser
   {
    //this.iconSrc = "netscape.gif"
    this.iconSrc= "ftv2blank.gif"
   }
  else //Its a MSIE Browser
   {
    //this.iconSrc = "ftv2doc.gif"
    this.iconSrc= "ftv2blank.gif"
   }

  // methods
  this.initialize = initializeItem
  this.createIndex = createEntryIndex
  this.hide = hideItem
  this.display = display
  this.renderOb = drawItem
  this.totalHeight = totalHeight
}

function hideItem()
{
  if (browserVersion == 1) {
    if (this.navObj.style.display == "none")
      return
    this.navObj.style.display = "none"
  } else {
    if (this.navObj.visibility == "hiden")
      return
    this.navObj.visibility = "hiden"
  }
}

function initializeItem(level, lastNode, leftSide)
{
  this.createIndex()

  if (level>0)
    if (lastNode) //the last 'brother' in the children array
    {
      this.renderOb(leftSide + "<img src='/images/trees/ftv2lastnode.gif' width=16 height=22>")
      leftSide = leftSide + "<img src='/images/trees/ftv2blank.gif' width=16 height=22>"
    }
    else
    {
      this.renderOb(leftSide + "<img src='/images/trees/ftv2node.gif' width=16 height=22>")
      leftSide = leftSide + "<img src='/images/trees/ftv2vertline.gif' width=16 height=22>"
    }
  else
    this.renderOb("")
}

function drawItem(leftSide)
{
  if (browserVersion == 2)
    doc.write("<layer id='item" + this.id + "' top=" + doc.yPos + " visibility=hiden>")

  doc.write("<table ")
  if (browserVersion == 1)
    doc.write(" id='item" + this.id + "' style='position:block;' ")
  doc.write(" border=0 cellspacing=0 cellpadding=0>")
  doc.write("<tr><td>&nbsp;</td><td>")
  doc.write(leftSide)
  doc.write("<a href=" + this.link + ">")
  doc.write("<img id='itemIcon"+this.id+"' ")
  doc.write("src='/images/trees/"+this.iconSrc+"' border=0>")
  doc.write("</a>")
  doc.write("</td><td valign=middle nowrap>")
  if (HYPERLINKS)
    doc.write("<a href=" + this.link + ">" + this.desc + "</a>")
  else
    doc.write(this.desc)
  doc.write("</table>")

  if (browserVersion == 2)
    doc.write("</layer>")

  if (browserVersion == 1) {
    this.navObj = doc.all["item"+this.id]
    this.iconImg = doc.all["itemIcon"+this.id]
  } else if (browserVersion == 2) {
    this.navObj = doc.layers["item"+this.id]
    this.iconImg = this.navObj.document.images["itemIcon"+this.id]
    doc.yPos=doc.yPos+this.navObj.clip.height
  }
}


// Methods common to both objects (pseudo-inheritance)
// ********************************************************

function display()
{
  if (browserVersion == 1)
    this.navObj.style.display = "block"
  else
    this.navObj.visibility = "show"
}

function createEntryIndex()
{
  this.id = nEntries
  indexOfEntries[nEntries] = this
  nEntries++
}

// total height of subEntries open
function totalHeight() //used with browserVersion == 2
{
  var h = this.navObj.clip.height
  var i = 0

  if (this.isOpen) //is a folder and _is_ open
    for (i=0 ; i < this.nChildren; i++)
      h = h + this.children[i].totalHeight()

  return h
}


// Events
// *********************************************************

function clickOnFolder(folderId)
{
  var clicked = indexOfEntries[folderId]

  if (!clicked.isOpen)
    OnClickNodeId(folderId)

  return

  if (clicked.isSelected)
    return
}

function OnClickNodeId(folderId)
{
  var clickedFolder = 0
  var state = 0

  clickedFolder = indexOfEntries[folderId]
  state = clickedFolder.isOpen

  clickedFolder.setState(!state) //open<->close
}

function DisplayDocument13()
{ //Payment Policies
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot13.initialize(0, 1, "")
  sRoot13.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument12()
{ //VCS-Policies and Procedures
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot12.initialize(0, 1, "")
  sRoot12.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument11()
{ //VCIPA-Policies and Procedures
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot11.initialize(0, 1, "")
  sRoot11.display()

 // if (browserVersion > 0)
   //{
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
  // }
}

function DisplayDocument10()
{ //Miscellaneous
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot10.initialize(0, 1, "")
  sRoot10.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument9()
{ //Physicians & Medicare...
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot9.initialize(0, 1, "")
  sRoot9.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument8()
{ //Memos and Notices
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot8.initialize(0, 1, "")
  sRoot8.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument7()
{ //Clinical Advisory
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot7.initialize(0, 1, "")
  sRoot7.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument6()
{ //Radnet
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  
  sRoot6.initialize(0, 1, "")
  sRoot6.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument5()
{ //Forms
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  sRoot5.initialize(0, 1, "")
  sRoot5.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument4()
{ //Coding & Compliance
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other  
  sRoot4.initialize(0, 1, "")
  sRoot4.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument3()
{ //Provider Reference Information
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other

  //RootTree.initialize(0, 1, "")
  //RootTree.display()
  sRoot3.initialize(0, 1, "")
  sRoot3.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument2()
{ //HealthPlan Updates...
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other

  //RootTree.initialize(0, 1, "")
  //RootTree.display()
  sRoot2.initialize(0, 1, "")
  sRoot2.display()

  if (browserVersion > 0)
   {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
   }
}

function DisplayDocument()
{ //Physician Facts...
  if (doc.all)
    browserVersion = 1 //IE4
  else
    if (doc.layers)
      browserVersion = 2 //NS4
    else
      browserVersion = 0 //other

  //RootTree.initialize(0, 1, "")
  //RootTree.display()
  sRoot.initialize(0, 1, "")
  sRoot.display()

  if (browserVersion > 0)
  {
    doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+">&nbsp;</layer>")

    // close the whole tree
    OnClickNodeId(0)
    // open the root folder
    OnClickNodeId(0)
  }
}

// Auxiliary Functions for Folder-Treee backward compatibility
// *********************************************************

function GetFolder(description, hreference, OpenImg, CloseImg)
{
  folder = new Folder(description, hreference, OpenImg, CloseImg)
  return folder
}

function GetLink(target, description, linkData)
{
  fullLink = ""

  if (target==0)
  {
    fullLink = "'" + linkData + "' target='" + FrmName + "'"
  }
  else
  {
    if (target==1)
      {
        fullLink = "'http://"+linkData+"' target=_blank"
      }
    else
      {
       fullLink = "'http://" + linkData + "' target='" + FrmName + "'"
      }
  }

   linkItem = new Item(description, fullLink)
   return linkItem
}

function InsertFolder(parentFolder, childFolder)
{
  return parentFolder.addChild(childFolder)
}

function InsertDoc(parentFolder, document)
{
  parentFolder.addChild(document)
}

// Global variables
// ****************
//The Name of the frame you are using, default is set to _parent, change it on your main page.
FrmName= "_parent"
HYPERLINKS = 0
indexOfEntries = new Array
var Level1FolderIds = new Array(); //Contains all of the level 1 Ids.
var IdCntr=0; //Folder Id counter
nEntries = 0
doc = document
browserVersion = 0
selectedFolder=0



