//
//	Copyright (c) 2003 General Electric Company
//
//	Version control:
//		$Archive: /releases/FreeViewer_2.0/src/WebViewer/FreeViewer/HTML/config.js $
//		$Revision: 1 $
//		$Date: 3/04/03 3:43p $
//		$Author: Marceld $
//

//
// ConfigFile C'tor
//
function ConfigFile()
{
	this._xmlCfg = CreateXmlDoc('config.xml');
}

function ConfigFile.prototype.GetItem(strXPath, strDefault)
{ with(this) {
	if (strDefault == null)
	{
		strDefault = '';
	}
	var node = _xmlCfg.selectSingleNode(strXPath);
	return node ? node.text : strDefault;
}}

//
// ProvidedByTitle
//
function ConfigFile.prototype.ProvidedByTitle()
{ with(this) {
	return GetItem('/cdviewer/providedBy/title');
}}

//
// ProvidedByText
//
function ConfigFile.prototype.ProvidedByText()
{ with(this) {
	return GetItem('/cdviewer/providedBy/text');
}}

//
// ProvidedByUrl
//
function ConfigFile.prototype.ProvidedByUrl()
{ with(this) {
	return GetItem('/cdviewer/providedBy/url');
}}

//
// ProvidedByPicture
//
function ConfigFile.prototype.ProvidedByPicture()
{ with(this) {
	return GetItem('/cdviewer/providedBy/picture');
}}

//
// LocaleId
//
function ConfigFile.prototype.LocaleId()
{ with(this) {
	return GetItem('/cdviewer/config/locale', 'en');
}}

//
// LocalFormatFontOptions
//
function ConfigFile.prototype.LocalFormatFontOptions(rgnode)
{
	var strResult = '';
	for (var i = 0; i < rgnode.length; i++)
	{
		switch(rgnode[i].nodeName)
		{
			case 'color':
				strResult += 'Color="' + rgnode[i].text + '";';
				break;
			case 'size':
				strResult += 'FontSize="' + rgnode[i].text + '";';
				break;
			case 'relsize':
				strResult += 'FontRelSize="' + rgnode[i].text + '";';
				break;
			case 'maxsize':
				strResult += 'FontMaxSize="' + rgnode[i].text + '";';
				break;
			case 'minsize':
				strResult += 'FontMinSize="' + rgnode[i].text + '";';
				break;
			case 'font':
				strResult += 'Font="' + rgnode[i].text + '";';
				break;
		}
	}
	return strResult;
}

//
// ImageAnnotationOptionsString
//
function ConfigFile.prototype.ImageAnnotationOptionsString()
{ with(this) {
	var rgnode = _xmlCfg.selectNodes('/cdviewer/config/imageannotations/*');
	return LocalFormatFontOptions(rgnode);
}}

//
// ViewportAnnotationOptionsString
//
function ConfigFile.prototype.ViewportAnnotationOptionsString()
{ with(this) {
	var rgnode = _xmlCfg.selectNodes('/cdviewer/config/viewportannotations/*');
	return LocalFormatFontOptions(rgnode);
}}

//
// GetWindowLevelPresetNode
//
function ConfigFile.prototype.GetWindowLevelPresetNode()
{ with(this) {
	return _xmlCfg.selectSingleNode('/cdviewer/windowpresets');
}}

