/*******************************

 Configuration.js, Version 4.1, 3-Apr-2008
 Copyright Northgate Information Solutions UK Limited, 2002-2008

 *******************************/

/***********************
 Configuration class

 Constructor:
	Configuration(parent)
 Properties:
	controlFolder
	dataFrameId
	defaultSection
	externalUrl
	linksFrameId
	linksFolder
	linksSettings
	navbarFrameId
	navFrameId
	navigationFiles
	optFrameId
	siteMap
	topicFolder
	topicFrameId
Class methods:
	terminateFolder(folder)

 ***********************/

// *** Constructor for Configuration class ***
function Configuration(parent) {
	this.parent = ((typeof parent == "object") 
		&& (parent.constructor == HelpSystem)
		? parent : null);
	if (parent == null)
		return(null);

    var uan = navigator.appName;
    var ua = navigator.userAgent;

	// Frame names.
	this.contentFrameId = (self.contentFrame != null ? self.contentFrame : "fraContent");
	this.topicFrameId = (self.topicFrame != null ? self.topicFrame : "HelpTopic");
	this.navbarFrameId = (self.navbarFrame != null ? self.navbarFrame : "fraNavbar");
	this.optFrameId = (self.optFrame != null ? self.optFrame : "Banner");
	this.navFrameId = (self.navFrame != null ? self.navFrame : "Navigation");
	this.linksFrameId = (self.linksFrame != null ? self.linksFrame : "fraLinks");
	this.dataFrameId = (self.dataFrame != null ? self.dataFrame : "Data");

	// Folder names.
	this.topicFolder = (self.topicFolder != null ? self.topicFolder : "topics");
	this.linksFolder = (self.linksFolder != null ? self.linksFolder : "_links");
	this.controlFolder = (self.controlFolder != null ? self.controlFolder : "_control");
	this.topicFolder = Configuration.terminateFolder(this.topicFolder.toLowerCase());
	this.linksFolder = Configuration.terminateFolder(this.linksFolder.toLowerCase());
	this.controlFolder = Configuration.terminateFolder(this.controlFolder.toLowerCase());

	// The name of the topic map object.
	this.topicMap = (self.topicMap != null ? self.topicMap : "topicMap");

	// Navigation files.
	var temp = new NavPages(self.siteMap, self.defaultSection);
	switch (DHTML.browserType) {
		case "IE":
			if (self.ieContentsFile != null)
				temp.setContents(self.ieContentsFile);
			if (self.ieIndexFile != null)
				temp.setIndex(self.ieIndexFile);
			break;
		case "FF":
		default:
			if (self.nsContentsFile != null)
				temp.setContents(self.nsContentsFile);
			if (self.nsIndexFile != null)
				temp.setIndex(self.nsIndexFile);
			break;
	}
	if (self.searchFile != null)
		temp.setSearch(self.searchFile);
	if (self.searchData != null)
		temp.setGlobalSearchData(self.searchData);
	if (self.localSearchData != null)
		temp.setLocalSearchData(self.localSearchData);
	if (self.linkFrameFile != null)
		temp.setLinksFrame(self.linkFrameFile);
	if (self.glossaryFile != null)
		temp.setGlossary(self.glossaryFile);
	temp.controlFolder = this.controlFolder.toLowerCase();
	temp.topicFolder = this.topicFolder.toLowerCase();
	temp.helpRoot = this.parent.rootFolder;
	this.navigationFiles = temp;

	// Initial navigation settings.
	var temp = new Array();
	temp["initial"] = new NavSettings();
	temp["initial"].tool = (self.initialNavTool != null ? self.initialNavTool : "links");
	temp["initial"].linksFile = this.linksFolder
			+ (self.initialLinksFile != null ? self.initialLinksFile : "");
	temp["initial"].index = (self.initialNavIndex != null ? self.initialNavIndex : 0);

	// Global navigation settings.
	temp["global"] = new NavSettings();
	temp["global"].tool = (self.globalNavTool != null ? self.globalNavTool : "links");
	temp["global"].linksFile = (self.globalLinksFile != null
			? this.linksFolder + self.globalLinksFile
			: "");
	temp["global"].index = (self.globalNavIndex != null ? self.globalNavIndex : 0);

	/* Default navigation settings. Used for files that are not part of
	   the help system (e.g. dynamically generated search results). */
	temp["default"] = new NavSettings();
	temp["default"].tool = (self.defaultNavTool != null ? self.defaultNavTool : "*");
	temp["default"].linksFile = this.linksFolder
			+ (self.defaultLinksFile != null ? self.defaultLinksFile : "");
	temp["default"].index = (self.defaultNavIndex != null ? self.defaultNavIndex : 0);
	this.linksSettings = temp;

	// Allow filename search flag.
	this.allowFilenameSearch = (self.allowFilenameSearch != null ? self.allowFilenameSearch : false);
	// Stylesheet for formatting search results.
	this.searchResultsStylesheet = self.searchResultsStylesheet;
	
	this.dataObjects = (self.dataObjects != null
		? self.dataObjects
		: [
			{ name: "topicMap",
			  constructor: "TopicMap",
			  filename: "map.htm"
			}
		  ]);

	this.exitButtonCaption = (self.exitButtonCaption != null ? self.exitButtonCaption : "");
	if (self.searchPollInterval != null)
		this.parent.navigationTools.search.searchPollInterval 
			= self.searchPollInterval;
}


// *** Configuration class methods ***
Configuration.terminateFolder = function cfgTerminateFolder(f) {
	return(f.charAt(f.length - 1) == "/" ? f : f + "/");
}

