//File Name: messages.js. Created On: 6/20/05. Loads the Messages from messages.xml corresponding to current manual's language.
var messages = new Object();
loadMessages();
/*
	Function to get current Manual's language.	
*/
function getManualLanguage()
{
  var dom = createDOMDocument();
  dom.async = false;
  dom.load("../data/manualInfo.xml");
  if (dom.documentElement == null)
  {
    dom.load("../../data/manualInfo.xml");
  }
  if (dom.documentElement == null)
  {
    alert("ManualInfo file could not be found!");
  }
  return dom.documentElement.selectNodes("/ManualInfo/lang").item(0).text;
}
/**
	Function to load the messages from messages.xml.
*/
function loadMessages()
{
  var manualLang = getManualLanguage();
  var langTable = new Object();
  var dom = createDOMDocument();
  dom.async = false;
  dom.load("../data/messages.xml");
  if (dom.documentElement == null)
  {
    dom.load("../../data/messages.xml");
  }
  if (dom.documentElement == null)
  {
    dom.load("../../Common/data/languages/" + manualLang + ".xml");
  }
  if (dom.documentElement == null)
  {
    dom.load("../../../Common/data/languages/" + manualLang + ".xml");
  }
  if (dom.documentElement == null)
  {
    alert("Messages file could not be found!");
  }
  var condition="/table/row";
  var nodeList = dom.documentElement.selectNodes(condition);
  for(var i=0;i<nodeList.length;i++)
  {
    var key = nodeList.item(i).attributes.item(0).text;
    var value = nodeList.item(i).attributes.item(1).text;
    messages[key]=value;
  }
}
/**
	Function to Write the Message corresponding to given key to the out put html document.
*/
function writeMessage(key)
{
  document.write(messages[key]);
}

/**
	Function to return the message corresponding to given key.
*/
function getMessage(key)
{
  return messages[key];
}
