// =============================================================
//
// Copyright (c) 2000-2003 GE Smallworld. All Rights Reserved.
//
// =============================================================

//this builds an array for all folders
var MAX_FOLDERS = 10;
var contentFolders = new Array(MAX_FOLDERS);
var FOLDER_OFFSET = -12;
var FOLDER_ACTIVE_Z_INDEX = 11;
var FOLDER_MAX_Z_INDEX = 10;
var FOLDER_COUNT = 0;
var FOLDER_BAR_ID = 'folderBar';
var FOLDER_ACTIVE_CLASS_NAME = 'folderActive';
var FOLDER_CLASS_NAME = 'folder';


function Folder(aID, aName, aLink) {
//	----------------------------------------------------------------------
//	Folder class that contains several variables for creating folders on
//	the fly in the header.
//	Parameters:
//		aID: id for the folder, must be one word or number
//		aName: Name of the folder to be displayed on the page
//		aLink: hyperlink that the inactive folder points to
//	---------------------------------------------------------------------- 

	// define instance variables
	this.id = aID;
	this.name = aName;
	this.href = aLink;

	return this;
}

function setActiveFolder(sFolder) {
//	----------------------------------------------------------------------
//	Function that sets the active folder to sFolder. This function is called
//	by onContentLoaded to let the user know what folder is currently active
//	in the hcf_content frame.
//	Parameters:
//		sFolder: folder id of the folder to be activated
//	---------------------------------------------------------------------- 
	
	docBody = document.getElementsByTagName("body").item(0); 
	
	docBody.setAttribute("id",sFolder);
   // get the folder
   //var body = hcfRoot.xbGetElementById('body', window);
  
  
   
   // check to see if this folder is active or not
   //if (aFolder.className != this.FOLDER_ACTIVE_CLASS_NAME) {
     // hideActiveFolders();

      // set the class to the active folder
   //    aFolder.className = this.FOLDER_ACTIVE_CLASS_NAME;
   
      // now create a new style
   //    var aFolderStyle = new hcfRoot.xbStyle(aFolder);
   
      // set the z-index to 10
   //    aFolderStyle.setzIndex(this.FOLDER_ACTIVE_Z_INDEX);
 // }	
  
}


function hideActiveFolders() {
//	----------------------------------------------------------------------
//	Function that hides all active folders so that there is no chance that
//	two folders will be active at the same time
//	Parameters:
//		None
//	---------------------------------------------------------------------- 
	
   // get the folders bar div tag
   var foldersDiv = document.getElementById(this.FOLDER_BAR_ID);
   
   // now get all div tags - these are the individual folder objtects
   var folders = foldersDiv.getElementsByTagName("div");
   
   // loop over each folder
	for (var i=0; i < folders.length; i++) {
	
      // get first folder
      var aFolder = folders.item(i);

      // set the class name
      aFolder.className = "folder";

      // now create a new style
      var aFolderStyle = new hcfRoot.xbStyle(aFolder);
   
      // set the z-index to 10
      aFolderStyle.setzIndex(folders.length - i);
	}
	
}

function addContentFolder(sFolderID, sFolderName, sFolderLink) {
//	----------------------------------------------------------------------
//	Function that is called from within frames_header.html to add all content
//	folders to the screen. Takes all of the folder parameters and adds a Folder
//	object to the contentFolders array
//	Parameters:
//		aID: id for the folder, must be one word or number
//		aName: Name of the folder to be displayed on the page
//		aLink: hyperlink that the inactive folder points to
//	---------------------------------------------------------------------- 

	/*
	// now create a new folder object
	var aFolder = new Folder(sFolderID, sFolderName, sFolderLink);

	contentFolders[FOLDER_COUNT] = aFolder;
	FOLDER_COUNT ++;
	*/
}


function writeContentFolders() {
//	----------------------------------------------------------------------
//	Writes the HTML and CSS code for each folder in the contentFolders array
//
//	Parameters: none
//
//	Return: none
//	---------------------------------------------------------------------- 
/*
	// get the folderBar div tag.
  	var folderBarDiv = document.getElementById(this.FOLDER_BAR_ID);
	
	// figure out the number of div tags - there is one per folder
	var folders = folderBarDiv.getElementsByTagName("DIV");
	
	// loop over each folder
	for (var i =FOLDER_COUNT-1; i >= 0; i--) {
		// calcualte the number of folders
		var aFolderCount = folders.length + i;
		
		// create a new folder
		var aNewFolder = document.createElement("DIV");
		
		// create a new style object
		var aFolderStyle = new hcfRoot.xbStyle(aNewFolder);

		// Setup the position of the folder.  This will be 
		// calculated by multiplying the FOLDER_OFFSET by
		// the number of folders.
		aFolderStyle.setLeft(aFolderCount * this.FOLDER_OFFSET);

		// Setup the z-index of the folder.  This will be 
		// calculated by subtracting the folder count
		// from the FOLDER_MAX_Z_INDEX.
		aFolderStyle.setzIndex(this.FOLDER_MAX_Z_INDEX - aFolderCount);
		
		// set up class name
		aNewFolder.className = 'folder';
		
		// now create a link element
		var aNewLink = document.createElement("A");
		
		// set the link href
		aNewLink.href = contentFolders[i].href;
		
		// now create a text node for the link
		var aNewTextNode = document.createTextNode(contentFolders[i].name); 

		// add the text node to the link
		aNewLink.appendChild(aNewTextNode);
		
		// add the link to the folder
		aNewFolder.appendChild(aNewLink);

		// now add the new folder 
		folderBarDiv.appendChild(aNewFolder);
	}	
	*/
}

