//<script>
/*** X2WebConstsManager class ***
	
	Abstract:
		This object deals with the HTML constants of a tree object.
		The Object should load his members from a xml object in his loadXml method.
	Usage:
		
		*** 
			var oConstManger = new X2WebConstManager()
			oConstManger.loadXml(oXmlConsts);
		***
		should be created in the tree object for each type of our tree.
		
		
	Important notes:
		Beware of incorrect XML contents.
		
	History:
		Written by Avihai Tamari, 06/08/2002.
*/

function
X2WebConstsManager() {
	this.loadXml = X2WebConstsManager_loadXml;
	this.loadFromResource = X2WebConstsManager_loadFromResource;
	this.setConst = X2WebConstsManager_setConst;
	this.getConst = X2WebConstsManager_getConst;
	this.loadManager = X2WebConstsManager_loadManager;
}



/*** loadXml ***
	
	Parameters:
		oXmlConst - MSXML Object with the following format :
			<Constants>
				<Const>
					<Name/>
					<Value/>
				</Const>
				.
				.
				.	
			</Constants>	
		
	
	Return value:
		None.

	Description:
		This function creates the X2WebConstsManager members, that are meant to
		be used as constants, according to a given xml object.
	
	Important notes:
		
	History:
		Written by Avihai Tamari, 07/08/2002
*****/

function
X2WebConstsManager_loadXml(
	oXmlConsts
) {
	
	var strConstName;
	var strConstValue;
	
	var oConsts = oXmlConsts.selectNodes("/Constants/Const");
	var nLength = oConsts.length;
	for (
		var i = 0;
		i < nLength;
		i++
	) { 
		strConstName = oConsts.item(i).selectSingleNode("Name").text;
		strConstValue = oConsts.item(i).selectSingleNode("Value").text
		this.setConst(strConstName, strConstValue);
	}
}



function
X2WebConstsManager_loadFromResource(
	strUrl
) {
	var xmlConsts = new ActiveXObject("MSXML.DOMDocument");
	xmlConsts.async = false;
	xmlConsts.load(strUrl);
	this.loadXml(xmlConsts);
}


/***  loadManager ***
	
	Parameters:
		oConstManager : X2WebConstManager object.

	Return value:
		None.

	Description:
		This function creates the X2WebConstsManager members, that are meant to
		be used as constants, according to a given X2WebConstManager object.
		The function runs over the given X2WebConstManager members and copy only
		those who meant to be used as constants.
	
	Important notes:
		
	History:
		Written by Avihai Tamari, 07/08/2002
*****/

function
X2WebConstsManager_loadManager(oConstsManager) {
	/*
		We assume that members of X2WebConstsManager, that are meant to
		be used as constants (hence methods and normal properties are excluded)
		are defined in a specific format: they all begin with a capital letter
		or "_",  and after that zero or more occurances of letters (in capital),
		digits or "_".
	*/
	oRegExp = new RegExp("^[A-Z_][A-Z_0-9]*$");
	var oMember;
	for (oMember in oConstsManager) {
		/*
			Checking whether this member is a constant (according to
			the mentioned above), in order to copy only the constants
			(and not the methods and the normal properties).
		*/
		if (oMember.match(oRegExp)) {
			this.setConst(
				oMember, 
				eval("oConstsManager." + oMember)
			);
		}
	}
}

/*** invokeEvent setConst ***
	
	Parameters:
		strConstName : String. represants the constant name to be created.
		strConstValue : String. represants the constant value to be created.

	Return value:
		None.

	Description:
		This function creates a X2WebConstsManager member that meant to
		be used as constant, according to a given const name and value.

	Important notes:
		
	History:
		Written by Avihai Tamari, 07/08/2002
*****/

function
X2WebConstsManager_setConst(
	strConstName, 
	strConstValue
) {
	strConstValue = strConstValue.replace(/\'/g, "\"");
	strConstValue = strConstValue.replace(/[\n\r]/g, "");
	eval("this." + strConstName + " = '" + strConstValue + "'");
}

function
X2WebConstsManager_getConst(
	strConstName
) {
	strConstValue = eval("this." + strConstName );
	strConstValue = strConstValue.replace(/\"/g, "\'");
	return strConstValue;

}